Cleanup grammar file

- Formatting
- Remove generic `operator` and `operand`
  - used for testing
rewrite/grammar-implicit-whitespace
Raymon Zutekouw 3 years ago
parent 1ed3cc8bba
commit 877bb44c3e
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 41
      src/grammars/mblf.pest
  2. 7
      src/main.rs

@ -1,6 +1,3 @@
operator = @{ "operator" } // TODO
operand = @{ "operand" } // TODO
wordSeperator =_{ " " | "-" | "_" }
variable =@{ ASCII_ALPHA
~ (ASCII_ALPHANUMERIC | wordSeperator)*
@ -16,21 +13,21 @@ path = { "\"" ~ (!"\"" ~ ANY)+ ~ "\"" }
include =@{ "#include" ~ spacing+ ~ path }
var =@{ "var" ~ spacing+ ~ variable }
delvar =@{ "delvar" ~ spacing+ ~ variable }
var =@{ "var" ~ spacing+ ~ variable }
delvar =@{ "delvar" ~ spacing+ ~ variable }
point =@{ "point" ~ spacing+ ~ variable }
pointm =@{ "pointm" ~ spacing+ ~ variable }
point =@{ "point" ~ spacing+ ~ variable }
pointm =@{ "pointm" ~ spacing+ ~ variable }
add =@{ "add" ~ spacing+ ~ constant }
addb =@{ "addb" ~ spacing+ ~ constant }
addv =@{ "addv" ~ spacing+ ~ variable }
add =@{ "add" ~ spacing+ ~ constant }
addb =@{ "addb" ~ spacing+ ~ constant }
addv =@{ "addv" ~ spacing+ ~ variable }
sub =@{ "sub" ~ spacing+ ~ constant }
subb =@{ "subb" ~ spacing+ ~ constant }
subv =@{ "subv" ~ spacing+ ~ variable }
sub =@{ "sub" ~ spacing+ ~ constant }
subb =@{ "subb" ~ spacing+ ~ constant }
subv =@{ "subv" ~ spacing+ ~ variable }
copy =@{ "copy" ~ spacing+ ~ variable }
copy =@{ "copy" ~ spacing+ ~ variable }
setz =@{ "setz" }
getchr =@{ "getchr" }
@ -58,8 +55,6 @@ instruction =_{ macaroo
| getchr
| print
| operator ~ (spacing+ ~ operand)?
}
loopBlockStart = { "[" ~ NEWLINE }
@ -69,13 +64,13 @@ loopBlock = { loopBlockStart
~ spacing* ~ loopBlockEnd
}
statement = _{ spacing*
~ (instruction | loopBlock)
}
statement =_{ spacing*
~ (instruction | loopBlock)
}
statements = _{ (statement | NEWLINE)* }
statements =_{ (statement | NEWLINE)* }
spacing = _{ " " | "\t" }
COMMENT = _{ ";;" ~ (!NEWLINE ~ ANY)* ~ NEWLINE}
spacing =_{ " " | "\t" }
COMMENT =_{ ";;" ~ (!NEWLINE ~ ANY)* ~ NEWLINE }
file = {SOI ~ (statement ~ NEWLINE+)* ~ EOI}
file = { SOI ~ (statement ~ NEWLINE+)* ~ EOI }

@ -141,13 +141,6 @@ fn instruct(statement: Pair<Rule>, out: &mut Builder) {
Rule::instruction => {
out.append("\n");
}
Rule::operator => {
out.append("operator ");
}
Rule::operand => {
out.append("operand ");
}
Rule::loopBlock => {
for nested_statement in statement.into_inner() {
instruct(nested_statement, out);

Loading…
Cancel
Save