Add include statement

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-02-11 16:09:41 -08:00
parent 3563378db7
commit 25beed3cd4
2 changed files with 3 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ assign = { ":" ~ word }
atom = { float | int | assign | word | str | apply }
quote = { "[" ~ stmt* ~ "]" }
expr = { atom | quote }
stmt = { expr }
include = { "%include" ~ str }
stmt = { include | expr }
file = { SOI ~ stmt* ~ EOI }

View File

@@ -95,6 +95,7 @@ fn parse_stmt(source: &Rc<String>, pair: Pair<Rule>) -> Result<SpStmt> {
let pair_span = pair.as_span();
let stmt = match pair.as_rule() {
Rule::expr => Stmt::Expr(parse_expr(source, pair.into_inner().next().unwrap())?),
Rule::include => Stmt::Include(unescape_string(pair.into_inner().next().unwrap().as_str())),
rule => unreachable!("{:?}", rule),
};
let span = Span {