diff --git a/examples/factorial.sy b/examples/factorial.sy index 0a6048d..95d12f8 100644 --- a/examples/factorial.sy +++ b/examples/factorial.sy @@ -1,5 +1,7 @@ [ :x x x ] :dup +# This a dumb little workaround to allow for recursion so factorial inside of +# the function definition will look in the correct scope 0 :factorial [ dup! diff --git a/src/syn/parser.pest b/src/syn/parser.pest index a4bcc27..8427318 100644 --- a/src/syn/parser.pest +++ b/src/syn/parser.pest @@ -1,10 +1,11 @@ -WHITESPACE = _{ " " | "\r" | "\t" | "\n" } +newline = _{ "\n" | "\r\n" } +WHITESPACE = _{ newline | " " | "\r" | "\t"} +COMMENT = _{ "#" ~ (!newline ~ ANY)* } int = @{ ASCII_DIGIT+ } float = @{ ASCII_DIGIT+ ~ "." ~ ASCII_DIGIT+ ~ ("e" ~ ("+" | "-")? ~ ASCII_DIGIT+)? } word_char = @{ ASCII_ALPHA | "_" | "?" | "-" | "+" | "*" | "/" | "=" | "@" | "$" | "%" | "^" | "&" | "|" | "~" } word = @{ word_char+ } -// meta = ${ "%" ~ word } str = @{ "\"" ~ (