moved scanner elsehere
This commit is contained in:
parent
909a43114b
commit
0018a97b1e
3 changed files with 30 additions and 23 deletions
23
src/lexer.l
23
src/lexer.l
|
|
@ -3,28 +3,7 @@
|
|||
%option yyclass="Scanner"
|
||||
|
||||
%{
|
||||
#include "../build/parser.hpp"
|
||||
#include <string>
|
||||
|
||||
class Scanner : public yyFlexLexer {
|
||||
public:
|
||||
Scanner(std::istream* in) : yyFlexLexer(in) {}
|
||||
|
||||
int yylex();
|
||||
|
||||
int lex(yy::parser::semantic_type* yylval) {
|
||||
this->yylval = yylval;
|
||||
return yylex();
|
||||
}
|
||||
|
||||
private:
|
||||
yy::parser::semantic_type* yylval;
|
||||
};
|
||||
|
||||
int scanner_lex(yy::parser::semantic_type* yylval) {
|
||||
static Scanner scanner(&std::cin);
|
||||
return scanner.lex(yylval);
|
||||
}
|
||||
#include "../src/scanner.hpp"
|
||||
%}
|
||||
|
||||
%%
|
||||
|
|
|
|||
28
src/scanner.hpp
Normal file
28
src/scanner.hpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
#include "../build/parser.hpp"
|
||||
#include <string>
|
||||
|
||||
class yyFlexLexer;
|
||||
|
||||
class Scanner : public yyFlexLexer
|
||||
{
|
||||
public:
|
||||
Scanner(std::istream *in) : yyFlexLexer(in) {}
|
||||
|
||||
int yylex();
|
||||
|
||||
int lex(yy::parser::semantic_type *yylval)
|
||||
{
|
||||
this->yylval = yylval;
|
||||
return yylex();
|
||||
}
|
||||
|
||||
private:
|
||||
yy::parser::semantic_type *yylval;
|
||||
};
|
||||
|
||||
int scanner_lex(yy::parser::semantic_type *yylval)
|
||||
{
|
||||
static Scanner scanner(&std::cin);
|
||||
return scanner.lex(yylval);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue