diff --git a/schala-lang/language/src/parsing/new.rs b/schala-lang/language/src/parsing/new.rs index 1ba59d9..18b9d5a 100644 --- a/schala-lang/language/src/parsing/new.rs +++ b/schala-lang/language/src/parsing/new.rs @@ -9,11 +9,12 @@ fn rc_string(s: &str) -> Rc { peg::parser! { pub grammar schala_parser() for str { - rule whitespace() = [' ' | '\t' | '\n']* + rule whitespace() = [' ' | '\t' ]* + rule whitespace_or_newline() = [' ' | '\t' | '\n' ]* rule _ = quiet!{ whitespace() } - rule __ = quiet!{ [' ' | '\t' ]* } + rule __ = quiet!{ whitespace_or_newline() } pub rule program() -> AST = statements:(statement() ** delimiter() ) { AST { id: Default::default(), statements: statements.into() } } @@ -32,8 +33,8 @@ peg::parser! { kind:statement_kind() { Statement { id: Default::default(), location: Default::default(), kind } } rule statement_kind() -> StatementKind = - _ decl:declaration() { StatementKind::Declaration(decl) } / - _ expr:expression() { StatementKind::Expression(expr) } + __ decl:declaration() { StatementKind::Declaration(decl) } / + __ expr:expression() { StatementKind::Expression(expr) } rule declaration() -> Declaration = binding() / type_decl() / annotation() / func()