Consider Following Grammar Expr Term Termtail Termtail Addop Term Termtail Term Factor Fac Q37290021

Consider the following grammar

expr- term term_tail

term_tail -add_op term term_tail |

term – factor factor_tail

factor_tail-mult_op factor factor _tail |

factor -(expr) |id|literal

add_op -+|-

mult_op-*|/

Draw syntax tree for parsing each ofcdf+(a25+84),(a25+84)*cdf,84*cdf+a25,a25+84*cdf,a25*84*cdf.Notethat a25 and cdf are identifiers and 84 is a literal.You are notasked to do the tedious parsing process with stacksnapshots.Instead you only need to draw sysntax trees,but you doneed to do lexical analysis

N.B: I need only lexical analysis for this question


Answer


Dear student, according to the above question, thesolution is as follows:

Please note that you haven’t mentioned the epsilon (ε)in the term_tail and factor_tail Non-terminals in thegrammar.

So, I have included that and solved

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.