Question: Consider the following EBNF grammar for a very simple programming language: program ::= S {statemt} statemt ::= assnmt | ifstmt | do | inout |
Consider the following EBNF grammar for a very simple programming language: program ::= S {statemt} statemt ::= assnmt | ifstmt | do | inout | progcall assnmt ::= ident ~ exprsn ; ifstmt ::= I comprsn @ {statemt} [% {statemt}] & do ::= D {statemt} U comprsn E inout ::= iosym ident {, ident } ; iosym ::= R | O progcall ::= C program G comprsn ::= ( oprnd opratr oprnd ) exprsn ::= factor {+ factor} factor ::= oprnd {* oprnd} oprnd ::= integer | ident | bool | ( exprsn ) opratr ::= < | = | > | ! | ^ ident ::= letter {char} char ::= letter | digit integer ::= digit {digit} letter ::= W | X | Y | Z digit ::= 0 | 1 bool ::= T | F The tokens are: S I D U E R O C G W X Y Z 0 1 T F ; ~ @ % & , ( ) + * < = > ! ^ Nonterminals are shown as lowercase words. The following characters are NOT tokens (they are EBNF metasymbols): | { } [ ] Note that parentheses are TOKENS, not EBNF metasymbols in this particular grammar. 1. Draw Syntax Diagrams for the above grammar. 2. Show that the grammar satisfies the two requirements for predictive parsing. (it does, you just need to prove it). Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
