add std feature (#231)

- `std` feature is enabled by default
- By default enable #![no_std] compilation
- Import std create if `std` feature is enabled or if testing
- Use core, alloc types
- Make it clear where std types are being used
- In no std, use BTreeMap in place of HashMap.
   HashMap is not available in no std due to lack of a
   secure random number generator

Note: The project does not yet compile without std feature being specified.
But it's really close to being able to do so.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-05-09 14:28:42 -04:00
committed by GitHub
parent e9cd6d6afc
commit 01fc234a33
36 changed files with 128 additions and 69 deletions
+3 -1
View File
@@ -5,6 +5,7 @@ use crate::ast::*;
use crate::lexer::*;
use crate::number::*;
use crate::value::*;
use crate::*;
use alloc::collections::BTreeMap;
use core::str::FromStr;
@@ -73,7 +74,8 @@ impl<'source> Parser<'source> {
let msg = format!(
"`{kw}` will be treated as identifier due to missing `import future.keywords.{kw}`"
);
println!(
#[cfg(feature = "std")]
std::println!(
"{}",
self.source
.message(self.tok.1.line, self.tok.1.col, "warning", &msg)