From 9dae6ef05ba9b5a1022d343e6beb09b456125f62 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 11 Nov 2024 15:37:36 +0100 Subject: [PATCH] chore: no_std version --- .github/workflows/build.yml | 2 +- Cargo.toml | 8 +++++--- src/lib.rs | 5 +++++ src/parser.rs | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 968f81a..2481e7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - feature: [ ] + feature: [ std ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable diff --git a/Cargo.toml b/Cargo.toml index 8688394..5a7239f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ description = "Framework for declarative domain-specific languages" repository = "https://github.com/UBIDECO/parseltongue" homepage = "https://ubideco.org/ParselTongue" keywords = ["language", "declarative", "syntax", "parser"] -categories = ["parser-implementations"] +categories = ["parser-implementations", "no-std"] readme = "README.md" license = "Apache-2.0" edition = "2021" @@ -20,8 +20,10 @@ name = "parseltongue" amplify = "~4.8.0" [features] -default = [] -all = [] +default = ["std"] +all = ["std"] + +std = [] [package.metadata.docs.rs] features = ["all"] diff --git a/src/lib.rs b/src/lib.rs index 13b0152..30286fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,10 @@ // the License. #![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc; #[macro_use] extern crate amplify; @@ -28,4 +32,5 @@ extern crate amplify; mod statement; mod parser; +pub use parser::{Block, Brackets, ParseError, ParsedSource, Parser, Quotes, UnparsedSource}; pub use statement::{Decl, Module, Statement}; diff --git a/src/parser.rs b/src/parser.rs index 0e8b3ad..68c5d6f 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -20,6 +20,8 @@ // or implied. See the License for the specific language governing permissions and limitations under // the License. +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; use core::fmt::{self, Debug, Display, Formatter}; use core::str::Lines;