|
|
@ -4,14 +4,25 @@ WHITESPACE = _{ " " }
|
|
|
|
// characters are anything but newlines
|
|
|
|
// characters are anything but newlines
|
|
|
|
char = { !NEWLINE ~ ANY }
|
|
|
|
char = { !NEWLINE ~ ANY }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// token definition
|
|
|
|
|
|
|
|
// http://pest.rs/book/grammars/syntax.html#atomic
|
|
|
|
|
|
|
|
inner = @{ char* }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
token = { string | keyword }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// has to be atomic for no implicit separate (spaces)
|
|
|
|
|
|
|
|
keyword = @{ (!(WHITESPACE | NEWLINE) ~ ANY)+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// strings cannot contain quotes
|
|
|
|
|
|
|
|
// TODO: escaped quotes
|
|
|
|
|
|
|
|
string_data = @{ (!"\"" ~ ANY)* }
|
|
|
|
|
|
|
|
string = ${ "\"" ~ string_data ~ "\"" }
|
|
|
|
|
|
|
|
|
|
|
|
// comments are a # followed by
|
|
|
|
// comments are a # followed by
|
|
|
|
// any number of non-newline characters
|
|
|
|
// any number of non-newline characters
|
|
|
|
COMMENT = _{ "#" ~ char* }
|
|
|
|
COMMENT = _{ "#" ~ char* }
|
|
|
|
|
|
|
|
|
|
|
|
// statements are comprised of at least one character
|
|
|
|
|
|
|
|
statement = { char+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// lines are comprised of a statement
|
|
|
|
// lines are comprised of a statement
|
|
|
|
line = { statement }
|
|
|
|
line = { token+ }
|
|
|
|
|
|
|
|
|
|
|
|
file = { SOI ~ (line ~ ("\r\n" | "\n")*)* ~ "\n"* ~ EOI }
|
|
|
|
file = { SOI ~ line ~ (NEWLINE+ ~ line)* ~ NEWLINE* ~ EOI }
|