diff options
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/mod.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 88d0362..e061d67 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -49,6 +49,32 @@ pub struct Block { } #[derive(Debug, Clone, PartialEq)] +pub struct Script { + pub stmts: Vec<Ast<PreExpansion>>, +} + +impl Parse for Script { + fn parse(b: &mut Cursor<'_>) -> Result<Self> { + let mut stmts = Vec::new(); + + loop { + b.spaces(); + if b.is_empty() { + break; + } + + match Ast::parse(b) { + Ok(s) => stmts.push(s), + Err(ParseError::Eof) => break, + Err(e) => Err(e)?, + } + } + + Ok(Script { stmts }) + } +} + +#[derive(Debug, Clone, PartialEq)] pub enum Ast<T: Stage> { FunDecl(FunDecl<T>), VarAssign(VarAssign<T>), |
