Question

Check if i did the conversion correct or else please send me the correct Context Free...

Check if i did the conversion correct or else please send me the correct Context Free Gramer

Ambigious CFG :

S -> PROGRAM identifier SEMI Block
Block -> Declarations BlockStatements
Declarations -> VAR (VariableDeclarions SEMI)+ | eps
VariableDeclarions -> identifier (COMMA identifier)* COLON TypeSpec
TypeSpec -> INTEGER | REAL
BlockStatements -> BEGIN Statements END
Statements -> Statement | Statement Statements
Statement -> Assignment | eps
Assignment -> identifier ASSIGN Expr SEMI
Expr -> Term (ADD Term)* | Term (SUB Term)* | Term (MULT Term)* | Term (DIV Term)*
Term -> CONSTANT | LPAREN Expr RPAREN | identifier

Unambigious Grammer for C-language:

Start : _PROGRAM _ID _SEMI Block
Block : Declarations BlockStatements
Declarations : _VAR '('VariableDeclarions _SEMI')' A | ;
A: '('VariableDeclarions _SEMI')' A | ;
VariableDeclarions : _ID '('_COMMA _ID')' B _COLON TypeSpec
B: '('_COMMA _ID')' B|;
TypeSpec : _INTEGER | _REAL
BlockStatements : _BEGIN Statements _END
Statements : Statement | Statement Statements
Statement : Assignment | ;
Assignment : _ID _ASSIGN Expr _SEMI
Expr : Term '('_ADD Term')' C | Term '('_SUB Term')' D | Term '('_MULT Term')' E | Term '('_DIV Term')' F
Term : _CONST | _LPAREN Expr _RPAREN | _ID
C: '('_ADD Term')' C | ;
D: '('_SUB Term')' | ;
E: '('_MULT Term')' | ;
F: '('_DIV Term')'|;

0 0
Add a comment Improve this question Transcribed image text
Answer #1


T6Xm CONST ILPAREN EAP R PARENI-ID C:C-ADD Terw) Ci MULT TCY m F .1,m AICT C DE C I D 6100 -7oF E EF

Add a comment
Know the answer?
Add Answer to:
Check if i did the conversion correct or else please send me the correct Context Free...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Note: The question needs to be answered in "C Programming Languange ". And after the question fin...

    Note: The question needs to be answered in "C Programming Languange ". And after the question find 3 pages for needed informations. Spring CE4717 Language Processors Q1. Consider the following LEx program. return R1 return R2 return R3 return R4 return R5; return R6; IA-2a-z)[A-Za-z0-9]- -2 10-91+ 10-9a-EA-FI Ihi] [01] [01] 이삐 t Vtin) int main (void) int tcode; do f tcode -yylex()i printf ("token type td \"%s\"\n", tcode, yytext); ) while (tcode)i return 0; i. Explain the steps needed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT