aboutsummaryrefslogtreecommitdiffstats
path: root/src/grammar.pest
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2021-11-18 10:19:06 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2021-11-18 10:37:40 +0200
commit5a3bc07079b1e9d1692b15c59369f5e3871705d7 (patch)
tree5b2f391d20e9d838153d2567578c0837278a697c /src/grammar.pest
parenta4f91d8e4509ccacb2ad09d9ec47f77a5c01470e (diff)
WIP Rewrite to point-free style
Diffstat (limited to 'src/grammar.pest')
-rw-r--r--src/grammar.pest15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/grammar.pest b/src/grammar.pest
index 9ef2b1b..822e256 100644
--- a/src/grammar.pest
+++ b/src/grammar.pest
@@ -1,10 +1,9 @@
-WHITESPACE = _{ " " | "\t" }
-COMMENT = _{ "/*" ~ (!"*/" ~ ANY)* ~ "*/" ~ NEWLINE* }
+COMMENT = _{ "#" ~ (!("#" | NEWLINE) ~ ANY)* ~ NEWLINE* }
+WHITESPACE = _{ " " | "\t" | NEWLINE }
program = { SOI ~ statement+ ~ EOI }
-statement = { (definition | expression) ~ NEWLINE* }
-definition = { symbol+ ~ "=" ~ expression }
-expression = { expression_node+ }
-expression_node = { integer_literal | builtin | symbol }
-builtin = { "+" | "-" | "/" | "*" }
+statement = { (definition | expression)}
+definition = { symbol ~ "=" ~ expression ~ ";"+ }
+expression = { (symbol | integer_literal | string_literal | ("(" ~ expression ~ ")"))+ }
integer_literal = @{ "-"? ~ ASCII_DIGIT+ }
-symbol = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "-" | ".")* } \ No newline at end of file
+string_literal = { QUOTATION_MARK ~ (!QUOTATION_MARK ~ ANY)* ~ QUOTATION_MARK }
+symbol = @{ (ASCII_ALPHA | "_.") ~ (ASCII_ALPHANUMERIC | "-" | "." | "?" | "!")* }