Reorganized variable code

This commit is contained in:
2023-06-14 16:15:51 -07:00
parent 5ffad0cc4e
commit 00a421756d
10 changed files with 39 additions and 47 deletions

View File

@ -17,22 +17,26 @@ pub use self::{
token::Function,
};
use crate::context::Context;
pub fn parse(
s: &String
) -> Result<
Token,
(LineLocation, ParserError)
> {
s: &String, context: &Context
) -> Result<Token, (LineLocation, ParserError)> {
let tokens = stage::tokenize(s);
let (_, tokens) = stage::find_subs(tokens);
let g = stage::groupify(tokens)?;
let g = stage::treeify(g)?;
let g = stage::treeify(g, context)?;
return Ok(g);
}
pub fn parse_no_context(s: &String) -> Result<Token, (LineLocation, ParserError)> {
parse(s, &Context::new())
}
pub fn substitute(
s: &String, // The string to substitute