Need_MathHelp
Need_MathHelp

Reputation: 121

Parsers and BNF grammar

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

Answers (0)

Related Questions