MixFix.cxx File Reference

Implementation of mixfix mechanism and associated parsing. See (Plan for) MixFix Processing for a detailed discussion of how BitC handles MixFix. More...

#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< ASTASTPtr
typedef std::vector< ASTPtrASTVec
typedef std::vector< std::string > StringVec
typedef sherpa::EnumSet< MixElemModifierValuesMixElemModifiers
typedef std::vector< MixRuleElementMixElemVec
typedef shared_ptr< MixRuleMixRulePtr
typedef std::vector< MixFixNodeMixInput

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)
INOstreamoperator<< (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< ASTProcessMixFix (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])


Detailed Description

Implementation of mixfix mechanism and associated parsing. See (Plan for) MixFix Processing for a detailed discussion of how BitC handles MixFix.

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 Documentation

#define MIXDEBUG (  )     if (Options::mixfixDebug >= (n))

Definition at line 85 of file MixFix.cxx.

Referenced by MixContext::cannotPossiblyMatch(), MixContext::ParseOneMixFix(), ProcessMixFix(), and reduce().


Typedef Documentation

typedef shared_ptr<AST> ASTPtr

Definition at line 91 of file MixFix.cxx.

typedef std::vector<ASTPtr> ASTVec

Definition at line 92 of file MixFix.cxx.

typedef sherpa::EnumSet<MixElemModifierValues> MixElemModifiers

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.


Enumeration Type Documentation

enum MixElemModifierValues

Enumerator:
MEMV_NONE 
MEMV_THUNK 

Definition at line 190 of file MixFix.cxx.


Function Documentation

static ASTPtr CheckMixFix ( INOstream errStream,
ASTPtr  ast 
) [static]

Definition at line 708 of file MixFix.cxx.

Referenced by ProcessMixFix().

static ASTPtr CleanMixFix ( INOstream errStream,
ASTPtr  ast 
) [static]

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]

Definition at line 1188 of file MixFix.cxx.

References at_mixfix, and ProcessMixFix().

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().

INOstream& operator<< ( INOstream out,
MixRule rule 
)

Definition at line 296 of file MixFix.cxx.

References MixRule::PrettyPrint().

template<class T>
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().

shared_ptr<AST> ProcessMixFix ( std::ostream &  err,
shared_ptr< AST mixAST 
)

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().

template<class T>
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().

template<class T>
static T& top ( std::vector< T > &  vec  )  [inline, static]

Definition at line 109 of file MixFix.cxx.

References assert().

template<class T>
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().

template<class T>
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().


Variable Documentation

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.

MixRulePtr MixRules[]

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.

size_t nMixRules = sizeof(MixRules) / sizeof(MixRules[0]) [static]

Definition at line 1177 of file MixFix.cxx.

struct MixContext TheMixContext

Referenced by mixfix_init(), and ProcessMixFix().


Generated on Thu May 17 23:59:16 2012 for BitC Compiler by  doxygen 1.4.7