Cleanup grammar file
- Formatting - Remove generic `operator` and `operand` - used for testing
This commit is contained in:
+5
-10
@@ -1,6 +1,3 @@
|
|||||||
operator = @{ "operator" } // TODO
|
|
||||||
operand = @{ "operand" } // TODO
|
|
||||||
|
|
||||||
wordSeperator =_{ " " | "-" | "_" }
|
wordSeperator =_{ " " | "-" | "_" }
|
||||||
variable =@{ ASCII_ALPHA
|
variable =@{ ASCII_ALPHA
|
||||||
~ (ASCII_ALPHANUMERIC | wordSeperator)*
|
~ (ASCII_ALPHANUMERIC | wordSeperator)*
|
||||||
@@ -58,8 +55,6 @@ instruction =_{ macaroo
|
|||||||
|
|
||||||
| getchr
|
| getchr
|
||||||
| print
|
| print
|
||||||
|
|
||||||
| operator ~ (spacing+ ~ operand)?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loopBlockStart = { "[" ~ NEWLINE }
|
loopBlockStart = { "[" ~ NEWLINE }
|
||||||
@@ -69,13 +64,13 @@ loopBlock = { loopBlockStart
|
|||||||
~ spacing* ~ loopBlockEnd
|
~ spacing* ~ loopBlockEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
statement = _{ spacing*
|
statement =_{ spacing*
|
||||||
~ (instruction | loopBlock)
|
~ (instruction | loopBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
statements = _{ (statement | NEWLINE)* }
|
statements =_{ (statement | NEWLINE)* }
|
||||||
|
|
||||||
spacing = _{ " " | "\t" }
|
spacing =_{ " " | "\t" }
|
||||||
COMMENT = _{ ";;" ~ (!NEWLINE ~ ANY)* ~ NEWLINE}
|
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 => {
|
Rule::instruction => {
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
}
|
}
|
||||||
Rule::operator => {
|
|
||||||
out.append("operator ");
|
|
||||||
}
|
|
||||||
Rule::operand => {
|
|
||||||
out.append("operand ");
|
|
||||||
}
|
|
||||||
|
|
||||||
Rule::loopBlock => {
|
Rule::loopBlock => {
|
||||||
for nested_statement in statement.into_inner() {
|
for nested_statement in statement.into_inner() {
|
||||||
instruct(nested_statement, out);
|
instruct(nested_statement, out);
|
||||||
|
|||||||
Reference in New Issue
Block a user