Fix newlines

This commit is contained in:
Greg Shuflin 2021-11-11 19:36:48 -08:00
parent 8d7f8f555f
commit 08a4800175

View File

@ -9,11 +9,12 @@ fn rc_string(s: &str) -> Rc<String> {
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()