| 1 |
(* Copyright (c) 1998 by Lucent Technologies *) |
| 2 |
|
| 3 |
structure ParseTree = |
| 4 |
struct |
| 5 |
|
| 6 |
datatype qualifier = CONST | VOLATILE |
| 7 |
|
| 8 |
datatype storage |
| 9 |
= TYPEDEF |
| 10 |
| STATIC |
| 11 |
| EXTERN |
| 12 |
| REGISTER |
| 13 |
| AUTO |
| 14 |
|
| 15 |
datatype operator |
| 16 |
= Plus | Minus | Times | Divide | Mod |
| 17 |
| Gt | Lt | Gte | Lte | Eq | Neq | And | Or |
| 18 |
| BitOr | BitAnd | BitXor | Lshift | Rshift |
| 19 |
| Star | AddrOf | Dot | Arrow | Sub | Sizeof |
| 20 |
| PreInc | PostInc | PreDec | PostDec | Comma |
| 21 |
| Not | Negate | BitNot | Assign |
| 22 |
| PlusAssign | MinusAssign | TimesAssign | DivAssign |
| 23 |
| ModAssign | XorAssign | OrAssign | AndAssign |
| 24 |
| LshiftAssign | RshiftAssign |
| 25 |
| Uplus |
| 26 |
| SizeofType of ctype |
| 27 |
(* |
| 28 |
| OperatorExt of operatorExt |
| 29 |
*) |
| 30 |
|
| 31 |
and expression |
| 32 |
= EmptyExpr |
| 33 |
| IntConst of LargeInt.int |
| 34 |
| RealConst of real |
| 35 |
| String of string |
| 36 |
| Id of string |
| 37 |
| Unop of operator * expression |
| 38 |
| Binop of operator * expression * expression |
| 39 |
| QuestionColon of expression * expression * expression |
| 40 |
| Call of expression * expression list |
| 41 |
| Cast of ctype * expression |
| 42 |
| InitList of expression list |
| 43 |
(* |
| 44 |
| MARKexpression of (SourceMap.location * expression) |
| 45 |
| ExprExt of expressionExt |
| 46 |
*) |
| 47 |
|
| 48 |
and specifier |
| 49 |
= Void |
| 50 |
| Ellipses |
| 51 |
| Signed |
| 52 |
| Unsigned |
| 53 |
| Char |
| 54 |
| Short |
| 55 |
| Int |
| 56 |
| Long |
| 57 |
| Float |
| 58 |
| Double |
| 59 |
| Fractional |
| 60 |
| Wholenum |
| 61 |
| Saturate |
| 62 |
| Nonsaturate |
| 63 |
| Array of expression * ctype |
| 64 |
| Pointer of ctype |
| 65 |
| Function of |
| 66 |
{retType : ctype, |
| 67 |
params : (decltype * declarator) list} |
| 68 |
| Enum of |
| 69 |
{tagOpt : string option, |
| 70 |
enumerators : (string * expression) list, |
| 71 |
trailingComma : bool} (* true if there was there a trailing comma in the declaration *) |
| 72 |
| Struct of |
| 73 |
{isStruct : bool, (* struct or union; true => struct *) |
| 74 |
tagOpt : string option, (* optional tag *) |
| 75 |
members: (ctype * (declarator * expression) list) list} (* member specs *) |
| 76 |
| TypedefName of string |
| 77 |
| StructTag of |
| 78 |
{isStruct : bool, (* ??? *) |
| 79 |
name : string} |
| 80 |
| EnumTag of string |
| 81 |
(* |
| 82 |
| SpecExt of specifierExt |
| 83 |
*) |
| 84 |
|
| 85 |
and declarator (* constructor suffix: "Decr" *) |
| 86 |
= EmptyDecr |
| 87 |
| EllipsesDecr |
| 88 |
| VarDecr of string |
| 89 |
| ArrayDecr of declarator * expression |
| 90 |
| PointerDecr of declarator |
| 91 |
| QualDecr of qualifier * declarator |
| 92 |
| FuncDecr of declarator * (decltype * declarator) list |
| 93 |
(* |
| 94 |
| MARKdeclarator of (SourceMap.location * declarator) |
| 95 |
| DecrExt of declaratorExt |
| 96 |
*) |
| 97 |
|
| 98 |
(* supports extensions of C in which expressions contain statements *) |
| 99 |
and statement |
| 100 |
= Decl of declaration |
| 101 |
| Expr of expression |
| 102 |
| Compound of statement list |
| 103 |
| While of expression * statement |
| 104 |
| Do of expression * statement |
| 105 |
| For of expression * expression * expression * statement |
| 106 |
| Labeled of string * statement |
| 107 |
| CaseLabel of expression * statement |
| 108 |
| DefaultLabel of statement |
| 109 |
| Goto of string |
| 110 |
| Break |
| 111 |
| Continue |
| 112 |
| Return of expression |
| 113 |
| IfThen of expression * statement |
| 114 |
| IfThenElse of expression * statement * statement |
| 115 |
| Switch of expression * statement |
| 116 |
(* |
| 117 |
| MARKstatement of (SourceMap.location * statement) |
| 118 |
| StatExt of statementExt |
| 119 |
*) |
| 120 |
|
| 121 |
and declaration |
| 122 |
= Declaration of decltype * (declarator * expression) list |
| 123 |
(* |
| 124 |
| MARKdeclaration of (SourceMap.location * declaration) |
| 125 |
| DeclarationExt of declarationExt |
| 126 |
*) |
| 127 |
|
| 128 |
and externalDecl |
| 129 |
= ExternalDecl of declaration |
| 130 |
| FunctionDef of (* record? *) |
| 131 |
{retType : decltype, (* return type *) |
| 132 |
funDecr : declarator, (* function name declarator *) |
| 133 |
krParams : declaration list, (* K&R-style parameter declarations *) |
| 134 |
body : statement} (* function body *) |
| 135 |
(* |
| 136 |
| MARKexternalDecl of (SourceMap.location * externalDecl) |
| 137 |
| ExternalDeclExt of externalDeclExt |
| 138 |
*) |
| 139 |
|
| 140 |
withtype ctype = |
| 141 |
{qualifiers : qualifier list, |
| 142 |
specifiers : specifier list} |
| 143 |
and decltype = |
| 144 |
{qualifiers : qualifier list, |
| 145 |
specifiers : specifier list, |
| 146 |
storage : storage list} |
| 147 |
|
| 148 |
(* |
| 149 |
and externalDeclExt = |
| 150 |
(specifier, declarator, ctype, decltype, operator, expression, statement) |
| 151 |
ParseTreeExt.externalDeclExt |
| 152 |
and declarationExt = |
| 153 |
(specifier, declarator, ctype, decltype, operator, expression, statement) |
| 154 |
ParseTreeExt.declarationExt |
| 155 |
and statementExt = |
| 156 |
(specifier, declarator, ctype, decltype, operator, expression, statement) |
| 157 |
ParseTreeExt.statementExt |
| 158 |
and declaratorExt = |
| 159 |
(specifier, declarator, ctype, decltype, operator, expression, statement) |
| 160 |
ParseTreeExt.declaratorExt |
| 161 |
and specifierExt = |
| 162 |
(specifier, declarator, ctype, decltype, operator, expression, statement) |
| 163 |
ParseTreeExt.specifierExt |
| 164 |
and expressionExt = |
| 165 |
(specifier, declarator, ctype, decltype, operator, expression, statement) |
| 166 |
ParseTreeExt.expressionExt |
| 167 |
and operatorExt = ParseTreeExt.operatorExt |
| 168 |
*) |
| 169 |
|
| 170 |
end (* structure ParseTree *) |