blob: 000ddd589f861b01dd6e21c67da299f8e20f9ab9 (
plain)
1
2
3
4
5
6
7
8
9
|
COMMENT = _{ "#" ~ (!("#" | NEWLINE) ~ ANY)* ~ NEWLINE* }
WHITESPACE = _{ " " | "\t" | NEWLINE }
program = { SOI ~ statement+ ~ EOI }
statement = { (definition | expression) }
definition = { symbol ~ "=" ~ expression ~ ";"+ }
expression = { (symbol | integer_literal | string_literal | ("(" ~ expression ~ ")"))+ }
integer_literal = @{ "-"? ~ ASCII_DIGIT+ }
string_literal = { QUOTATION_MARK ~ (!QUOTATION_MARK ~ ANY)* ~ QUOTATION_MARK }
symbol = @{ (ASCII_ALPHA | "_.") ~ (ASCII_ALPHANUMERIC | "-" | "." | "?" | "!")* }
|