From 12f606ce06ef926f366a03079c5e3107c23f18af Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 19 Nov 2010 13:18:48 +0000 Subject: Added tool bison++-1.21.11 --- tools/bison++/Example/MyCompiler.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tools/bison++/Example/MyCompiler.cc (limited to 'tools/bison++/Example/MyCompiler.cc') diff --git a/tools/bison++/Example/MyCompiler.cc b/tools/bison++/Example/MyCompiler.cc new file mode 100644 index 000000000..3c554bc40 --- /dev/null +++ b/tools/bison++/Example/MyCompiler.cc @@ -0,0 +1,32 @@ +#include "MyParser.h" +#define YY_DECL int yyFlexLexer::yylex(YY_MyParser_STYPE *val) +#include "FlexLexer.h" +#include + +class MyCompiler : public MyParser +{ +private: + yyFlexLexer theScanner; + public: + virtual int yylex(); + virtual void yyerror(char *m); + MyCompiler(){;} +}; + +int MyCompiler::yylex() +{ + return theScanner.yylex(&yylval); +} + +void MyCompiler::yyerror(char *m) +{ fprintf(stderr,"%d: %s at token '%s'\n",yylloc.first_line, m,yylloc.text); +} + +int main(int argc,char **argv) +{ + MyCompiler aCompiler; + int result=aCompiler.yyparse(); + printf("Resultat Parsing=%s\n",result?"Erreur":"OK"); + return 0; +}; + -- cgit v1.2.3