aboutsummaryrefslogtreecommitdiffstats
path: root/src/grammar.pest
blob: 333a58ef5295311ed4d99eaebd57e454198d87a8 (plain)
1
2
3
4
5
6
7
8
9
10
WHITESPACE = _{ " " | "\t" }
COMMENT = _{ "/*" ~ (!"*/" ~ ANY)* ~ "*/" ~ NEWLINE* }
program = { SOI ~ statement+ ~ EOI }
statement = { (definition | expression) ~ NEWLINE* }
definition = { symbol+ ~ "=" ~ expression }
expression = { expression_node+ }
expression_node = { integer_literal | operator | symbol | ("(" ~ expression ~ ")") }
operator = { "+" | "-" | "/" | "*" }
integer_literal = @{ "-"? ~ ASCII_DIGIT+ }
symbol = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "-" | ".")* }