From 9841a4c0de555e355c4513976af3646b296870cd Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Fri, 3 Apr 2015 22:40:44 +0100 Subject: [PATCH] Determine action type in a simpler way. --- re2c/code.cc | 2 +- re2c/dfa.h | 44 +------------------------------------------- 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/re2c/code.cc b/re2c/code.cc index 3e5a4def..c479db26 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -606,7 +606,7 @@ void State::emit(Output & output, uint ind, bool &readCh, const std::string& con { o << labelPrefix << label << ":\n"; } - if (dFlag && !action->isInitial()) + if (dFlag && (action->type != Action::INITIAL)) { o << indent(ind) << mapCodeName["YYDEBUG"] << "(" << label << ", " << input_api.expr_peek () << ");\n"; } diff --git a/re2c/dfa.h b/re2c/dfa.h index 6b9c34dc..8cc3eb13 100644 --- a/re2c/dfa.h +++ b/re2c/dfa.h @@ -37,9 +37,6 @@ public: virtual ~Action(); virtual void emit(Output &, uint, bool&, const std::string&) const = 0; - virtual bool isRule() const; - virtual bool isMatch() const; - virtual bool isInitial() const; virtual bool readAhead() const; #ifdef PEDANTIC @@ -63,7 +60,6 @@ class Match: public Action public: Match(State*); void emit(Output &, uint, bool&, const std::string&) const; - bool isMatch() const; }; class Enter: public Action @@ -84,7 +80,6 @@ public: public: Initial(State*, uint, bool); void emit(Output &, uint, bool&, const std::string&) const; - bool isInitial() const; }; class Save: public Match @@ -96,7 +91,6 @@ public: public: Save(State*, uint); void emit(Output &, uint, bool&, const std::string&) const; - bool isMatch() const; }; class Move: public Action @@ -150,7 +144,6 @@ public: public: Rule(State*, RuleOp*); void emit(Output &, uint, bool&, const std::string&) const; - bool isRule() const; #ifdef PEDANTIC private: @@ -279,24 +272,9 @@ inline Action::~Action() { } -inline bool Action::isRule() const -{ - return false; -} - -inline bool Action::isMatch() const -{ - return false; -} - -inline bool Action::isInitial() const -{ - return false; -} - inline bool Action::readAhead() const { - return !isMatch() || (state && state->next && state->next->action && !state->next->action->isRule()); + return (type != MATCH) || (state && state->next && state->next->action && (state->next->action->type != RULE)); } inline Match::Match(State *s) : Action(s) @@ -304,11 +282,6 @@ inline Match::Match(State *s) : Action(s) type = MATCH; } -inline bool Match::isMatch() const -{ - return true; -} - inline Enter::Enter(State *s, uint l) : Action(s), label(l) { type = ENTER; @@ -319,21 +292,11 @@ inline Initial::Initial(State *s, uint l, bool b) : Enter(s, l), setMarker(b) type = INITIAL; } -inline bool Initial::isInitial() const -{ - return true; -} - inline Save::Save(State *s, uint i) : Match(s), selector(i) { type = SAVE; } -inline bool Save::isMatch() const -{ - return false; -} - inline Move::Move(State *s) : Action(s) { type = MOVE; @@ -350,11 +313,6 @@ inline Rule::Rule(State *s, RuleOp *r) : Action(s), rule(r) type = RULE; } -inline bool Rule::isRule() const -{ - return true; -} - inline std::ostream& operator<<(std::ostream &o, const State *s) { return o << *s; -- 2.40.0