mbbill / flexbison Goto Github PK
View Code? Open in Web Editor NEWFlex and bison sample code
Flex and bison sample code
Sorry, if this is a dumb question. But the stmt
part in fb3-2.y seems like ambiguous, but why does bison accept it?
stmt: IF exp THEN list { $$ = newflow('I', $2, $4, NULL); }
| IF exp THEN list ELSE list { $$ = newflow('I', $2, $4, $6); }
| WHILE exp DO list { $$ = newflow('W', $2, $4, NULL); }
| exp
;
$ make -f Makefile.ch9
flex -opurewc.lex.c purewc.l
cc -g -c -o purewc.lex.o purewc.lex.c
purewc.l:32:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
int argc;
^~~~
cc -g -o purewc purewc.lex.c
purewc.l:32:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
int argc;
^~~~
flex -opurecalc.lex.c purecalc.l
bison -vd purecalc.y
cc -g -c -o purecalc.lex.o purecalc.lex.c
In file included from purecalc.l:14:0:
purecalc.tab.h:86:21: warning: ‘struct pcdata’ declared inside parameter list will not be visible outside of this definition or declaration
int yyparse (struct pcdata *pp);
^~~~~~
cc -g -c -o purecalc.tab.o purecalc.tab.c
purecalc.tab.c:143:21: warning: ‘struct pcdata’ declared inside parameter list will not be visible outside of this definition or declaration
int yyparse (struct pcdata *pp);
^~~~~~
purecalc.tab.c:1024:1: error: conflicting types for ‘yyparse’
yyparse (struct pcdata *pp)
^~~~~~~
purecalc.tab.c:143:5: note: previous declaration of ‘yyparse’ was here
int yyparse (struct pcdata *pp);
^~~~~~~
purecalc.tab.c: In function ‘yyparse’:
purecalc.tab.c:1193:16: error: too few arguments to function ‘yylex’
yychar = yylex (&yylval);
^~~~~
In file included from purecalc.y:26:0:
purecalc.lex.h:321:12: note: declared here
extern int yylex
^~~~~
: recipe for target 'purecalc.tab.o' failed
make: *** [purecalc.tab.o] Error 1
$ cc --version
cc (Debian 6.2.1-5) 6.2.1 20161124
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ flex --version
flex 2.6.1
$ bison --version
bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.