Starting from:

$25

Compiler- Lab 8: Lexical analysis and parsing using Lex/Flex and Yacc/Bison Solved

. Consider the following context-free grammar: 



Terminals: 



and (AND) (ASSIGN) : (COLON) , (COMMA) def (DEF) / (DIV) 



. (DOT) else (ELSE) end (END) = (EQ) exit (EXITLOOP) float (FLOAT) 



(FORMAT) from (FROM) fun (FUN) (GE) global (GLOBAL) 



> (GT) (ID) if (IF) int (INT) (- (MINUS) mod (MOD) * (MULT) (NE) 



not (NOT) null (NUL) or (OR) + (PLUS) print (PRINT) product (PRODUCT) read (READ) return (RETURN) -> (RETURNS) ) 



; (SEMICOLON) skip (SKIP) step (STEP) (STRING) to (TO while (WHILE) 



Note: ID, INT_CONST, FLOAT_CONST are identifier, integer constant and 



floating point constant. STRING is a string constant. FORMAT are %d %f %s

floating point constant. STRING is a string constant. FORMAT are %d %f %s

prog declList decl typeList varList var sizeListO sizeList type typeDef funDef funID fparamListO pList idP funBody stmtList 

stmtListO stmt assignmentStmt dotld readStmt printStmt ifStmt elsePart whileStmt loopStmt stepPart callStmt returnStmt expo exitLoop skip id indxListO 

indxList bExp relOP exp actParamListO actParamList 

Start symbol: prog

 Production Rules 

GLOBAL decil„ist stmtListO END 

decl declList 

DEF typeList END 

FUN funDef END 

typeList SEMICOLON varl.ist COLON type 

varList COLON type 

typeDef 

var COMMA varList 

ID sizeListO 

sizeList 

sizeList LEFT-SQÆKT INT-CONST RIGHTSQBICT 

LEFTSQ_BIU INT_CONST RIGHTSQ_BICT 

INT 

FLOAT 

STRING 

NUL 

typeDef 

ID

 

 

 

 

More products