Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE HELP. The lex and yacc file is attached. In this labwork, you will implement a lex/yacc program that will accept map initialization statements. -
PLEASE HELP. The lex and yacc file is attached.
In this labwork, you will implement a lex/yacc program that will accept map initialization statements. - A map initialization starts with the name of map and continues with a list that contains key/value pairs denoted with \{"str", number\}. - Be careful, there can be countless numbers of key/value pairs in a list. - Your program should accept only the correct inputs and reject the others - In addition, you should detect missing "," symbol between key and value. letter [A2az] su Anclude (stdlo.hs \#include (string. h ) "include "y.tab. h" Include f " return OCB; j - return CCB; "." return EQUAL; \" [a2Az]+1" return staing; [09]+ return INTEGER; (letter) (\{letter\}|(digit\})" return IoentIfIER; in \{IInenum ++;} [lt]+ 88 8 *include ciostreas anclude // use varlable 11 nenue froe the lex flle int nap(ount-1; int count-8; 8) Xtoken cown SERTCOLON OCB CCB Equal STRING INTEGER IDENTIFIER 8s void yyerror(string s) ( \} cerres"Error at line: "eslinenumceendl; int yyerap() return 1; \} int main(int argc, char *argv[1) t /* Call the lexer, then quit. "/ yyln=fopen (argv[1], "r"); yyparse (): felose(yyin); return 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started