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" |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 15 | #include "parse/t_scope.h" |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 16 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 17 | /** |
| 18 | * This global variable is used for automatic numbering of field indices etc. |
| 19 | * when parsing the members of a struct. Field values are automatically |
| 20 | * assigned starting from -1 and working their way down. |
| 21 | */ |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 22 | int y_field_val = -1; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 23 | |
| 24 | %} |
| 25 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 26 | /** |
| 27 | * This structure is used by the parser to hold the data types associated with |
| 28 | * various parse nodes. |
| 29 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 30 | %union { |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 31 | char* id; |
| 32 | int iconst; |
| 33 | double dconst; |
| 34 | bool tbool; |
| 35 | t_type* ttype; |
| 36 | t_typedef* ttypedef; |
| 37 | t_enum* tenum; |
| 38 | t_enum_value* tenumv; |
| 39 | t_const* tconst; |
| 40 | t_const_value* tconstv; |
| 41 | t_struct* tstruct; |
| 42 | t_service* tservice; |
| 43 | t_function* tfunction; |
| 44 | t_field* tfield; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 47 | /** |
| 48 | * Strings identifier |
| 49 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 50 | %token<id> tok_identifier |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 51 | %token<id> tok_literal |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 54 | * Constant values |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 55 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 56 | %token<iconst> tok_int_constant |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 57 | %token<dconst> tok_dub_constant |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 58 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 59 | /** |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 60 | * Header keywoards |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 61 | */ |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 62 | %token tok_include |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 63 | %token tok_namespace |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 64 | %token tok_cpp_namespace |
| 65 | %token tok_cpp_include |
| 66 | %token tok_cpp_type |
Mark Slee | e888b37 | 2007-01-12 01:06:24 +0000 | [diff] [blame] | 67 | %token tok_php_namespace |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 68 | %token tok_java_package |
Mark Slee | 782abbb | 2007-01-19 00:17:02 +0000 | [diff] [blame] | 69 | %token tok_xsd_all |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 70 | %token tok_xsd_optional |
Mark Slee | 0d9199e | 2007-01-31 02:08:30 +0000 | [diff] [blame] | 71 | %token tok_xsd_namespace |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 72 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 73 | /** |
| 74 | * Base datatype keywords |
| 75 | */ |
| 76 | %token tok_void |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 77 | %token tok_bool |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 78 | %token tok_byte |
| 79 | %token tok_string |
Mark Slee | b6200d8 | 2007-01-19 19:14:36 +0000 | [diff] [blame] | 80 | %token tok_slist |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 81 | %token tok_i16 |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 82 | %token tok_i32 |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 83 | %token tok_i64 |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 84 | %token tok_double |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 85 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 86 | /** |
| 87 | * Complex type keywords |
| 88 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 89 | %token tok_map |
| 90 | %token tok_list |
| 91 | %token tok_set |
| 92 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 93 | /** |
| 94 | * Function modifiers |
| 95 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 96 | %token tok_async |
| 97 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 98 | /** |
| 99 | * Thrift language keywords |
| 100 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 101 | %token tok_typedef |
| 102 | %token tok_struct |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 103 | %token tok_xception |
| 104 | %token tok_throws |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 105 | %token tok_extends |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 106 | %token tok_service |
| 107 | %token tok_enum |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 108 | %token tok_const |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 109 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 110 | /** |
| 111 | * Grammar nodes |
| 112 | */ |
| 113 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 114 | %type<ttype> BaseType |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 115 | %type<ttype> ContainerType |
| 116 | %type<ttype> MapType |
| 117 | %type<ttype> SetType |
| 118 | %type<ttype> ListType |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 119 | |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 120 | %type<ttype> TypeDefinition |
| 121 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 122 | %type<ttypedef> Typedef |
| 123 | %type<ttype> DefinitionType |
| 124 | |
| 125 | %type<tfield> Field |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 126 | %type<iconst> FieldIdentifier |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 127 | %type<ttype> FieldType |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 128 | %type<tconstv> FieldValue |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 129 | %type<tstruct> FieldList |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 130 | |
| 131 | %type<tenum> Enum |
| 132 | %type<tenum> EnumDefList |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 133 | %type<tenumv> EnumDef |
| 134 | |
| 135 | %type<tconst> Const |
| 136 | %type<tconstv> ConstValue |
| 137 | %type<tconstv> ConstList |
| 138 | %type<tconstv> ConstListContents |
| 139 | %type<tconstv> ConstMap |
| 140 | %type<tconstv> ConstMapContents |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 141 | |
| 142 | %type<tstruct> Struct |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 143 | %type<tstruct> Xception |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 144 | %type<tservice> Service |
| 145 | |
| 146 | %type<tfunction> Function |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 147 | %type<ttype> FunctionType |
| 148 | %type<tservice> FunctionList |
| 149 | |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 150 | %type<tstruct> Throws |
| 151 | %type<tservice> Extends |
| 152 | %type<tbool> Async |
| 153 | %type<tbool> XsdAll |
| 154 | %type<tbool> XsdOptional |
| 155 | %type<id> CppType |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 156 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 157 | %% |
| 158 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 159 | /** |
| 160 | * Thrift Grammar Implementation. |
| 161 | * |
| 162 | * For the most part this source file works its way top down from what you |
| 163 | * might expect to find in a typical .thrift file, i.e. type definitions and |
| 164 | * namespaces up top followed by service definitions using those types. |
| 165 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 166 | |
| 167 | Program: |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 168 | HeaderList DefinitionList |
| 169 | { |
| 170 | pdebug("Program -> Headers DefinitionList"); |
| 171 | } |
| 172 | |
| 173 | HeaderList: |
| 174 | HeaderList Header |
| 175 | { |
| 176 | pdebug("HeaderList -> HeaderList Header"); |
| 177 | } |
| 178 | | |
| 179 | { |
| 180 | pdebug("HeaderList -> "); |
| 181 | } |
| 182 | |
| 183 | Header: |
| 184 | Include |
| 185 | { |
| 186 | pdebug("Header -> Include"); |
| 187 | } |
| 188 | | tok_namespace tok_identifier |
| 189 | { |
| 190 | pwarning(1, "'namespace' is deprecated. Use 'cpp_namespace' and/or 'java_package' instead"); |
| 191 | if (g_parse_mode == PROGRAM) { |
| 192 | g_program->set_cpp_namespace($2); |
| 193 | g_program->set_java_package($2); |
| 194 | } |
| 195 | } |
| 196 | | tok_cpp_namespace tok_identifier |
| 197 | { |
| 198 | pdebug("Header -> tok_cpp_namespace tok_identifier"); |
| 199 | if (g_parse_mode == PROGRAM) { |
| 200 | g_program->set_cpp_namespace($2); |
| 201 | } |
| 202 | } |
| 203 | | tok_cpp_include tok_literal |
| 204 | { |
| 205 | pdebug("Header -> tok_cpp_include tok_literal"); |
| 206 | if (g_parse_mode == PROGRAM) { |
| 207 | g_program->add_cpp_include($2); |
| 208 | } |
| 209 | } |
Mark Slee | e888b37 | 2007-01-12 01:06:24 +0000 | [diff] [blame] | 210 | | tok_php_namespace tok_identifier |
| 211 | { |
| 212 | pdebug("Header -> tok_php_namespace tok_identifier"); |
| 213 | if (g_parse_mode == PROGRAM) { |
| 214 | g_program->set_php_namespace($2); |
| 215 | } |
| 216 | } |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 217 | | tok_java_package tok_identifier |
| 218 | { |
| 219 | pdebug("Header -> tok_java_package tok_identifier"); |
| 220 | if (g_parse_mode == PROGRAM) { |
| 221 | g_program->set_java_package($2); |
| 222 | } |
| 223 | } |
Mark Slee | 0d9199e | 2007-01-31 02:08:30 +0000 | [diff] [blame] | 224 | | tok_xsd_namespace tok_literal |
| 225 | { |
| 226 | pdebug("Header -> tok_xsd_namespace tok_literal"); |
| 227 | if (g_parse_mode == PROGRAM) { |
| 228 | g_program->set_xsd_namespace($2); |
| 229 | } |
| 230 | } |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 231 | |
| 232 | Include: |
| 233 | tok_include tok_literal |
| 234 | { |
| 235 | pdebug("Include -> tok_include tok_literal"); |
| 236 | if (g_parse_mode == INCLUDES) { |
| 237 | std::string path = include_file(std::string($2)); |
| 238 | if (!path.empty()) { |
| 239 | g_program->add_include(path); |
| 240 | } |
| 241 | } |
| 242 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 243 | |
| 244 | DefinitionList: |
| 245 | DefinitionList Definition |
| 246 | { |
| 247 | pdebug("DefinitionList -> DefinitionList Definition"); |
| 248 | } |
| 249 | | |
| 250 | { |
| 251 | pdebug("DefinitionList -> "); |
| 252 | } |
| 253 | |
| 254 | Definition: |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 255 | Const |
| 256 | { |
| 257 | pdebug("Definition -> Const"); |
| 258 | if (g_parse_mode == PROGRAM) { |
| 259 | g_program->add_const($1); |
| 260 | } |
| 261 | } |
| 262 | | TypeDefinition |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 263 | { |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 264 | pdebug("Definition -> TypeDefinition"); |
| 265 | if (g_parse_mode == PROGRAM) { |
| 266 | g_scope->add_type($1->get_name(), $1); |
| 267 | if (g_parent_scope != NULL) { |
| 268 | g_parent_scope->add_type(g_parent_prefix + $1->get_name(), $1); |
| 269 | } |
| 270 | } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 271 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 272 | | Service |
| 273 | { |
| 274 | pdebug("Definition -> Service"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 275 | if (g_parse_mode == PROGRAM) { |
| 276 | g_scope->add_service($1->get_name(), $1); |
| 277 | if (g_parent_scope != NULL) { |
| 278 | g_parent_scope->add_service(g_parent_prefix + $1->get_name(), $1); |
| 279 | } |
| 280 | g_program->add_service($1); |
| 281 | } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 282 | } |
| 283 | |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 284 | TypeDefinition: |
| 285 | Typedef |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 286 | { |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 287 | pdebug("TypeDefinition -> Typedef"); |
| 288 | if (g_parse_mode == PROGRAM) { |
| 289 | g_program->add_typedef($1); |
| 290 | } |
| 291 | } |
| 292 | | Enum |
| 293 | { |
| 294 | pdebug("TypeDefinition -> Enum"); |
| 295 | if (g_parse_mode == PROGRAM) { |
| 296 | g_program->add_enum($1); |
| 297 | } |
| 298 | } |
| 299 | | Struct |
| 300 | { |
| 301 | pdebug("TypeDefinition -> Struct"); |
| 302 | if (g_parse_mode == PROGRAM) { |
| 303 | g_program->add_struct($1); |
| 304 | } |
| 305 | } |
| 306 | | Xception |
| 307 | { |
| 308 | pdebug("TypeDefinition -> Xception"); |
| 309 | if (g_parse_mode == PROGRAM) { |
| 310 | g_program->add_xception($1); |
| 311 | } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 312 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 313 | |
| 314 | Typedef: |
| 315 | tok_typedef DefinitionType tok_identifier |
| 316 | { |
| 317 | pdebug("TypeDef -> tok_typedef DefinitionType tok_identifier"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 318 | t_typedef *td = new t_typedef(g_program, $2, $3); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 319 | $$ = td; |
| 320 | } |
| 321 | |
| 322 | Enum: |
| 323 | tok_enum tok_identifier '{' EnumDefList '}' |
| 324 | { |
| 325 | pdebug("Enum -> tok_enum tok_identifier { EnumDefList }"); |
| 326 | $$ = $4; |
| 327 | $$->set_name($2); |
| 328 | } |
| 329 | |
Mark Slee | 207cb46 | 2006-11-02 18:43:12 +0000 | [diff] [blame] | 330 | CommaOrSemicolonOptional: |
| 331 | ',' |
| 332 | {} |
| 333 | | ';' |
| 334 | {} |
| 335 | | |
| 336 | {} |
| 337 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 338 | EnumDefList: |
Mark Slee | 207cb46 | 2006-11-02 18:43:12 +0000 | [diff] [blame] | 339 | EnumDefList EnumDef |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 340 | { |
| 341 | pdebug("EnumDefList -> EnumDefList EnumDef"); |
| 342 | $$ = $1; |
Mark Slee | 207cb46 | 2006-11-02 18:43:12 +0000 | [diff] [blame] | 343 | $$->append($2); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 344 | } |
| 345 | | |
| 346 | { |
| 347 | pdebug("EnumDefList -> "); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 348 | $$ = new t_enum(g_program); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | EnumDef: |
Mark Slee | 207cb46 | 2006-11-02 18:43:12 +0000 | [diff] [blame] | 352 | tok_identifier '=' tok_int_constant CommaOrSemicolonOptional |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 353 | { |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 354 | pdebug("EnumDef -> tok_identifier = tok_int_constant"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 355 | if ($3 < 0) { |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 356 | pwarning(1, "Negative value supplied for enum %s.\n", $1); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 357 | } |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 358 | $$ = new t_enum_value($1, $3); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 359 | } |
| 360 | | |
Mark Slee | 04cc605 | 2006-11-15 21:25:34 +0000 | [diff] [blame] | 361 | tok_identifier CommaOrSemicolonOptional |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 362 | { |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 363 | pdebug("EnumDef -> tok_identifier"); |
| 364 | $$ = new t_enum_value($1); |
| 365 | } |
| 366 | |
| 367 | Const: |
| 368 | tok_const FieldType tok_identifier '=' ConstValue CommaOrSemicolonOptional |
| 369 | { |
| 370 | pdebug("Const -> tok_const FieldType tok_identifier = ConstValue"); |
Mark Slee | aa7671d | 2006-11-29 03:19:31 +0000 | [diff] [blame] | 371 | if (g_parse_mode == PROGRAM) { |
| 372 | $$ = new t_const($2, $3, $5); |
| 373 | validate_const_type($$); |
| 374 | } else { |
| 375 | $$ = NULL; |
| 376 | } |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | ConstValue: |
| 380 | tok_int_constant |
| 381 | { |
| 382 | pdebug("ConstValue => tok_int_constant"); |
| 383 | $$ = new t_const_value(); |
| 384 | $$->set_integer($1); |
| 385 | } |
| 386 | | tok_dub_constant |
| 387 | { |
| 388 | pdebug("ConstValue => tok_dub_constant"); |
| 389 | $$ = new t_const_value(); |
| 390 | $$->set_double($1); |
| 391 | } |
| 392 | | tok_literal |
| 393 | { |
| 394 | pdebug("ConstValue => tok_literal"); |
| 395 | $$ = new t_const_value(); |
| 396 | $$->set_string($1); |
| 397 | } |
Mark Slee | 67fc634 | 2006-11-29 03:37:04 +0000 | [diff] [blame] | 398 | | tok_identifier |
| 399 | { |
| 400 | pdebug("ConstValue => tok_identifier"); |
| 401 | $$ = new t_const_value(); |
| 402 | $$->set_string($1); |
| 403 | } |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 404 | | ConstList |
| 405 | { |
| 406 | pdebug("ConstValue => ConstList"); |
| 407 | $$ = $1; |
| 408 | } |
| 409 | | ConstMap |
| 410 | { |
| 411 | pdebug("ConstValue => ConstMap"); |
| 412 | $$ = $1; |
| 413 | } |
| 414 | |
| 415 | ConstList: |
| 416 | '[' ConstListContents ']' |
| 417 | { |
| 418 | pdebug("ConstList => [ ConstListContents ]"); |
| 419 | $$ = $2; |
| 420 | } |
| 421 | |
| 422 | ConstListContents: |
| 423 | ConstListContents ConstValue CommaOrSemicolonOptional |
| 424 | { |
| 425 | pdebug("ConstListContents => ConstListContents ConstValue CommaOrSemicolonOptional"); |
| 426 | $$ = $1; |
| 427 | $$->add_list($2); |
| 428 | } |
| 429 | | |
| 430 | { |
| 431 | pdebug("ConstListContents =>"); |
| 432 | $$ = new t_const_value(); |
| 433 | $$->set_list(); |
| 434 | } |
| 435 | |
| 436 | ConstMap: |
| 437 | '{' ConstMapContents '}' |
| 438 | { |
| 439 | pdebug("ConstMap => { ConstMapContents }"); |
| 440 | $$ = $2; |
| 441 | } |
| 442 | |
| 443 | ConstMapContents: |
| 444 | ConstMapContents ConstValue ':' ConstValue CommaOrSemicolonOptional |
| 445 | { |
| 446 | pdebug("ConstMapContents => ConstMapContents ConstValue CommaOrSemicolonOptional"); |
| 447 | $$ = $1; |
| 448 | $$->add_map($2, $4); |
| 449 | } |
| 450 | | |
| 451 | { |
| 452 | pdebug("ConstMapContents =>"); |
| 453 | $$ = new t_const_value(); |
| 454 | $$->set_map(); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | Struct: |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 458 | tok_struct tok_identifier XsdAll '{' FieldList '}' |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 459 | { |
| 460 | pdebug("Struct -> tok_struct tok_identifier { FieldList }"); |
Mark Slee | 782abbb | 2007-01-19 00:17:02 +0000 | [diff] [blame] | 461 | $5->set_name($2); |
| 462 | $5->set_xsd_all($3); |
| 463 | $$ = $5; |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 464 | y_field_val = -1; |
| 465 | } |
| 466 | |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 467 | XsdAll: |
Mark Slee | 782abbb | 2007-01-19 00:17:02 +0000 | [diff] [blame] | 468 | tok_xsd_all |
| 469 | { |
| 470 | $$ = true; |
| 471 | } |
| 472 | | |
| 473 | { |
| 474 | $$ = false; |
| 475 | } |
| 476 | |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 477 | XsdOptional: |
| 478 | tok_xsd_optional |
| 479 | { |
| 480 | $$ = true; |
| 481 | } |
| 482 | | |
| 483 | { |
| 484 | $$ = false; |
| 485 | } |
| 486 | |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 487 | Xception: |
| 488 | tok_xception tok_identifier '{' FieldList '}' |
| 489 | { |
| 490 | pdebug("Xception -> tok_xception tok_identifier { FieldList }"); |
| 491 | $4->set_name($2); |
| 492 | $4->set_xception(true); |
| 493 | $$ = $4; |
| 494 | y_field_val = -1; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | Service: |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 498 | tok_service tok_identifier Extends '{' FunctionList '}' |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 499 | { |
| 500 | pdebug("Service -> tok_service tok_identifier { FunctionList }"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 501 | $$ = $5; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 502 | $$->set_name($2); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 503 | $$->set_extends($3); |
| 504 | } |
| 505 | |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 506 | Extends: |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 507 | tok_extends tok_identifier |
| 508 | { |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 509 | pdebug("Extends -> tok_extends tok_identifier"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 510 | $$ = NULL; |
| 511 | if (g_parse_mode == PROGRAM) { |
| 512 | $$ = g_scope->get_service($2); |
| 513 | if ($$ == NULL) { |
| 514 | yyerror("Service \"%s\" has not been defined.", $2); |
| 515 | exit(1); |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | | |
| 520 | { |
| 521 | $$ = NULL; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | FunctionList: |
Mark Slee | 207cb46 | 2006-11-02 18:43:12 +0000 | [diff] [blame] | 525 | FunctionList Function |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 526 | { |
| 527 | pdebug("FunctionList -> FunctionList Function"); |
| 528 | $$ = $1; |
| 529 | $1->add_function($2); |
| 530 | } |
| 531 | | |
| 532 | { |
| 533 | pdebug("FunctionList -> "); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 534 | $$ = new t_service(g_program); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | Function: |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 538 | Async FunctionType tok_identifier '(' FieldList ')' Throws CommaOrSemicolonOptional |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 539 | { |
Mark Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 540 | $5->set_name(std::string($3) + "_args"); |
Mark Slee | 4e755ca | 2006-09-12 00:46:08 +0000 | [diff] [blame] | 541 | $$ = new t_function($2, $3, $5, $7, $1); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 542 | y_field_val = -1; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 543 | } |
| 544 | |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 545 | Async: |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 546 | tok_async |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 547 | { |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 548 | $$ = true; |
| 549 | } |
| 550 | | |
| 551 | { |
| 552 | $$ = false; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 553 | } |
| 554 | |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 555 | Throws: |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 556 | tok_throws '(' FieldList ')' |
| 557 | { |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 558 | pdebug("Throws -> tok_throws ( FieldList )"); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 559 | $$ = $3; |
| 560 | } |
| 561 | | |
| 562 | { |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 563 | $$ = new t_struct(g_program); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 564 | } |
| 565 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 566 | FieldList: |
Mark Slee | 207cb46 | 2006-11-02 18:43:12 +0000 | [diff] [blame] | 567 | FieldList Field |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 568 | { |
| 569 | pdebug("FieldList -> FieldList , Field"); |
| 570 | $$ = $1; |
Mark Slee | 207cb46 | 2006-11-02 18:43:12 +0000 | [diff] [blame] | 571 | $$->append($2); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 572 | } |
| 573 | | |
| 574 | { |
| 575 | pdebug("FieldList -> "); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 576 | $$ = new t_struct(g_program); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | Field: |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 580 | FieldIdentifier FieldType tok_identifier FieldValue XsdOptional CommaOrSemicolonOptional |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 581 | { |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 582 | pdebug("tok_int_constant : Field -> FieldType tok_identifier"); |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 583 | if ($1 < 0) { |
| 584 | pwarning(2, "No field key specified for %s, resulting protocol may have conflicts or not be backwards compatible!\n", $3); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 585 | } |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 586 | $$ = new t_field($2, $3, $1); |
| 587 | if ($4 != NULL) { |
| 588 | validate_field_value($$, $4); |
| 589 | $$->set_value($4); |
| 590 | } |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 591 | $$->set_xsd_optional($5); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 592 | } |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 593 | |
| 594 | FieldIdentifier: |
| 595 | tok_int_constant ':' |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 596 | { |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 597 | if ($1 <= 0) { |
| 598 | pwarning(1, "Nonpositive value (%d) not allowed as a field key.\n", $1); |
| 599 | $1 = y_field_val--; |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 600 | } |
Mark Slee | 7ff3245 | 2007-02-01 05:26:18 +0000 | [diff] [blame] | 601 | $$ = $1; |
| 602 | } |
| 603 | | |
| 604 | { |
| 605 | $$ = y_field_val--; |
| 606 | } |
| 607 | |
| 608 | FieldValue: |
| 609 | '=' ConstValue |
| 610 | { |
| 611 | if (g_parse_mode == PROGRAM) { |
| 612 | $$ = $2; |
| 613 | } else { |
| 614 | $$ = NULL; |
| 615 | } |
| 616 | } |
| 617 | | |
| 618 | { |
| 619 | $$ = NULL; |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 620 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 621 | |
| 622 | DefinitionType: |
| 623 | BaseType |
| 624 | { |
| 625 | pdebug("DefinitionType -> BaseType"); |
| 626 | $$ = $1; |
| 627 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 628 | | ContainerType |
| 629 | { |
| 630 | pdebug("DefinitionType -> ContainerType"); |
| 631 | $$ = $1; |
| 632 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 633 | |
| 634 | FunctionType: |
| 635 | FieldType |
| 636 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 637 | pdebug("FunctionType -> FieldType"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 638 | $$ = $1; |
| 639 | } |
| 640 | | tok_void |
| 641 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 642 | pdebug("FunctionType -> tok_void"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 643 | $$ = g_type_void; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | FieldType: |
| 647 | tok_identifier |
| 648 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 649 | pdebug("FieldType -> tok_identifier"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 650 | if (g_parse_mode == INCLUDES) { |
| 651 | // Ignore identifiers in include mode |
| 652 | $$ = NULL; |
| 653 | } else { |
| 654 | // Lookup the identifier in the current scope |
| 655 | $$ = g_scope->get_type($1); |
| 656 | if ($$ == NULL) { |
| 657 | yyerror("Type \"%s\" has not been defined.", $1); |
| 658 | exit(1); |
| 659 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 660 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 661 | } |
| 662 | | BaseType |
| 663 | { |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 664 | pdebug("FieldType -> BaseType"); |
| 665 | $$ = $1; |
| 666 | } |
| 667 | | ContainerType |
| 668 | { |
| 669 | pdebug("FieldType -> ContainerType"); |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 670 | $$ = $1; |
| 671 | } |
| 672 | |
| 673 | BaseType: |
| 674 | tok_string |
| 675 | { |
| 676 | pdebug("BaseType -> tok_string"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 677 | $$ = g_type_string; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 678 | } |
Mark Slee | b6200d8 | 2007-01-19 19:14:36 +0000 | [diff] [blame] | 679 | | tok_slist |
| 680 | { |
| 681 | pdebug("BaseType -> tok_slist"); |
| 682 | $$ = g_type_slist; |
| 683 | } |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 684 | | tok_bool |
| 685 | { |
| 686 | pdebug("BaseType -> tok_bool"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 687 | $$ = g_type_bool; |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 688 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 689 | | tok_byte |
| 690 | { |
| 691 | pdebug("BaseType -> tok_byte"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 692 | $$ = g_type_byte; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 693 | } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 694 | | tok_i16 |
| 695 | { |
| 696 | pdebug("BaseType -> tok_i16"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 697 | $$ = g_type_i16; |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 698 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 699 | | tok_i32 |
| 700 | { |
| 701 | pdebug("BaseType -> tok_i32"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 702 | $$ = g_type_i32; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 703 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 704 | | tok_i64 |
| 705 | { |
| 706 | pdebug("BaseType -> tok_i64"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 707 | $$ = g_type_i64; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 708 | } |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 709 | | tok_double |
| 710 | { |
| 711 | pdebug("BaseType -> tok_double"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 712 | $$ = g_type_double; |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 713 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 714 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 715 | ContainerType: |
| 716 | MapType |
| 717 | { |
| 718 | pdebug("ContainerType -> MapType"); |
| 719 | $$ = $1; |
| 720 | } |
| 721 | | SetType |
| 722 | { |
| 723 | pdebug("ContainerType -> SetType"); |
| 724 | $$ = $1; |
| 725 | } |
| 726 | | ListType |
| 727 | { |
| 728 | pdebug("ContainerType -> ListType"); |
| 729 | $$ = $1; |
| 730 | } |
| 731 | |
| 732 | MapType: |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 733 | tok_map CppType '<' FieldType ',' FieldType '>' |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 734 | { |
| 735 | pdebug("MapType -> tok_map <FieldType, FieldType>"); |
Mark Slee | 4f8da1d | 2006-10-12 02:47:27 +0000 | [diff] [blame] | 736 | $$ = new t_map($4, $6); |
| 737 | if ($2 != NULL) { |
| 738 | ((t_container*)$$)->set_cpp_name(std::string($2)); |
| 739 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | SetType: |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 743 | tok_set CppType '<' FieldType '>' |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 744 | { |
| 745 | pdebug("SetType -> tok_set<FieldType>"); |
Mark Slee | 4f8da1d | 2006-10-12 02:47:27 +0000 | [diff] [blame] | 746 | $$ = new t_set($4); |
| 747 | if ($2 != NULL) { |
| 748 | ((t_container*)$$)->set_cpp_name(std::string($2)); |
| 749 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | ListType: |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 753 | tok_list '<' FieldType '>' CppType |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 754 | { |
| 755 | pdebug("ListType -> tok_list<FieldType>"); |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 756 | $$ = new t_list($3); |
| 757 | if ($5 != NULL) { |
| 758 | ((t_container*)$$)->set_cpp_name(std::string($5)); |
Mark Slee | 4f8da1d | 2006-10-12 02:47:27 +0000 | [diff] [blame] | 759 | } |
| 760 | } |
| 761 | |
Mark Slee | 36bfa2e | 2007-01-19 20:09:51 +0000 | [diff] [blame] | 762 | CppType: |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 763 | '[' tok_cpp_type tok_literal ']' |
Mark Slee | 4f8da1d | 2006-10-12 02:47:27 +0000 | [diff] [blame] | 764 | { |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 765 | $$ = $3; |
Mark Slee | 4f8da1d | 2006-10-12 02:47:27 +0000 | [diff] [blame] | 766 | } |
| 767 | | |
| 768 | { |
| 769 | $$ = NULL; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 770 | } |
| 771 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 772 | %% |