Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Function Paradox definition in Ocaml

I'm trying to implement parser with this grammar:

program> ::= <function>
<function> ::= "int" <id> "(" ")" "{" <statement> "}"
<statement> ::= "return" <exp> ";"
<exp> ::= <term> { ("+" | "-") <term> }
<term> ::= <factor> { ("*" | "/") <factor> }
<factor> ::= "(" <exp> ")" | <unary_op> <factor> | <int>

{} means it can be repeated zero or more times

I'm using the recursive method, basically one function for each production rule, so first I defined the function Function then Statement then Exp then Term and finally Factor, but Factor uses Exp, so how can I use it if I have to define it above????????

Comments