I want to create an unambiguous grammar for arithmetic expressions. Now the exponentiation should be of higher precedence and associate to the right. All other operations associate to the left. This is what I have so far but I don't know if the exponentiation is correct
E -> E+T | E-T | T
T -> T*F | T/F | L
L -> F^ L|F
F -> i | (E)
I am curious, because this is tagged recursive-descent, which makes me think LL.
When creating a grammar for an LL parser, remember these rules.
Repetition is used for left associativity:
Foo -> Bar (op Bar)*
Tail recursion is used for right associativity:
Foo -> Bar (op Foo)?
Now, you don't have an LL-parser-friendly grammar because you have left recursion:
E -> E+T
On the other hand, if it were LL, your exponentiation uses tail recursion, so that would work.
I suggest wikipedia's Top Down Parsing and Left-Recursion articles (these are easier reads than the LL parser article). And note, LR parsers work different, and result in different grammars for left and right associativity.
Oh, and your rule ordering is correct for what LL parsers need for precedence. Your lower-precedence operator rules come first in the production rule chain.