Use alloc, core instead of std (#225)

- Replace std with alloc, core in most places in src
  Tests, bindings aren't changed.
- Introduce BuiltinsMap type alias inplace of HashMap.
  In no_std case, this could be aliases to BTreeMap
- Fix clippy warnings

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-05-07 21:41:09 -04:00
committed by GitHub
parent 0a39e434db
commit 69d6426663
38 changed files with 137 additions and 165 deletions

View File

@@ -6,8 +6,8 @@ use crate::lexer::*;
use crate::number::*;
use crate::value::*;
use std::collections::BTreeMap;
use std::str::FromStr;
use alloc::collections::BTreeMap;
use core::str::FromStr;
use anyhow::{anyhow, bail, Result};
@@ -65,7 +65,7 @@ impl<'source> Parser<'source> {
}
fn is_imported_future_keyword(&self, kw: &str) -> bool {
self.future_keywords.get(kw).is_some()
self.future_keywords.contains_key(kw)
}
pub fn warn_future_keyword(&self) {
@@ -515,9 +515,9 @@ impl<'source> Parser<'source> {
while possible_fcn {
match expr {
Expr::Var(_) => break,
Expr::RefDot { refr, .. } => expr = &refr,
Expr::RefDot { refr, .. } => expr = refr,
Expr::RefBrack { refr, index, .. } => {
expr = &refr;
expr = refr;
possible_fcn = matches!(index.as_ref(), Expr::String(_));
}
_ => {
@@ -787,7 +787,7 @@ impl<'source> Parser<'source> {
let start = self.tok.1.start;
let mut expr = self.parse_bool_expr()?;
while self.token_text() == "in" && self.future_keywords.get("in").is_some() {
while self.token_text() == "in" && self.future_keywords.contains_key("in") {
expr = self.parse_membership_tail(start, expr, None)?;
}
@@ -976,7 +976,7 @@ impl<'source> Parser<'source> {
match self.token_text() {
"some" => return self.parse_some_stmt(),
"every" => {
if self.future_keywords.get("every").is_some() {
if self.future_keywords.contains_key("every") {
return self.parse_every_stmt();
}
self.warn_future_keyword();
@@ -1326,7 +1326,7 @@ impl<'source> Parser<'source> {
}
pub fn if_is_keyword(&self) -> bool {
self.future_keywords.get("if").is_some()
self.future_keywords.contains_key("if")
}
pub fn parse_query_or_literal_stmt(&mut self) -> Result<Query> {