File: MyCompiler.cc

package info (click to toggle)
bison%2B%2B 1.21.11-3.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,628 kB
  • ctags: 882
  • sloc: cpp: 8,198; sh: 613; ansic: 464; makefile: 112; yacc: 44; lex: 30
file content (32 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "MyParser.h"
#define YY_DECL int yyFlexLexer::yylex(YY_MyParser_STYPE *val)
#include "FlexLexer.h"
#include <stdio.h>

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;
};