Question: I need help, now im trying to made the main.cpp code in visual studio 2 0 2 2 . i already made a . l
I need help, now im trying to made the main.cpp code in visual studio i already made a l file and y file using bison and flex. The l file code is the following
#include "cminusminusparser.tab.h Generated by Bison
return PLUS;
return MINUS;
return MULTIPLY;
return DIVIDE;
INT return INT;
azAZazAZ return ID;
return NUMBER;
r
r
Ignore comments
tr
Ignore whitespace
For any unrecognized character
and y file is the following
#include
#include
#include "cminusminusparser.tab.h
extern int yylex;
extern int yyparse;
extern FILE yyin;
void yyerrorconst char s;
token PLUS MINUS MULTIPLY DIVIDE INT ID NUMBER
left PLUS MINUS
left MULTIPLY DIVIDE
program:
declarationlist
;
declarationlist:
declarationlist declaration
declaration
;
declaration:
vardeclaration
fundeclaration
;
vardeclaration:
INT ID ;
;
fundeclaration:
INT ID params compoundstmt
;
params:
paramlist
;
paramlist:
paramlist param
param
;
param:
INT ID
;
compoundstmt:
localdeclarations statementlist
;
localdeclarations:
localdeclarations vardeclaration
;
statementlist:
statementlist statement
;
statement:
expressionstmt
compoundstmt
;
expressionstmt:
expression ;
;
;
expression:
var expression
simpleexpression
;
var:
ID
;
simpleexpression:
additiveexpression
;
additiveexpression:
additiveexpression PLUS term
additiveexpression MINUS term
term
;
term:
term MULTIPLY factor
term DIVIDE factor
factor
;
factor:
expression
var
NUMBER
;
void yyerrorconst char s
fprintfstderr "Error: s
s;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
