From b4ae93683264585200ddd0a787b0ba1e08dbf1b9 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Fri, 11 Feb 2022 18:31:12 -0800 Subject: [PATCH] Add comment processing, add a comment to factorial.sy to test it out Signed-off-by: Alek Ratzloff --- examples/factorial.sy | 2 ++ src/syn/parser.pest | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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 = @{ "\"" ~ (