summaryrefslogtreecommitdiff
path: root/Lexer.l
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-13 00:40:23 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-13 00:40:23 +0800
commitc7d52437db42232d98e585a52ed2fdf75eb7f1af (patch)
tree46f6c75f49de6c53937b53266fcf153cc0f8c510 /Lexer.l
parent61d670dda6f95aa414b4ea4a7dcaba25890b9e6b (diff)
code refactoring
Diffstat (limited to 'Lexer.l')
-rw-r--r--Lexer.l26
1 files changed, 11 insertions, 15 deletions
diff --git a/Lexer.l b/Lexer.l
index aef2259..cd1b634 100644
--- a/Lexer.l
+++ b/Lexer.l
@@ -7,13 +7,12 @@
#include "Log.hh"
#include "Driver.hh"
-#include "Location.hh"
+#include "Lexer.hh"
using pcc::Parser;
using pcc::Location;
namespace pcc {
- class Lexer;
char ToLower(char c){
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
}
@@ -175,7 +174,7 @@ white [\t\f\r ]
}
}
*p++='\0';
- return Parser::make_STRING_LITERAL(str, loc);
+ return pcc::Lexer::make_STRING_LITERAL(str, driver, loc);
}
{identifier} {
@@ -196,17 +195,14 @@ white [\t\f\r ]
%%
namespace pcc {
- int Driver::StartLexer(std::string &filename)
- {
- yyin=std::fopen(filename.c_str(),"r");
- if(yyin==NULL){
- Log(PCC_ERROR, "Failed to open file %s", filename.c_str());
- return -1;
- }
- return 0;
- }
-
- void Driver::StopLexer(){
- std::fclose(yyin);
+int Driver::StartLexer(std::string& filename) {
+ yyin = std::fopen(filename.c_str(), "r");
+ if (yyin == NULL) {
+ Log(PCC_ERROR, "Failed to open file %s", filename.c_str());
+ return -1;
}
+ return 0;
}
+
+void Driver::StopLexer() { std::fclose(yyin); }
+} // namespace pcc