I'm working on a program that needs to decide if a string "(example + another) * other" belongs to a certain grammar.
    Start = Expr endline
    Expr  = Term Expr2
    Expr2 = + Term Expr2 | - Term Expr2 | e
    Term  = Factor Term2
    Term2 = * Factor Term2 | / Factor Term2 | e
    Factor= id | ( Expr ) | num 
For example I'm trying to implement something similar to above grammar in Java. So far I have switch statements with recusion but I feel this is not the way to do it. Are there simpler ways of representing productions? Any tips would be appreciated. Thanks