#include <limits.h>
#include <iostream>
#include "shared_ptr.hxx"
#include "Options.hxx"
#include "AST.hxx"
#include "MixFix.hxx"
#include "UocInfo.hxx"
#include "libsherpa/INOstream.hxx"
#include "BUILD/TransitionParser.hxx"
Go to the source code of this file.
Data Structures | |
| struct | QuasiKeyword |
| struct | QuasiKeywordMap |
| struct | MixRuleElement |
| struct | MixRule |
| struct | MixFixNode |
| struct | MixContext |
Defines | |
| #define | MIXDEBUG(n) if (Options::mixfixDebug >= (n)) |
Typedefs | |
| typedef shared_ptr< AST > | ASTPtr |
| typedef std::vector< ASTPtr > | ASTVec |
| typedef std::vector< std::string > | StringVec |
| typedef sherpa::EnumSet< MixElemModifierValues > | MixElemModifiers |
| typedef std::vector< MixRuleElement > | MixElemVec |
| typedef shared_ptr< MixRule > | MixRulePtr |
| typedef std::vector< MixFixNode > | MixInput |
Enumerations | |
| enum | MixElemModifierValues { MEMV_NONE, MEMV_THUNK } |
Functions | |
| template<class T> | |
| static const T & | top (const std::vector< T > &vec) |
| template<class T> | |
| static T & | top (std::vector< T > &vec) |
| template<class T> | |
| static const T & | topNext (const std::vector< T > &vec) |
| template<class T> | |
| static void | push (std::vector< T > &vec, const T &elem) |
| template<class T> | |
| static T | pop (std::vector< T > &vec) |
| INOstream & | operator<< (INOstream &out, MixRule &rule) |
| static ASTPtr | CleanMixFix (INOstream &errStream, ASTPtr ast) |
| Rewrite the parse tree produced by ParseMixFix to handle some odd cases. | |
| static ASTPtr | CheckMixFix (INOstream &errStream, ASTPtr ast) |
| shared_ptr< AST > | ProcessMixFix (std::ostream &err, shared_ptr< AST > mixAST) |
| Wrapper for ParseMixFix. | |
| static MixFixNode | reduce (INOstream &errStream, MixInput &shunt, MixRulePtr rule) |
| void | mixfix_init () |
| Initialize the mixfix rule table (temporary expedient for testing). | |
| static bool | HandleMixFix (std::ostream &errStream, shared_ptr< AST > ast) |
Variables | |
| MixContext | TheMixContext |
| static MixRulePtr | MixNoRuleFound = MixRule::make(msc_expr, "_", INT_MIN, assoc_none) |
| static MixRulePtr | MixStartRule = MixRule::make(msc_expr, "_", INT_MIN, assoc_none) |
| static MixRulePtr | MixInputRule = MixRule::make(msc_expr, "(_)", INT_MIN, assoc_none) |
| MixRulePtr | MixRules [] |
| List of built-in mixfix rules. | |
| static size_t | nMixRules = sizeof(MixRules) / sizeof(MixRules[0]) |
This is a PLACEHOLDER implementation. I'm using a fixed operator table while I get this debugged, and there is a bunch of global state in this file that needs to be gathered into a suitable object/structure once I sort out the implementation.
Part of the question at hand is that it's not clear how early the mixfix stuff needs to be taken into account. Some questions in my mind at the moment:
Definition in file MixFix.cxx.
| #define MIXDEBUG | ( | n | ) | if (Options::mixfixDebug >= (n)) |
Definition at line 85 of file MixFix.cxx.
Referenced by MixContext::cannotPossiblyMatch(), MixContext::ParseOneMixFix(), ProcessMixFix(), and reduce().
Definition at line 91 of file MixFix.cxx.
Definition at line 92 of file MixFix.cxx.
Definition at line 195 of file MixFix.cxx.
| typedef std::vector<MixRuleElement> MixElemVec |
Definition at line 215 of file MixFix.cxx.
| typedef std::vector<MixFixNode> MixInput |
Definition at line 345 of file MixFix.cxx.
| typedef shared_ptr<MixRule> MixRulePtr |
Definition at line 294 of file MixFix.cxx.
| typedef std::vector<std::string> StringVec |
Definition at line 93 of file MixFix.cxx.
Rewrite the parse tree produced by ParseMixFix to handle some odd cases.
Definition at line 615 of file MixFix.cxx.
References at_and, at_apply, at_ident, at_nth, at_or, at_select, at_unit, and AST::make().
Referenced by ProcessMixFix().
| static bool HandleMixFix | ( | std::ostream & | errStream, | |
| shared_ptr< AST > | ast | |||
| ) | [static] |
| void mixfix_init | ( | ) |
Initialize the mixfix rule table (temporary expedient for testing).
Definition at line 1180 of file MixFix.cxx.
References MixContext::add(), and TheMixContext.
Referenced by main().
| static T pop | ( | std::vector< T > & | vec | ) | [inline, static] |
Definition at line 132 of file MixFix.cxx.
References top().
Referenced by MixContext::ParseOneMixFix(), and TopInit().
Wrapper for ParseMixFix.
We need to shift/pushback on the input, so we implement it as a stack such that the top element is the first element of the input.
Definition at line 723 of file MixFix.cxx.
References CheckMixFix(), CleanMixFix(), boost::GC_NULL, MixContext::isKwd(), sherpa::INOstream::less(), MIXDEBUG, sherpa::INOstream::more(), MixContext::ParseMixFix(), pp_FinalNewline, pp_NONE, push(), MixContext::rules, TheMixContext, and top().
Referenced by HandleMixFix(), and resolve().
| static void push | ( | std::vector< T > & | vec, | |
| const T & | elem | |||
| ) | [inline, static] |
Definition at line 125 of file MixFix.cxx.
Referenced by MixContext::ParseOneMixFix(), and ProcessMixFix().
| static MixFixNode reduce | ( | INOstream & | errStream, | |
| MixInput & | shunt, | |||
| MixRulePtr | rule | |||
| ) | [static] |
Definition at line 785 of file MixFix.cxx.
References assert(), MixFixNode::ast, at_apply, at_argVec, at_ident, at_labeledBlock, at_lambda, at_typeapp, AST::make(), MEMV_THUNK, MIXDEBUG, msc_expr, msc_type, and pp_FinalNewline.
Referenced by MixContext::ParseOneMixFix().
| static T& top | ( | std::vector< T > & | vec | ) | [inline, static] |
| static const T& top | ( | const std::vector< T > & | vec | ) | [inline, static] |
Definition at line 101 of file MixFix.cxx.
References assert().
Referenced by MixContext::cannotPossiblyMatch(), MixContext::ParseOneMixFix(), pop(), ProcessMixFix(), and Specialize().
| static const T& topNext | ( | const std::vector< T > & | vec | ) | [inline, static] |
Definition at line 117 of file MixFix.cxx.
References assert().
Referenced by MixContext::cannotPossiblyMatch().
MixRulePtr MixInputRule = MixRule::make(msc_expr, "(_)", INT_MIN, assoc_none) [static] |
Definition at line 715 of file MixFix.cxx.
MixRulePtr MixNoRuleFound = MixRule::make(msc_expr, "_", INT_MIN, assoc_none) [static] |
Definition at line 713 of file MixFix.cxx.
List of built-in mixfix rules.
For the moment, this is actually all of the mixfix rules. Once I get the mixfix mechanism debugged and the syntax for mixfix introduction in place many of these will move to the prelude.
User-defined mixfix rules have precedence between 0 and 15 (inclusive). Application and array indexing have precedence -1, while constant definition syntax has precedence -3 (but is closed, so that doesn't really matter.
Definition at line 1103 of file MixFix.cxx.
MixRulePtr MixStartRule = MixRule::make(msc_expr, "_", INT_MIN, assoc_none) [static] |
Definition at line 714 of file MixFix.cxx.
Definition at line 1177 of file MixFix.cxx.
| struct MixContext TheMixContext |
Referenced by mixfix_init(), and ProcessMixFix().
1.4.7