From 283bfdb95e741c057259931307a3da3cc2b4e58b Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 26 Feb 2015 12:37:07 +0000 Subject: [PATCH] 'token.h' no longer depends on 'file_info'. Part of campaign to remove 'stream_lc.h'. --- re2c/bootstrap/parser.cc | 6 +++--- re2c/parser.y | 6 +++--- re2c/token.h | 27 ++------------------------- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/re2c/bootstrap/parser.cc b/re2c/bootstrap/parser.cc index 2a7be601..7e61a5c6 100644 --- a/re2c/bootstrap/parser.cc +++ b/re2c/bootstrap/parser.cc @@ -157,7 +157,7 @@ void context_rule(CondList *clist, RegExp *expr, RegExp *look, Str *newcond, Tok for(CondList::const_iterator it = clist->begin(); it != clist->end(); ++it) { //Str *condcpy = newcond ? new Str(*newcond) : newcond; - Token *token = new Token(code, sourceFileInfo, newcond);//condcpy); + Token *token = new Token(code, sourceFileInfo.fname, sourceFileInfo.ln->get_line (), newcond);//condcpy); RuleOp *rule = new RuleOp(expr, look, token, accept++, ins_access); RegExpMap::iterator itRE = specMap.find(*it); @@ -1723,7 +1723,7 @@ yyreduce: { assert((yyvsp[(7) - (7)].str)); context_check(NULL); - Token *token = new Token(NULL, sourceFileInfo, (yyvsp[(7) - (7)].str)); + Token *token = new Token(NULL, sourceFileInfo.fname, sourceFileInfo.ln->get_line (), (yyvsp[(7) - (7)].str)); delete (yyvsp[(7) - (7)].str); specStar.push_back(new RuleOp((yyvsp[(4) - (7)].regexp), (yyvsp[(5) - (7)].regexp), token, accept++, RegExp::PRIVATE)); } @@ -1779,7 +1779,7 @@ yyreduce: { in->fatal("code to handle illegal condition already defined"); } - Token *token = new Token(NULL, sourceFileInfo, (yyvsp[(3) - (3)].str)); + Token *token = new Token(NULL, sourceFileInfo.fname, sourceFileInfo.ln->get_line (), (yyvsp[(3) - (3)].str)); delete (yyvsp[(3) - (3)].str); (yyval.regexp) = specNone = new RuleOp(new NullOp(), new NullOp(), token, accept++, RegExp::SHARED); } diff --git a/re2c/parser.y b/re2c/parser.y index 530785a2..6b8752b5 100644 --- a/re2c/parser.y +++ b/re2c/parser.y @@ -89,7 +89,7 @@ void context_rule(CondList *clist, RegExp *expr, RegExp *look, Str *newcond, Tok for(CondList::const_iterator it = clist->begin(); it != clist->end(); ++it) { //Str *condcpy = newcond ? new Str(*newcond) : newcond; - Token *token = new Token(code, sourceFileInfo, newcond);//condcpy); + Token *token = new Token(code, sourceFileInfo.fname, sourceFileInfo.ln->get_line (), newcond);//condcpy); RuleOp *rule = new RuleOp(expr, look, token, accept++, ins_access); RegExpMap::iterator itRE = specMap.find(*it); @@ -281,7 +281,7 @@ rule: { assert($7); context_check(NULL); - Token *token = new Token(NULL, sourceFileInfo, $7); + Token *token = new Token(NULL, sourceFileInfo.fname, sourceFileInfo.ln->get_line (), $7); delete $7; specStar.push_back(new RuleOp($4, $5, token, accept++, RegExp::PRIVATE)); } @@ -322,7 +322,7 @@ rule: { in->fatal("code to handle illegal condition already defined"); } - Token *token = new Token(NULL, sourceFileInfo, $3); + Token *token = new Token(NULL, sourceFileInfo.fname, sourceFileInfo.ln->get_line (), $3); delete $3; $$ = specNone = new RuleOp(new NullOp(), new NullOp(), token, accept++, RegExp::SHARED); } diff --git a/re2c/token.h b/re2c/token.h index 9ef5b258..c7410797 100644 --- a/re2c/token.h +++ b/re2c/token.h @@ -3,7 +3,6 @@ #define _token_h #include "substr.h" -#include "stream_lc.h" namespace re2c { @@ -18,24 +17,12 @@ public: const bool autogen; public: - Token(const SubStr&, const file_info&); Token(const SubStr&, const std::string&, uint); - Token(const Token*, const file_info&, const Str*); Token(const Token*, const std::string&, uint, const Str*); Token(const Token& oth); ~Token(); }; -inline Token::Token(const SubStr& t, const file_info& fi) - : text(t) - , newcond() - , source(fi.fname) - , line(fi.ln->get_line()) - , autogen(false) -{ - ; -} - inline Token::Token(const SubStr& t, const std::string& s, uint l) : text(t) , newcond() @@ -46,21 +33,11 @@ inline Token::Token(const SubStr& t, const std::string& s, uint l) ; } -inline Token::Token(const Token* t, const file_info& fi, const Str *c) - : text(t ? t->text.to_string().c_str() : "") - , newcond(c ? c->to_string() : "") - , source(t ? t->source : fi.fname) - , line(t ? t->line : fi.ln->get_line()) - , autogen(t == NULL) -{ - ; -} - inline Token::Token(const Token* t, const std::string& s, uint l, const Str *c) : text(t ? t->text.to_string().c_str() : "") , newcond(c ? c->to_string() : "") - , source(s) - , line(l) + , source(t ? t->source : s) + , line(t ? t->line : l) , autogen(t == NULL) { ; -- 2.40.0