From 5fe6681b0d281b81a6d60ecac6ea9ac5f4d2d1b6 Mon Sep 17 00:00:00 2001 From: Li Haokun Date: Thu, 12 Aug 2021 19:00:17 +0800 Subject: [PATCH] update lexer --- nasal_lexer.h | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/nasal_lexer.h b/nasal_lexer.h index 52c766c..48faf16 100644 --- a/nasal_lexer.h +++ b/nasal_lexer.h @@ -101,7 +101,7 @@ private: int line; int ptr; std::string line_code; - std::vector res; + std::string res; std::vector token_list; int get_tok_type(std::string&); void die(const char*); @@ -125,7 +125,6 @@ void nasal_lexer::openfile(std::string& filename) { ++error; std::cout<<"[lexer] cannot open file <"<.\n"; - fin.close(); return; } while(!fin.eof()) @@ -133,9 +132,8 @@ void nasal_lexer::openfile(std::string& filename) char c=fin.get(); if(fin.eof()) break; - res.push_back(c); + res+=c; } - fin.close(); return; } @@ -177,7 +175,7 @@ std::string nasal_lexer::num_gen() while(ptr