1. Write a BNF grammar that describes the structure of a nonterminal called <number>. Assume that <number> contains an optional + sign followed by exactly 2 decimal digits, the first of which cannot be a 0. Thus 23, +91, and +40 are legal, but 9, +01, and 123 are not.
Using this grammar, show a parse tree for the value +90.
2. Write a BNF grammar for identifiers that consist of an arbitrarily long string of letters and digits, the first one of which must be a letter.
Using this grammar, show a parse tree for the identifier AB5C8.© BrainMass Inc. brainmass.com October 9, 2019, 9:36 pm ad1c9bdddf
1. BNF grammar :
<number> ::= + <nzdigit> <digit> | <nzdigit> <digit>
<digit> ::= 0 | <nzdigit>
<nzdigit> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Parse tree for +90 :
Answer shows the parse trees (drawn neatly) in text mode.