Public Types | |
| typedef std::set< MixRulePtr > | RuleSet |
Public Member Functions | |
| void | add (MixRulePtr rule) |
| Add a new mixfix rule to the ruleset. | |
| void | remove (MixRulePtr rule) |
| Remove an existing mixfix rule from the ruleset. | |
| MixRulePtr | ParseOneMixFix (sherpa::INOstream &errStream, MixInput &origInput, MixRulePtr parentRule) |
| Perform one leading reduction on the input. | |
| MixRulePtr | ParseMixFix (sherpa::INOstream &errStream, MixInput &origInput, MixRulePtr parentRule) |
| Trivial wrapper on ParseOneMixFix. | |
| bool | isKwd (const MixFixNode &mixNode) |
| bool | cannotPossiblyMatch (sherpa::INOstream &errStream, MixRulePtr rule, const MixInput &mixExpr) |
| Return true if this rule definitely cannot match the beginning of the lookahead stream. | |
Data Fields | |
| RuleSet | rules |
| QuasiKeywordMap | kwMap |
Definition at line 347 of file MixFix.cxx.
| typedef std::set<MixRulePtr> MixContext::RuleSet |
Definition at line 348 of file MixFix.cxx.
| void MixContext::add | ( | MixRulePtr | rule | ) |
Add a new mixfix rule to the ruleset.
Definition at line 564 of file MixFix.cxx.
References QuasiKeywordMap::add(), kwMap, and rules.
Referenced by mixfix_init().
| bool MixContext::cannotPossiblyMatch | ( | sherpa::INOstream & | errStream, | |
| MixRulePtr | rule, | |||
| const MixInput & | mixExpr | |||
| ) |
Return true if this rule definitely cannot match the beginning of the lookahead stream.
This is for use as an early filter. It does not consider the possibility that reductions occurring at the head of the input stream might later lead to a match being possible.
Definition at line 493 of file MixFix.cxx.
References MIXDEBUG, top(), and topNext().
Referenced by ParseOneMixFix().
| bool MixContext::isKwd | ( | const MixFixNode & | mixNode | ) |
Definition at line 484 of file MixFix.cxx.
References MixFixNode::ast, at_ident, QuasiKeywordMap::contains(), and kwMap.
Referenced by ProcessMixFix().
| MixRulePtr MixContext::ParseMixFix | ( | sherpa::INOstream & | errStream, | |
| MixInput & | origInput, | |||
| MixRulePtr | parentRule | |||
| ) |
Trivial wrapper on ParseOneMixFix.
When ParseOneMixFix succeeds at performing a reduction, the input has changed, and we need to try repeatedly until no further reductions are possible. The final call to ParseOneMixFix will fail, which is expected and okay.
Definition at line 1080 of file MixFix.cxx.
References boost::GC_NULL, and ParseOneMixFix().
Referenced by ParseOneMixFix(), and ProcessMixFix().
| MixRulePtr MixContext::ParseOneMixFix | ( | sherpa::INOstream & | errStream, | |
| MixInput & | origInput, | |||
| MixRulePtr | parentRule | |||
| ) |
Perform one leading reduction on the input.
The ``one'' should be taken with salt, because ParseOneMixFix has to deal with precedence inversion at the right, and can therefore end up performing what amounts to multiple reductions. Given the rules and input:
infix 3 _+_ infix 4 _*_ 1 * 2 + 3
The parser initially proceeds left-to-right looking for the matching rule with highest precedence that can be made to ``fit'' on the left. In this case, that's _*_. When it goes to parse the trailing hole, it reduces _+_ and then reduces _+_. Ordinarily, this would produce:
1 * ( 2 + 3 )
which is clearly wrong. The reduce action, however, is aware of precedence inversion on the right, and performs a tree-rotate at reduce time. Note that this issue cannot arise on the left, because we always seek the reduction with the highest possible precedence from the left.
Definition at line 872 of file MixFix.cxx.
References assert(), assoc_right, cannotPossiblyMatch(), boost::GC_NULL, sherpa::INOstream::less(), MIXDEBUG, sherpa::INOstream::more(), ParseMixFix(), pop(), pp_FinalNewline, pp_NONE, push(), reduce(), rules, and top().
Referenced by ParseMixFix().
| void MixContext::remove | ( | MixRulePtr | rule | ) |
Remove an existing mixfix rule from the ruleset.
Definition at line 589 of file MixFix.cxx.
References kwMap, QuasiKeywordMap::remove(), and rules.
Definition at line 349 of file MixFix.cxx.
Referenced by add(), ParseOneMixFix(), ProcessMixFix(), and remove().
1.4.7