Well, I'm not sure how to write a function using recursive parsing to parse the grammar, as shown below. In fact, I'm not sure if I did it right ...
BNF:
A : B | A '!'
B : '[' ']'
pseudo code:
f()
{
if(tok is B)
parse_b();
return somethingB
else if(????) how will I know if it start of A or I don't need to?
x = f();
parse_c();
return somethingA
}
I did this (there is no check to determine if this is A, but I feel that something is wrong with it):
f()
{
if(tok is B)
parse_b();
return somethingB
else
x = f();
parse_c();
return somethingA
}
source
share