Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 1 | %{ |
| 2 | |
| 3 | /** |
| 4 | * Thrift parser. |
| 5 | * |
| 6 | * This parser is used on a thrift definition file. |
| 7 | * |
| 8 | * @author Mark Slee <mcslee@facebook.com> |
| 9 | */ |
| 10 | |
| 11 | #include <stdio.h> |
| 12 | #include "main.h" |
| 13 | #include "globals.h" |
| 14 | #include "parse/t_program.h" |
| 15 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 16 | /** |
| 17 | * This global variable is used for automatic numbering of field indices etc. |
| 18 | * when parsing the members of a struct. Field values are automatically |
| 19 | * assigned starting from -1 and working their way down. |
| 20 | */ |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 21 | int y_field_val = -1; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 22 | |
| 23 | %} |
| 24 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 25 | /** |
| 26 | * This structure is used by the parser to hold the data types associated with |
| 27 | * various parse nodes. |
| 28 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 29 | %union { |
| 30 | char* id; |
| 31 | int iconst; |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 32 | bool tbool; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 33 | t_type* ttype; |
| 34 | t_typedef* ttypedef; |
| 35 | t_enum* tenum; |
| 36 | t_struct* tstruct; |
| 37 | t_service* tservice; |
| 38 | t_function* tfunction; |
| 39 | t_field* tfield; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 40 | t_constant* tconstant; |
| 41 | } |
| 42 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 43 | /** |
| 44 | * Strings identifier |
| 45 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 46 | %token<id> tok_identifier |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Integer constant value |
| 50 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 51 | %token<iconst> tok_int_constant |
| 52 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 53 | /** |
| 54 | * Namespace keyword |
| 55 | */ |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 56 | %token tok_namespace |
| 57 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 58 | /** |
| 59 | * Base datatype keywords |
| 60 | */ |
| 61 | %token tok_void |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 62 | %token tok_bool |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 63 | %token tok_byte |
| 64 | %token tok_string |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 65 | %token tok_i16 |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 66 | %token tok_i32 |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 67 | %token tok_i64 |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 68 | %token tok_double |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 69 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 70 | /** |
| 71 | * Complex type keywords |
| 72 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 73 | %token tok_map |
| 74 | %token tok_list |
| 75 | %token tok_set |
| 76 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 77 | /** |
| 78 | * Function modifiers |
| 79 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 80 | %token tok_async |
| 81 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 82 | /** |
| 83 | * Thrift language keywords |
| 84 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 85 | %token tok_typedef |
| 86 | %token tok_struct |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 87 | %token tok_xception |
| 88 | %token tok_throws |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 89 | %token tok_service |
| 90 | %token tok_enum |
| 91 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 92 | /** |
| 93 | * Grammar nodes |
| 94 | */ |
| 95 | |
| 96 | %type<id> Namespace |
| 97 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 98 | %type<ttype> BaseType |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 99 | %type<ttype> ContainerType |
| 100 | %type<ttype> MapType |
| 101 | %type<ttype> SetType |
| 102 | %type<ttype> ListType |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 103 | |
| 104 | %type<ttypedef> Typedef |
| 105 | %type<ttype> DefinitionType |
| 106 | |
| 107 | %type<tfield> Field |
| 108 | %type<ttype> FieldType |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 109 | %type<tstruct> FieldList |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 110 | |
| 111 | %type<tenum> Enum |
| 112 | %type<tenum> EnumDefList |
| 113 | %type<tconstant> EnumDef |
| 114 | |
| 115 | %type<tstruct> Struct |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 116 | %type<tstruct> Xception |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 117 | %type<tservice> Service |
| 118 | |
| 119 | %type<tfunction> Function |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 120 | %type<ttype> FunctionType |
| 121 | %type<tservice> FunctionList |
| 122 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 123 | %type<tstruct> ThrowsOptional |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 124 | %type<tbool> AsyncOptional |
| 125 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 126 | %% |
| 127 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 128 | /** |
| 129 | * Thrift Grammar Implementation. |
| 130 | * |
| 131 | * For the most part this source file works its way top down from what you |
| 132 | * might expect to find in a typical .thrift file, i.e. type definitions and |
| 133 | * namespaces up top followed by service definitions using those types. |
| 134 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 135 | |
| 136 | Program: |
| 137 | DefinitionList |
| 138 | { |
| 139 | pdebug("Program -> DefinitionList"); |
| 140 | } |
| 141 | |
| 142 | DefinitionList: |
| 143 | DefinitionList Definition |
| 144 | { |
| 145 | pdebug("DefinitionList -> DefinitionList Definition"); |
| 146 | } |
| 147 | | |
| 148 | { |
| 149 | pdebug("DefinitionList -> "); |
| 150 | } |
| 151 | |
| 152 | Definition: |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 153 | Namespace |
| 154 | { |
| 155 | pdebug("Definition -> Namespace"); |
| 156 | g_program->set_namespace($1); |
| 157 | } |
| 158 | | Typedef |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 159 | { |
| 160 | pdebug("Definition -> Typedef"); |
| 161 | g_program->add_typedef($1); |
| 162 | } |
| 163 | | Enum |
| 164 | { |
| 165 | pdebug("Definition -> Enum"); |
| 166 | g_program->add_enum($1); |
| 167 | } |
| 168 | | Struct |
| 169 | { |
| 170 | pdebug("Definition -> Struct"); |
| 171 | g_program->add_struct($1); |
| 172 | } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 173 | | Xception |
| 174 | { |
| 175 | pdebug("Definition -> Xception"); |
| 176 | g_program->add_xception($1); |
| 177 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 178 | | Service |
| 179 | { |
| 180 | pdebug("Definition -> Service"); |
| 181 | g_program->add_service($1); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | Namespace: |
| 185 | tok_namespace tok_identifier |
| 186 | { |
| 187 | pdebug("Namespace -> tok_namespace tok_identifier"); |
| 188 | $$ = $2; |
| 189 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 190 | |
| 191 | Typedef: |
| 192 | tok_typedef DefinitionType tok_identifier |
| 193 | { |
| 194 | pdebug("TypeDef -> tok_typedef DefinitionType tok_identifier"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 195 | t_typedef *td = new t_typedef($2, $3); |
| 196 | $$ = td; |
| 197 | } |
| 198 | |
| 199 | Enum: |
| 200 | tok_enum tok_identifier '{' EnumDefList '}' |
| 201 | { |
| 202 | pdebug("Enum -> tok_enum tok_identifier { EnumDefList }"); |
| 203 | $$ = $4; |
| 204 | $$->set_name($2); |
| 205 | } |
| 206 | |
| 207 | EnumDefList: |
| 208 | EnumDefList ',' EnumDef |
| 209 | { |
| 210 | pdebug("EnumDefList -> EnumDefList EnumDef"); |
| 211 | $$ = $1; |
| 212 | $$->append($3); |
| 213 | } |
| 214 | | EnumDef |
| 215 | { |
| 216 | pdebug("EnumDefList -> EnumDef"); |
| 217 | $$ = new t_enum; |
| 218 | $$->append($1); |
| 219 | } |
| 220 | | |
| 221 | { |
| 222 | pdebug("EnumDefList -> "); |
| 223 | $$ = new t_enum; |
| 224 | } |
| 225 | |
| 226 | EnumDef: |
| 227 | tok_identifier '=' tok_int_constant |
| 228 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 229 | pdebug("EnumDef => tok_identifier = tok_int_constant"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 230 | if ($3 < 0) { |
| 231 | printf("WARNING (%d): Negative value supplied for enum %s.\n", yylineno, $1); |
| 232 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 233 | $$ = new t_constant($1, $3); |
| 234 | } |
| 235 | | |
| 236 | tok_identifier |
| 237 | { |
| 238 | pdebug("EnumDef => tok_identifier"); |
| 239 | $$ = new t_constant($1); |
| 240 | } |
| 241 | |
| 242 | Struct: |
| 243 | tok_struct tok_identifier '{' FieldList '}' |
| 244 | { |
| 245 | pdebug("Struct -> tok_struct tok_identifier { FieldList }"); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 246 | $4->set_name($2); |
| 247 | $$ = $4; |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 248 | y_field_val = -1; |
| 249 | } |
| 250 | |
| 251 | Xception: |
| 252 | tok_xception tok_identifier '{' FieldList '}' |
| 253 | { |
| 254 | pdebug("Xception -> tok_xception tok_identifier { FieldList }"); |
| 255 | $4->set_name($2); |
| 256 | $4->set_xception(true); |
| 257 | $$ = $4; |
| 258 | y_field_val = -1; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | Service: |
| 262 | tok_service tok_identifier '{' FunctionList '}' |
| 263 | { |
| 264 | pdebug("Service -> tok_service tok_identifier { FunctionList }"); |
| 265 | $$ = $4; |
| 266 | $$->set_name($2); |
| 267 | } |
| 268 | |
| 269 | FunctionList: |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 270 | FunctionList Function CommaOptional |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 271 | { |
| 272 | pdebug("FunctionList -> FunctionList Function"); |
| 273 | $$ = $1; |
| 274 | $1->add_function($2); |
| 275 | } |
| 276 | | |
| 277 | { |
| 278 | pdebug("FunctionList -> "); |
| 279 | $$ = new t_service; |
| 280 | } |
| 281 | |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 282 | CommaOptional: |
| 283 | ',' |
| 284 | {} |
| 285 | | |
| 286 | {} |
| 287 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 288 | Function: |
Mark Slee | 4e755ca | 2006-09-12 00:46:08 +0000 | [diff] [blame] | 289 | AsyncOptional FunctionType tok_identifier '(' FieldList ')' ThrowsOptional |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 290 | { |
Mark Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 291 | $5->set_name(std::string($3) + "_args"); |
Mark Slee | 4e755ca | 2006-09-12 00:46:08 +0000 | [diff] [blame] | 292 | $$ = new t_function($2, $3, $5, $7, $1); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 293 | y_field_val = -1; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 296 | AsyncOptional: |
| 297 | tok_async |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 298 | { |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 299 | $$ = true; |
| 300 | } |
| 301 | | |
| 302 | { |
| 303 | $$ = false; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 306 | ThrowsOptional: |
| 307 | tok_throws '(' FieldList ')' |
| 308 | { |
| 309 | $$ = $3; |
| 310 | } |
| 311 | | |
| 312 | { |
| 313 | $$ = new t_struct; |
| 314 | } |
| 315 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 316 | FieldList: |
| 317 | FieldList ',' Field |
| 318 | { |
| 319 | pdebug("FieldList -> FieldList , Field"); |
| 320 | $$ = $1; |
| 321 | $$->append($3); |
| 322 | } |
| 323 | | Field |
| 324 | { |
| 325 | pdebug("FieldList -> Field"); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 326 | $$ = new t_struct; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 327 | $$->append($1); |
| 328 | } |
| 329 | | |
| 330 | { |
| 331 | pdebug("FieldList -> "); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 332 | $$ = new t_struct; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | Field: |
| 336 | FieldType tok_identifier '=' tok_int_constant |
| 337 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 338 | pdebug("Field -> FieldType tok_identifier = tok_int_constant"); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 339 | if ($4 <= 0) { |
| 340 | printf("WARNING (%d): Nonpositive value (%d) not allowed as a field key for '%s'.\n", yylineno, $4, $2); |
| 341 | $4 = y_field_val--; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 342 | } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 343 | $$ = new t_field($1, $2, $4); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 344 | } |
| 345 | | FieldType tok_identifier |
| 346 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 347 | pdebug("Field -> FieldType tok_identifier"); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 348 | printf("WARNING (%d): No field key specified for '%s', resulting protocol may have conflicts or not be backwards compatible!\n", yylineno, $2); |
| 349 | $$ = new t_field($1, $2, y_field_val--); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | DefinitionType: |
| 353 | BaseType |
| 354 | { |
| 355 | pdebug("DefinitionType -> BaseType"); |
| 356 | $$ = $1; |
| 357 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 358 | | ContainerType |
| 359 | { |
| 360 | pdebug("DefinitionType -> ContainerType"); |
| 361 | $$ = $1; |
| 362 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 363 | |
| 364 | FunctionType: |
| 365 | FieldType |
| 366 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 367 | pdebug("FunctionType -> FieldType"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 368 | $$ = $1; |
| 369 | } |
| 370 | | tok_void |
| 371 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 372 | pdebug("FunctionType -> tok_void"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 373 | $$ = g_program->get_void_type(); |
| 374 | } |
| 375 | |
| 376 | FieldType: |
| 377 | tok_identifier |
| 378 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 379 | pdebug("FieldType -> tok_identifier"); |
| 380 | $$ = g_program->get_custom_type($1); |
| 381 | if ($$ == NULL) { |
| 382 | yyerror("Type \"%s\" has not been defined.", $1); |
| 383 | exit(1); |
| 384 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 385 | } |
| 386 | | BaseType |
| 387 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 388 | pdebug("FieldType -> BaseType"); |
| 389 | $$ = $1; |
| 390 | } |
| 391 | | ContainerType |
| 392 | { |
| 393 | pdebug("FieldType -> ContainerType"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 394 | $$ = $1; |
| 395 | } |
| 396 | |
| 397 | BaseType: |
| 398 | tok_string |
| 399 | { |
| 400 | pdebug("BaseType -> tok_string"); |
| 401 | $$ = g_program->get_string_type(); |
| 402 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 403 | | tok_bool |
| 404 | { |
| 405 | pdebug("BaseType -> tok_bool"); |
| 406 | $$ = g_program->get_bool_type(); |
| 407 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 408 | | tok_byte |
| 409 | { |
| 410 | pdebug("BaseType -> tok_byte"); |
| 411 | $$ = g_program->get_byte_type(); |
| 412 | } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 413 | | tok_i16 |
| 414 | { |
| 415 | pdebug("BaseType -> tok_i16"); |
| 416 | $$ = g_program->get_i16_type(); |
| 417 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 418 | | tok_i32 |
| 419 | { |
| 420 | pdebug("BaseType -> tok_i32"); |
| 421 | $$ = g_program->get_i32_type(); |
| 422 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 423 | | tok_i64 |
| 424 | { |
| 425 | pdebug("BaseType -> tok_i64"); |
| 426 | $$ = g_program->get_i64_type(); |
| 427 | } |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 428 | | tok_double |
| 429 | { |
| 430 | pdebug("BaseType -> tok_double"); |
| 431 | $$ = g_program->get_double_type(); |
| 432 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 433 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 434 | ContainerType: |
| 435 | MapType |
| 436 | { |
| 437 | pdebug("ContainerType -> MapType"); |
| 438 | $$ = $1; |
| 439 | } |
| 440 | | SetType |
| 441 | { |
| 442 | pdebug("ContainerType -> SetType"); |
| 443 | $$ = $1; |
| 444 | } |
| 445 | | ListType |
| 446 | { |
| 447 | pdebug("ContainerType -> ListType"); |
| 448 | $$ = $1; |
| 449 | } |
| 450 | |
| 451 | MapType: |
| 452 | tok_map '<' FieldType ',' FieldType '>' |
| 453 | { |
| 454 | pdebug("MapType -> tok_map <FieldType, FieldType>"); |
| 455 | $$ = new t_map($3, $5); |
| 456 | } |
| 457 | |
| 458 | SetType: |
| 459 | tok_set '<' FieldType '>' |
| 460 | { |
| 461 | pdebug("SetType -> tok_set<FieldType>"); |
| 462 | $$ = new t_set($3); |
| 463 | } |
| 464 | |
| 465 | ListType: |
| 466 | tok_list '<' FieldType '>' |
| 467 | { |
| 468 | pdebug("ListType -> tok_list<FieldType>"); |
| 469 | $$ = new t_list($3); |
| 470 | } |
| 471 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 472 | %% |