Reputation: 121
So I making a grammar for turtle language but I have been stuck trying to define a grammar.I have tried to make multiple ones but these are the ones that seem alright to me but I have no idea whether they are correct or easy to work with. This is what I've tried so far:
<unaryExpr> ::= Forward Decimal | Back Decimal | Left Decimal | Right Decimal | Color
Hex | Up | Down
<binaryExpr> ::= Reps Decimal unaryExpr | Reps Decimal binaryExpr
<Decimals> ::= [0-9]+
<Hex> ::= [a-fA-F0-9]*
OR
<statement> ::= movement| repeat
<movement> ::= forward | backward | left | right
<forward> ::= forward Decimal
<backward> ::= backward Decimal
<left> ::= left Decimal
<right> ::= right Decimal
<color> ::= color Hex
<repetition> ::= repeat Decimal <statement>
Upvotes: 0
Views: 80