diff options
| author | Nagi5Yeq <wu@x-nagi.com> | 2020-05-13 00:40:23 +0800 |
|---|---|---|
| committer | Nagi5Yeq <wu@x-nagi.com> | 2020-05-13 00:40:23 +0800 |
| commit | c7d52437db42232d98e585a52ed2fdf75eb7f1af (patch) | |
| tree | 46f6c75f49de6c53937b53266fcf153cc0f8c510 /Lexer.l | |
| parent | 61d670dda6f95aa414b4ea4a7dcaba25890b9e6b (diff) | |
code refactoring
Diffstat (limited to 'Lexer.l')
| -rw-r--r-- | Lexer.l | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -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 |
