Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started