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')'|;
Check if i did the conversion correct or else please send me the correct Context Free...
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...