The compiler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.8 KiB

wordSeperator =_{ " " | "-" | "_" }
variable =@{ ASCII_ALPHA
~ (ASCII_ALPHANUMERIC | wordSeperator)*
~ "?"?
}
char =_{ "\"" ~ ANY ~ "\"" }
decNum =_{ ASCII_DIGIT+ }
hexNum =_{ "0x" ~ ASCII_HEX_DIGIT+ }
num =_{ hexNum | decNum }
constant = { char | num }
path = { "\"" ~ (!"\"" ~ ANY)+ ~ "\"" }
include = { "#include" ~ path }
var = { "var" ~ variable }
delvar = { "delvar" ~ variable }
point = { "point" ~ variable }
pointm = { "pointm" ~ variable }
add = { "add" ~ constant }
addb = { "addb" ~ constant }
addv = { "addv" ~ variable }
sub = { "sub" ~ constant }
subb = { "subb" ~ constant }
subv = { "subv" ~ variable }
copy = { "copy" ~ variable }
setz = { "setz" }
getchr = { "getchr" }
print = { "print" }
macaroo =_{ include }
instruction =_{ macaroo
| var
| delvar
| point
| pointm
| add
| addb
| addv
| sub
| subb
| subv
| copy
| setz
| getchr
| print
}
loopBlockStart = { "[" ~ NEWLINE }
loopBlockEnd = { "]" }
loopBlock = { loopBlockStart
~ statements
~ loopBlockEnd
}
statement =_{ (instruction | loopBlock) }
statements =_{ (statement | NEWLINE)* }
WHITESPACE =_{ " " | "\t" }
COMMENT =_{ ";;" ~ (!NEWLINE ~ ANY)* ~ NEWLINE+ }
file = { SOI ~ (statement ~ NEWLINE+)* ~ EOI }