fixed scanner.hpp
This commit is contained in:
parent
0018a97b1e
commit
05ba6f6e7f
4 changed files with 18 additions and 9 deletions
4
makefile
4
makefile
|
|
@ -5,7 +5,7 @@ FLEX = flex
|
|||
|
||||
TARGET = build/py2rb
|
||||
|
||||
$(TARGET): build/parser.o build/lexer.o build/main.o
|
||||
$(TARGET): build/parser.o build/lexer.o build/main.o build/scanner.o
|
||||
$(CXX) $^ -o $@
|
||||
|
||||
build/parser.cpp build/parser.hpp: src/parser.y | build
|
||||
|
|
@ -17,7 +17,7 @@ build/lexer.cpp build/lexer.hpp: src/lexer.l build/parser.hpp src/scanner.hpp |
|
|||
build/%.o: build/%.cpp
|
||||
$(CXX) -c $(ARGS) $< -o $@
|
||||
|
||||
build/main.o: src/main.cpp | build
|
||||
build/%.o: src/%.cpp | build
|
||||
$(CXX) -c $(ARGS) $< -o $@
|
||||
|
||||
build:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "../build/parser.hpp"
|
||||
#include "../src/scanner.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
|||
7
src/scanner.cpp
Normal file
7
src/scanner.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include "../src/scanner.hpp"
|
||||
|
||||
int scanner_lex(yy::parser::semantic_type *yylval)
|
||||
{
|
||||
static Scanner scanner(&std::cin);
|
||||
return scanner.lex(yylval);
|
||||
}
|
||||
|
|
@ -1,4 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
// fucking piece of shit flex, doesn't even have proper macro directives
|
||||
#ifndef yyFlexLexer
|
||||
#include <FlexLexer.h>
|
||||
#endif
|
||||
|
||||
#include "../build/parser.hpp"
|
||||
#include <string>
|
||||
|
||||
|
|
@ -9,8 +15,6 @@ class Scanner : public yyFlexLexer
|
|||
public:
|
||||
Scanner(std::istream *in) : yyFlexLexer(in) {}
|
||||
|
||||
int yylex();
|
||||
|
||||
int lex(yy::parser::semantic_type *yylval)
|
||||
{
|
||||
this->yylval = yylval;
|
||||
|
|
@ -18,11 +22,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
virtual int yylex();
|
||||
yy::parser::semantic_type *yylval;
|
||||
};
|
||||
|
||||
int scanner_lex(yy::parser::semantic_type *yylval)
|
||||
{
|
||||
static Scanner scanner(&std::cin);
|
||||
return scanner.lex(yylval);
|
||||
}
|
||||
int scanner_lex(yy::parser::semantic_type *yylval);
|
||||
Loading…
Add table
Add a link
Reference in a new issue