00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef COMMA_PARSER_BRIDGE_HDR_GUARD
00010 #define COMMA_PARSER_BRIDGE_HDR_GUARD
00011
00012 #include "comma/basic/IdentifierInfo.h"
00013 #include "llvm/Support/DataTypes.h"
00014
00015 namespace comma {
00016
00017 class Node {
00018
00019 public:
00020
00021 Node() : payload(1) { }
00022 Node(void *ptr) : payload(reinterpret_cast<uintptr_t>(ptr)) { }
00023
00024 static Node getInvalidNode() { return Node(); }
00025
00026
00027 bool isInvalid() const { return payload & 1u; }
00028
00029
00030 bool isValid() const { return !isInvalid(); }
00031
00032
00033 template <class T> static T *lift(Node &node) {
00034 return reinterpret_cast<T*>(node.payload & ~((uintptr_t)1));
00035 }
00036
00037 private:
00038 uintptr_t payload;
00039 };
00040
00041 class Bridge {
00042
00043 public:
00044
00045
00046
00047
00048 virtual void deleteNode(Node node) = 0;
00049
00050
00051
00052
00053 virtual void beginSignatureDefinition(IdentifierInfo *name,
00054 Location loc) = 0;
00055
00056 virtual void beginDomainDefinition(IdentifierInfo *name, Location loc) = 0;
00057
00058 virtual void endModelDefinition() = 0;
00059
00060
00061
00062
00063
00064
00065 virtual Node acceptModelParameter(IdentifierInfo *formal,
00066 Node typeNode, Location loc) = 0;
00067
00068
00069
00070
00071
00072 virtual void acceptModelParameterList(Node *params,
00073 Location *locs, unsigned arity) = 0;
00074
00075
00076
00077
00078
00079
00080 virtual Node acceptModelSupersignature(Node typeNode, Location loc) = 0;
00081
00082
00083
00084
00085
00086 virtual void acceptModelSupersignatureList(Node *sigs,
00087 unsigned numSigs) = 0;
00088
00089 virtual Node acceptSignatureComponent(IdentifierInfo *name,
00090 Node typeNode, Location loc) = 0;
00091
00092 virtual void acceptSignatureComponentList(Node *components,
00093 unsigned numComponents) = 0;
00094
00095
00096 virtual Node acceptPercent(Location loc) = 0;
00097
00098 virtual Node acceptTypeIdentifier(IdentifierInfo *info, Location loc) = 0;
00099
00100 virtual Node acceptTypeApplication(IdentifierInfo *connective,
00101 Node *argumentNodes,
00102 Location *argumentLocs,
00103 unsigned numArgs,
00104 IdentifierInfo **selectors,
00105 Location *selectorLocs,
00106 unsigned numSelectors,
00107 Location loc) = 0;
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 virtual Node acceptFunctionType(IdentifierInfo **formals,
00118 Location *formalLocations,
00119 Node *types,
00120 Location *typeLocations,
00121 unsigned arity,
00122 Node returnType,
00123 Location returnLocation) = 0;
00124 };
00125
00126 }
00127
00128 #endif