Permalink
Browse files
Re-added silent output for nodes
- Loading branch information
Showing
with
24 additions
and
2 deletions.
-
+2
−1
exstatik/Lexer.cpp
-
+10
−0
statik/OutputFunc.cpp
-
+11
−0
statik/OutputFunc.h
-
+1
−1
statik/Rule.cpp
|
@@ -234,6 +234,7 @@ auto_ptr<Rule> exstatik::CreateLexer_C() { |
|
|
// regexps |
|
|
or_->AddChild(REGEXP("ID", boost::regex("[A-Za-z_][0-9A-Za-z_]*"))); |
|
|
or_->AddChild(REGEXP("INT", boost::regex("[0-9]+"))); |
|
|
or_->AddChild(REGEXP("WS", boost::regex("[ \t\r\n]+"))); |
|
|
or_->AddChild(REGEXP("WS", boost::regex("[ \t\r\n]+"))) |
|
|
->SilenceOutput(); |
|
|
return lexer; |
|
|
} |
|
@@ -27,6 +27,10 @@ auto_ptr<OutputFunc> statik::MakeOutputFunc_Root() { |
|
|
return auto_ptr<OutputFunc>(new OutputFunc_Root()); |
|
|
} |
|
|
|
|
|
auto_ptr<OutputFunc> statik::MakeOutputFunc_Silent() { |
|
|
return auto_ptr<OutputFunc>(new OutputFunc_Silent()); |
|
|
} |
|
|
|
|
|
auto_ptr<OutputFunc> statik::MakeOutputFunc_Basic(const string& name, const string& value) { |
|
|
return auto_ptr<OutputFunc>(new OutputFunc_Basic(name, value)); |
|
|
} |
|
@@ -101,6 +105,12 @@ void OutputFunc_Root::operator() () { |
|
|
} |
|
|
} |
|
|
|
|
|
/* OutputFunc_Silent */ |
|
|
|
|
|
auto_ptr<OutputFunc> OutputFunc_Silent::Clone() { |
|
|
return std::auto_ptr<OutputFunc>(new OutputFunc_Silent()); |
|
|
} |
|
|
|
|
|
/* OutputFunc_Basic */ |
|
|
|
|
|
OutputFunc_Basic::OutputFunc_Basic(const string& name, const string& value) |
|
|
|
@@ -20,6 +20,7 @@ class STree; |
|
|
class OutputFunc; |
|
|
|
|
|
std::auto_ptr<OutputFunc> MakeOutputFunc_Root(); |
|
|
std::auto_ptr<OutputFunc> MakeOutputFunc_Silent(); |
|
|
std::auto_ptr<OutputFunc> MakeOutputFunc_Basic(const std::string& name, const std::string& value = ""); |
|
|
std::auto_ptr<OutputFunc> MakeOutputFunc_IValues(const std::string& name); |
|
|
std::auto_ptr<OutputFunc> MakeOutputFunc_Winner(); |
|
@@ -90,6 +91,16 @@ class OutputFunc_Root : public OutputFunc { |
|
|
virtual std::auto_ptr<OutputFunc> Clone(); |
|
|
}; |
|
|
|
|
|
// Emits nothing |
|
|
class OutputFunc_Silent : public OutputFunc { |
|
|
public: |
|
|
OutputFunc_Silent() {} |
|
|
virtual ~OutputFunc_Silent() {} |
|
|
|
|
|
virtual void operator() () {} |
|
|
virtual std::auto_ptr<OutputFunc> Clone(); |
|
|
}; |
|
|
|
|
|
// Emits a single output list node, that contains the provided name and value. |
|
|
class OutputFunc_Basic : public OutputFunc { |
|
|
public: |
|
|
|
@@ -67,7 +67,7 @@ Rule& Rule::SetOutputFunc(auto_ptr<OutputFunc> outputFunc) { |
|
|
} |
|
|
|
|
|
Rule* Rule::SilenceOutput() { |
|
|
m_outputFunc = MakeOutputFunc_Basic(""); |
|
|
m_outputFunc = MakeOutputFunc_Silent(); |
|
|
return this; |
|
|
} |
|
|
|
|
|
0 comments on commit
1ec806b