[SOLVED] Compiler- Lab 8: Lexical analysis and parsing using Lex/Flex and Yacc/Bison

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

. 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

 

 

 

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.