diff options
| author | Jonas Maier <> | 2026-04-20 11:29:20 +0200 |
|---|---|---|
| committer | Jonas Maier <> | 2026-04-20 11:29:20 +0200 |
| commit | 3b06d1aa9ee674d6a66457eb38e0c0989cd4628d (patch) | |
| tree | 57dcec174dd690882e61ae37ad98b2809c4f5b56 /src/parse/mod.rs | |
| parent | 9a277b18f976305be0a56c01f125501937852005 (diff) | |
| download | pish-3b06d1aa9ee674d6a66457eb38e0c0989cd4628d.tar.gz | |
reading rc file
Diffstat (limited to 'src/parse/mod.rs')
| -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>), |
