Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | ******************************************************************************/ | |
8 | /* | |
9 | * Asn1:1997 parser | |
10 | * | |
11 | * Written by Matyas Forstner | |
12 | * 20021119 | |
13 | */ | |
14 | ||
15 | %{ | |
16 | ||
17 | /********************************************************************* | |
18 | * C(++) declarations | |
19 | *********************************************************************/ | |
20 | ||
21 | /* These declarations, intended for asn1p.tab.cc, are written by Bison | |
22 | * into asn1p.tab.hh, which is included from multiple C++ files. | |
23 | * YYBISON is defined in asn1p.tab.cc */ | |
24 | #ifdef YYBISON | |
25 | ||
26 | #include <errno.h> | |
27 | #include <limits.h> | |
28 | ||
29 | #include "../Identifier.hh" | |
30 | #include "AST_asn1.hh" | |
31 | #include "Ref.hh" | |
32 | #include "../Value.hh" | |
33 | #include "../Valuestuff.hh" | |
34 | #include "../Type.hh" | |
35 | #include "../Typestuff.hh" // FIXME CTs | |
36 | #include "../CompField.hh" | |
37 | #include "../EnumItem.hh" | |
38 | #include "Tag.hh" | |
39 | #include "TableConstraint.hh" | |
40 | #include "Object.hh" | |
41 | #include "Block.hh" | |
42 | #include "../main.hh" | |
43 | ||
44 | using namespace Asn; | |
45 | using namespace Common; | |
46 | ||
47 | extern Modules *modules; | |
48 | ||
49 | extern const char *asn1_infile; | |
50 | extern bool asn1_yy_parse_internal; | |
51 | extern void asn1la_newfile(const char *filename); | |
52 | ||
53 | /* defined in lexer c-file */ | |
54 | extern FILE *asn1_yyin; | |
55 | #define yyin asn1_yyin | |
56 | extern int asn1_yylineno; | |
57 | #define yylineno asn1_yylineno | |
58 | int asn1_plineno; | |
59 | #define plineno asn1_plineno | |
60 | /* copy-paste from xxxxx.yy.cc */ | |
61 | #define YY_BUF_SIZE 16384 | |
62 | extern int asn1_yylex_my(); | |
63 | #define asn1_yylex asn1_yylex_my | |
64 | struct yy_buffer_state; | |
65 | extern yy_buffer_state *asn1_yy_create_buffer(FILE *file, int size); | |
66 | extern void asn1_yy_switch_to_buffer(yy_buffer_state *new_buffer); | |
67 | extern int asn1_yylex_destroy (void); | |
68 | extern yy_buffer_state *asn1_yy_scan_string(const char *yy_str); | |
69 | ||
70 | static Asn::Module *act_asn1_module = NULL; | |
71 | ||
72 | #define YYERROR_VERBOSE | |
73 | ||
74 | void yyerror(const char *s) | |
75 | { | |
76 | Location loc(asn1_infile, plineno); | |
77 | loc.error("%s", s); | |
78 | } | |
79 | ||
80 | void yywarning(const char *s) | |
81 | { | |
82 | Location loc(asn1_infile, plineno); | |
83 | loc.warning("%s", s); | |
84 | } | |
85 | ||
86 | #endif /* YYBISON */ | |
87 | %} | |
88 | ||
89 | /********************************************************************* | |
90 | * Bison declarations | |
91 | *********************************************************************/ | |
92 | ||
93 | %name-prefix="asn1_yy" | |
94 | %output="asn1p.tab.cc" | |
95 | %defines | |
96 | %verbose | |
97 | %glr-parser | |
98 | /** | |
99 | shift-reduce conflicts: | |
100 | 2: in IMPORTS clause | |
101 | SymbolsFromModule: | |
102 | SymbolList KW_FROM TOK_UpperIdentifier . AssignedIdentifier | |
103 | ||
104 | 1: in upper references (Upper_FromObjs and ExtUpperRef) | |
105 | "A" . "." "zzz" <--> "A" . "." "&zzz" | |
106 | ||
107 | 1: in constraints: "(" lowerid "<" . ... | |
108 | selectiontype or (minvalue < .. maxvalue) | |
109 | */ | |
110 | %expect 4 | |
111 | %start GrammarRoot | |
112 | ||
113 | /********************************************************************* | |
114 | * The union-type | |
115 | *********************************************************************/ | |
116 | ||
117 | %union { | |
118 | /** The Asn namespace must be explicitly used here because this block | |
119 | * is also visible from the common header files. */ | |
120 | ||
121 | bool b; | |
122 | Common::Int _i; | |
123 | Common::int_val_t *i; | |
124 | string *str; | |
125 | ||
126 | Common::Node *node; | |
127 | Common::Identifier *id; | |
128 | Asn::Ref_defd_simple *ref_ds; | |
129 | Asn::Ref_defd *ref_d; | |
130 | Asn::FieldName *fieldname; | |
131 | Asn::FromObj *fromobj; | |
132 | Asn::Reference *ref; | |
133 | ||
134 | Asn::Module *module; | |
135 | Asn::TagDefault::tagdef_t tagging; | |
136 | struct { | |
137 | Asn::Exports *exp; | |
138 | Asn::Imports *imp; | |
139 | Asn::Assignments *asss; | |
140 | } modbody; | |
141 | Asn::Symbols *syms; | |
142 | Asn::Exports *exports; | |
143 | Asn::ImpMod *impmod; | |
144 | Asn::Imports *impmods; | |
145 | Asn::Assignments *asss; | |
146 | Asn::Assignment *ass; | |
147 | Asn::Ass_pard *ass_pard; | |
148 | ||
149 | Common::Block *block; | |
150 | ||
151 | /* type stuff */ | |
152 | Common::Type *type; | |
153 | struct { | |
154 | Common::Identifier *name; | |
155 | Common::Type *type; | |
156 | } namedType; | |
157 | Common::Tag *tag; | |
158 | Common::Tag::tagclass_t tagclass; | |
159 | ||
160 | Common::EnumItem *enumitem; | |
161 | Common::EnumItems *enumitems; | |
162 | Common::ExcSpec *excSpec; | |
163 | Common::CTs_EE_CTs *ctss; | |
164 | Common::CTs *cts; | |
165 | Common::ExtAndExc *extAndExc; | |
166 | Common::ExtAdds *extAdds; | |
167 | Common::ExtAdd *extAdd; | |
168 | Common::CT *ct; | |
169 | Common::CompField *compField; | |
170 | Common::Constraint *constraint; | |
171 | Common::RangeEndpoint *rangeendpoint; | |
172 | Common::Constraints *constraints; | |
173 | ||
174 | /* sub-type constraints */ | |
175 | Common::ContainedSubtypeConstraint* contsubt__constraint; | |
176 | Common::ValueRangeConstraint* valuerange_constraint; | |
177 | Common::SizeConstraint* size_constraint; | |
178 | Common::PermittedAlphabetConstraint* permalpha_constraint; | |
179 | Common::SetOperationConstraint* setoperation_constraint; | |
180 | Common::PatternConstraint* pattern_constraint; | |
181 | Common::SingleInnerTypeConstraint* single_inner_constraint; | |
182 | Common::MultipleInnerTypeConstraint* multiple_inner_constraint; | |
183 | Common::NamedConstraint* named_constraint; | |
184 | Common::NamedConstraint::presence_constraint_t presence_constraint; | |
185 | ||
186 | /* value stuff */ | |
187 | Common::Value *value; | |
188 | Common::Values *values; | |
189 | Common::NamedValue *namedValue; | |
190 | Common::NamedValues *namedValues; | |
191 | Common::OID_comp *oic; | |
192 | Common::CharsDefn *charsdefn; | |
193 | Common::CharSyms *charsyms; | |
194 | ||
195 | /* object/class/set stuff */ | |
196 | Asn::ObjectClass *objclass; | |
197 | Asn::Object *obj; | |
198 | Asn::ObjectSet *objset; | |
199 | Asn::FieldSpec *fieldspec; | |
200 | Asn::FieldSpecs *fieldspecs; | |
201 | Asn::OS_Element *os_element; | |
202 | Asn::OS_defn *os_defn; | |
203 | Asn::AtNotation *an; | |
204 | Asn::AtNotations *ans; | |
205 | Asn::TableConstraint *tbl_cnstr; | |
206 | } | |
207 | ||
208 | /********************************************************************* | |
209 | * Tokens with semantic value | |
210 | *********************************************************************/ | |
211 | ||
212 | %token <id> TOK_UpperIdentifier "<upperidentifier>" | |
213 | TOK_LowerIdentifier "<loweridentifier>" | |
214 | TOK_ampUpperIdentifier "<&upperidentifier>" | |
215 | TOK_ampLowerIdentifier "<&loweridentifier>" | |
216 | %token <i> TOK_Number "<number>" | |
217 | %token <str> TOK_CString "<cstring>" | |
218 | %token <value> | |
219 | TOK_RealNumber "<realnumber>" | |
220 | TOK_BString "<bstring>" | |
221 | TOK_HString "<hstring>" | |
222 | %token <block> TOK_Block "{block}" | |
223 | ||
224 | /* special keyword-like tokens */ | |
225 | ||
226 | %token | |
227 | KW_Block_NamedNumberList | |
228 | KW_Block_Enumerations | |
229 | KW_Block_Assignment | |
230 | KW_Block_NamedBitList | |
231 | KW_Block_IdentifierList | |
232 | KW_Block_FieldSpecList | |
233 | KW_Block_ComponentTypeLists | |
234 | KW_Block_AlternativeTypeLists | |
235 | KW_Block_Type | |
236 | KW_Block_Value | |
237 | KW_Block_Object | |
238 | KW_Block_ObjectSet | |
239 | KW_Block_SeqOfValue | |
240 | KW_Block_SetOfValue | |
241 | KW_Block_SequenceValue | |
242 | KW_Block_SetValue | |
243 | KW_Block_ObjectSetSpec | |
244 | KW_Block_DefinedObjectSetBlock | |
245 | KW_Block_AtNotationList | |
246 | KW_Block_OIDValue | |
247 | KW_Block_ROIDValue | |
248 | KW_Block_CharStringValue | |
249 | KW_Block_QuadrupleOrTuple | |
250 | KW_TITAN_Assignments | |
251 | KW_Block_DefinitiveOIDValue | |
252 | KW_Block_ValueSet | |
253 | KW_Block_MultipleTypeConstraints | |
254 | ||
255 | /********************************************************************* | |
256 | * Tokens without semantic value (keywords, operators) | |
257 | *********************************************************************/ | |
258 | ||
259 | %token TOK_Assignment "::=" | |
260 | %token TOK_RangeSeparator ".." | |
261 | %token TOK_Ellipsis "..." | |
262 | %token TOK_LeftVersionBrackets "[[" | |
263 | %token TOK_RightVersionBrackets "]]" | |
264 | %token '{' "{" | |
265 | %token '}' "}" | |
266 | %token '(' "(" | |
267 | %token ')' ")" | |
268 | %token '[' "[" | |
269 | %token ']' "]" | |
270 | %token ',' "," | |
271 | %token '.' "." | |
272 | %token '-' "-" | |
273 | %token ':' ":" | |
274 | %token ';' ";" | |
275 | %token '@' "@" | |
276 | %token '|' "|" | |
277 | %token '!' "!" | |
278 | %token '^' "^" | |
279 | %token '\'' "'" | |
280 | %token '"' "\"" | |
281 | %token '<' "<" | |
282 | %token '>' ">" | |
283 | ||
284 | %token | |
285 | KW_ABSENT "ABSENT" | |
286 | /* | |
287 | KW_ABSTRACT_SYNTAX "ABSTRACT-SYNTAX" | |
288 | */ | |
289 | KW_ALL "ALL" | |
290 | KW_ANY "ANY" | |
291 | KW_APPLICATION "APPLICATION" | |
292 | KW_AUTOMATIC "AUTOMATIC" | |
293 | KW_BEGIN "BEGIN" | |
294 | KW_BIT "BIT" | |
295 | KW_BMPString "BMPString" | |
296 | KW_BOOLEAN "BOOLEAN" | |
297 | KW_BY "BY" | |
298 | KW_CHARACTER "CHARACTER" | |
299 | KW_CHOICE "CHOICE" | |
300 | KW_CLASS "CLASS" | |
301 | KW_COMPONENT "COMPONENT" | |
302 | KW_COMPONENTS "COMPONENTS" | |
303 | KW_CONSTRAINED "CONSTRAINED" | |
304 | KW_CONTAINING "CONTAINING" | |
305 | KW_DEFAULT "DEFAULT" | |
306 | KW_DEFINED "DEFINED" | |
307 | KW_DEFINITIONS "DEFINITIONS" | |
308 | KW_EMBEDDED "EMBEDDED" | |
309 | KW_ENCODED "ENCODED" | |
310 | KW_END "END" | |
311 | KW_ENUMERATED "ENUMERATED" | |
312 | KW_EXCEPT "EXCEPT" | |
313 | KW_EXPLICIT "EXPLICIT" | |
314 | KW_EXPORTS "EXPORTS" | |
315 | KW_EXTENSIBILITY "EXTENSIBILITY" | |
316 | KW_EXTERNAL "EXTERNAL" | |
317 | KW_FALSE "FALSE" | |
318 | KW_FROM "FROM" | |
319 | KW_GeneralizedTime "GeneralizedTime" | |
320 | KW_GeneralString "GeneralString" | |
321 | KW_GraphicString "GraphicString" | |
322 | KW_IA5String "IA5String" | |
323 | KW_IDENTIFIER "IDENTIFIER" | |
324 | KW_IMPLICIT "IMPLICIT" | |
325 | KW_IMPLIED "IMPLIED" | |
326 | KW_IMPORTS "IMPORTS" | |
327 | KW_INCLUDES "INCLUDES" | |
328 | KW_INSTANCE "INSTANCE" | |
329 | KW_INTEGER "INTEGER" | |
330 | KW_INTERSECTION "INTERSECTION" | |
331 | KW_ISO646String "ISO646String" | |
332 | KW_MAX "MAX" | |
333 | KW_MIN "MIN" | |
334 | KW_MINUS_INFINITY "MINUS-INFINITY" | |
335 | KW_NOT_A_NUMBER "NOT-A-NUMBER" | |
336 | KW_NULL "NULL" | |
337 | KW_NumericString "NumericString" | |
338 | KW_OBJECT "OBJECT" | |
339 | KW_ObjectDescriptor "ObjectDescriptor" | |
340 | KW_OCTET "OCTET" | |
341 | KW_OF "OF" | |
342 | KW_OPTIONAL "OPTIONAL" | |
343 | KW_PATTERN "PATTERN" | |
344 | KW_PDV "PDV" | |
345 | KW_PLUS_INFINITY "PLUS-INFINITY" | |
346 | KW_PRESENT "PRESENT" | |
347 | KW_PrintableString "PrintableString" | |
348 | KW_PRIVATE "PRIVATE" | |
349 | KW_REAL "REAL" | |
350 | KW_RELATIVE_OID "RELATIVE-OID" | |
351 | KW_SEQUENCE "SEQUENCE" | |
352 | KW_SET "SET" | |
353 | KW_SIZE "SIZE" | |
354 | KW_STRING "STRING" | |
355 | KW_SYNTAX "SYNTAX" | |
356 | KW_T61String "T61String" | |
357 | KW_TAGS "TAGS" | |
358 | KW_TeletexString "TeletexString" | |
359 | KW_TRUE "TRUE" | |
360 | /* | |
361 | KW_TYPE_IDENTIFIER "TYPE-IDENTIFIER" | |
362 | */ | |
363 | KW_UNION "UNION" | |
364 | KW_UNIQUE "UNIQUE" | |
365 | KW_UNIVERSAL "UNIVERSAL" | |
366 | KW_UniversalString "UniversalString" | |
367 | KW_UTCTime "UTCTime" | |
368 | KW_UTF8String "UTF8String" | |
369 | KW_VideotexString "VideotexString" | |
370 | KW_VisibleString "VisibleString" | |
371 | KW_WITH "WITH" | |
372 | ||
373 | /********************************************************************* | |
374 | * Semantic types of nonterminals | |
375 | *********************************************************************/ | |
376 | ||
377 | %type <id> ModuleIdentifier | |
378 | %type <module> ModuleDefinition | |
379 | %type <tagging> TagDefault | |
380 | %type <b> ExtensionDefault | |
381 | %type <modbody> ModuleBody | |
382 | %type <id> Symbol | |
383 | %type <syms> SymbolList | |
384 | %type <exports> Exports SymbolsExported | |
385 | %type <impmod> SymbolsFromModule | |
386 | %type <impmods> SymbolsFromModuleList SymbolsImported Imports | |
387 | %type <asss> AssignmentList | |
388 | %type <ass_pard> OptParList | |
389 | %type <ass> Assignment TypeAssignment ValueAssignment | |
390 | ValueSetTypeAssignment /*ObjectSetAssignment*/ | |
391 | ObjectClassAssignment /*ObjectAssignment*/ | |
392 | UndefAssignment | |
393 | %type <objclass> /*ObjectClass DefinedObjectClass*/ ObjectClassDefn | |
394 | /*UsefulObjectClassReference*/ | |
395 | %type <obj> Object DefinedObject ObjectDefn | |
396 | %type <objset> ObjectSet DefinedObjectSetBlock | |
397 | %type <os_element> ObjectSetElements | |
398 | %type <os_defn> ObjectSetSpec ObjectSetSpec0 | |
399 | %type <_i> Levels Level | |
400 | %type <an> AtNotation | |
401 | %type <ans> AtNotationList | |
402 | %type <tbl_cnstr> TableConstraint ComponentRelationConstraint | |
403 | %type <type> | |
404 | Type Type_reg BuiltinType BuiltinType_reg | |
405 | NakedType NakedType_reg | |
406 | ConstrainedType SeqOfSetOfWithConstraint | |
407 | ReferencedType /*DefinedType*/ | |
408 | UsefulType | |
409 | EmbeddedPDVType ExternalType | |
410 | CharacterStringType RestrictedCharacterStringType | |
411 | UnrestrictedCharacterStringType | |
412 | Dflt_Type | |
413 | %type <ctss> ComponentTypeLists AlternativeTypeLists | |
414 | %type <extAdds> ExtensionAdditionList ExtensionAdditionAlternativesList | |
415 | %type <extAdd> ExtensionAddition ExtensionAdditionGroup | |
416 | ExtensionAdditionAlternative | |
417 | %type <cts> ComponentTypeList AlternativeTypeList | |
418 | %type <ct> ComponentType | |
419 | %type <compField> ComponentType_reg | |
420 | %type <namedType> NamedType | |
421 | %type <excSpec> ExceptionIdentification ExceptionSpec | |
422 | %type <extAndExc> ExtensionAndException | |
423 | %type <type> ChoiceType SelectionType SelectionTypeType | |
424 | %type <type> SequenceType SetType | |
425 | %type <type> SequenceOfType SetOfType | |
426 | %type <enumitem> EnumerationItem | |
427 | %type <enumitems> Enumeration | |
428 | %type <type> Enumerations EnumeratedType | |
429 | %type <type> AnyType | |
430 | %type <type> IntegerType | |
431 | %type <type> BooleanType | |
432 | %type <type> NullType | |
433 | %type <type> ObjectIdentifierType RelativeOIDType | |
434 | %type <type> OctetStringType | |
435 | %type <type> BitStringType | |
436 | %type <type> GeneralString | |
437 | BMPString GraphicString IA5String NumericString PrintableString | |
438 | TeletexString UniversalString UTF8String VideotexString | |
439 | VisibleString | |
440 | %type <type> RealType | |
441 | %type <tagclass> Class | |
442 | %type <tag> Tag | |
443 | %type <rangeendpoint> LowerEndpoint UpperEndpoint LowerEndValue UpperEndValue | |
444 | %type <constraint> Constraint ConstraintSpec SubtypeConstraint GeneralConstraint | |
445 | ElementSetSpecs RootElementSetSpec ElementSetSpec Unions Intersections | |
446 | IntersectionElements Elements SubtypeElements SingleValue | |
447 | InnerTypeConstraints Elems IElems UElems AdditionalElementSetSpec | |
448 | ValueConstraint | |
449 | %type <contsubt__constraint> ContainedSubtype | |
450 | %type <valuerange_constraint> ValueRange | |
451 | %type <size_constraint> SizeConstraint | |
452 | %type <permalpha_constraint> PermittedAlphabet | |
453 | %type <setoperation_constraint> Exclusions | |
454 | %type <pattern_constraint> PatternConstraint | |
455 | %type <single_inner_constraint> SingleTypeConstraint | |
456 | %type <multiple_inner_constraint> MultipleTypeConstraints TypeConstraints | |
457 | %type <named_constraint> NamedConstraint | |
458 | %type <presence_constraint> PresenceConstraint | |
459 | %type <constraints> Constraints | |
460 | %type <value> Val_Number Val_CString Value Value_reg | |
461 | ObjectClassFieldValue ObjectClassFieldValue_reg | |
462 | /* | |
463 | OpenTypeFieldValue OpenTypeFieldValue_reg | |
464 | */ | |
465 | FixedTypeFieldValue FixedTypeFieldValue_reg | |
466 | BuiltinValue BuiltinValue_reg | |
467 | ReferencedValue ReferencedValue_reg | |
468 | DefinitiveIdentifier AssignedIdentifier | |
469 | ClassNumber | |
470 | Dflt_Value Dflt_Value_reg Dflt_NullValue | |
471 | DefinedValue DefinedValue_reg | |
472 | BooleanValue | |
473 | ChoiceValue | |
474 | SignedNumber | |
475 | LowerIdValue | |
476 | RealValue SpecialRealValue NumericRealValue | |
477 | NullValue | |
478 | DefinitiveOIDValue DefinitiveObjIdComponentList | |
479 | ObjectIdentifierValue ObjIdComponentList | |
480 | RelativeOIDValue RelativeOIDComponentList | |
481 | %type <oic> DefinitiveObjIdComponent | |
482 | ObjIdComponent ObjIdComponentNumber | |
483 | DefinitiveNameAndNumberForm NameAndNumberForm | |
484 | RelativeOIDComponent | |
485 | %type <value> SequenceValue SetValue | |
486 | SeqOfValue SetOfValue | |
487 | %type <values> ValueList ValueList0 | |
488 | %type <namedValue> NamedValue NamedNumber NamedBit | |
489 | %type <namedValues> NamedNumberList | |
490 | ComponentValueList NamedBitList | |
491 | %type <charsdefn> CharsDefn QuadrupleOrTuple QuadrupleOrTuple0 | |
492 | %type <charsyms> CharStringValue CharSyms | |
493 | %type <value> IdentifierList IdentifierList1 | |
494 | %type <ref_ds> UpperRef ExtUpperRef SimplDefdUpper | |
495 | LowerRef ExtLowerRef SimplDefdLower SimplDefdLower_reg | |
496 | %type <ref_d> PardUpper DefdUpper | |
497 | PardLower DefdLower DefdLower_reg | |
498 | %type <fieldname> FieldNameUpper FieldNameUppers FieldNameLower | |
499 | ComponentIdList | |
500 | %type <fromobj> UpperFromObj FromObjs Lower_FromObjs | |
501 | LowerFromObj Upper_FromObjs SimplUpper_FromObjs PardUpper_FromObjs | |
502 | %type <ref> RefdUpper RefdLower RefdLower_reg | |
503 | Dflt_RefdLower Dflt_RefdLower_reg | |
504 | %type <fieldspec> FieldSpec TypeFieldSpec FixedTypeValueFieldSpec | |
505 | UndefFieldSpec | |
506 | %type <fieldspecs> FieldSpecList | |
507 | %type <block> Dflt_Block | |
508 | %type <id> Dflt_LowerId | |
509 | %type <block> WithSyntaxSpec_opt | |
510 | %type <b> UNIQ_opt | |
511 | %type <node> BlockDefinition | |
512 | ||
513 | /********************************************************************* | |
514 | * Destructors | |
515 | *********************************************************************/ | |
516 | ||
517 | %destructor {delete $$;} | |
518 | TOK_BString | |
519 | TOK_Block | |
520 | TOK_CString | |
521 | TOK_HString | |
522 | TOK_LowerIdentifier | |
523 | TOK_Number | |
524 | TOK_RealNumber | |
525 | TOK_UpperIdentifier | |
526 | TOK_ampLowerIdentifier | |
527 | TOK_ampUpperIdentifier | |
528 | AlternativeTypeList | |
529 | AlternativeTypeLists | |
530 | AnyType | |
531 | AssignedIdentifier | |
532 | Assignment | |
533 | AtNotation | |
534 | AtNotationList | |
535 | BMPString | |
536 | BitStringType | |
537 | BlockDefinition | |
538 | BooleanType | |
539 | BooleanValue | |
540 | BuiltinType | |
541 | BuiltinType_reg | |
542 | BuiltinValue | |
543 | BuiltinValue_reg | |
544 | CharStringValue | |
545 | CharSyms | |
546 | CharacterStringType | |
547 | CharsDefn | |
548 | ChoiceType | |
549 | ChoiceValue | |
550 | ClassNumber | |
551 | ComponentIdList | |
552 | ComponentRelationConstraint | |
553 | ComponentType | |
554 | ComponentTypeList | |
555 | ComponentTypeLists | |
556 | ComponentType_reg | |
557 | ComponentValueList | |
558 | ConstrainedType | |
559 | Constraint | |
560 | ConstraintSpec | |
561 | Constraints | |
562 | DefdLower | |
563 | DefdLower_reg | |
564 | DefdUpper | |
565 | DefinedObject | |
566 | //DefinedObjectClass | |
567 | DefinedObjectSetBlock | |
568 | //DefinedType | |
569 | DefinedValue | |
570 | DefinedValue_reg | |
571 | DefinitiveIdentifier | |
572 | DefinitiveNameAndNumberForm | |
573 | DefinitiveOIDValue | |
574 | DefinitiveObjIdComponent | |
575 | DefinitiveObjIdComponentList | |
576 | Dflt_Block | |
577 | Dflt_LowerId | |
578 | Dflt_NullValue | |
579 | Dflt_RefdLower | |
580 | Dflt_RefdLower_reg | |
581 | Dflt_Type | |
582 | Dflt_Value | |
583 | Dflt_Value_reg | |
584 | ElementSetSpec | |
585 | ElementSetSpecs | |
586 | Elements | |
587 | EmbeddedPDVType | |
588 | EnumeratedType | |
589 | Enumeration | |
590 | EnumerationItem | |
591 | Enumerations | |
592 | ExceptionIdentification | |
593 | ExceptionSpec | |
594 | Exports | |
595 | ExtLowerRef | |
596 | ExtUpperRef | |
597 | ExtensionAddition | |
598 | ExtensionAdditionAlternative | |
599 | ExtensionAdditionAlternativesList | |
600 | ExtensionAdditionGroup | |
601 | ExtensionAdditionList | |
602 | ExtensionAndException | |
603 | ExternalType | |
604 | FieldNameLower | |
605 | FieldNameUpper | |
606 | FieldNameUppers | |
607 | FieldSpec | |
608 | FieldSpecList | |
609 | FixedTypeFieldValue | |
610 | FixedTypeFieldValue_reg | |
611 | FixedTypeValueFieldSpec | |
612 | FromObjs | |
613 | GeneralConstraint | |
614 | GeneralString | |
615 | GraphicString | |
616 | IA5String | |
617 | IdentifierList | |
618 | IdentifierList1 | |
619 | Imports | |
620 | IntegerType | |
621 | IntersectionElements | |
622 | Intersections | |
623 | LowerFromObj | |
624 | LowerIdValue | |
625 | LowerRef | |
626 | Lower_FromObjs | |
627 | ModuleDefinition | |
628 | ModuleIdentifier | |
629 | NakedType | |
630 | NakedType_reg | |
631 | NameAndNumberForm | |
632 | NamedBit | |
633 | NamedBitList | |
634 | NamedNumber | |
635 | NamedNumberList | |
636 | NamedValue | |
637 | NullType | |
638 | NullValue | |
639 | NumericRealValue | |
640 | NumericString | |
641 | ObjIdComponent | |
642 | ObjIdComponentList | |
643 | ObjIdComponentNumber | |
644 | Object | |
645 | //ObjectClass | |
646 | ObjectClassAssignment | |
647 | ObjectClassDefn | |
648 | ObjectClassFieldValue | |
649 | ObjectClassFieldValue_reg | |
650 | ObjectDefn | |
651 | ObjectIdentifierType | |
652 | ObjectIdentifierValue | |
653 | ObjectSet | |
654 | ObjectSetElements | |
655 | ObjectSetSpec | |
656 | ObjectSetSpec0 | |
657 | OctetStringType | |
658 | OptParList | |
659 | PardLower | |
660 | PardUpper | |
661 | PrintableString | |
662 | QuadrupleOrTuple | |
663 | QuadrupleOrTuple0 | |
664 | RealType | |
665 | RealValue | |
666 | RefdLower | |
667 | RefdLower_reg | |
668 | RefdUpper | |
669 | ReferencedType | |
670 | ReferencedValue | |
671 | ReferencedValue_reg | |
672 | RelativeOIDComponent | |
673 | RelativeOIDComponentList | |
674 | RelativeOIDType | |
675 | RelativeOIDValue | |
676 | RestrictedCharacterStringType | |
677 | RootElementSetSpec | |
678 | AdditionalElementSetSpec | |
679 | SelectionType | |
680 | SelectionTypeType | |
681 | SeqOfSetOfWithConstraint | |
682 | SeqOfValue | |
683 | SequenceOfType | |
684 | SequenceType | |
685 | SequenceValue | |
686 | SetOfType | |
687 | SetOfValue | |
688 | SetType | |
689 | SetValue | |
690 | SignedNumber | |
691 | SimplDefdLower | |
692 | SimplDefdLower_reg | |
693 | SimplDefdUpper | |
694 | SingleValue | |
695 | SpecialRealValue | |
696 | SubtypeConstraint | |
697 | SubtypeElements | |
698 | Symbol | |
699 | SymbolList | |
700 | SymbolsExported | |
701 | SymbolsFromModule | |
702 | SymbolsFromModuleList | |
703 | SymbolsImported | |
704 | TableConstraint | |
705 | Tag | |
706 | TeletexString | |
707 | Type | |
708 | TypeAssignment | |
709 | TypeFieldSpec | |
710 | Type_reg | |
711 | UTF8String | |
712 | UndefAssignment | |
713 | UndefFieldSpec | |
714 | Unions | |
715 | UniversalString | |
716 | UnrestrictedCharacterStringType | |
717 | UpperFromObj | |
718 | UpperRef | |
719 | Upper_FromObjs | |
720 | UsefulType | |
721 | Val_CString | |
722 | Val_Number | |
723 | Value | |
724 | ValueAssignment | |
725 | ValueList ValueList0 | |
726 | ValueSetTypeAssignment | |
727 | Value_reg | |
728 | VideotexString | |
729 | VisibleString | |
730 | WithSyntaxSpec_opt | |
731 | ContainedSubtype | |
732 | ValueRange | |
733 | PermittedAlphabet | |
734 | SizeConstraint | |
735 | InnerTypeConstraints | |
736 | PatternConstraint | |
737 | LowerEndpoint | |
738 | UpperEndpoint | |
739 | LowerEndValue | |
740 | UpperEndValue | |
741 | Exclusions | |
742 | Elems | |
743 | IElems | |
744 | UElems | |
745 | SingleTypeConstraint | |
746 | MultipleTypeConstraints | |
747 | TypeConstraints | |
748 | NamedConstraint | |
749 | ValueConstraint | |
750 | ||
751 | %destructor { | |
752 | delete $$.exp; | |
753 | delete $$.imp; | |
754 | delete $$.asss; | |
755 | } | |
756 | ModuleBody | |
757 | ||
758 | %destructor { | |
759 | delete $$.name; | |
760 | delete $$.type; | |
761 | } | |
762 | NamedType | |
763 | ||
764 | %printer { fprintf(yyoutput, "'%s'", $$->c_str()); } TOK_CString | |
765 | ||
766 | %printer { fprintf(yyoutput, "%s", $$->get_asnname().c_str()); } TOK_UpperIdentifier | |
767 | TOK_LowerIdentifier | |
768 | TOK_ampUpperIdentifier | |
769 | TOK_ampLowerIdentifier | |
770 | /* With 2.4 (or even 2.3a) we could use | |
771 | * %printer { ... } <id> | |
772 | * Alas, not with Bison 2.3 */ | |
773 | ||
774 | %printer { fprintf(yyoutput, "%s", $$->t_str().c_str()); } TOK_Number; | |
775 | ||
776 | /*%printer { | |
777 | int old_v = verb_level; | |
778 | verb_level = 255; | |
779 | $$->dump(0); | |
780 | verb_level = old_v; | |
781 | } TOK_Block;*/ | |
782 | ||
783 | ||
784 | %% | |
785 | ||
786 | /********************************************************************* | |
787 | * Grammar | |
788 | *********************************************************************/ | |
789 | ||
790 | GrammarRoot: | |
791 | ModuleDefinition {act_asn1_module=$1;} | |
792 | | BlockDefinition {parsed_node=$1;} | |
793 | | KW_TITAN_Assignments AssignmentList {parsed_assignments=$2;} | |
794 | | error {act_asn1_module=0; parsed_node=0;} | |
795 | ; | |
796 | ||
797 | /* 12.1 page 22 */ | |
798 | ModuleDefinition: | |
799 | ModuleIdentifier DefinitiveIdentifier | |
800 | KW_DEFINITIONS | |
801 | TagDefault | |
802 | ExtensionDefault | |
803 | TOK_Assignment | |
804 | KW_BEGIN | |
805 | ModuleBody | |
806 | ModuleEnd | |
807 | { | |
808 | DEBUG(6, "Module `%s' parsed successfully.", | |
809 | $1->get_dispname().c_str()); | |
810 | $$=new Asn::Module($1, $4, $5, $8.exp, $8.imp, $8.asss); | |
811 | $$->set_location(asn1_infile, @1.first_line); | |
812 | delete $2; | |
813 | } | |
814 | ; | |
815 | ||
816 | /********************************************************************* | |
817 | * Module header | |
818 | *********************************************************************/ | |
819 | ||
820 | ModuleIdentifier: | |
821 | TOK_UpperIdentifier | |
822 | { | |
823 | $$=$1; | |
824 | } | |
825 | ; | |
826 | ||
827 | DefinitiveIdentifier: | |
828 | /* | |
829 | '{' DefinitiveObjIdComponentList '}' {$$=new Asn_Value_ObjId($2);} | |
830 | */ | |
831 | TOK_Block | |
832 | { | |
833 | $$=new Value(Value::V_UNDEF_BLOCK, $1); | |
834 | $$->set_location(asn1_infile, @1.first_line); | |
835 | } | |
836 | | /* empty */ {$$=0;} | |
837 | ; | |
838 | ||
839 | DefinitiveOIDValue: | |
840 | DefinitiveObjIdComponentList {$$=$1;} | |
841 | ; | |
842 | ||
843 | DefinitiveObjIdComponentList: | |
844 | DefinitiveObjIdComponent | |
845 | { | |
846 | $$=new Value(Value::V_OID); | |
847 | $$->set_location(asn1_infile, @1.first_line); | |
848 | $$->add_oid_comp($1); | |
849 | } | |
850 | | DefinitiveObjIdComponentList DefinitiveObjIdComponent | |
851 | {$$=$1; $$->add_oid_comp($2);} | |
852 | ; | |
853 | ||
854 | DefinitiveObjIdComponent: | |
855 | TOK_LowerIdentifier | |
856 | { | |
857 | $$=new OID_comp($1, 0); | |
858 | $$->set_location(asn1_infile, @1.first_line); | |
859 | } | |
860 | | Val_Number | |
861 | { | |
862 | $1->set_location(asn1_infile, @1.first_line); | |
863 | $$=new OID_comp(0, $1); | |
864 | $$->set_location(asn1_infile, @1.first_line); | |
865 | } | |
866 | | DefinitiveNameAndNumberForm {$$=$1;} | |
867 | ; | |
868 | ||
869 | /* 12.1 page 23 */ | |
870 | TagDefault: | |
871 | KW_EXPLICIT KW_TAGS {$$=TagDefault::EXPLICIT;} | |
872 | | KW_IMPLICIT KW_TAGS {$$=TagDefault::IMPLICIT;} | |
873 | | KW_AUTOMATIC KW_TAGS {$$=TagDefault::AUTOMATIC;} | |
874 | | /* empty */ {$$=TagDefault::EXPLICIT;} | |
875 | ; | |
876 | ||
877 | /* 12.1 page 23 */ | |
878 | ExtensionDefault: | |
879 | KW_EXTENSIBILITY KW_IMPLIED {$$=true;} | |
880 | | /* empty */ {$$=false;} | |
881 | ; | |
882 | ||
883 | /********************************************************************* | |
884 | * Module body | |
885 | *********************************************************************/ | |
886 | ||
887 | /* 12.1 page 23 */ | |
888 | ModuleBody: | |
889 | Exports Imports AssignmentList | |
890 | { | |
891 | $$.exp = $1; | |
892 | $$.imp = $2; | |
893 | $$.asss = $3; | |
894 | } | |
895 | | /* empty */ | |
896 | { | |
897 | $$.exp = new Exports(false); | |
898 | $$.imp = new Imports(); | |
899 | $$.asss = new Asn::Assignments(); | |
900 | } | |
901 | ; | |
902 | ||
903 | ModuleEnd: | |
904 | KW_END | |
905 | | /* empty - error */ | |
906 | {yyerror("Missing `END'");} | |
907 | | KW_END error | |
908 | {yyerror("Something after `END'");} | |
909 | ; | |
910 | ||
911 | /* 12.1 page 23 */ | |
912 | Exports: | |
913 | /* empty */ | |
914 | { | |
915 | $$=new Exports(true); /* exports all */ | |
916 | $$->set_location(asn1_infile); | |
917 | } | |
918 | | KW_EXPORTS SymbolsExported ";" {$$=$2;} | |
919 | ; | |
920 | ||
921 | /* 12.1 page 23 */ | |
922 | SymbolsExported: | |
923 | SymbolList | |
924 | { | |
925 | $$=new Exports($1); | |
926 | $$->set_location(asn1_infile, @1.first_line); | |
927 | } | |
928 | | /* empty */ | |
929 | { | |
930 | $$=new Exports(false); /* exports nothing */ | |
931 | $$->set_location(asn1_infile); | |
932 | } | |
933 | | KW_ALL | |
934 | { | |
935 | $$=new Exports(true); /* exports all */ | |
936 | $$->set_location(asn1_infile); | |
937 | } | |
938 | ; | |
939 | ||
940 | /* 12.1 page 23 */ | |
941 | Imports: | |
942 | /* empty */ | |
943 | { | |
944 | $$=new Imports(); | |
945 | $$->set_location(asn1_infile); | |
946 | yywarning("Missing IMPORTS clause is interpreted as `IMPORTS ;'" | |
947 | " (import nothing) instead of importing all symbols" | |
948 | " from all modules."); | |
949 | } | |
950 | | KW_IMPORTS SymbolsImported ";" {$$=$2;} | |
951 | ; | |
952 | ||
953 | /* 12.1 page 23 */ | |
954 | SymbolsImported: | |
955 | SymbolsFromModuleList {$$=$1;} | |
956 | | /* empty */ | |
957 | { | |
958 | $$=new Imports(); | |
959 | $$->set_location(asn1_infile); | |
960 | } | |
961 | ; | |
962 | ||
963 | /* 12.1 page 23 */ | |
964 | SymbolsFromModuleList: | |
965 | SymbolsFromModule | |
966 | { | |
967 | $$=new Imports(); | |
968 | $$->set_location(asn1_infile, @1.first_line); | |
969 | $$->add_impmod($1); | |
970 | } | |
971 | | SymbolsFromModuleList SymbolsFromModule {$$=$1; $$->add_impmod($2);} | |
972 | ; | |
973 | ||
974 | /* 12.1 page 23 */ | |
975 | SymbolsFromModule: | |
976 | SymbolList KW_FROM TOK_UpperIdentifier AssignedIdentifier | |
977 | { | |
978 | $$=new ImpMod($3, $1); | |
979 | $$->set_location(asn1_infile, @1.first_line); | |
980 | delete $4; | |
981 | } | |
982 | ; | |
983 | ||
984 | /* 12.1 page 23 */ | |
985 | AssignedIdentifier: | |
986 | /* | |
987 | ObjectIdentifierValue {$$=$1;} | |
988 | */ | |
989 | TOK_Block | |
990 | { | |
991 | $$=new Value(Value::V_UNDEF_BLOCK, $1); | |
992 | $$->set_location(asn1_infile, @1.first_line); | |
993 | } | |
994 | | DefinedValue {$$=$1;} | |
995 | | /* empty */ {$$=0;} | |
996 | ; | |
997 | ||
998 | /* 12.1 page 23 */ | |
999 | SymbolList: | |
1000 | Symbol {$$=new Symbols(); $$->add_sym($1);} | |
1001 | | SymbolList "," Symbol {$$=$1; $$->add_sym($3);} | |
1002 | ; | |
1003 | ||
1004 | /* 12.1 page 23 */ | |
1005 | Symbol: | |
1006 | TOK_UpperIdentifier {$$=$1;} | |
1007 | | TOK_LowerIdentifier {$$=$1;} | |
1008 | | TOK_UpperIdentifier TOK_Block {$$=$1; delete $2;} | |
1009 | | TOK_LowerIdentifier TOK_Block {$$=$1; delete $2;} | |
1010 | /* | |
1011 | | ParameterizedReference | |
1012 | | objectclassreference | |
1013 | | objectreference | |
1014 | | objectsetreference | |
1015 | */ | |
1016 | ; | |
1017 | ||
1018 | /********************************************************************* | |
1019 | * BlockDefinition | |
1020 | *********************************************************************/ | |
1021 | ||
1022 | BlockDefinition: | |
1023 | KW_Block_NamedNumberList NamedNumberList {$$=$2;} | |
1024 | | KW_Block_Enumerations Enumerations {$$=$2;} | |
1025 | | KW_Block_Assignment Assignment {$$=$2;} | |
1026 | | KW_Block_Assignment Assignment error {$$=$2;} | |
1027 | | KW_Block_NamedBitList NamedBitList {$$=$2;} | |
1028 | | KW_Block_IdentifierList IdentifierList {$$=$2;} | |
1029 | | KW_Block_FieldSpecList FieldSpecList {$$=$2;} | |
1030 | | KW_Block_ComponentTypeLists ComponentTypeLists {$$=$2;} | |
1031 | | KW_Block_AlternativeTypeLists AlternativeTypeLists {$$=$2;} | |
1032 | | KW_Block_Type Type {$$=$2;} | |
1033 | | KW_Block_Type Type error {$$=$2;} | |
1034 | | KW_Block_Value Value {$$=$2;} | |
1035 | | KW_Block_Value Value error {$$=$2;} | |
1036 | | KW_Block_Object Object {$$=$2;} | |
1037 | | KW_Block_Object Object error {$$=$2;} | |
1038 | | KW_Block_ObjectSet ObjectSet {$$=$2;} | |
1039 | | KW_Block_ObjectSet ObjectSet error {$$=$2;} | |
1040 | | KW_Block_SeqOfValue SeqOfValue {$$=$2;} | |
1041 | | KW_Block_SetOfValue SetOfValue {$$=$2;} | |
1042 | | KW_Block_SequenceValue SequenceValue {$$=$2;} | |
1043 | | KW_Block_SetValue SetValue {$$=$2;} | |
1044 | | KW_Block_ObjectSetSpec ObjectSetSpec {$$=$2;} | |
1045 | | KW_Block_DefinedObjectSetBlock DefinedObjectSetBlock {$$=$2;} | |
1046 | | KW_Block_AtNotationList AtNotationList {$$=$2;} | |
1047 | | KW_Block_OIDValue ObjectIdentifierValue {$$=$2;} | |
1048 | | KW_Block_ROIDValue RelativeOIDValue {$$=$2;} | |
1049 | | KW_Block_CharStringValue CharStringValue {$$=$2;} | |
1050 | | KW_Block_QuadrupleOrTuple QuadrupleOrTuple {$$=$2;} | |
1051 | | KW_Block_DefinitiveOIDValue DefinitiveOIDValue {$$=$2;} | |
1052 | | KW_Block_ValueSet ElementSetSpecs {$$=$2;} | |
1053 | | KW_Block_MultipleTypeConstraints MultipleTypeConstraints {$$=$2;} | |
1054 | ; | |
1055 | ||
1056 | /********************************************************************* | |
1057 | * Assignments | |
1058 | *********************************************************************/ | |
1059 | ||
1060 | /* 12.1 page 24 */ | |
1061 | AssignmentList: | |
1062 | Assignment {$$=new Asn::Assignments(); $$->add_ass($1);} | |
1063 | | AssignmentList Assignment {$$=$1; $$->add_ass($2);} | |
1064 | | error Assignment {$$=new Asn::Assignments(); $$->add_ass($2);} | |
1065 | | AssignmentList error {$$=$1;} | |
1066 | ; | |
1067 | ||
1068 | /* 12.1 page 24 */ | |
1069 | Assignment: | |
1070 | TypeAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
1071 | | ValueAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
1072 | | ValueSetTypeAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
1073 | | ObjectClassAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
1074 | /* | |
1075 | | ObjectAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
1076 | | ObjectSetAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
1077 | | ParameterizedAssignment | |
1078 | */ | |
1079 | | UndefAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
1080 | ; | |
1081 | ||
1082 | /* | |
1083 | AbsoluteReference: | |
1084 | '@' GlobalModuleReference '.' ItemSpec | |
1085 | ; | |
1086 | ||
1087 | ItemSpec: | |
1088 | TOK_UpperIdentifier | |
1089 | | ItemId '.' ComponentId | |
1090 | ; | |
1091 | ||
1092 | ItemId: | |
1093 | ItemSpec | |
1094 | ; | |
1095 | ||
1096 | ComponentId: | |
1097 | TOK_LowerIdentifier | |
1098 | | TOK_Number | |
1099 | | '*' | |
1100 | ; | |
1101 | */ | |
1102 | ||
1103 | OptParList: | |
1104 | /* empty */ {$$=0;} | |
1105 | | TOK_Block {$$=new Ass_pard($1);} | |
1106 | ||
1107 | ObjectClassAssignment: | |
1108 | TOK_UpperIdentifier OptParList TOK_Assignment ObjectClassDefn | |
1109 | {$$=new Ass_OC($1, $2, $4);} | |
1110 | ; | |
1111 | ||
1112 | /* | |
1113 | ObjectAssignment: | |
1114 | TOK_LowerIdentifier OptParList DefinedObjectClass_reg TOK_Assignment | |
1115 | TOK_Block | |
1116 | {$$=new Ass_O($1, $2, $3, $5);} | |
1117 | | TOK_LowerIdentifier OptParList DefinedObjectClass_reg TOK_Assignment | |
1118 | RefdLower | |
1119 | {$$=new Ass_O($1, $2, $3, $5);} | |
1120 | ; | |
1121 | */ | |
1122 | ||
1123 | /* | |
1124 | ObjectSetAssignment: | |
1125 | TOK_UpperIdentifier OptParList DefinedObjectClass_reg | |
1126 | TOK_Assignment TOK_Block | |
1127 | {$$=new Ass_OS($1, $2, $3, $5);} | |
1128 | ; | |
1129 | */ | |
1130 | ||
1131 | /* 15.1 page 28 */ | |
1132 | TypeAssignment: | |
1133 | TOK_UpperIdentifier OptParList TOK_Assignment Type_reg | |
1134 | {$$=new Ass_T($1, $2, $4);} | |
1135 | | TOK_UpperIdentifier OptParList TOK_Assignment UpperFromObj | |
1136 | { | |
1137 | Type *t = new Type(Type::T_REFD, $4); | |
1138 | t->set_location(asn1_infile, @4.first_line); | |
1139 | $$ = new Ass_T($1, $2, t); | |
1140 | } | |
1141 | | TOK_UpperIdentifier OptParList TOK_Assignment FromObjs | |
1142 | { | |
1143 | Type *t = new Type(Type::T_REFD, $4); | |
1144 | t->set_location(asn1_infile, @4.first_line); | |
1145 | $$ = new Ass_T($1, $2, t); | |
1146 | } | |
1147 | ; | |
1148 | ||
1149 | /* 15.2 page 28 */ | |
1150 | ValueAssignment: | |
1151 | TOK_LowerIdentifier OptParList Type_reg TOK_Assignment Value_reg | |
1152 | {$$=new Ass_V($1, $2, $3, $5);} | |
1153 | | TOK_LowerIdentifier OptParList Type_reg TOK_Assignment NullValue | |
1154 | {$$=new Ass_V($1, $2, $3, $5);} | |
1155 | | TOK_LowerIdentifier OptParList Type_reg TOK_Assignment TOK_Block | |
1156 | { | |
1157 | Value *v = new Value(Value::V_UNDEF_BLOCK, $5); | |
1158 | v->set_location(asn1_infile, @5.first_line); | |
1159 | $$=new Ass_V($1, $2, $3, v); | |
1160 | } | |
1161 | | TOK_LowerIdentifier OptParList Type_reg TOK_Assignment ReferencedValue_reg | |
1162 | {$$=new Ass_V($1, $2, $3, $5);} | |
1163 | | TOK_LowerIdentifier OptParList Type_reg TOK_Assignment LowerIdValue | |
1164 | {$$=new Ass_V($1, $2, $3, $5);} | |
1165 | | TOK_LowerIdentifier OptParList DefdUpper TOK_Assignment Value_reg | |
1166 | { | |
1167 | Type *t = new Type(Type::T_REFD, $3); | |
1168 | t->set_location(asn1_infile, @3.first_line); | |
1169 | $$ = new Ass_V($1, $2, t, $5); | |
1170 | } | |
1171 | | TOK_LowerIdentifier OptParList DefdUpper TOK_Assignment NullValue | |
1172 | { | |
1173 | Type *t = new Type(Type::T_REFD, $3); | |
1174 | t->set_location(asn1_infile, @3.first_line); | |
1175 | $$ = new Ass_V($1, $2, t, $5); | |
1176 | } | |
1177 | | TOK_LowerIdentifier OptParList UpperFromObj TOK_Assignment Value | |
1178 | { | |
1179 | Type *t = new Type(Type::T_REFD, $3); | |
1180 | t->set_location(asn1_infile, @3.first_line); | |
1181 | $$ = new Ass_V($1, $2, t, $5); | |
1182 | } | |
1183 | | TOK_LowerIdentifier OptParList FromObjs TOK_Assignment Value | |
1184 | { | |
1185 | Type *t = new Type(Type::T_REFD, $3); | |
1186 | t->set_location(asn1_infile, @3.first_line); | |
1187 | $$ = new Ass_V($1, $2, t, $5); | |
1188 | } | |
1189 | ; | |
1190 | ||
1191 | /* 15.6 page 29 */ | |
1192 | ValueSetTypeAssignment: | |
1193 | TOK_UpperIdentifier OptParList Type_reg TOK_Assignment TOK_Block | |
1194 | {$$=new Ass_VS($1, $2, $3, $5);} | |
1195 | ; | |
1196 | ||
1197 | UndefAssignment: | |
1198 | TOK_UpperIdentifier OptParList DefdUpper TOK_Assignment TOK_Block | |
1199 | {$$=new Ass_Undef($1, $2, $3, $5);} | |
1200 | | TOK_UpperIdentifier OptParList TOK_Assignment DefdUpper | |
1201 | {$$=new Ass_Undef($1, $2, 0, $4);} | |
1202 | | TOK_LowerIdentifier OptParList DefdUpper TOK_Assignment TOK_Block | |
1203 | {$$=new Ass_Undef($1, $2, $3, $5);} | |
1204 | | TOK_LowerIdentifier OptParList DefdUpper TOK_Assignment RefdLower | |
1205 | {$$=new Ass_Undef($1, $2, $3, $5);} | |
1206 | ; | |
1207 | ||
1208 | /* 15.7 page 29 */ | |
1209 | //ValueSet: | |
1210 | ///* | |
1211 | // "{" ElementSetSpecs "}" | |
1212 | //*/ | |
1213 | // TOK_Block {delete $1;} | |
1214 | //; | |
1215 | ||
1216 | /********************************************************************* | |
1217 | * Tag stuff | |
1218 | *********************************************************************/ | |
1219 | ||
1220 | /* | |
1221 | TaggedType: | |
1222 | Tag Type | |
1223 | | Tag KW_IMPLICIT Type | |
1224 | | Tag KW_EXPLICIT Type | |
1225 | ; | |
1226 | */ | |
1227 | ||
1228 | Tag: | |
1229 | "[" Class ClassNumber "]" | |
1230 | { | |
1231 | $$=new Tag(Tag::TAG_DEFPLICIT, $2, $3); | |
1232 | $$->set_location(asn1_infile, @1.first_line); | |
1233 | } | |
1234 | | "[" Class ClassNumber "]" KW_IMPLICIT | |
1235 | { | |
1236 | $$=new Tag(Tag::TAG_IMPLICIT, $2, $3); | |
1237 | $$->set_location(asn1_infile, @1.first_line); | |
1238 | } | |
1239 | | "[" Class ClassNumber "]" KW_EXPLICIT | |
1240 | { | |
1241 | $$=new Tag(Tag::TAG_EXPLICIT, $2, $3); | |
1242 | $$->set_location(asn1_infile, @1.first_line); | |
1243 | } | |
1244 | ; | |
1245 | ||
1246 | ClassNumber: | |
1247 | Val_Number | |
1248 | { | |
1249 | $$=$1; | |
1250 | $1->set_location(asn1_infile, @1.first_line); | |
1251 | } | |
1252 | | DefinedValue {$$=$1;} | |
1253 | ; | |
1254 | ||
1255 | /* 30.1 page 48 */ | |
1256 | Class: | |
1257 | KW_UNIVERSAL | |
1258 | { | |
1259 | $$=Tag::TAG_UNIVERSAL; | |
1260 | if(!asn1_yy_parse_internal) | |
1261 | yywarning("Using of UNIVERSAL tagclass is not recommended."); | |
1262 | } | |
1263 | | KW_APPLICATION {$$=Tag::TAG_APPLICATION;} | |
1264 | | KW_PRIVATE {$$=Tag::TAG_PRIVATE;} | |
1265 | | /* empty */ {$$=Tag::TAG_CONTEXT;} | |
1266 | ; | |
1267 | ||
1268 | /********************************************************************* | |
1269 | * Type stuff | |
1270 | *********************************************************************/ | |
1271 | ||
1272 | /* 16.1 page 30 */ | |
1273 | Type_reg: | |
1274 | ConstrainedType | |
1275 | { | |
1276 | $$=$1; | |
1277 | $$->set_location(asn1_infile, @1.first_line); | |
1278 | } | |
1279 | | BuiltinType | |
1280 | { | |
1281 | $$=$1; | |
1282 | $$->set_location(asn1_infile, @1.first_line); | |
1283 | } | |
1284 | | Tag Type | |
1285 | { | |
1286 | $$=$2; | |
1287 | $$->set_location(asn1_infile, @2.first_line); | |
1288 | $$->add_tag($1); | |
1289 | } | |
1290 | ; | |
1291 | ||
1292 | Type: | |
1293 | ConstrainedType | |
1294 | { | |
1295 | $$=$1; | |
1296 | $$->set_location(asn1_infile, @1.first_line); | |
1297 | } | |
1298 | | NakedType | |
1299 | { | |
1300 | $$=$1; | |
1301 | $$->set_location(asn1_infile, @1.first_line); | |
1302 | } | |
1303 | | Tag Type | |
1304 | { | |
1305 | $$=$2; | |
1306 | $$->set_location(asn1_infile, @2.first_line); | |
1307 | $$->add_tag($1); | |
1308 | } | |
1309 | ; | |
1310 | ||
1311 | /* 45.1 page 66 */ | |
1312 | ConstrainedType: | |
1313 | NakedType_reg Constraints {$$=$1; $$->add_constraints($2);} | |
1314 | | SeqOfSetOfWithConstraint {$$=$1;} | |
1315 | ; | |
1316 | ||
1317 | NakedType: | |
1318 | NakedType_reg {$$=$1;} | |
1319 | | SequenceOfType {$$=$1;} | |
1320 | | SetOfType {$$=$1;} | |
1321 | ; | |
1322 | ||
1323 | NakedType_reg: | |
1324 | ReferencedType {$$=$1;} | |
1325 | | BuiltinType_reg {$$=$1;} | |
1326 | ; | |
1327 | ||
1328 | BuiltinType: | |
1329 | BuiltinType_reg {$$=$1;} | |
1330 | | SequenceOfType {$$=$1;} | |
1331 | | SetOfType {$$=$1;} | |
1332 | ; | |
1333 | ||
1334 | BuiltinType_reg: | |
1335 | NullType {$$=$1;} | |
1336 | | BitStringType {$$=$1;} | |
1337 | | BooleanType {$$=$1;} | |
1338 | | CharacterStringType {$$=$1;} | |
1339 | | ChoiceType {$$=$1;} | |
1340 | | SelectionType {$$=$1;} | |
1341 | | EnumeratedType {$$=$1;} | |
1342 | | IntegerType {$$=$1;} | |
1343 | | ObjectIdentifierType {$$=$1;} | |
1344 | | RelativeOIDType {$$=$1;} | |
1345 | | OctetStringType {$$=$1;} | |
1346 | | RealType {$$=$1;} | |
1347 | | SequenceType {$$=$1;} | |
1348 | | SetType {$$=$1;} | |
1349 | | EmbeddedPDVType {$$=$1;} | |
1350 | | ExternalType {$$=$1;} | |
1351 | | AnyType {$$=$1;} | |
1352 | | UsefulType {$$=$1;} | |
1353 | /* | |
1354 | | InstanceOfType | |
1355 | | ObjectClassFieldType | |
1356 | */ | |
1357 | ; | |
1358 | ||
1359 | ||
1360 | /* to eliminate the following reduce/reduce conflict: | |
1361 | Constraint ... -> | |
1362 | SubtypeElements->ContainedSubtype->Type->KW_NULL | |
1363 | SubtypeElements->TypeConstraint->Type->KW_NULL | |
1364 | SubtypeElements->SingleValue->Value->KW_NULL | |
1365 | */ | |
1366 | ||
1367 | /********************************************************************* | |
1368 | * Value stuff | |
1369 | *********************************************************************/ | |
1370 | ||
1371 | BuiltinValue: | |
1372 | BuiltinValue_reg {$$=$1;} | |
1373 | | NullValue {$$=$1;} | |
1374 | | LowerIdValue {$$=$1;} | |
1375 | | TOK_Block | |
1376 | { | |
1377 | $$=new Value(Value::V_UNDEF_BLOCK, $1); | |
1378 | $$->set_location(asn1_infile, @1.first_line); | |
1379 | } | |
1380 | ; | |
1381 | ||
1382 | /* | |
1383 | e.g., the EnumeratedValue is LowerIdValue | |
1384 | */ | |
1385 | LowerIdValue: | |
1386 | TOK_LowerIdentifier | |
1387 | { | |
1388 | $$=new Value(Value::V_UNDEF_LOWERID, $1); | |
1389 | $$->set_location(asn1_infile, @1.first_line); | |
1390 | } | |
1391 | ; | |
1392 | ||
1393 | BuiltinValue_reg: | |
1394 | TOK_BString | |
1395 | { | |
1396 | $$=$1; | |
1397 | $$->set_location(asn1_infile, @1.first_line); | |
1398 | } | |
1399 | | TOK_HString | |
1400 | { | |
1401 | $$=$1; | |
1402 | $$->set_location(asn1_infile, @1.first_line); | |
1403 | } | |
1404 | | Val_CString | |
1405 | { | |
1406 | $$=$1; | |
1407 | $$->set_location(asn1_infile, @1.first_line); | |
1408 | } | |
1409 | | BooleanValue | |
1410 | { | |
1411 | $$=$1; | |
1412 | $$->set_location(asn1_infile, @1.first_line); | |
1413 | } | |
1414 | | ChoiceValue | |
1415 | { | |
1416 | $$=$1; | |
1417 | $$->set_location(asn1_infile, @1.first_line); | |
1418 | } | |
1419 | | SignedNumber {$$=$1;} | |
1420 | | RealValue | |
1421 | { | |
1422 | $$=$1; | |
1423 | $$->set_location(asn1_infile, @1.first_line); | |
1424 | } | |
1425 | /* | |
1426 | | EmbeddedPDVValue | |
1427 | | InstanceOfValue | |
1428 | | ExternalValue | |
1429 | --> SequenceOrSetValue | |
1430 | | EnumeratedValue | |
1431 | --> TOK_LowerIdentifier | |
1432 | */ | |
1433 | ; | |
1434 | ||
1435 | /********************************************************************* | |
1436 | * The individual types and its value notation | |
1437 | *********************************************************************/ | |
1438 | ||
1439 | BooleanType: | |
1440 | KW_BOOLEAN {$$=new Type(Type::T_BOOL);} | |
1441 | ; | |
1442 | ||
1443 | BooleanValue: | |
1444 | KW_TRUE {$$=new Value(Value::V_BOOL, true);} | |
1445 | | KW_FALSE {$$=new Value(Value::V_BOOL, false);} | |
1446 | ; | |
1447 | ||
1448 | IntegerType: | |
1449 | KW_INTEGER | |
1450 | {$$=new Type(Type::T_INT_A);} | |
1451 | | KW_INTEGER TOK_Block {$$=new Type(Type::T_INT_A, $2);} | |
1452 | ; | |
1453 | ||
1454 | /********************************************************************* | |
1455 | * NamedNumberList | |
1456 | *********************************************************************/ | |
1457 | ||
1458 | NamedNumberList: | |
1459 | NamedNumber | |
1460 | { | |
1461 | $$=new NamedValues(); | |
1462 | $$->add_nv($1); | |
1463 | } | |
1464 | | NamedNumberList "," NamedNumber | |
1465 | { | |
1466 | $$=$1; | |
1467 | $$->add_nv($3); | |
1468 | } | |
1469 | | error NamedNumber | |
1470 | { | |
1471 | $$=new NamedValues(); | |
1472 | $$->add_nv($2); | |
1473 | } | |
1474 | | NamedNumberList error | |
1475 | {$$=$1;} | |
1476 | ; | |
1477 | ||
1478 | NamedNumber: | |
1479 | TOK_LowerIdentifier "(" SignedNumber ")" | |
1480 | { | |
1481 | $$=new NamedValue($1, $3); | |
1482 | $$->set_location(asn1_infile, @1.first_line); | |
1483 | } | |
1484 | | TOK_LowerIdentifier "(" DefinedValue ")" | |
1485 | { | |
1486 | $$=new NamedValue($1, $3); | |
1487 | $$->set_location(asn1_infile, @1.first_line); | |
1488 | } | |
1489 | ; | |
1490 | ||
1491 | SignedNumber: | |
1492 | Val_Number | |
1493 | { | |
1494 | $1->set_location(asn1_infile, @1.first_line); | |
1495 | $$=$1; | |
1496 | } | |
1497 | | "-" Val_Number | |
1498 | { | |
1499 | $2->set_location(asn1_infile, @2.first_line); | |
1500 | if(*$2->get_val_Int()==0) | |
1501 | $2->error("-0 is not a valid signed number"); | |
1502 | $$=$2; | |
1503 | $$->change_sign(); | |
1504 | } | |
1505 | ; | |
1506 | ||
1507 | EnumeratedType: | |
1508 | KW_ENUMERATED TOK_Block {$$=new Type(Type::T_ENUM_A, $2);} | |
1509 | ; | |
1510 | ||
1511 | Enumerations: | |
1512 | Enumeration | |
1513 | {$$=new Type(Type::T_ENUM_A, $1, false, 0);} | |
1514 | | Enumeration "," TOK_Ellipsis ExceptionSpec | |
1515 | {$$=new Type(Type::T_ENUM_A, $1, true, 0); delete $4;} | |
1516 | | Enumeration "," TOK_Ellipsis ExceptionSpec "," Enumeration | |
1517 | {$$=new Type(Type::T_ENUM_A, $1, true, $6); delete $4;} | |
1518 | ; | |
1519 | ||
1520 | Enumeration: | |
1521 | EnumerationItem | |
1522 | { | |
1523 | $$=new EnumItems(); | |
1524 | $$->add_ei($1); | |
1525 | } | |
1526 | | Enumeration "," EnumerationItem | |
1527 | { | |
1528 | $$=$1; | |
1529 | $$->add_ei($3); | |
1530 | } | |
1531 | | error EnumerationItem | |
1532 | { | |
1533 | $$=new EnumItems(); | |
1534 | $$->add_ei($2); | |
1535 | } | |
1536 | | Enumeration error | |
1537 | {$$=$1;} | |
1538 | ; | |
1539 | ||
1540 | EnumerationItem: | |
1541 | TOK_LowerIdentifier | |
1542 | { | |
1543 | $$=new EnumItem($1, 0); | |
1544 | $$->set_location(asn1_infile, @1.first_line); | |
1545 | } | |
1546 | | NamedNumber | |
1547 | { | |
1548 | $$=new EnumItem($1->get_name().clone(), $1->get_value()->clone()); | |
1549 | $$->set_location(asn1_infile, @1.first_line); | |
1550 | delete $1; | |
1551 | } | |
1552 | ; | |
1553 | ||
1554 | RealType: | |
1555 | KW_REAL {$$=new Type(Type::T_REAL);} | |
1556 | ; | |
1557 | ||
1558 | RealValue: | |
1559 | SpecialRealValue {$$=$1;} | |
1560 | | NumericRealValue {$$=$1;} | |
1561 | ; | |
1562 | ||
1563 | NumericRealValue: | |
1564 | TOK_RealNumber {$$=$1;} | |
1565 | | "-" TOK_RealNumber | |
1566 | { | |
1567 | $$=$2; | |
1568 | $$->change_sign(); | |
1569 | } | |
1570 | /* | |
1571 | | SequenceValue | |
1572 | */ | |
1573 | ; | |
1574 | ||
1575 | SpecialRealValue: | |
1576 | KW_PLUS_INFINITY | |
1577 | { | |
1578 | Location loc(asn1_infile, @1.first_line); | |
1579 | $$=new Value(Value::V_REAL, string2Real("INF", loc)); | |
1580 | } | |
1581 | | KW_MINUS_INFINITY | |
1582 | { | |
1583 | Location loc(asn1_infile, @1.first_line); | |
1584 | $$=new Value(Value::V_REAL, string2Real("-INF", loc)); | |
1585 | } | |
1586 | | KW_NOT_A_NUMBER | |
1587 | { | |
1588 | Location loc(asn1_infile, @1.first_line); | |
1589 | $$=new Value(Value::V_REAL, string2Real("NaN", loc)); | |
1590 | } | |
1591 | ; | |
1592 | ||
1593 | BitStringType: | |
1594 | KW_BIT KW_STRING {$$=new Type(Type::T_BSTR_A);} | |
1595 | | KW_BIT KW_STRING TOK_Block {$$=new Type(Type::T_BSTR_A, $3);} | |
1596 | ; | |
1597 | ||
1598 | NamedBitList: | |
1599 | NamedBit | |
1600 | { | |
1601 | $$=new NamedValues(); | |
1602 | $$->add_nv($1); | |
1603 | } | |
1604 | | NamedBitList "," NamedBit | |
1605 | { | |
1606 | $$=$1; | |
1607 | $$->add_nv($3); | |
1608 | } | |
1609 | | error NamedBit | |
1610 | { | |
1611 | $$=new NamedValues(); | |
1612 | $$->add_nv($2); | |
1613 | } | |
1614 | | NamedBitList error | |
1615 | {$$=$1;} | |
1616 | ; | |
1617 | ||
1618 | NamedBit: | |
1619 | TOK_LowerIdentifier "(" Val_Number ")" | |
1620 | { | |
1621 | $$=new NamedValue($1, $3); | |
1622 | $3->set_location(asn1_infile, @3.first_line); | |
1623 | $$->set_location(asn1_infile, @1.first_line); | |
1624 | } | |
1625 | | TOK_LowerIdentifier "(" DefinedValue ")" | |
1626 | { | |
1627 | $$=new NamedValue($1, $3); | |
1628 | $$->set_location(asn1_infile, @1.first_line); | |
1629 | } | |
1630 | ; | |
1631 | ||
1632 | /* used in bitstring values */ | |
1633 | IdentifierList: | |
1634 | /* empty */ | |
1635 | { | |
1636 | $$=new Value(Value::V_NAMEDBITS); | |
1637 | $$->set_location(asn1_infile); | |
1638 | } | |
1639 | | IdentifierList1 {$$=$1;} | |
1640 | ; | |
1641 | ||
1642 | IdentifierList1: | |
1643 | TOK_LowerIdentifier | |
1644 | { | |
1645 | $$=new Value(Value::V_NAMEDBITS); | |
1646 | $$->add_id($1); | |
1647 | $$->set_location(asn1_infile, @1.first_line); | |
1648 | } | |
1649 | | IdentifierList1 "," TOK_LowerIdentifier | |
1650 | { | |
1651 | $$=$1; | |
1652 | $$->add_id($3); | |
1653 | $$->set_location(asn1_infile, @1.first_line); | |
1654 | } | |
1655 | | error TOK_LowerIdentifier | |
1656 | { | |
1657 | $$=new Value(Value::V_NAMEDBITS); | |
1658 | $$->add_id($2); | |
1659 | $$->set_location(asn1_infile, @2.first_line); | |
1660 | } | |
1661 | | IdentifierList1 error | |
1662 | {$$=$1;} | |
1663 | ; | |
1664 | ||
1665 | OctetStringType: | |
1666 | KW_OCTET KW_STRING {$$=new Type(Type::T_OSTR);} | |
1667 | ; | |
1668 | ||
1669 | AnyType: | |
1670 | KW_ANY {$$=new Type(Type::T_ANY);} | |
1671 | | KW_ANY KW_DEFINED KW_BY TOK_LowerIdentifier | |
1672 | {delete $4; $$=new Type(Type::T_ANY);} | |
1673 | ; | |
1674 | ||
1675 | NullType: | |
1676 | KW_NULL {$$=new Type(Type::T_NULL);} | |
1677 | ; | |
1678 | ||
1679 | NullValue: | |
1680 | KW_NULL | |
1681 | { | |
1682 | $$=new Value(Value::V_NULL); | |
1683 | $$->set_location(asn1_infile, @1.first_line); | |
1684 | } | |
1685 | ; | |
1686 | ||
1687 | /* | |
1688 | SequenceType: | |
1689 | KW_SEQUENCE '{' '}' | |
1690 | | KW_SEQUENCE '{' ExtensionAndException OptionalExtensionMarker '}' | |
1691 | | KW_SEQUENCE '{' ComponentTypeLists '}' | |
1692 | ; | |
1693 | */ | |
1694 | ||
1695 | SequenceType: | |
1696 | KW_SEQUENCE TOK_Block | |
1697 | {$$=new Type(Type::T_SEQ_A, $2);} | |
1698 | ; | |
1699 | ||
1700 | ExtensionAndException: | |
1701 | TOK_Ellipsis ExceptionSpec | |
1702 | {$$=new ExtAndExc($2);} | |
1703 | /* | |
1704 | | TOK_Ellipsis | |
1705 | --> ExceptionSpec can be empty, so this is surplus | |
1706 | */ | |
1707 | ; | |
1708 | ||
1709 | ComponentTypeLists: | |
1710 | /* empty */ | |
1711 | {$$=new CTs_EE_CTs(0, 0, 0);} | |
1712 | | ComponentTypeList | |
1713 | {$$=new CTs_EE_CTs($1, 0, 0);} | |
1714 | | ComponentTypeList "," ExtensionAndException OptionalExtensionMarker | |
1715 | {$$=new CTs_EE_CTs($1, $3, 0);} | |
1716 | | ComponentTypeList "," ExtensionAndException "," ExtensionAdditionList | |
1717 | OptionalExtensionMarker | |
1718 | { | |
1719 | $3->set_eas($5); | |
1720 | $$=new CTs_EE_CTs($1, $3, 0); | |
1721 | } | |
1722 | | ComponentTypeList "," ExtensionAndException "," ExtensionAdditionList | |
1723 | ExtensionEndMarker "," ComponentTypeList | |
1724 | { | |
1725 | $3->set_eas($5); | |
1726 | $$=new CTs_EE_CTs($1, $3, $8); | |
1727 | } | |
1728 | | ComponentTypeList "," ExtensionAndException ExtensionEndMarker "," | |
1729 | ComponentTypeList | |
1730 | { | |
1731 | $$=new CTs_EE_CTs($1, $3, $6); | |
1732 | } | |
1733 | | ExtensionAndException "," ExtensionAdditionList ExtensionEndMarker "," | |
1734 | ComponentTypeList | |
1735 | { | |
1736 | $1->set_eas($3); | |
1737 | $$=new CTs_EE_CTs(0, $1, $6); | |
1738 | } | |
1739 | | ExtensionAndException "," ExtensionEndMarker "," ComponentTypeList | |
1740 | {$$=new CTs_EE_CTs(0, $1, $5);} | |
1741 | | ExtensionAndException "," ExtensionAdditionList OptionalExtensionMarker | |
1742 | { | |
1743 | $1->set_eas($3); | |
1744 | $$ = new CTs_EE_CTs(0, $1, 0); | |
1745 | } | |
1746 | | ExtensionAndException OptionalExtensionMarker | |
1747 | {$$=new CTs_EE_CTs(0, $1, 0);} | |
1748 | | error | |
1749 | {$$=0;} | |
1750 | ; | |
1751 | ||
1752 | /* | |
1753 | ExtensionAdditions: | |
1754 | ',' ExtensionAdditionList | |
1755 | | * empty * | |
1756 | ; | |
1757 | */ | |
1758 | ||
1759 | ExtensionAdditionList: | |
1760 | ExtensionAddition | |
1761 | { | |
1762 | $$=new ExtAdds(); | |
1763 | $$->add_ea($1); | |
1764 | } | |
1765 | | ExtensionAdditionList "," ExtensionAddition | |
1766 | { | |
1767 | $$=$1; | |
1768 | $$->add_ea($3); | |
1769 | } | |
1770 | | error ExtensionAddition | |
1771 | { | |
1772 | $$=new ExtAdds(); | |
1773 | $$->add_ea($2); | |
1774 | } | |
1775 | | ExtensionAdditionList error | |
1776 | {$$=$1;} | |
1777 | ; | |
1778 | ||
1779 | ExtensionEndMarker: | |
1780 | "," TOK_Ellipsis | |
1781 | ; | |
1782 | ||
1783 | OptionalExtensionMarker: | |
1784 | ExtensionEndMarker | |
1785 | | /* empty */ | |
1786 | ; | |
1787 | ||
1788 | ExtensionAddition: | |
1789 | ComponentType {$$=$1;} | |
1790 | | ExtensionAdditionGroup {$$=$1;} | |
1791 | ; | |
1792 | ||
1793 | ExtensionAdditionGroup: | |
1794 | TOK_LeftVersionBrackets ComponentTypeList TOK_RightVersionBrackets | |
1795 | {$$=new ExtAddGrp(0, $2);} | |
1796 | | TOK_LeftVersionBrackets error TOK_RightVersionBrackets | |
1797 | {$$=new ExtAddGrp(0, new CTs());} | |
1798 | ; | |
1799 | ||
1800 | ComponentTypeList: | |
1801 | ComponentType | |
1802 | { | |
1803 | $$=new CTs(); | |
1804 | $$->add_ct($1); | |
1805 | } | |
1806 | | ComponentTypeList "," ComponentType | |
1807 | { | |
1808 | $$=$1; | |
1809 | $$->add_ct($3); | |
1810 | } | |
1811 | | error ComponentType | |
1812 | { | |
1813 | $$=new CTs(); | |
1814 | $$->add_ct($2); | |
1815 | } | |
1816 | | ComponentTypeList error | |
1817 | {$$=$1;} | |
1818 | ; | |
1819 | ||
1820 | ComponentType: | |
1821 | ComponentType_reg | |
1822 | { | |
1823 | $$=new CT_reg($1); | |
1824 | $$->set_location(asn1_infile, @1.first_line); | |
1825 | } | |
1826 | | KW_COMPONENTS KW_OF Type | |
1827 | { | |
1828 | $$=new CT_CompsOf($3); | |
1829 | $$->set_location(asn1_infile, @1.first_line); | |
1830 | } | |
1831 | ; | |
1832 | ||
1833 | ComponentType_reg: | |
1834 | NamedType | |
1835 | { | |
1836 | $$=new CompField($1.name, $1.type, false, 0); | |
1837 | $$->set_location(asn1_infile, @1.first_line); | |
1838 | } | |
1839 | | NamedType KW_OPTIONAL | |
1840 | { | |
1841 | $$=new CompField($1.name, $1.type, true, 0); | |
1842 | $$->set_location(asn1_infile, @1.first_line); | |
1843 | } | |
1844 | | NamedType KW_DEFAULT Value | |
1845 | { | |
1846 | if (default_as_optional) { /* optional should not have a default value */ | |
1847 | delete $3; | |
1848 | } | |
1849 | $$=new CompField($1.name, $1.type, default_as_optional, | |
1850 | default_as_optional ? NULL : $3); | |
1851 | $$->set_location(asn1_infile, @1.first_line); | |
1852 | } | |
1853 | ; | |
1854 | ||
1855 | SequenceValue: | |
1856 | ComponentValueList | |
1857 | { | |
1858 | $$=new Value(Value::V_SEQ, $1); | |
1859 | $$->set_location(asn1_infile, @1.first_line); | |
1860 | } | |
1861 | | /* empty */ | |
1862 | { | |
1863 | $$=new Value(Value::V_SEQ, new NamedValues()); | |
1864 | $$->set_location(asn1_infile, @0.first_line); | |
1865 | } | |
1866 | ; | |
1867 | ||
1868 | SetValue: | |
1869 | ComponentValueList | |
1870 | { | |
1871 | $$=new Value(Value::V_SET, $1); | |
1872 | $$->set_location(asn1_infile, @1.first_line); | |
1873 | } | |
1874 | | /* empty */ | |
1875 | { | |
1876 | $$=new Value(Value::V_SET, new NamedValues()); | |
1877 | $$->set_location(asn1_infile, @0.first_line); | |
1878 | } | |
1879 | ; | |
1880 | ||
1881 | ComponentValueList: | |
1882 | NamedValue | |
1883 | { | |
1884 | $$=new NamedValues(); | |
1885 | $$->add_nv($1); | |
1886 | } | |
1887 | | ComponentValueList "," NamedValue | |
1888 | { | |
1889 | $$=$1; | |
1890 | $$->add_nv($3); | |
1891 | } | |
1892 | | error NamedValue | |
1893 | { | |
1894 | $$=new NamedValues(); | |
1895 | $$->add_nv($2); | |
1896 | } | |
1897 | | ComponentValueList error | |
1898 | {$$=$1;} | |
1899 | ; | |
1900 | ||
1901 | SequenceOfType: | |
1902 | KW_SEQUENCE KW_OF Type {$$=new Type(Type::T_SEQOF, $3);} | |
1903 | | KW_SEQUENCE KW_OF NamedType {delete $3.name; $$=new Type(Type::T_SEQOF, $3.type);} | |
1904 | ; | |
1905 | ||
1906 | SetOfType: | |
1907 | KW_SET KW_OF Type {$$=new Type(Type::T_SETOF, $3);} | |
1908 | | KW_SET KW_OF NamedType {delete $3.name; $$=new Type(Type::T_SETOF, $3.type);} | |
1909 | ; | |
1910 | ||
1911 | SeqOfValue: | |
1912 | ValueList0 | |
1913 | { | |
1914 | $$=new Value(Value::V_SEQOF, $1); | |
1915 | $$->set_location(asn1_infile, @1.first_line); | |
1916 | } | |
1917 | ; | |
1918 | ||
1919 | SetOfValue: | |
1920 | ValueList0 | |
1921 | { | |
1922 | $$=new Value(Value::V_SETOF, $1); | |
1923 | $$->set_location(asn1_infile, @1.first_line); | |
1924 | } | |
1925 | ; | |
1926 | ||
1927 | ValueList0: | |
1928 | /* empty */ {$$ = new Values();} | |
1929 | | ValueList {$$ = $1;} | |
1930 | ; | |
1931 | ||
1932 | ValueList: | |
1933 | Value {$$=new Values(); $$->add_v($1);} | |
1934 | | ValueList "," Value {$$=$1; $$->add_v($3);} | |
1935 | | error Value {$$=new Values(); $$->add_v($2);} | |
1936 | | ValueList error {$$=$1;} | |
1937 | ; | |
1938 | ||
1939 | /* | |
1940 | SetType: | |
1941 | KW_SET '{' '}' | |
1942 | | KW_SET '{' ExtensionAndException OptionalExtensionMarker '}' | |
1943 | | KW_SET '{' ComponentTypeLists '}' | |
1944 | ; | |
1945 | */ | |
1946 | ||
1947 | SetType: | |
1948 | KW_SET TOK_Block | |
1949 | {$$=new Type(Type::T_SET_A, $2);} | |
1950 | ; | |
1951 | ||
1952 | ChoiceType: | |
1953 | KW_CHOICE TOK_Block {$$=new Type(Type::T_CHOICE_A, $2);} | |
1954 | ; | |
1955 | ||
1956 | AlternativeTypeLists: | |
1957 | AlternativeTypeList | |
1958 | {$$=new CTs_EE_CTs($1, 0, 0);} | |
1959 | | AlternativeTypeList "," ExtensionAndException OptionalExtensionMarker | |
1960 | {$$=new CTs_EE_CTs($1, $3, 0);} | |
1961 | | AlternativeTypeList "," ExtensionAndException "," | |
1962 | ExtensionAdditionAlternativesList OptionalExtensionMarker | |
1963 | { | |
1964 | $3->set_eas($5); | |
1965 | $$=new CTs_EE_CTs($1, $3, 0); | |
1966 | } | |
1967 | | error | |
1968 | {$$=0;} | |
1969 | ; | |
1970 | ||
1971 | ExtensionAdditionAlternativesList: | |
1972 | ExtensionAdditionAlternative | |
1973 | { | |
1974 | $$=new ExtAdds(); | |
1975 | $$->add_ea($1); | |
1976 | } | |
1977 | | ExtensionAdditionAlternativesList "," ExtensionAdditionAlternative | |
1978 | { | |
1979 | $$=$1; | |
1980 | $$->add_ea($3); | |
1981 | } | |
1982 | | error ExtensionAdditionAlternative | |
1983 | { | |
1984 | $$=new ExtAdds(); | |
1985 | $$->add_ea($2); | |
1986 | } | |
1987 | | ExtensionAdditionAlternativesList error | |
1988 | {$$=$1;} | |
1989 | ; | |
1990 | ||
1991 | ExtensionAdditionAlternative: | |
1992 | TOK_LeftVersionBrackets AlternativeTypeList TOK_RightVersionBrackets | |
1993 | {$$=new ExtAddGrp(0, $2);} | |
1994 | | NamedType | |
1995 | { | |
1996 | CompField *cf = new CompField($1.name, $1.type, false, 0); | |
1997 | cf->set_location(asn1_infile, @1.first_line); | |
1998 | $$=new CT_reg(cf); | |
1999 | } | |
2000 | | TOK_LeftVersionBrackets error TOK_RightVersionBrackets | |
2001 | {$$=new ExtAddGrp(0, new CTs());} | |
2002 | ; | |
2003 | ||
2004 | AlternativeTypeList: | |
2005 | NamedType | |
2006 | { | |
2007 | $$=new CTs(); | |
2008 | CompField *cf = new CompField($1.name, $1.type, false, 0); | |
2009 | cf->set_location(asn1_infile, @1.first_line); | |
2010 | $$->add_ct(new CT_reg(cf)); | |
2011 | } | |
2012 | | AlternativeTypeList "," NamedType | |
2013 | { | |
2014 | $$=$1; | |
2015 | CompField *cf = new CompField($3.name, $3.type, false, 0); | |
2016 | cf->set_location(asn1_infile, @3.first_line); | |
2017 | $$->add_ct(new CT_reg(cf)); | |
2018 | } | |
2019 | | error NamedType | |
2020 | { | |
2021 | $$=new CTs(); | |
2022 | CompField *cf = new CompField($2.name, $2.type, false, 0); | |
2023 | cf->set_location(asn1_infile, @2.first_line); | |
2024 | $$->add_ct(new CT_reg(cf)); | |
2025 | } | |
2026 | | AlternativeTypeList error | |
2027 | {$$=$1;} | |
2028 | ; | |
2029 | ||
2030 | ChoiceValue: | |
2031 | TOK_LowerIdentifier ":" Value | |
2032 | {$$=new Value(Value::V_CHOICE, $1, $3);} | |
2033 | ; | |
2034 | ||
2035 | /* | |
2036 | SelectionType: | |
2037 | TOK_LowerIdentifier "<" Type | |
2038 | ; | |
2039 | */ | |
2040 | ||
2041 | SelectionTypeType: | |
2042 | ReferencedType {$$=$1;} | |
2043 | | ChoiceType {$$=$1;} | |
2044 | | SelectionType {$$=$1;} | |
2045 | | Tag SelectionTypeType | |
2046 | { | |
2047 | $$=$2; | |
2048 | $$->set_location(asn1_infile, @2.first_line); | |
2049 | $$->add_tag($1); | |
2050 | } | |
2051 | ; | |
2052 | ||
2053 | SelectionType: | |
2054 | TOK_LowerIdentifier "<" SelectionTypeType | |
2055 | { | |
2056 | $$=new Type(Type::T_SELTYPE, $1, $3); | |
2057 | $$->set_location(asn1_infile, @1.first_line); | |
2058 | } | |
2059 | ; | |
2060 | ||
2061 | ObjectIdentifierType: | |
2062 | KW_OBJECT KW_IDENTIFIER {$$=new Type(Type::T_OID);} | |
2063 | ; | |
2064 | ||
2065 | RelativeOIDType: | |
2066 | KW_RELATIVE_OID {$$=new Type(Type::T_ROID);} | |
2067 | ; | |
2068 | ||
2069 | ObjectIdentifierValue: | |
2070 | ObjIdComponentList {$$=$1;} | |
2071 | /* | |
2072 | | '{' DefinedValue ObjIdComponentList '}' | |
2073 | --> it must be checked if the ObjIdComponentList's first component | |
2074 | is a DefinedValue to a type OBJECT IDENTIFIER | |
2075 | */ | |
2076 | ; | |
2077 | ||
2078 | RelativeOIDValue: | |
2079 | RelativeOIDComponentList {$$=$1;} | |
2080 | ; | |
2081 | ||
2082 | ObjIdComponentList: | |
2083 | ObjIdComponent | |
2084 | { | |
2085 | $$=new Value(Value::V_OID); | |
2086 | $$->set_location(asn1_infile, @1.first_line); | |
2087 | $$->add_oid_comp($1); | |
2088 | } | |
2089 | | ObjIdComponentList ObjIdComponent | |
2090 | { | |
2091 | $$=$1; | |
2092 | $$->add_oid_comp($2); | |
2093 | } | |
2094 | | ObjIdComponentList error | |
2095 | {$$=$1;} | |
2096 | ; | |
2097 | ||
2098 | RelativeOIDComponentList: | |
2099 | RelativeOIDComponent | |
2100 | { | |
2101 | $$=new Value(Value::V_ROID); | |
2102 | $$->set_location(asn1_infile, @1.first_line); | |
2103 | $$->add_oid_comp($1); | |
2104 | } | |
2105 | | RelativeOIDComponentList RelativeOIDComponent | |
2106 | { | |
2107 | $$=$1; | |
2108 | $$->add_oid_comp($2); | |
2109 | } | |
2110 | | RelativeOIDComponentList error | |
2111 | {$$=$1;} | |
2112 | ; | |
2113 | ||
2114 | /* | |
2115 | ObjIdComponent: | |
2116 | NameForm | |
2117 | | NumberForm | |
2118 | | NameAndNumberForm | |
2119 | ; | |
2120 | */ | |
2121 | ||
2122 | ObjIdComponent: | |
2123 | ObjIdComponentNumber {$$=$1;} | |
2124 | | TOK_LowerIdentifier /* NameForm or reference */ | |
2125 | { | |
2126 | $$=new OID_comp($1, 0); | |
2127 | $$->set_location(asn1_infile, @1.first_line); | |
2128 | } | |
2129 | | DefinedValue_reg | |
2130 | { | |
2131 | $$=new OID_comp($1); | |
2132 | $$->set_location(asn1_infile, @1.first_line); | |
2133 | } | |
2134 | ; | |
2135 | ||
2136 | RelativeOIDComponent: | |
2137 | ObjIdComponentNumber {$$=$1;} | |
2138 | | DefinedValue | |
2139 | { | |
2140 | $$=new OID_comp($1); | |
2141 | $$->set_location(asn1_infile, @1.first_line); | |
2142 | } | |
2143 | ; | |
2144 | ||
2145 | ObjIdComponentNumber: | |
2146 | NameAndNumberForm {$$=$1;} | |
2147 | | Val_Number | |
2148 | { | |
2149 | $1->set_location(asn1_infile, @1.first_line); | |
2150 | $$=new OID_comp(0, $1); | |
2151 | $$->set_location(asn1_infile, @1.first_line); | |
2152 | } | |
2153 | ; | |
2154 | ||
2155 | NameAndNumberForm: | |
2156 | DefinitiveNameAndNumberForm {$$=$1;} | |
2157 | | TOK_LowerIdentifier "(" DefinedValue ")" | |
2158 | { | |
2159 | $$=new OID_comp($1, $3); | |
2160 | $$->set_location(asn1_infile, @1.first_line); | |
2161 | } | |
2162 | ; | |
2163 | ||
2164 | DefinitiveNameAndNumberForm: | |
2165 | TOK_LowerIdentifier "(" Val_Number ")" | |
2166 | { | |
2167 | $3->set_location(asn1_infile, @3.first_line); | |
2168 | $$=new OID_comp($1, $3); | |
2169 | $$->set_location(asn1_infile, @1.first_line); | |
2170 | } | |
2171 | ; | |
2172 | ||
2173 | EmbeddedPDVType: | |
2174 | KW_EMBEDDED KW_PDV {$$=new Type(Type::T_EMBEDDED_PDV);} | |
2175 | ; | |
2176 | ||
2177 | /* | |
2178 | EmbeddedPDVValue: | |
2179 | SequenceValue | |
2180 | ; | |
2181 | */ | |
2182 | ||
2183 | ExternalType: | |
2184 | KW_EXTERNAL {$$=new Type(Type::T_EXTERNAL);} | |
2185 | ; | |
2186 | ||
2187 | /* | |
2188 | ExternalValue: | |
2189 | SequenceValue | |
2190 | ; | |
2191 | */ | |
2192 | ||
2193 | /********************************************************************* | |
2194 | * Character string stuff | |
2195 | *********************************************************************/ | |
2196 | ||
2197 | /* 36.1 page 55 */ | |
2198 | CharacterStringType: | |
2199 | RestrictedCharacterStringType {$$=$1;} | |
2200 | | UnrestrictedCharacterStringType {$$=$1;} | |
2201 | ; | |
2202 | ||
2203 | /* | |
2204 | CharacterStringValue: | |
2205 | RestrictedCharacterStringValue | |
2206 | | UnrestrictedCharacterStringValue | |
2207 | --> SequenceValue | |
2208 | ; | |
2209 | */ | |
2210 | ||
2211 | /* 37 page 55 */ | |
2212 | RestrictedCharacterStringType: | |
2213 | GeneralString {$$=$1;} | |
2214 | | BMPString {$$=$1;} | |
2215 | | GraphicString {$$=$1;} | |
2216 | | IA5String {$$=$1;} | |
2217 | | NumericString {$$=$1;} | |
2218 | | PrintableString {$$=$1;} | |
2219 | | TeletexString {$$=$1;} | |
2220 | | UniversalString {$$=$1;} | |
2221 | | UTF8String {$$=$1;} | |
2222 | | VideotexString {$$=$1;} | |
2223 | | VisibleString {$$=$1;} | |
2224 | ; | |
2225 | ||
2226 | GeneralString: | |
2227 | KW_GeneralString | |
2228 | {$$=new Type(Type::T_GENERALSTRING);} | |
2229 | ; | |
2230 | ||
2231 | BMPString: | |
2232 | KW_BMPString | |
2233 | {$$=new Type(Type::T_BMPSTRING);} | |
2234 | ; | |
2235 | ||
2236 | GraphicString: | |
2237 | KW_GraphicString | |
2238 | {$$=new Type(Type::T_GRAPHICSTRING);} | |
2239 | ; | |
2240 | ||
2241 | IA5String: | |
2242 | KW_IA5String | |
2243 | {$$=new Type(Type::T_IA5STRING);} | |
2244 | ; | |
2245 | ||
2246 | NumericString: | |
2247 | KW_NumericString | |
2248 | {$$=new Type(Type::T_NUMERICSTRING);} | |
2249 | ; | |
2250 | ||
2251 | PrintableString: | |
2252 | KW_PrintableString | |
2253 | {$$=new Type(Type::T_PRINTABLESTRING);} | |
2254 | ; | |
2255 | ||
2256 | TeletexString: | |
2257 | KW_TeletexString | |
2258 | {$$=new Type(Type::T_TELETEXSTRING);} | |
2259 | | KW_T61String | |
2260 | {$$=new Type(Type::T_TELETEXSTRING);} | |
2261 | ; | |
2262 | ||
2263 | UniversalString: | |
2264 | KW_UniversalString | |
2265 | {$$=new Type(Type::T_UNIVERSALSTRING);} | |
2266 | ; | |
2267 | ||
2268 | UTF8String: | |
2269 | KW_UTF8String | |
2270 | {$$=new Type(Type::T_UTF8STRING);} | |
2271 | ; | |
2272 | ||
2273 | VideotexString: | |
2274 | KW_VideotexString | |
2275 | {$$=new Type(Type::T_VIDEOTEXSTRING);} | |
2276 | ; | |
2277 | ||
2278 | VisibleString: | |
2279 | KW_VisibleString | |
2280 | {$$=new Type(Type::T_VISIBLESTRING);} | |
2281 | | KW_ISO646String | |
2282 | {$$=new Type(Type::T_VISIBLESTRING);} | |
2283 | ; | |
2284 | ||
2285 | /* | |
2286 | RestrictedCharacterStringValue: | |
2287 | TOK_CString {$$=$1;} | |
2288 | | CharacterStringList | |
2289 | | Quadruple | |
2290 | | Tuple | |
2291 | ; | |
2292 | ||
2293 | CharacterStringList: | |
2294 | '{' CharSyms '}' | |
2295 | ; | |
2296 | */ | |
2297 | ||
2298 | CharStringValue: | |
2299 | CharSyms {$$=$1;} | |
2300 | | QuadrupleOrTuple | |
2301 | { | |
2302 | $$=new CharSyms(); | |
2303 | $$->add_cd($1); | |
2304 | } | |
2305 | ; | |
2306 | ||
2307 | CharSyms: | |
2308 | CharsDefn | |
2309 | { | |
2310 | $$=new CharSyms(); | |
2311 | $$->add_cd($1); | |
2312 | $$->set_location(asn1_infile, @1.first_line); | |
2313 | } | |
2314 | | CharSyms "," CharsDefn | |
2315 | { | |
2316 | $$=$1; | |
2317 | $$->add_cd($3); | |
2318 | } | |
2319 | | error CharsDefn | |
2320 | { | |
2321 | $$=new CharSyms(); | |
2322 | $$->add_cd($2); | |
2323 | $$->set_location(asn1_infile, @1.first_line); | |
2324 | } | |
2325 | | CharSyms error | |
2326 | { | |
2327 | $$=$1; | |
2328 | } | |
2329 | ; | |
2330 | ||
2331 | /* | |
2332 | CharsDefn: | |
2333 | TOK_CString | |
2334 | | Quadruple | |
2335 | | Tuple | |
2336 | | DefinedValue | |
2337 | ; | |
2338 | */ | |
2339 | ||
2340 | CharsDefn: | |
2341 | TOK_CString | |
2342 | { | |
2343 | $$=new CharsDefn($1); | |
2344 | $$->set_location(asn1_infile, @1.first_line); | |
2345 | } | |
2346 | | TOK_Block | |
2347 | { | |
2348 | $$=new CharsDefn($1); | |
2349 | $$->set_location(asn1_infile, @1.first_line); | |
2350 | } | |
2351 | | ReferencedValue | |
2352 | { | |
2353 | $$=new CharsDefn($1); | |
2354 | $$->set_location(asn1_infile, @1.first_line); | |
2355 | } | |
2356 | ; | |
2357 | ||
2358 | QuadrupleOrTuple: | |
2359 | QuadrupleOrTuple0 {$$=$1;} | |
2360 | | QuadrupleOrTuple0 error {$$=$1;} | |
2361 | | error | |
2362 | { | |
2363 | $$=new CharsDefn(0, 0, 0, 0); | |
2364 | $$->set_location(asn1_infile, @1.first_line); | |
2365 | } | |
2366 | ; | |
2367 | ||
2368 | QuadrupleOrTuple0: | |
2369 | TOK_Number "," TOK_Number "," TOK_Number "," TOK_Number | |
2370 | { | |
2371 | Int group = 0, plane = 0, row = 0, cell = 0; | |
2372 | if (*$1 > INT_MAX) { | |
2373 | Location loc(asn1_infile, @1); | |
2374 | loc.error("The first number of quadruple (group) should be less than " | |
2375 | "%d instead of %s", INT_MAX, ($1->t_str()).c_str()); | |
2376 | } else { | |
2377 | group = $1->get_val(); | |
2378 | } | |
2379 | if (*$3 > INT_MAX) { | |
2380 | Location loc(asn1_infile, @3); | |
2381 | loc.error("The second number of quadruple (plane) should be less than " | |
2382 | "%d instead of %s", INT_MAX, ($3->t_str()).c_str()); | |
2383 | } else { | |
2384 | plane = $3->get_val(); | |
2385 | } | |
2386 | if (*$5 > INT_MAX) { | |
2387 | Location loc(asn1_infile, @5); | |
2388 | loc.error("The third number of quadruple (row) should be less than %d " | |
2389 | "instead of %s", INT_MAX, ($5->t_str()).c_str()); | |
2390 | } else { | |
2391 | row = $5->get_val(); | |
2392 | } | |
2393 | if (*$7 > INT_MAX) { | |
2394 | Location loc(asn1_infile, @7); | |
2395 | loc.error("The fourth number of quadruple (cell) should be less than " | |
2396 | "%d instead of %s", INT_MAX, ($7->t_str()).c_str()); | |
2397 | } else { | |
2398 | cell = $7->get_val(); | |
2399 | } | |
2400 | $$=new CharsDefn(group, plane, row, cell); | |
2401 | $$->set_location(asn1_infile, @1.first_line); | |
2402 | delete $1; | |
2403 | delete $3; | |
2404 | delete $5; | |
2405 | delete $7; | |
2406 | } | |
2407 | | TOK_Number "," TOK_Number | |
2408 | { | |
2409 | Int table_column = 0, table_row = 0; | |
2410 | if (*$1 > INT_MAX) { | |
2411 | Location loc(asn1_infile, @1); | |
2412 | loc.error("The first number of tuple (table column) should be less " | |
2413 | "than %d instead of %s", INT_MAX, ($1->t_str()).c_str()); | |
2414 | } else { | |
2415 | table_column = $1->get_val(); | |
2416 | } | |
2417 | if (*$3 > INT_MAX) { | |
2418 | Location loc(asn1_infile, @3); | |
2419 | loc.error("The second number of tuple (table row) should be less than " | |
2420 | "%d instead of %s", INT_MAX, ($3->t_str()).c_str()); | |
2421 | } else { | |
2422 | table_row = $3->get_val(); | |
2423 | } | |
2424 | $$=new CharsDefn(table_column, table_row); | |
2425 | $$->set_location(asn1_infile, @1.first_line); | |
2426 | delete $1; | |
2427 | delete $3; | |
2428 | } | |
2429 | ; | |
2430 | ||
2431 | /* | |
2432 | Quadruple: | |
2433 | '{' Group ',' Plane ',' Row ',' Cell '}' | |
2434 | ; | |
2435 | ||
2436 | Group: | |
2437 | TOK_Number | |
2438 | ; | |
2439 | ||
2440 | Plane: | |
2441 | TOK_Number | |
2442 | ; | |
2443 | ||
2444 | Row: | |
2445 | TOK_Number | |
2446 | ; | |
2447 | ||
2448 | Cell: | |
2449 | TOK_Number | |
2450 | ; | |
2451 | ||
2452 | Tuple: | |
2453 | '{' TableColumn ',' TableRow '}' | |
2454 | ; | |
2455 | ||
2456 | TableColumn: | |
2457 | TOK_Number | |
2458 | ; | |
2459 | ||
2460 | TableRow: | |
2461 | TOK_Number | |
2462 | ; | |
2463 | */ | |
2464 | ||
2465 | UnrestrictedCharacterStringType: | |
2466 | KW_CHARACTER KW_STRING {$$=new Type(Type::T_UNRESTRICTEDSTRING);} | |
2467 | ; | |
2468 | ||
2469 | /* | |
2470 | UnrestrictedCharacterStringValue: | |
2471 | SequenceValue | |
2472 | ; | |
2473 | */ | |
2474 | ||
2475 | UsefulType: | |
2476 | KW_GeneralizedTime | |
2477 | {$$=new Type(Type::T_GENERALIZEDTIME);} | |
2478 | | KW_UTCTime | |
2479 | {$$=new Type(Type::T_UTCTIME);} | |
2480 | | KW_ObjectDescriptor | |
2481 | {$$=new Type(Type::T_OBJECTDESCRIPTOR);} | |
2482 | ; | |
2483 | ||
2484 | /********************************************************************* | |
2485 | * Constraint stuff | |
2486 | *********************************************************************/ | |
2487 | ||
2488 | /* | |
2489 | ConstrainedType: | |
2490 | Type Constraint | |
2491 | | TypeWithConstraint | |
2492 | ; | |
2493 | */ | |
2494 | ||
2495 | SeqOfSetOfWithConstraint: | |
2496 | KW_SET Constraint KW_OF Type | |
2497 | { | |
2498 | $$=new Type(Type::T_SETOF, $4); | |
2499 | Constraints *cons = new Constraints(); | |
2500 | if ($2) cons->add_con($2); | |
2501 | $$->add_constraints(cons); | |
2502 | } | |
2503 | | KW_SET Constraint KW_OF NamedType | |
2504 | { | |
2505 | delete $4.name; | |
2506 | $$=new Type(Type::T_SETOF, $4.type); | |
2507 | Constraints *cons = new Constraints(); | |
2508 | if ($2) cons->add_con($2); | |
2509 | $$->add_constraints(cons); | |
2510 | } | |
2511 | | KW_SET SizeConstraint KW_OF Type | |
2512 | { | |
2513 | $$=new Type(Type::T_SETOF, $4); | |
2514 | Constraints *cons = new Constraints(); | |
2515 | if ($2) cons->add_con($2); | |
2516 | $$->add_constraints(cons); | |
2517 | } | |
2518 | | KW_SET SizeConstraint KW_OF NamedType | |
2519 | { | |
2520 | delete $4.name; | |
2521 | $$=new Type(Type::T_SETOF, $4.type); | |
2522 | Constraints *cons = new Constraints(); | |
2523 | if ($2) cons->add_con($2); | |
2524 | $$->add_constraints(cons); | |
2525 | } | |
2526 | | KW_SEQUENCE Constraint KW_OF Type | |
2527 | { | |
2528 | $$=new Type(Type::T_SEQOF, $4); | |
2529 | Constraints *cons = new Constraints(); | |
2530 | if ($2) cons->add_con($2); | |
2531 | $$->add_constraints(cons); | |
2532 | } | |
2533 | | KW_SEQUENCE Constraint KW_OF NamedType | |
2534 | { | |
2535 | delete $4.name; | |
2536 | $$=new Type(Type::T_SEQOF, $4.type); | |
2537 | Constraints *cons = new Constraints(); | |
2538 | if ($2) cons->add_con($2); | |
2539 | $$->add_constraints(cons); | |
2540 | } | |
2541 | | KW_SEQUENCE SizeConstraint KW_OF Type | |
2542 | { | |
2543 | $$=new Type(Type::T_SEQOF, $4); | |
2544 | Constraints *cons = new Constraints(); | |
2545 | if ($2) cons->add_con($2); | |
2546 | $$->add_constraints(cons); | |
2547 | } | |
2548 | | KW_SEQUENCE SizeConstraint KW_OF NamedType | |
2549 | { | |
2550 | delete $4.name; | |
2551 | $$=new Type(Type::T_SEQOF, $4.type); | |
2552 | Constraints *cons = new Constraints(); | |
2553 | if ($2) cons->add_con($2); | |
2554 | $$->add_constraints(cons); | |
2555 | } | |
2556 | ; | |
2557 | ||
2558 | Constraints: | |
2559 | Constraint | |
2560 | { | |
2561 | $$ = new Constraints(); | |
2562 | if ($1) $$->add_con($1); | |
2563 | } | |
2564 | | Constraints Constraint | |
2565 | { | |
2566 | $$ = $1; | |
2567 | if ($2) $$->add_con($2); | |
2568 | } | |
2569 | ; | |
2570 | ||
2571 | Constraint: | |
2572 | "(" ConstraintSpec ExceptionSpec ")" | |
2573 | { | |
2574 | $$ = $2; | |
2575 | delete $3; | |
2576 | } | |
2577 | | "(" error ")" | |
2578 | { | |
2579 | $$ = new IgnoredConstraint("invalid constraint"); | |
2580 | } | |
2581 | ; | |
2582 | ||
2583 | /* 45.6 page 67 */ | |
2584 | ConstraintSpec: | |
2585 | SubtypeConstraint { $$ = $1; } | |
2586 | | GeneralConstraint { $$ = $1; } | |
2587 | ; | |
2588 | ||
2589 | /* 45.7 page 67 */ | |
2590 | SubtypeConstraint: | |
2591 | ElementSetSpecs { $$ = $1; } | |
2592 | ; | |
2593 | ||
2594 | /* 49.4 page 76 */ | |
2595 | ExceptionSpec: | |
2596 | "!" ExceptionIdentification {$$=$2;} | |
2597 | | /* empty */ {$$=0;} | |
2598 | | "!" error {$$=0;} | |
2599 | ; | |
2600 | ||
2601 | /* 49.4 page 76 */ | |
2602 | ExceptionIdentification: | |
2603 | SignedNumber {$$=new ExcSpec(0, $1);} | |
2604 | | DefinedValue {$$=new ExcSpec(0, $1);} | |
2605 | | Type ":" Value {$$=new ExcSpec($1, $3);} | |
2606 | ; | |
2607 | ||
2608 | /* 46.1 page 67 */ | |
2609 | ElementSetSpecs: | |
2610 | RootElementSetSpec | |
2611 | { | |
2612 | $$ = $1; | |
2613 | } | |
2614 | | RootElementSetSpec "," TOK_Ellipsis | |
2615 | { | |
2616 | $$ = new ElementSetSpecsConstraint($1, NULL); | |
2617 | $$->set_location(asn1_infile, @1.first_line); | |
2618 | } | |
2619 | | RootElementSetSpec "," TOK_Ellipsis "," AdditionalElementSetSpec | |
2620 | { | |
2621 | $$ = new ElementSetSpecsConstraint($1, $5); | |
2622 | $$->set_location(asn1_infile, @1.first_line); | |
2623 | } | |
2624 | ; | |
2625 | ||
2626 | /* 46.1 page 67 */ | |
2627 | RootElementSetSpec: | |
2628 | ElementSetSpec | |
2629 | { | |
2630 | $$ = $1; | |
2631 | } | |
2632 | ; | |
2633 | ||
2634 | /* 46.1 page 67 */ | |
2635 | AdditionalElementSetSpec: | |
2636 | ElementSetSpec | |
2637 | { | |
2638 | $$ = $1; | |
2639 | } | |
2640 | ; | |
2641 | ||
2642 | /* 46.1 page 67 */ | |
2643 | ElementSetSpec: | |
2644 | Unions { $$ = $1; } | |
2645 | | KW_ALL Exclusions | |
2646 | { | |
2647 | $2->set_first_operand(new FullSetConstraint()); | |
2648 | $$ = $2; | |
2649 | $$->set_location(asn1_infile, @1.first_line); | |
2650 | } | |
2651 | ; | |
2652 | ||
2653 | /* 46.1 page 67 */ | |
2654 | Unions: | |
2655 | Intersections { $$ = $1; } | |
2656 | | UElems UnionMark Intersections | |
2657 | { | |
2658 | $$ = new SetOperationConstraint($1, SetOperationConstraint::UNION, $3); | |
2659 | $$->set_location(asn1_infile, @1.first_line); | |
2660 | } | |
2661 | ; | |
2662 | ||
2663 | /* 46.1 page 67 */ | |
2664 | UElems: | |
2665 | Unions | |
2666 | { | |
2667 | $$ = $1; | |
2668 | } | |
2669 | ; | |
2670 | ||
2671 | /* 46.1 page 67 */ | |
2672 | Intersections: | |
2673 | IntersectionElements { $$ = $1; } | |
2674 | | IElems IntersectionMark IntersectionElements | |
2675 | { | |
2676 | $$ = new SetOperationConstraint($1, SetOperationConstraint::INTERSECTION, $3); | |
2677 | $$->set_location(asn1_infile, @1.first_line); | |
2678 | } | |
2679 | ; | |
2680 | ||
2681 | /* 46.1 page 67 */ | |
2682 | IElems: | |
2683 | Intersections | |
2684 | { | |
2685 | $$ = $1; | |
2686 | } | |
2687 | ; | |
2688 | ||
2689 | /* 46.1 page 67 */ | |
2690 | IntersectionElements: | |
2691 | Elements { $$ = $1; } | |
2692 | | Elems Exclusions | |
2693 | { | |
2694 | $2->set_first_operand($1); | |
2695 | $$ = $2; | |
2696 | $$->set_location(asn1_infile, @1.first_line); | |
2697 | } | |
2698 | ; | |
2699 | ||
2700 | /* 46.1 page 67 */ | |
2701 | Elems: | |
2702 | Elements | |
2703 | { | |
2704 | $$ = $1; | |
2705 | } | |
2706 | ; | |
2707 | ||
2708 | /* 46.1 page 67 */ | |
2709 | Exclusions: | |
2710 | KW_EXCEPT Elements | |
2711 | { | |
2712 | $$ = new SetOperationConstraint(0, SetOperationConstraint::EXCEPT, $2); | |
2713 | $$->set_location(asn1_infile, @1.first_line); | |
2714 | } | |
2715 | ; | |
2716 | ||
2717 | /* 46.1 page 67 */ | |
2718 | UnionMark: | |
2719 | "|" | |
2720 | | KW_UNION | |
2721 | ; | |
2722 | ||
2723 | /* 46.1 page 67 */ | |
2724 | IntersectionMark: | |
2725 | "^" | |
2726 | | KW_INTERSECTION | |
2727 | ; | |
2728 | ||
2729 | /* 46.5 page 68 */ | |
2730 | Elements: | |
2731 | SubtypeElements { $$ = $1; } | |
2732 | /* | |
2733 | | ObjectSetElements | |
2734 | */ | |
2735 | | "(" ElementSetSpec ")" | |
2736 | { | |
2737 | $$ = $2; | |
2738 | } | |
2739 | ; | |
2740 | ||
2741 | /* 47.1 page 69 */ | |
2742 | SubtypeElements: | |
2743 | SingleValue { $$ = $1; } | |
2744 | | ContainedSubtype { $$ = $1; } | |
2745 | | ValueRange { $$ = $1; } | |
2746 | | PermittedAlphabet { $$ = $1; } | |
2747 | | SizeConstraint { $$ = $1; } | |
2748 | | InnerTypeConstraints { $$ = $1; } | |
2749 | | PatternConstraint { $$ = $1; } | |
2750 | ; | |
2751 | ||
2752 | /* 47.2.1 page 70 */ | |
2753 | SingleValue: | |
2754 | Value_reg | |
2755 | { | |
2756 | $$ = new SingleValueConstraint($1); | |
2757 | $$->set_location(asn1_infile, @1.first_line); | |
2758 | } | |
2759 | | LowerIdValue | |
2760 | { | |
2761 | $$ = new SingleValueConstraint($1); | |
2762 | $$->set_location(asn1_infile, @1.first_line); | |
2763 | } | |
2764 | | TOK_Block | |
2765 | { | |
2766 | /** \todo: It would be more straightforward to create an undefined | |
2767 | * constraint here and classify it later on during parsing or semantic | |
2768 | * analysis to SimpleTableConstraint or SingleValue. */ | |
2769 | $$ = new TableConstraint($1, 0); | |
2770 | $$->set_location(asn1_infile, @1.first_line); | |
2771 | } | |
2772 | | ReferencedValue_reg | |
2773 | { | |
2774 | $$ = new SingleValueConstraint($1); | |
2775 | $$->set_location(asn1_infile, @1.first_line); | |
2776 | } | |
2777 | ; | |
2778 | ||
2779 | /* 47.3.1 page 70 | |
2780 | TypeConstraint (47.6.1 page 72) has been removed because it's conflicting | |
2781 | with second option of ContainedSubtype rule */ | |
2782 | ContainedSubtype: | |
2783 | KW_INCLUDES Type | |
2784 | { | |
2785 | $$ = new ContainedSubtypeConstraint($2, true); | |
2786 | $$->set_location(asn1_infile, @1.first_line); | |
2787 | } | |
2788 | | Type | |
2789 | { | |
2790 | $$ = new ContainedSubtypeConstraint($1, false); | |
2791 | $$->set_location(asn1_infile, @1.first_line); | |
2792 | } | |
2793 | ; | |
2794 | ||
2795 | /* 47.4.1 page 71 */ | |
2796 | ValueRange: | |
2797 | LowerEndpoint TOK_RangeSeparator UpperEndpoint | |
2798 | { | |
2799 | $$ = new ValueRangeConstraint($1,$3); | |
2800 | $$->set_location(asn1_infile, @1.first_line); | |
2801 | } | |
2802 | ; | |
2803 | ||
2804 | LowerEndpoint: | |
2805 | LowerEndValue | |
2806 | { | |
2807 | $$ = $1; | |
2808 | } | |
2809 | | LowerEndValue "<" | |
2810 | { | |
2811 | $$ = $1; | |
2812 | $$->set_exclusive(); | |
2813 | } | |
2814 | ; | |
2815 | ||
2816 | UpperEndpoint: | |
2817 | UpperEndValue | |
2818 | { | |
2819 | $$ = $1; | |
2820 | } | |
2821 | | "<" UpperEndValue | |
2822 | { | |
2823 | $$ = $2; | |
2824 | $$->set_exclusive(); | |
2825 | } | |
2826 | ; | |
2827 | ||
2828 | LowerEndValue: | |
2829 | Value | |
2830 | { | |
2831 | $$ = new RangeEndpoint($1); | |
2832 | $$->set_location(asn1_infile, @1.first_line); | |
2833 | } | |
2834 | | KW_MIN | |
2835 | { | |
2836 | $$ = new RangeEndpoint(RangeEndpoint::MIN); | |
2837 | $$->set_location(asn1_infile, @1.first_line); | |
2838 | } | |
2839 | ; | |
2840 | ||
2841 | UpperEndValue: | |
2842 | Value | |
2843 | { | |
2844 | $$ = new RangeEndpoint($1); | |
2845 | $$->set_location(asn1_infile, @1.first_line); | |
2846 | } | |
2847 | | KW_MAX | |
2848 | { | |
2849 | $$ = new RangeEndpoint(RangeEndpoint::MAX); | |
2850 | $$->set_location(asn1_infile, @1.first_line); | |
2851 | } | |
2852 | ; | |
2853 | ||
2854 | /* 47.5.1 page 71 */ | |
2855 | SizeConstraint: | |
2856 | KW_SIZE Constraint | |
2857 | { | |
2858 | $$ = new SizeConstraint($2); | |
2859 | $$->set_location(asn1_infile, @1.first_line); | |
2860 | } | |
2861 | ; | |
2862 | ||
2863 | /* 47.7.1 page 72 */ | |
2864 | PermittedAlphabet: | |
2865 | KW_FROM Constraint | |
2866 | { | |
2867 | $$ = new PermittedAlphabetConstraint($2); | |
2868 | $$->set_location(asn1_infile, @1.first_line); | |
2869 | } | |
2870 | ; | |
2871 | ||
2872 | /* 47.8.1 page 72 */ | |
2873 | InnerTypeConstraints: | |
2874 | KW_WITH KW_COMPONENT SingleTypeConstraint | |
2875 | { | |
2876 | $$ = $3; | |
2877 | $$->set_location(asn1_infile, @1.first_line); | |
2878 | } | |
2879 | | KW_WITH KW_COMPONENTS TOK_Block | |
2880 | { | |
2881 | $$ = new UnparsedMultipleInnerTypeConstraint($3); | |
2882 | $$->set_location(asn1_infile, @1.first_line); | |
2883 | } | |
2884 | ; | |
2885 | ||
2886 | /* 47.8.3 page 72 */ | |
2887 | SingleTypeConstraint: | |
2888 | Constraint | |
2889 | { | |
2890 | $$ = new SingleInnerTypeConstraint($1); | |
2891 | $$->set_location(asn1_infile, @1.first_line); | |
2892 | } | |
2893 | ; | |
2894 | ||
2895 | /* 47.8.4 page 72 */ | |
2896 | MultipleTypeConstraints: | |
2897 | TypeConstraints | |
2898 | { | |
2899 | $$ = $1; | |
2900 | $$->set_partial(false); | |
2901 | $$->set_location(asn1_infile, @1.first_line); | |
2902 | } | |
2903 | | TOK_Ellipsis "," TypeConstraints | |
2904 | { | |
2905 | $$ = $3; | |
2906 | $$->set_partial(true); | |
2907 | $$->set_location(asn1_infile, @1.first_line); | |
2908 | } | |
2909 | ; | |
2910 | ||
2911 | TypeConstraints: | |
2912 | NamedConstraint | |
2913 | { | |
2914 | $$ = new MultipleInnerTypeConstraint(); | |
2915 | $$->addNamedConstraint($1); | |
2916 | } | |
2917 | | TypeConstraints "," NamedConstraint | |
2918 | { | |
2919 | $$ = $1; | |
2920 | $$->addNamedConstraint($3); | |
2921 | } | |
2922 | | error NamedConstraint | |
2923 | { | |
2924 | $$ = new MultipleInnerTypeConstraint(); | |
2925 | $$->addNamedConstraint($2); | |
2926 | } | |
2927 | | TypeConstraints error | |
2928 | { | |
2929 | $$ = $1; | |
2930 | } | |
2931 | ; | |
2932 | ||
2933 | NamedConstraint: | |
2934 | TOK_LowerIdentifier ValueConstraint PresenceConstraint | |
2935 | { | |
2936 | $$ = new NamedConstraint($1, $2, $3); | |
2937 | $$->set_location(asn1_infile, @1.first_line); | |
2938 | } | |
2939 | ; | |
2940 | ||
2941 | ValueConstraint: | |
2942 | Constraint | |
2943 | { | |
2944 | $$ = $1; | |
2945 | } | |
2946 | | /* empty */ | |
2947 | { | |
2948 | $$ = NULL; | |
2949 | } | |
2950 | ; | |
2951 | ||
2952 | PresenceConstraint: | |
2953 | KW_PRESENT { $$ = NamedConstraint::PC_PRESENT; } | |
2954 | | KW_ABSENT { $$ = NamedConstraint::PC_ABSENT; } | |
2955 | | KW_OPTIONAL { $$ = NamedConstraint::PC_OPTIONAL; } | |
2956 | | /* empty */ { $$ = NamedConstraint::PC_NONE; } | |
2957 | ; | |
2958 | ||
2959 | /* 47.9.1 page 73 */ | |
2960 | PatternConstraint: | |
2961 | KW_PATTERN Value | |
2962 | { | |
2963 | $$ = new PatternConstraint($2); | |
2964 | $$->set_location(asn1_infile, @1.first_line); | |
2965 | } | |
2966 | ; | |
2967 | ||
2968 | /* X.682 clause 8.1 */ | |
2969 | GeneralConstraint: | |
2970 | UserDefinedConstraint | |
2971 | { | |
2972 | $$ = new IgnoredConstraint("user defined constraint"); | |
2973 | $$->set_location(asn1_infile, @1.first_line); | |
2974 | } | |
2975 | | TableConstraint | |
2976 | { | |
2977 | $$=$1; | |
2978 | } | |
2979 | | ContentsConstraint /* TODO? */ | |
2980 | { | |
2981 | $$ = new IgnoredConstraint("content constraint"); | |
2982 | $$->set_location(asn1_infile, @1.first_line); | |
2983 | } | |
2984 | ; | |
2985 | ||
2986 | /* X.682 clause 9.1 */ | |
2987 | UserDefinedConstraint: | |
2988 | KW_CONSTRAINED KW_BY TOK_Block {delete $3;} | |
2989 | ; | |
2990 | ||
2991 | /* X.682 clause 11.1 */ | |
2992 | ContentsConstraint: | |
2993 | KW_CONTAINING Type {delete $2;} | |
2994 | | KW_ENCODED KW_BY Value {delete $3;} | |
2995 | | KW_CONTAINING Type KW_ENCODED KW_BY Value {delete $2; delete $5;} | |
2996 | ; | |
2997 | ||
2998 | /* X.682 clause 10.3 */ | |
2999 | TableConstraint: | |
3000 | /* SimpleTableConstraint | |
3001 | | */ | |
3002 | ComponentRelationConstraint { $$ = $1; } | |
3003 | ; | |
3004 | ||
3005 | /* commented out to eliminate reduce/reduce conflicts: | |
3006 | SimpleTableConstraint containing TOK_Block is reachable by path | |
3007 | Constraint->SubtypeConstraint->...->SingleValue->Value->TOK_Block | |
3008 | ||
3009 | SimpleTableConstraint: | |
3010 | ObjectSetSpec | |
3011 | ; | |
3012 | */ | |
3013 | ||
3014 | /* X.682 clause 10.7 */ | |
3015 | /* the first block contains DefinedObjectSet, the second AtNotationList */ | |
3016 | ComponentRelationConstraint: | |
3017 | TOK_Block TOK_Block {$$=new TableConstraint($1, $2);} | |
3018 | ; | |
3019 | ||
3020 | DefinedObjectSetBlock: | |
3021 | RefdUpper {$$=new OS_refd($1);} | |
3022 | ; | |
3023 | ||
3024 | AtNotationList: | |
3025 | AtNotation {$$=new AtNotations(); $$->add_an($1);} | |
3026 | | AtNotationList "," AtNotation {$$=$1; $$->add_an($3);} | |
3027 | | error AtNotation {$$=new AtNotations(); $$->add_an($2);} | |
3028 | | AtNotationList error {$$=$1;} | |
3029 | ; | |
3030 | ||
3031 | AtNotation: | |
3032 | // No `BIGNUM' for Levels. | |
3033 | "@" Levels ComponentIdList {$$=new AtNotation($2, $3);} | |
3034 | ; | |
3035 | ||
3036 | Levels: | |
3037 | /* empty */ {$$=0;} | |
3038 | | Level {$$=$1;} | |
3039 | ; | |
3040 | ||
3041 | Level: | |
3042 | "." {$$=1;} | |
3043 | | TOK_RangeSeparator {$$=2;} /* ".." */ | |
3044 | | TOK_Ellipsis {$$=3;} /* "..." */ | |
3045 | | Level "." {$$=$1+1;} | |
3046 | | Level TOK_RangeSeparator {$$=$1+2;} | |
3047 | | Level TOK_Ellipsis {$$=$1+3;} | |
3048 | ; | |
3049 | ||
3050 | ComponentIdList: | |
3051 | TOK_LowerIdentifier {$$=new FieldName(); $$->add_field($1);} | |
3052 | | ComponentIdList "." TOK_LowerIdentifier {$$=$1; $$->add_field($3);} | |
3053 | ; | |
3054 | ||
3055 | ||
3056 | /********************************************************************* | |
3057 | * X.681 - stuff | |
3058 | *********************************************************************/ | |
3059 | ||
3060 | //ObjectClass: | |
3061 | // DefinedObjectClass {$$=$1;} | |
3062 | //| ObjectClassDefn {$$=$1;} | |
3063 | ///* | |
3064 | //| ParameterizedObjectClass | |
3065 | // */ | |
3066 | //; | |
3067 | ||
3068 | //DefinedObjectClass: | |
3069 | // DefdUpper | |
3070 | // { | |
3071 | // $$=new OC_refd($1); | |
3072 | // $$->set_location(asn1_infile, @1.first_line); | |
3073 | // } | |
3074 | //; | |
3075 | ||
3076 | /* | |
3077 | UsefulObjectClassReference: | |
3078 | KW_TYPE_IDENTIFIER | |
3079 | | KW_ABSTRACT_SYNTAX | |
3080 | ; | |
3081 | */ | |
3082 | ||
3083 | /* X.681 clause 9.3 */ | |
3084 | ObjectClassDefn: | |
3085 | KW_CLASS TOK_Block WithSyntaxSpec_opt | |
3086 | { | |
3087 | $$=new OC_defn($2, $3); | |
3088 | $$->set_location(asn1_infile, @1.first_line); | |
3089 | } | |
3090 | ; | |
3091 | ||
3092 | FieldSpecList: | |
3093 | FieldSpec | |
3094 | { | |
3095 | $$=new FieldSpecs(); $$->add_fs($1); | |
3096 | $1->set_location(asn1_infile, @1.first_line); | |
3097 | } | |
3098 | | FieldSpecList "," FieldSpec | |
3099 | { | |
3100 | $$=$1; $$->add_fs($3); | |
3101 | $3->set_location(asn1_infile, @3.first_line); | |
3102 | } | |
3103 | | error FieldSpec | |
3104 | { | |
3105 | $$=new FieldSpecs(); $$->add_fs($2); | |
3106 | $2->set_location(asn1_infile, @2.first_line); | |
3107 | } | |
3108 | | FieldSpecList error | |
3109 | {$$=$1;} | |
3110 | ; | |
3111 | ||
3112 | /* X.681 clause 9.4 */ | |
3113 | /** \todo add support for ValueSet and VariableType FieldSpecs | |
3114 | * (new AST nodes are required) */ | |
3115 | FieldSpec: | |
3116 | TypeFieldSpec {$$=$1;} | |
3117 | | FixedTypeValueFieldSpec {$$=$1;} | |
3118 | /* | |
3119 | | VariableTypeValueFieldSpec {$$=$1;} | |
3120 | | FixedTypeValueSetFieldSpec {$$=$1;} | |
3121 | | VariableTypeValueSetFieldSpec {$$=$1;} | |
3122 | | ObjectFieldSpec {$$=$1;} | |
3123 | | ObjectSetFieldSpec {$$=$1;} | |
3124 | */ | |
3125 | | UndefFieldSpec {$$=$1;} | |
3126 | ; | |
3127 | ||
3128 | UNIQ_opt: | |
3129 | KW_UNIQUE {$$=true;} | |
3130 | | /* empty */ {$$=false;} | |
3131 | ; | |
3132 | ||
3133 | Dflt_Type: | |
3134 | KW_DEFAULT Type {$$=$2;} | |
3135 | ; | |
3136 | ||
3137 | Dflt_Value: | |
3138 | KW_DEFAULT Value {$$=$2;} | |
3139 | ; | |
3140 | ||
3141 | Dflt_Value_reg: | |
3142 | KW_DEFAULT Value_reg {$$=$2;} | |
3143 | ; | |
3144 | ||
3145 | Dflt_NullValue: | |
3146 | KW_DEFAULT NullValue {$$=$2;} | |
3147 | ; | |
3148 | ||
3149 | Dflt_Block: | |
3150 | KW_DEFAULT TOK_Block {$$=$2;} | |
3151 | ; | |
3152 | ||
3153 | Dflt_RefdLower: | |
3154 | KW_DEFAULT RefdLower {$$=$2;} | |
3155 | ; | |
3156 | ||
3157 | Dflt_RefdLower_reg: | |
3158 | KW_DEFAULT RefdLower_reg {$$=$2;} | |
3159 | ; | |
3160 | ||
3161 | Dflt_LowerId: | |
3162 | KW_DEFAULT TOK_LowerIdentifier {$$=$2;} | |
3163 | ; | |
3164 | ||
3165 | TypeFieldSpec: | |
3166 | TOK_ampUpperIdentifier | |
3167 | {$$=new FieldSpec_T($1, false, 0);} | |
3168 | | TOK_ampUpperIdentifier KW_OPTIONAL | |
3169 | {$$=new FieldSpec_T($1, true, 0);} | |
3170 | | TOK_ampUpperIdentifier Dflt_Type | |
3171 | {$$=new FieldSpec_T($1, false, $2);} | |
3172 | ; | |
3173 | ||
3174 | FixedTypeValueFieldSpec: | |
3175 | /* 1 */ | |
3176 | TOK_ampLowerIdentifier Type_reg UNIQ_opt | |
3177 | {$$=new FieldSpec_V_FT($1, $2, $3, false, 0);} | |
3178 | | TOK_ampLowerIdentifier Type_reg UNIQ_opt KW_OPTIONAL | |
3179 | {$$=new FieldSpec_V_FT($1, $2, $3, true, 0);} | |
3180 | | TOK_ampLowerIdentifier Type_reg UNIQ_opt Dflt_Value | |
3181 | {$$=new FieldSpec_V_FT($1, $2, $3, false, $4);} | |
3182 | ||
3183 | /* 2 */ | |
3184 | | TOK_ampLowerIdentifier UpperFromObj UNIQ_opt | |
3185 | { | |
3186 | Type *t = new Type(Type::T_REFD, $2); | |
3187 | t->set_location(asn1_infile, @2.first_line); | |
3188 | $$=new FieldSpec_V_FT($1, t, $3, false, 0); | |
3189 | } | |
3190 | | TOK_ampLowerIdentifier UpperFromObj UNIQ_opt KW_OPTIONAL | |
3191 | { | |
3192 | Type *t = new Type(Type::T_REFD, $2); | |
3193 | t->set_location(asn1_infile, @2.first_line); | |
3194 | $$=new FieldSpec_V_FT($1, t, $3, true, 0); | |
3195 | } | |
3196 | | TOK_ampLowerIdentifier UpperFromObj UNIQ_opt Dflt_Value | |
3197 | { | |
3198 | Type *t = new Type(Type::T_REFD, $2); | |
3199 | t->set_location(asn1_infile, @2.first_line); | |
3200 | $$=new FieldSpec_V_FT($1, t, $3, false, $4); | |
3201 | } | |
3202 | ||
3203 | /* 3 */ | |
3204 | | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE | |
3205 | { | |
3206 | Type *t = new Type(Type::T_REFD, $2); | |
3207 | t->set_location(asn1_infile, @2.first_line); | |
3208 | $$=new FieldSpec_V_FT($1, t, true, false, 0); | |
3209 | } | |
3210 | | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE KW_OPTIONAL | |
3211 | { | |
3212 | Type *t = new Type(Type::T_REFD, $2); | |
3213 | t->set_location(asn1_infile, @2.first_line); | |
3214 | $$=new FieldSpec_V_FT($1, t, true, true, 0); | |
3215 | } | |
3216 | ||
3217 | | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_Value_reg | |
3218 | { | |
3219 | Type *t = new Type(Type::T_REFD, $2); | |
3220 | t->set_location(asn1_infile, @2.first_line); | |
3221 | $$=new FieldSpec_V_FT($1, t, true, false, $4); | |
3222 | } | |
3223 | | TOK_ampLowerIdentifier SimplDefdUpper Dflt_Value_reg | |
3224 | { | |
3225 | Type *t = new Type(Type::T_REFD, $2); | |
3226 | t->set_location(asn1_infile, @2.first_line); | |
3227 | $$=new FieldSpec_V_FT($1, t, false, false, $3); | |
3228 | } | |
3229 | | TOK_ampLowerIdentifier PardUpper Dflt_Value_reg | |
3230 | { | |
3231 | Type *t = new Type(Type::T_REFD, $2); | |
3232 | t->set_location(asn1_infile, @2.first_line); | |
3233 | $$=new FieldSpec_V_FT($1, t, false, false, $3); | |
3234 | } | |
3235 | ||
3236 | /* 4 */ | |
3237 | | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_NullValue | |
3238 | { | |
3239 | Type *t = new Type(Type::T_REFD, $2); | |
3240 | t->set_location(asn1_infile, @2.first_line); | |
3241 | $$=new FieldSpec_V_FT($1, t, true, false, $4); | |
3242 | } | |
3243 | | TOK_ampLowerIdentifier SimplDefdUpper Dflt_NullValue | |
3244 | { | |
3245 | Type *t = new Type(Type::T_REFD, $2); | |
3246 | t->set_location(asn1_infile, @2.first_line); | |
3247 | $$=new FieldSpec_V_FT($1, t, false, false, $3); | |
3248 | } | |
3249 | | TOK_ampLowerIdentifier PardUpper Dflt_NullValue | |
3250 | { | |
3251 | Type *t = new Type(Type::T_REFD, $2); | |
3252 | t->set_location(asn1_infile, @2.first_line); | |
3253 | $$=new FieldSpec_V_FT($1, t, false, false, $3); | |
3254 | } | |
3255 | ||
3256 | /* 5 */ | |
3257 | | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_Block | |
3258 | { | |
3259 | Type *t = new Type(Type::T_REFD, $2); | |
3260 | t->set_location(asn1_infile, @2.first_line); | |
3261 | Value *v = new Value(Value::V_UNDEF_BLOCK, $4); | |
3262 | v->set_location(asn1_infile, @4.first_line); | |
3263 | $$=new FieldSpec_V_FT($1, t, true, false, v); | |
3264 | } | |
3265 | ||
3266 | /* 6 */ | |
3267 | | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_LowerId | |
3268 | { | |
3269 | Type *t = new Type(Type::T_REFD, $2); | |
3270 | t->set_location(asn1_infile, @2.first_line); | |
3271 | Value *v = new Value(Value::V_UNDEF_LOWERID, $4); | |
3272 | v->set_location(asn1_infile, @4.first_line); | |
3273 | $$=new FieldSpec_V_FT($1, t, true, false, v); | |
3274 | } | |
3275 | ||
3276 | /* 7 */ | |
3277 | | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_RefdLower_reg | |
3278 | { | |
3279 | Type *t = new Type(Type::T_REFD, $2); | |
3280 | t->set_location(asn1_infile, @2.first_line); | |
3281 | Value *v = new Value(Value::V_REFD, $4); | |
3282 | v->set_location(asn1_infile, @4.first_line); | |
3283 | $$=new FieldSpec_V_FT($1, t, true, false, v); | |
3284 | } | |
3285 | ||
3286 | /* 8-9 */ | |
3287 | | TOK_ampLowerIdentifier PardUpper | |
3288 | { | |
3289 | Type *t = new Type(Type::T_REFD, $2); | |
3290 | t->set_location(asn1_infile, @2.first_line); | |
3291 | $$=new FieldSpec_V_FT($1, t, false, false, 0); | |
3292 | } | |
3293 | | TOK_ampLowerIdentifier PardUpper KW_OPTIONAL | |
3294 | { | |
3295 | Type *t = new Type(Type::T_REFD, $2); | |
3296 | t->set_location(asn1_infile, @2.first_line); | |
3297 | $$=new FieldSpec_V_FT($1, t, false, true, 0); | |
3298 | } | |
3299 | | TOK_ampLowerIdentifier PardUpper Dflt_Block | |
3300 | { | |
3301 | Type *t = new Type(Type::T_REFD, $2); | |
3302 | t->set_location(asn1_infile, @2.first_line); | |
3303 | Value *v = new Value(Value::V_UNDEF_BLOCK, $3); | |
3304 | v->set_location(asn1_infile, @3.first_line); | |
3305 | $$=new FieldSpec_V_FT($1, t, false, false, v); | |
3306 | } | |
3307 | | TOK_ampLowerIdentifier PardUpper Dflt_LowerId | |
3308 | { | |
3309 | Type *t = new Type(Type::T_REFD, $2); | |
3310 | t->set_location(asn1_infile, @2.first_line); | |
3311 | Value *v = new Value(Value::V_UNDEF_LOWERID, $3); | |
3312 | v->set_location(asn1_infile, @3.first_line); | |
3313 | $$=new FieldSpec_V_FT($1, t, false, false, v); | |
3314 | } | |
3315 | | TOK_ampLowerIdentifier PardUpper Dflt_RefdLower_reg | |
3316 | { | |
3317 | Type *t = new Type(Type::T_REFD, $2); | |
3318 | t->set_location(asn1_infile, @2.first_line); | |
3319 | Value *v = new Value(Value::V_REFD, $3); | |
3320 | v->set_location(asn1_infile, @3.first_line); | |
3321 | $$=new FieldSpec_V_FT($1, t, false, false, v); | |
3322 | } | |
3323 | ||
3324 | /* ObjectClassFieldType */ | |
3325 | /* UpperFromObjs szetbombazva */ | |
3326 | | TOK_ampLowerIdentifier PardUpper_FromObjs UNIQ_opt | |
3327 | { | |
3328 | Type *t=new Type(Type::T_REFD, $2); | |
3329 | t->set_location(asn1_infile, @2.first_line); | |
3330 | $$=new FieldSpec_V_FT($1, t, $3, false, 0); | |
3331 | } | |
3332 | /* SimplUpper_FromObjs szetbombazva */ | |
3333 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameLower UNIQ_opt | |
3334 | { | |
3335 | FromObj *fo=new FromObj($2, $4); | |
3336 | fo->set_location(asn1_infile, @2.first_line); | |
3337 | Type *t=new Type(Type::T_REFD, fo); | |
3338 | t->set_location(asn1_infile, @2.first_line); | |
3339 | $$=new FieldSpec_V_FT($1, t, $5, false, 0); | |
3340 | } | |
3341 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUpper UNIQ_opt | |
3342 | { | |
3343 | FromObj *fo=new FromObj($2, $4); | |
3344 | fo->set_location(asn1_infile, @2.first_line); | |
3345 | Type *t=new Type(Type::T_REFD, fo); | |
3346 | t->set_location(asn1_infile, @2.first_line); | |
3347 | $$=new FieldSpec_V_FT($1, t, $5, false, 0); | |
3348 | } | |
3349 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUppers UNIQ_opt | |
3350 | { | |
3351 | FromObj *fo=new FromObj($2, $4); | |
3352 | fo->set_location(asn1_infile, @2.first_line); | |
3353 | Type *t=new Type(Type::T_REFD, fo); | |
3354 | t->set_location(asn1_infile, @2.first_line); | |
3355 | $$=new FieldSpec_V_FT($1, t, $5, false, 0); | |
3356 | } | |
3357 | /* UpperFromObjs szetbombazva */ | |
3358 | | TOK_ampLowerIdentifier PardUpper_FromObjs UNIQ_opt KW_OPTIONAL | |
3359 | { | |
3360 | Type *t=new Type(Type::T_REFD, $2); | |
3361 | t->set_location(asn1_infile, @2.first_line); | |
3362 | $$=new FieldSpec_V_FT($1, t, $3, true, 0); | |
3363 | } | |
3364 | /* SimplUpper_FromObjs szetbombazva */ | |
3365 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameLower UNIQ_opt KW_OPTIONAL | |
3366 | { | |
3367 | FromObj *fo=new FromObj($2, $4); | |
3368 | fo->set_location(asn1_infile, @2.first_line); | |
3369 | Type *t=new Type(Type::T_REFD, fo); | |
3370 | t->set_location(asn1_infile, @2.first_line); | |
3371 | $$=new FieldSpec_V_FT($1, t, $5, true, 0); | |
3372 | } | |
3373 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUpper UNIQ_opt KW_OPTIONAL | |
3374 | { | |
3375 | FromObj *fo=new FromObj($2, $4); | |
3376 | fo->set_location(asn1_infile, @2.first_line); | |
3377 | Type *t=new Type(Type::T_REFD, fo); | |
3378 | t->set_location(asn1_infile, @2.first_line); | |
3379 | $$=new FieldSpec_V_FT($1, t, $5, true, 0); | |
3380 | } | |
3381 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUppers UNIQ_opt | |
3382 | KW_OPTIONAL | |
3383 | { | |
3384 | FromObj *fo=new FromObj($2, $4); | |
3385 | fo->set_location(asn1_infile, @2.first_line); | |
3386 | Type *t=new Type(Type::T_REFD, fo); | |
3387 | t->set_location(asn1_infile, @2.first_line); | |
3388 | $$=new FieldSpec_V_FT($1, t, $5, true, 0); | |
3389 | } | |
3390 | /* UpperFromObjs szetbombazva */ | |
3391 | | TOK_ampLowerIdentifier PardUpper_FromObjs UNIQ_opt Dflt_Value | |
3392 | { | |
3393 | Type *t=new Type(Type::T_REFD, $2); | |
3394 | t->set_location(asn1_infile, @2.first_line); | |
3395 | $$=new FieldSpec_V_FT($1, t, $3, false, $4); | |
3396 | } | |
3397 | /* SimplUpper_FromObjs szetbombazva */ | |
3398 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameLower UNIQ_opt Dflt_Value | |
3399 | { | |
3400 | FromObj *fo=new FromObj($2, $4); | |
3401 | fo->set_location(asn1_infile, @2.first_line); | |
3402 | Type *t=new Type(Type::T_REFD, fo); | |
3403 | t->set_location(asn1_infile, @2.first_line); | |
3404 | $$=new FieldSpec_V_FT($1, t, $5, false, $6); | |
3405 | } | |
3406 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUpper UNIQ_opt Dflt_Value | |
3407 | { | |
3408 | FromObj *fo=new FromObj($2, $4); | |
3409 | fo->set_location(asn1_infile, @2.first_line); | |
3410 | Type *t=new Type(Type::T_REFD, fo); | |
3411 | t->set_location(asn1_infile, @2.first_line); | |
3412 | $$=new FieldSpec_V_FT($1, t, $5, false, $6); | |
3413 | } | |
3414 | | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUppers UNIQ_opt Dflt_Value | |
3415 | { | |
3416 | FromObj *fo=new FromObj($2, $4); | |
3417 | fo->set_location(asn1_infile, @2.first_line); | |
3418 | Type *t=new Type(Type::T_REFD, fo); | |
3419 | t->set_location(asn1_infile, @2.first_line); | |
3420 | $$=new FieldSpec_V_FT($1, t, $5, false, $6); | |
3421 | } | |
3422 | ; | |
3423 | ||
3424 | /** \todo PardUpper as governor can be either Type or OC reference | |
3425 | * the respective rules of FixedTypeValueFieldSpec should be moved here */ | |
3426 | UndefFieldSpec: | |
3427 | /* &lower */ | |
3428 | TOK_ampLowerIdentifier SimplDefdUpper | |
3429 | {$$=new FieldSpec_Undef($1, $2, false, 0);} | |
3430 | | TOK_ampLowerIdentifier SimplDefdUpper KW_OPTIONAL | |
3431 | {$$=new FieldSpec_Undef($1, $2, true, 0);} | |
3432 | | TOK_ampLowerIdentifier SimplDefdUpper Dflt_Block | |
3433 | {$$=new FieldSpec_Undef($1, $2, false, $3);} | |
3434 | | TOK_ampLowerIdentifier SimplDefdUpper Dflt_RefdLower | |
3435 | {$$=new FieldSpec_Undef($1, $2, false, $3);} | |
3436 | /* &upper */ | |
3437 | | TOK_ampUpperIdentifier SimplDefdUpper | |
3438 | {$$=new FieldSpec_Undef($1, $2, false, 0);} | |
3439 | | TOK_ampUpperIdentifier SimplDefdUpper KW_OPTIONAL | |
3440 | {$$=new FieldSpec_Undef($1, $2, true, 0);} | |
3441 | | TOK_ampUpperIdentifier SimplDefdUpper Dflt_Block | |
3442 | {$$=new FieldSpec_Undef($1, $2, false, $3);} | |
3443 | ; | |
3444 | ||
3445 | /* | |
3446 | VariableTypeValueFieldSpec: | |
3447 | TOK_ampLowerIdentifier FieldName {} | |
3448 | ; | |
3449 | ||
3450 | FixedTypeValueSetFieldSpec: | |
3451 | TOK_ampUpperIdentifier Type ValueSetOptionalitySpec {} | |
3452 | ; | |
3453 | ||
3454 | ValueSetOptionalitySpec: | |
3455 | KW_OPTIONAL {} | |
3456 | | KW_DEFAULT ValueSet {} | |
3457 | | / * empty * / {} | |
3458 | ; | |
3459 | ||
3460 | VariableTypeValueSetFieldSpec: | |
3461 | TOK_ampUpperIdentifier FieldName ValueSetOptionalitySpec {} | |
3462 | ; | |
3463 | ||
3464 | ObjectFieldSpec: | |
3465 | TOK_ampLowerIdentifier DefinedObjectClass ObjectOptionalitySpec {} | |
3466 | ; | |
3467 | ||
3468 | ObjectOptionalitySpec: | |
3469 | KW_OPTIONAL {} | |
3470 | | KW_DEFAULT Object {} | |
3471 | | / * empty * / {} | |
3472 | ; | |
3473 | ||
3474 | ObjectSetFieldSpec: | |
3475 | TOK_ampUpperIdentifier DefinedObjectClass ObjectSetOptionalitySpec {} | |
3476 | ; | |
3477 | ||
3478 | ObjectSetOptionalitySpec: | |
3479 | KW_OPTIONAL {} | |
3480 | | KW_DEFAULT ObjectSet {} | |
3481 | | / * empty * / {} | |
3482 | ; | |
3483 | */ | |
3484 | ||
3485 | WithSyntaxSpec_opt: | |
3486 | KW_WITH KW_SYNTAX TOK_Block {$$=$3;} | |
3487 | | /* empty */ {$$=0;} | |
3488 | ; | |
3489 | ||
3490 | Object: | |
3491 | DefinedObject {$$=$1;} | |
3492 | | ObjectDefn {$$=$1;} | |
3493 | /* | |
3494 | | ObjectFromObject | |
3495 | | ParameterizedObject | |
3496 | */ | |
3497 | ; | |
3498 | ||
3499 | DefinedObject: | |
3500 | RefdLower | |
3501 | { | |
3502 | $$=new Obj_refd($1); | |
3503 | $$->set_location(asn1_infile, @1.first_line); | |
3504 | } | |
3505 | ; | |
3506 | ||
3507 | ObjectDefn: | |
3508 | TOK_Block | |
3509 | { | |
3510 | $$=new Obj_defn($1); | |
3511 | $$->set_location(asn1_infile, @1.first_line); | |
3512 | } | |
3513 | ; | |
3514 | ||
3515 | ObjectSet: | |
3516 | TOK_Block | |
3517 | { | |
3518 | $$=new OS_defn($1); | |
3519 | $$->set_location(asn1_infile, @1.first_line); | |
3520 | } | |
3521 | ; | |
3522 | ||
3523 | ObjectSetElements: | |
3524 | Object {$$=$1;} | |
3525 | | RefdUpper | |
3526 | { | |
3527 | OS_refd *os_refd=new OS_refd($1); | |
3528 | os_refd->set_location(asn1_infile, @1.first_line); | |
3529 | $$=os_refd; | |
3530 | } | |
3531 | ; | |
3532 | ||
3533 | ObjectSetSpec: | |
3534 | ObjectSetSpec0 {$$=$1;} | |
3535 | | ObjectSetSpec0 "," TOK_Ellipsis {$$=$1;} | |
3536 | | TOK_Ellipsis | |
3537 | {$$=new OS_defn(); $$->set_location(asn1_infile, @1.first_line);} | |
3538 | | TOK_Ellipsis "," ObjectSetSpec0 {$$=$3;} | |
3539 | | ObjectSetSpec0 "," TOK_Ellipsis "," ObjectSetSpec0 | |
3540 | {$$=$1; $$->steal_oses($5);} | |
3541 | ; | |
3542 | ||
3543 | /* | |
3544 | this is a temporary solution. only unions are supported | |
3545 | (intersections, and except are not...) | |
3546 | */ | |
3547 | ObjectSetSpec0: | |
3548 | ObjectSetElements | |
3549 | { | |
3550 | $$=new OS_defn(); | |
3551 | $$->set_location(asn1_infile, @1.first_line); | |
3552 | $$->add_ose($1); | |
3553 | } | |
3554 | | ObjectSetSpec0 UnionMark ObjectSetElements {$$=$1; $$->add_ose($3);} | |
3555 | | error ObjectSetElements | |
3556 | { | |
3557 | $$=new OS_defn(); | |
3558 | $$->set_location(asn1_infile, @2.first_line); | |
3559 | $$->add_ose($2); | |
3560 | } | |
3561 | | ObjectSetSpec0 error {$$=$1;} | |
3562 | ; | |
3563 | ||
3564 | /********************************************************************* | |
3565 | * Type - stuff | |
3566 | *********************************************************************/ | |
3567 | ||
3568 | /* 16.3 page 30 */ | |
3569 | ReferencedType: | |
3570 | RefdUpper {$$=new Type(Type::T_REFD, $1);} | |
3571 | /* | |
3572 | includes TypeFromObject, ValueSetFromObjects and DefinedType | |
3573 | */ | |
3574 | /* | |
3575 | | SelectionType {$$=$1;} | |
3576 | */ | |
3577 | ; | |
3578 | ||
3579 | //DefinedType: | |
3580 | // DefdUpper {$$=new Type_refd($1);} | |
3581 | ///* | |
3582 | //| ParameterizedType | |
3583 | //| ParameterizedValueSetType | |
3584 | //*/ | |
3585 | //; | |
3586 | ||
3587 | /********************************************************************* | |
3588 | * Value - stuff | |
3589 | *********************************************************************/ | |
3590 | ||
3591 | /* 16.7 page 31 */ | |
3592 | Value: | |
3593 | ObjectClassFieldValue | |
3594 | {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
3595 | ; | |
3596 | ||
3597 | Value_reg: | |
3598 | ObjectClassFieldValue_reg | |
3599 | {$$=$1; $$->set_location(asn1_infile, @1.first_line);} | |
3600 | ; | |
3601 | ||
3602 | ObjectClassFieldValue: | |
3603 | FixedTypeFieldValue {$$=$1;} | |
3604 | /* | |
3605 | | OpenTypeFieldValue | |
3606 | */ | |
3607 | ; | |
3608 | ||
3609 | ObjectClassFieldValue_reg: | |
3610 | FixedTypeFieldValue_reg {$$=$1;} | |
3611 | /* | |
3612 | | OpenTypeFieldValue | |
3613 | */ | |
3614 | ; | |
3615 | ||
3616 | FixedTypeFieldValue: | |
3617 | BuiltinValue {$$=$1;} | |
3618 | | ReferencedValue_reg {$$=$1;} | |
3619 | ; | |
3620 | ||
3621 | FixedTypeFieldValue_reg: | |
3622 | BuiltinValue_reg {$$=$1;} | |
3623 | ; | |
3624 | ||
3625 | ReferencedValue: | |
3626 | RefdLower | |
3627 | { | |
3628 | $$=new Value(Value::V_REFD, $1); | |
3629 | $$->set_location(asn1_infile, @1.first_line); | |
3630 | } | |
3631 | /* | |
3632 | | ValueFromObject | |
3633 | */ | |
3634 | ; | |
3635 | ||
3636 | ReferencedValue_reg: | |
3637 | RefdLower_reg | |
3638 | { | |
3639 | $$=new Value(Value::V_REFD, $1); | |
3640 | $$->set_location(asn1_infile, @1.first_line); | |
3641 | } | |
3642 | /* | |
3643 | | ValueFromObject | |
3644 | */ | |
3645 | ; | |
3646 | ||
3647 | DefinedValue: | |
3648 | DefdLower | |
3649 | { | |
3650 | $$=new Value(Value::V_REFD, $1); | |
3651 | $$->set_location(asn1_infile, @1.first_line); | |
3652 | } | |
3653 | ; | |
3654 | ||
3655 | DefinedValue_reg: | |
3656 | DefdLower_reg | |
3657 | { | |
3658 | $$=new Value(Value::V_REFD, $1); | |
3659 | $$->set_location(asn1_infile, @1.first_line); | |
3660 | } | |
3661 | /* | |
3662 | | ParameterizedValue | |
3663 | */ | |
3664 | ; | |
3665 | ||
3666 | Val_Number: | |
3667 | TOK_Number {$$=new Value(Value::V_INT, $1);} | |
3668 | ; | |
3669 | ||
3670 | Val_CString: | |
3671 | TOK_CString {$$=new Value(Value::V_CSTR, $1);} | |
3672 | ; | |
3673 | ||
3674 | /********************************************************************* | |
3675 | * Named Type/Value | |
3676 | *********************************************************************/ | |
3677 | ||
3678 | NamedType: | |
3679 | TOK_LowerIdentifier Type | |
3680 | { | |
3681 | $$.name = $1; | |
3682 | $$.type = $2; | |
3683 | } | |
3684 | ; | |
3685 | ||
3686 | NamedValue: | |
3687 | TOK_LowerIdentifier Value | |
3688 | { | |
3689 | $$=new NamedValue($1, $2); | |
3690 | $$->set_location(asn1_infile, @1.first_line); | |
3691 | } | |
3692 | ; | |
3693 | ||
3694 | /********************************************************************* | |
3695 | * FieldName stuff | |
3696 | *********************************************************************/ | |
3697 | ||
3698 | /* | |
3699 | FieldName: | |
3700 | PrimitiveFieldNameList {} | |
3701 | ; | |
3702 | ||
3703 | PrimitiveFieldNameList: | |
3704 | PrimitiveFieldName {} | |
3705 | | PrimitiveFieldNameList "." PrimitiveFieldName {} | |
3706 | ; | |
3707 | ||
3708 | PrimitiveFieldName: | |
3709 | TOK_ampUpperIdentifier {} | |
3710 | | TOK_ampLowerIdentifier {} | |
3711 | ; | |
3712 | */ | |
3713 | ||
3714 | FieldNameLower: | |
3715 | TOK_ampLowerIdentifier {$$=new FieldName(); $$->add_field($1);} | |
3716 | | FieldNameLower "." TOK_ampLowerIdentifier {$$=$1; $$->add_field($3);} | |
3717 | ; | |
3718 | ||
3719 | FieldNameUpper: | |
3720 | TOK_ampUpperIdentifier {$$=new FieldName(); $$->add_field($1);} | |
3721 | | FieldNameLower "." TOK_ampUpperIdentifier {$$=$1; $$->add_field($3);} | |
3722 | ; | |
3723 | ||
3724 | FieldNameUppers: | |
3725 | FieldNameUpper "." TOK_ampLowerIdentifier {$$=$1; $$->add_field($3);} | |
3726 | | FieldNameUpper "." TOK_ampUpperIdentifier {$$=$1; $$->add_field($3);} | |
3727 | | FieldNameUppers "." TOK_ampLowerIdentifier {$$=$1; $$->add_field($3);} | |
3728 | | FieldNameUppers "." TOK_ampUpperIdentifier {$$=$1; $$->add_field($3);} | |
3729 | ; | |
3730 | ||
3731 | /********************************************************************* | |
3732 | * Referenced upper stuff | |
3733 | *********************************************************************/ | |
3734 | ||
3735 | RefdUpper: | |
3736 | DefdUpper {$$=$1;} | |
3737 | | UpperFromObj {$$=$1;} | |
3738 | | FromObjs {$$=$1;} | |
3739 | ; | |
3740 | ||
3741 | UpperFromObj: | |
3742 | DefdLower "." FieldNameUpper | |
3743 | { | |
3744 | $$=new FromObj($1, $3); | |
3745 | $$->set_location(asn1_infile, @1.first_line); | |
3746 | } | |
3747 | ; | |
3748 | ||
3749 | FromObjs: | |
3750 | Upper_FromObjs {$$=$1;} | |
3751 | | Lower_FromObjs {$$=$1;} | |
3752 | ; | |
3753 | ||
3754 | /* | |
3755 | Upper_FromObjs: | |
3756 | DefdUpper "." FieldNameLower | |
3757 | { | |
3758 | $$=new FromObj($1, $3); | |
3759 | $$->set_location(asn1_infile, @1.first_line); | |
3760 | } | |
3761 | | DefdUpper "." FieldNameUpper | |
3762 | { | |
3763 | $$=new FromObj($1, $3); | |
3764 | $$->set_location(asn1_infile, @1.first_line); | |
3765 | } | |
3766 | | DefdUpper "." FieldNameUppers | |
3767 | { | |
3768 | $$=new FromObj($1, $3); | |
3769 | $$->set_location(asn1_infile, @1.first_line); | |
3770 | } | |
3771 | ; | |
3772 | */ | |
3773 | ||
3774 | Upper_FromObjs: | |
3775 | SimplUpper_FromObjs {$$=$1;} | |
3776 | | PardUpper_FromObjs {$$=$1;} | |
3777 | ; | |
3778 | ||
3779 | SimplUpper_FromObjs: | |
3780 | SimplDefdUpper "." FieldNameLower | |
3781 | { | |
3782 | $$=new FromObj($1, $3); | |
3783 | $$->set_location(asn1_infile, @1.first_line); | |
3784 | } | |
3785 | | SimplDefdUpper "." FieldNameUpper | |
3786 | { | |
3787 | $$=new FromObj($1, $3); | |
3788 | $$->set_location(asn1_infile, @1.first_line); | |
3789 | } | |
3790 | | SimplDefdUpper "." FieldNameUppers | |
3791 | { | |
3792 | $$=new FromObj($1, $3); | |
3793 | $$->set_location(asn1_infile, @1.first_line); | |
3794 | } | |
3795 | ; | |
3796 | ||
3797 | PardUpper_FromObjs: | |
3798 | PardUpper "." FieldNameLower | |
3799 | { | |
3800 | $$=new FromObj($1, $3); | |
3801 | $$->set_location(asn1_infile, @1.first_line); | |
3802 | } | |
3803 | | PardUpper "." FieldNameUpper | |
3804 | { | |
3805 | $$=new FromObj($1, $3); | |
3806 | $$->set_location(asn1_infile, @1.first_line); | |
3807 | } | |
3808 | | PardUpper "." FieldNameUppers | |
3809 | { | |
3810 | $$=new FromObj($1, $3); | |
3811 | $$->set_location(asn1_infile, @1.first_line); | |
3812 | } | |
3813 | ; | |
3814 | ||
3815 | Lower_FromObjs: | |
3816 | DefdLower "." FieldNameUppers | |
3817 | { | |
3818 | $$=new FromObj($1, $3); | |
3819 | $$->set_location(asn1_infile, @1.first_line); | |
3820 | } | |
3821 | ; | |
3822 | ||
3823 | DefdUpper: | |
3824 | SimplDefdUpper {$$=$1;} | |
3825 | | PardUpper {$$=$1;} | |
3826 | ; | |
3827 | ||
3828 | PardUpper: | |
3829 | SimplDefdUpper TOK_Block | |
3830 | { | |
3831 | $$=new Ref_pard($1, $2); | |
3832 | $$->set_location(asn1_infile, @1.first_line); | |
3833 | } | |
3834 | ; | |
3835 | ||
3836 | SimplDefdUpper: | |
3837 | ExtUpperRef {$$=$1;} | |
3838 | | UpperRef {$$=$1;} | |
3839 | ; | |
3840 | ||
3841 | ExtUpperRef: | |
3842 | TOK_UpperIdentifier "." TOK_UpperIdentifier | |
3843 | { | |
3844 | $$=new Ref_defd_simple($1, $3); | |
3845 | $$->set_location(asn1_infile, @1.first_line); | |
3846 | } | |
3847 | ; | |
3848 | ||
3849 | UpperRef: | |
3850 | TOK_UpperIdentifier | |
3851 | { | |
3852 | $$=new Ref_defd_simple(0, $1); | |
3853 | $$->set_location(asn1_infile, @1.first_line); | |
3854 | } | |
3855 | ; | |
3856 | ||
3857 | /********************************************************************* | |
3858 | * Referenced lower stuff | |
3859 | *********************************************************************/ | |
3860 | ||
3861 | RefdLower_reg: | |
3862 | DefdLower_reg {$$=$1;} | |
3863 | | LowerFromObj {$$=$1;} | |
3864 | ; | |
3865 | ||
3866 | RefdLower: | |
3867 | DefdLower {$$=$1;} | |
3868 | | LowerFromObj {$$=$1;} | |
3869 | ; | |
3870 | ||
3871 | LowerFromObj: | |
3872 | DefdLower "." FieldNameLower | |
3873 | { | |
3874 | $$=new FromObj($1, $3); | |
3875 | $$->set_location(asn1_infile, @1.first_line); | |
3876 | } | |
3877 | ; | |
3878 | ||
3879 | DefdLower_reg: | |
3880 | SimplDefdLower_reg {$$=$1;} | |
3881 | | PardLower {$$=$1;} | |
3882 | ; | |
3883 | ||
3884 | DefdLower: | |
3885 | SimplDefdLower {$$=$1;} | |
3886 | | PardLower {$$=$1;} | |
3887 | ; | |
3888 | ||
3889 | PardLower: | |
3890 | SimplDefdLower TOK_Block | |
3891 | { | |
3892 | $$=new Ref_pard($1, $2); | |
3893 | $$->set_location(asn1_infile, @1.first_line); | |
3894 | } | |
3895 | ; | |
3896 | ||
3897 | SimplDefdLower_reg: | |
3898 | ExtLowerRef {$$=$1;} | |
3899 | ; | |
3900 | ||
3901 | SimplDefdLower: | |
3902 | ExtLowerRef {$$=$1;} | |
3903 | | LowerRef {$$=$1;} | |
3904 | ; | |
3905 | ||
3906 | ExtLowerRef: | |
3907 | TOK_UpperIdentifier "." TOK_LowerIdentifier | |
3908 | { | |
3909 | $$=new Ref_defd_simple($1, $3); | |
3910 | $$->set_location(asn1_infile, @1.first_line); | |
3911 | } | |
3912 | ; | |
3913 | ||
3914 | LowerRef: | |
3915 | TOK_LowerIdentifier | |
3916 | { | |
3917 | $$=new Ref_defd_simple(0, $1); | |
3918 | $$->set_location(asn1_infile, @1.first_line); | |
3919 | } | |
3920 | ; | |
3921 | ||
3922 | %% | |
3923 | ||
3924 | /********************************************************************* | |
3925 | * Interface | |
3926 | *********************************************************************/ | |
3927 | ||
3928 | int asn1_parse_file(const char* filename, boolean generate_code) | |
3929 | { | |
3930 | asn1_yy_parse_internal=false; | |
3931 | int retval=0; | |
3932 | asn1la_newfile(filename); | |
3933 | yyin=fopen(filename, "r"); | |
3934 | if(yyin==NULL) { | |
3935 | ERROR("Cannot open input file `%s': %s", | |
3936 | filename, strerror(errno)); | |
3937 | return -1; | |
3938 | } | |
3939 | yy_buffer_state *flex_buffer = asn1_yy_create_buffer(yyin, YY_BUF_SIZE); | |
3940 | asn1_yy_switch_to_buffer(flex_buffer); | |
3941 | act_asn1_module=0; | |
3942 | NOTIFY("Parsing ASN.1 module `%s'...", filename); | |
3943 | retval=yyparse(); | |
3944 | fclose(yyin); | |
3945 | asn1_yylex_destroy(); | |
3946 | if(retval==0 && act_asn1_module!=0) { | |
3947 | act_asn1_module->set_location(filename); | |
3948 | if (generate_code) act_asn1_module->set_gen_code(); | |
3949 | modules->add_mod(act_asn1_module); | |
3950 | } | |
3951 | act_asn1_module=0; | |
3952 | return retval; | |
3953 | } | |
3954 | ||
3955 | /** | |
3956 | * This functions is used to parse internal stuff. :) | |
3957 | */ | |
3958 | int asn1_parse_string(const char* p_str) | |
3959 | { | |
3960 | unsigned verb_level_backup=verb_level; | |
3961 | verb_level=0; // be vewy, vewy quiet | |
3962 | asn1la_newfile("<internal>"); | |
3963 | ||
3964 | asn1_yy_parse_internal=true; | |
3965 | yy_buffer_state *flex_buffer = asn1_yy_scan_string(p_str); | |
3966 | if(flex_buffer == NULL) { | |
3967 | ERROR("Flex buffer creation failed."); | |
3968 | verb_level=verb_level_backup; | |
3969 | return -1; | |
3970 | } | |
3971 | int retval=yyparse(); | |
3972 | asn1_yylex_destroy(); | |
3973 | verb_level=verb_level_backup; | |
3974 | return retval; | |
3975 | } | |
3976 | ||
3977 |