From 08a4800175c90f7602bef74559beb0fa12681787 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 11 Nov 2021 19:36:48 -0800 Subject: [PATCH] Fix newlines --- schala-lang/language/src/parsing/new.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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()