Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

Write a recursive descent parser for this grammar: A ::= Id "(" B ")" B ::= Id | Id "," B where Id ::= [a-ZA-Z]+ My question is, how to do I implement the ID? parseId(){ accept('a' | 'b' | ... 'Z')+ [?] } parseB(){ parseId(); case(,): parseB(); } parseA(){ parseId(); accept( '(' ); parseB(); accept( ')' ); } Thanks!

OpenStudy (anonymous):

Usually, terminal symbols like Id are handled by the lexer that's transforming your source file into tokens. If you want to do that with a parser, you'll need to change it a bit, I guess. Try parsing something like this: char ::= [a-zA-Z] Id ::= char | char Id

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!