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 ******************************************************************************/
11 * Written by Matyas Forstner
17 /*********************************************************************
19 *********************************************************************/
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 */
29 #include "../Identifier.hh"
30 #include "AST_asn1.hh"
32 #include "../Value.hh"
33 #include "../Valuestuff.hh"
35 #include "../Typestuff.hh" // FIXME CTs
36 #include "../CompField.hh"
37 #include "../EnumItem.hh"
39 #include "TableConstraint.hh"
45 using namespace Common;
47 extern Modules *modules;
49 extern const char *asn1_infile;
50 extern bool asn1_yy_parse_internal;
51 extern void asn1la_newfile(const char *filename);
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
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);
70 static Asn::Module *act_asn1_module = NULL;
72 #define YYERROR_VERBOSE
74 void yyerror(const char *s)
76 Location loc(asn1_infile, plineno);
80 void yywarning(const char *s)
82 Location loc(asn1_infile, plineno);
89 /*********************************************************************
91 *********************************************************************/
93 %name-prefix="asn1_yy"
94 %output="asn1p.tab.cc"
99 shift-reduce conflicts:
102 SymbolList KW_FROM TOK_UpperIdentifier . AssignedIdentifier
104 1: in upper references (Upper_FromObjs and ExtUpperRef)
105 "A" . "." "zzz" <--> "A" . "." "&zzz"
107 1: in constraints: "(" lowerid "<" . ...
108 selectiontype or (minvalue < .. maxvalue)
113 /*********************************************************************
115 *********************************************************************/
118 /** The Asn namespace must be explicitly used here because this block
119 * is also visible from the common header files. */
123 Common::int_val_t *i;
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;
135 Asn::TagDefault::tagdef_t tagging;
139 Asn::Assignments *asss;
142 Asn::Exports *exports;
144 Asn::Imports *impmods;
145 Asn::Assignments *asss;
146 Asn::Assignment *ass;
147 Asn::Ass_pard *ass_pard;
149 Common::Block *block;
154 Common::Identifier *name;
158 Common::Tag::tagclass_t tagclass;
160 Common::EnumItem *enumitem;
161 Common::EnumItems *enumitems;
162 Common::ExcSpec *excSpec;
163 Common::CTs_EE_CTs *ctss;
165 Common::ExtAndExc *extAndExc;
166 Common::ExtAdds *extAdds;
167 Common::ExtAdd *extAdd;
169 Common::CompField *compField;
170 Common::Constraint *constraint;
171 Common::RangeEndpoint *rangeendpoint;
172 Common::Constraints *constraints;
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;
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;
195 /* object/class/set stuff */
196 Asn::ObjectClass *objclass;
198 Asn::ObjectSet *objset;
199 Asn::FieldSpec *fieldspec;
200 Asn::FieldSpecs *fieldspecs;
201 Asn::OS_Element *os_element;
202 Asn::OS_defn *os_defn;
204 Asn::AtNotations *ans;
205 Asn::TableConstraint *tbl_cnstr;
208 /*********************************************************************
209 * Tokens with semantic value
210 *********************************************************************/
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>"
219 TOK_RealNumber "<realnumber>"
220 TOK_BString "<bstring>"
221 TOK_HString "<hstring>"
222 %token <block> TOK_Block "{block}"
224 /* special keyword-like tokens */
227 KW_Block_NamedNumberList
228 KW_Block_Enumerations
230 KW_Block_NamedBitList
231 KW_Block_IdentifierList
232 KW_Block_FieldSpecList
233 KW_Block_ComponentTypeLists
234 KW_Block_AlternativeTypeLists
241 KW_Block_SequenceValue
243 KW_Block_ObjectSetSpec
244 KW_Block_DefinedObjectSetBlock
245 KW_Block_AtNotationList
248 KW_Block_CharStringValue
249 KW_Block_QuadrupleOrTuple
251 KW_Block_DefinitiveOIDValue
253 KW_Block_MultipleTypeConstraints
255 /*********************************************************************
256 * Tokens without semantic value (keywords, operators)
257 *********************************************************************/
259 %token TOK_Assignment "::="
260 %token TOK_RangeSeparator ".."
261 %token TOK_Ellipsis "..."
262 %token TOK_LeftVersionBrackets "[["
263 %token TOK_RightVersionBrackets "]]"
287 KW_ABSTRACT_SYNTAX "ABSTRACT-SYNTAX"
291 KW_APPLICATION "APPLICATION"
292 KW_AUTOMATIC "AUTOMATIC"
295 KW_BMPString "BMPString"
298 KW_CHARACTER "CHARACTER"
301 KW_COMPONENT "COMPONENT"
302 KW_COMPONENTS "COMPONENTS"
303 KW_CONSTRAINED "CONSTRAINED"
304 KW_CONTAINING "CONTAINING"
307 KW_DEFINITIONS "DEFINITIONS"
308 KW_EMBEDDED "EMBEDDED"
311 KW_ENUMERATED "ENUMERATED"
313 KW_EXPLICIT "EXPLICIT"
315 KW_EXTENSIBILITY "EXTENSIBILITY"
316 KW_EXTERNAL "EXTERNAL"
319 KW_GeneralizedTime "GeneralizedTime"
320 KW_GeneralString "GeneralString"
321 KW_GraphicString "GraphicString"
322 KW_IA5String "IA5String"
323 KW_IDENTIFIER "IDENTIFIER"
324 KW_IMPLICIT "IMPLICIT"
327 KW_INCLUDES "INCLUDES"
328 KW_INSTANCE "INSTANCE"
330 KW_INTERSECTION "INTERSECTION"
331 KW_ISO646String "ISO646String"
334 KW_MINUS_INFINITY "MINUS-INFINITY"
335 KW_NOT_A_NUMBER "NOT-A-NUMBER"
337 KW_NumericString "NumericString"
339 KW_ObjectDescriptor "ObjectDescriptor"
342 KW_OPTIONAL "OPTIONAL"
345 KW_PLUS_INFINITY "PLUS-INFINITY"
347 KW_PrintableString "PrintableString"
350 KW_RELATIVE_OID "RELATIVE-OID"
351 KW_SEQUENCE "SEQUENCE"
356 KW_T61String "T61String"
358 KW_TeletexString "TeletexString"
361 KW_TYPE_IDENTIFIER "TYPE-IDENTIFIER"
365 KW_UNIVERSAL "UNIVERSAL"
366 KW_UniversalString "UniversalString"
368 KW_UTF8String "UTF8String"
369 KW_VideotexString "VideotexString"
370 KW_VisibleString "VisibleString"
373 /*********************************************************************
374 * Semantic types of nonterminals
375 *********************************************************************/
377 %type <id> ModuleIdentifier
378 %type <module> ModuleDefinition
379 %type <tagging> TagDefault
380 %type <b> ExtensionDefault
381 %type <modbody> ModuleBody
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*/
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
404 Type Type_reg BuiltinType BuiltinType_reg
405 NakedType NakedType_reg
406 ConstrainedType SeqOfSetOfWithConstraint
407 ReferencedType /*DefinedType*/
409 EmbeddedPDVType ExternalType
410 CharacterStringType RestrictedCharacterStringType
411 UnrestrictedCharacterStringType
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
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
440 %type <type> RealType
441 %type <tagclass> Class
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
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
463 OpenTypeFieldValue OpenTypeFieldValue_reg
465 FixedTypeFieldValue FixedTypeFieldValue_reg
466 BuiltinValue BuiltinValue_reg
467 ReferencedValue ReferencedValue_reg
468 DefinitiveIdentifier AssignedIdentifier
470 Dflt_Value Dflt_Value_reg Dflt_NullValue
471 DefinedValue DefinedValue_reg
476 RealValue SpecialRealValue NumericRealValue
478 DefinitiveOIDValue DefinitiveObjIdComponentList
479 ObjectIdentifierValue ObjIdComponentList
480 RelativeOIDValue RelativeOIDComponentList
481 %type <oic> DefinitiveObjIdComponent
482 ObjIdComponent ObjIdComponentNumber
483 DefinitiveNameAndNumberForm NameAndNumberForm
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
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
506 %type <fieldspecs> FieldSpecList
507 %type <block> Dflt_Block
508 %type <id> Dflt_LowerId
509 %type <block> WithSyntaxSpec_opt
511 %type <node> BlockDefinition
513 /*********************************************************************
515 *********************************************************************/
517 %destructor {delete $$;}
526 TOK_ampLowerIdentifier
527 TOK_ampUpperIdentifier
552 ComponentRelationConstraint
567 DefinedObjectSetBlock
572 DefinitiveNameAndNumberForm
574 DefinitiveObjIdComponent
575 DefinitiveObjIdComponentList
592 ExceptionIdentification
598 ExtensionAdditionAlternative
599 ExtensionAdditionAlternativesList
600 ExtensionAdditionGroup
601 ExtensionAdditionList
602 ExtensionAndException
610 FixedTypeFieldValue_reg
611 FixedTypeValueFieldSpec
646 ObjectClassAssignment
648 ObjectClassFieldValue
649 ObjectClassFieldValue_reg
652 ObjectIdentifierValue
673 RelativeOIDComponentList
676 RestrictedCharacterStringType
678 AdditionalElementSetSpec
681 SeqOfSetOfWithConstraint
702 SymbolsFromModuleList
716 UnrestrictedCharacterStringType
726 ValueSetTypeAssignment
746 MultipleTypeConstraints
764 %printer { fprintf(yyoutput, "'%s'", $$->c_str()); } TOK_CString
766 %printer { fprintf(yyoutput, "%s", $$->get_asnname().c_str()); } TOK_UpperIdentifier
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 */
774 %printer { fprintf(yyoutput, "%s", $$->t_str().c_str()); } TOK_Number;
777 int old_v = verb_level;
786 /*********************************************************************
788 *********************************************************************/
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;}
799 ModuleIdentifier DefinitiveIdentifier
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);
816 /*********************************************************************
818 *********************************************************************/
827 DefinitiveIdentifier:
829 '{' DefinitiveObjIdComponentList '}' {$$=new Asn_Value_ObjId($2);}
833 $$=new Value(Value::V_UNDEF_BLOCK, $1);
834 $$->set_location(asn1_infile, @1.first_line);
836 | /* empty */ {$$=0;}
840 DefinitiveObjIdComponentList {$$=$1;}
843 DefinitiveObjIdComponentList:
844 DefinitiveObjIdComponent
846 $$=new Value(Value::V_OID);
847 $$->set_location(asn1_infile, @1.first_line);
848 $$->add_oid_comp($1);
850 | DefinitiveObjIdComponentList DefinitiveObjIdComponent
851 {$$=$1; $$->add_oid_comp($2);}
854 DefinitiveObjIdComponent:
857 $$=new OID_comp($1, 0);
858 $$->set_location(asn1_infile, @1.first_line);
862 $1->set_location(asn1_infile, @1.first_line);
863 $$=new OID_comp(0, $1);
864 $$->set_location(asn1_infile, @1.first_line);
866 | DefinitiveNameAndNumberForm {$$=$1;}
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;}
879 KW_EXTENSIBILITY KW_IMPLIED {$$=true;}
880 | /* empty */ {$$=false;}
883 /*********************************************************************
885 *********************************************************************/
889 Exports Imports AssignmentList
897 $$.exp = new Exports(false);
898 $$.imp = new Imports();
899 $$.asss = new Asn::Assignments();
905 | /* empty - error */
906 {yyerror("Missing `END'");}
908 {yyerror("Something after `END'");}
915 $$=new Exports(true); /* exports all */
916 $$->set_location(asn1_infile);
918 | KW_EXPORTS SymbolsExported ";" {$$=$2;}
926 $$->set_location(asn1_infile, @1.first_line);
930 $$=new Exports(false); /* exports nothing */
931 $$->set_location(asn1_infile);
935 $$=new Exports(true); /* exports all */
936 $$->set_location(asn1_infile);
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.");
950 | KW_IMPORTS SymbolsImported ";" {$$=$2;}
955 SymbolsFromModuleList {$$=$1;}
959 $$->set_location(asn1_infile);
964 SymbolsFromModuleList:
968 $$->set_location(asn1_infile, @1.first_line);
971 | SymbolsFromModuleList SymbolsFromModule {$$=$1; $$->add_impmod($2);}
976 SymbolList KW_FROM TOK_UpperIdentifier AssignedIdentifier
978 $$=new ImpMod($3, $1);
979 $$->set_location(asn1_infile, @1.first_line);
987 ObjectIdentifierValue {$$=$1;}
991 $$=new Value(Value::V_UNDEF_BLOCK, $1);
992 $$->set_location(asn1_infile, @1.first_line);
994 | DefinedValue {$$=$1;}
995 | /* empty */ {$$=0;}
1000 Symbol {$$=new Symbols(); $$->add_sym($1);}
1001 | SymbolList "," Symbol {$$=$1; $$->add_sym($3);}
1006 TOK_UpperIdentifier {$$=$1;}
1007 | TOK_LowerIdentifier {$$=$1;}
1008 | TOK_UpperIdentifier TOK_Block {$$=$1; delete $2;}
1009 | TOK_LowerIdentifier TOK_Block {$$=$1; delete $2;}
1011 | ParameterizedReference
1012 | objectclassreference
1014 | objectsetreference
1018 /*********************************************************************
1020 *********************************************************************/
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;}
1056 /*********************************************************************
1058 *********************************************************************/
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;}
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);}
1075 | ObjectAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);}
1076 | ObjectSetAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);}
1077 | ParameterizedAssignment
1079 | UndefAssignment {$$=$1; $$->set_location(asn1_infile, @1.first_line);}
1084 '@' GlobalModuleReference '.' ItemSpec
1089 | ItemId '.' ComponentId
1105 | TOK_Block {$$=new Ass_pard($1);}
1107 ObjectClassAssignment:
1108 TOK_UpperIdentifier OptParList TOK_Assignment ObjectClassDefn
1109 {$$=new Ass_OC($1, $2, $4);}
1114 TOK_LowerIdentifier OptParList DefinedObjectClass_reg TOK_Assignment
1116 {$$=new Ass_O($1, $2, $3, $5);}
1117 | TOK_LowerIdentifier OptParList DefinedObjectClass_reg TOK_Assignment
1119 {$$=new Ass_O($1, $2, $3, $5);}
1124 ObjectSetAssignment:
1125 TOK_UpperIdentifier OptParList DefinedObjectClass_reg
1126 TOK_Assignment TOK_Block
1127 {$$=new Ass_OS($1, $2, $3, $5);}
1133 TOK_UpperIdentifier OptParList TOK_Assignment Type_reg
1134 {$$=new Ass_T($1, $2, $4);}
1135 | TOK_UpperIdentifier OptParList TOK_Assignment UpperFromObj
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);
1141 | TOK_UpperIdentifier OptParList TOK_Assignment FromObjs
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);
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
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);
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
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);
1171 | TOK_LowerIdentifier OptParList DefdUpper TOK_Assignment NullValue
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);
1177 | TOK_LowerIdentifier OptParList UpperFromObj TOK_Assignment Value
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);
1183 | TOK_LowerIdentifier OptParList FromObjs TOK_Assignment Value
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);
1192 ValueSetTypeAssignment:
1193 TOK_UpperIdentifier OptParList Type_reg TOK_Assignment TOK_Block
1194 {$$=new Ass_VS($1, $2, $3, $5);}
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);}
1211 // "{" ElementSetSpecs "}"
1213 // TOK_Block {delete $1;}
1216 /*********************************************************************
1218 *********************************************************************/
1223 | Tag KW_IMPLICIT Type
1224 | Tag KW_EXPLICIT Type
1229 "[" Class ClassNumber "]"
1231 $$=new Tag(Tag::TAG_DEFPLICIT, $2, $3);
1232 $$->set_location(asn1_infile, @1.first_line);
1234 | "[" Class ClassNumber "]" KW_IMPLICIT
1236 $$=new Tag(Tag::TAG_IMPLICIT, $2, $3);
1237 $$->set_location(asn1_infile, @1.first_line);
1239 | "[" Class ClassNumber "]" KW_EXPLICIT
1241 $$=new Tag(Tag::TAG_EXPLICIT, $2, $3);
1242 $$->set_location(asn1_infile, @1.first_line);
1250 $1->set_location(asn1_infile, @1.first_line);
1252 | DefinedValue {$$=$1;}
1259 $$=Tag::TAG_UNIVERSAL;
1260 if(!asn1_yy_parse_internal)
1261 yywarning("Using of UNIVERSAL tagclass is not recommended.");
1263 | KW_APPLICATION {$$=Tag::TAG_APPLICATION;}
1264 | KW_PRIVATE {$$=Tag::TAG_PRIVATE;}
1265 | /* empty */ {$$=Tag::TAG_CONTEXT;}
1268 /*********************************************************************
1270 *********************************************************************/
1277 $$->set_location(asn1_infile, @1.first_line);
1282 $$->set_location(asn1_infile, @1.first_line);
1287 $$->set_location(asn1_infile, @2.first_line);
1296 $$->set_location(asn1_infile, @1.first_line);
1301 $$->set_location(asn1_infile, @1.first_line);
1306 $$->set_location(asn1_infile, @2.first_line);
1313 NakedType_reg Constraints {$$=$1; $$->add_constraints($2);}
1314 | SeqOfSetOfWithConstraint {$$=$1;}
1318 NakedType_reg {$$=$1;}
1319 | SequenceOfType {$$=$1;}
1320 | SetOfType {$$=$1;}
1324 ReferencedType {$$=$1;}
1325 | BuiltinType_reg {$$=$1;}
1329 BuiltinType_reg {$$=$1;}
1330 | SequenceOfType {$$=$1;}
1331 | SetOfType {$$=$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;}
1347 | SequenceType {$$=$1;}
1349 | EmbeddedPDVType {$$=$1;}
1350 | ExternalType {$$=$1;}
1352 | UsefulType {$$=$1;}
1355 | ObjectClassFieldType
1360 /* to eliminate the following reduce/reduce conflict:
1362 SubtypeElements->ContainedSubtype->Type->KW_NULL
1363 SubtypeElements->TypeConstraint->Type->KW_NULL
1364 SubtypeElements->SingleValue->Value->KW_NULL
1367 /*********************************************************************
1369 *********************************************************************/
1372 BuiltinValue_reg {$$=$1;}
1373 | NullValue {$$=$1;}
1374 | LowerIdValue {$$=$1;}
1377 $$=new Value(Value::V_UNDEF_BLOCK, $1);
1378 $$->set_location(asn1_infile, @1.first_line);
1383 e.g., the EnumeratedValue is LowerIdValue
1388 $$=new Value(Value::V_UNDEF_LOWERID, $1);
1389 $$->set_location(asn1_infile, @1.first_line);
1397 $$->set_location(asn1_infile, @1.first_line);
1402 $$->set_location(asn1_infile, @1.first_line);
1407 $$->set_location(asn1_infile, @1.first_line);
1412 $$->set_location(asn1_infile, @1.first_line);
1417 $$->set_location(asn1_infile, @1.first_line);
1419 | SignedNumber {$$=$1;}
1423 $$->set_location(asn1_infile, @1.first_line);
1429 --> SequenceOrSetValue
1431 --> TOK_LowerIdentifier
1435 /*********************************************************************
1436 * The individual types and its value notation
1437 *********************************************************************/
1440 KW_BOOLEAN {$$=new Type(Type::T_BOOL);}
1444 KW_TRUE {$$=new Value(Value::V_BOOL, true);}
1445 | KW_FALSE {$$=new Value(Value::V_BOOL, false);}
1450 {$$=new Type(Type::T_INT_A);}
1451 | KW_INTEGER TOK_Block {$$=new Type(Type::T_INT_A, $2);}
1454 /*********************************************************************
1456 *********************************************************************/
1461 $$=new NamedValues();
1464 | NamedNumberList "," NamedNumber
1471 $$=new NamedValues();
1474 | NamedNumberList error
1479 TOK_LowerIdentifier "(" SignedNumber ")"
1481 $$=new NamedValue($1, $3);
1482 $$->set_location(asn1_infile, @1.first_line);
1484 | TOK_LowerIdentifier "(" DefinedValue ")"
1486 $$=new NamedValue($1, $3);
1487 $$->set_location(asn1_infile, @1.first_line);
1494 $1->set_location(asn1_infile, @1.first_line);
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");
1508 KW_ENUMERATED TOK_Block {$$=new Type(Type::T_ENUM_A, $2);}
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;}
1526 | Enumeration "," EnumerationItem
1531 | error EnumerationItem
1543 $$=new EnumItem($1, 0);
1544 $$->set_location(asn1_infile, @1.first_line);
1548 $$=new EnumItem($1->get_name().clone(), $1->get_value()->clone());
1549 $$->set_location(asn1_infile, @1.first_line);
1555 KW_REAL {$$=new Type(Type::T_REAL);}
1559 SpecialRealValue {$$=$1;}
1560 | NumericRealValue {$$=$1;}
1564 TOK_RealNumber {$$=$1;}
1565 | "-" TOK_RealNumber
1578 Location loc(asn1_infile, @1.first_line);
1579 $$=new Value(Value::V_REAL, string2Real("INF", loc));
1583 Location loc(asn1_infile, @1.first_line);
1584 $$=new Value(Value::V_REAL, string2Real("-INF", loc));
1588 Location loc(asn1_infile, @1.first_line);
1589 $$=new Value(Value::V_REAL, string2Real("NaN", loc));
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);}
1601 $$=new NamedValues();
1604 | NamedBitList "," NamedBit
1611 $$=new NamedValues();
1614 | NamedBitList error
1619 TOK_LowerIdentifier "(" Val_Number ")"
1621 $$=new NamedValue($1, $3);
1622 $3->set_location(asn1_infile, @3.first_line);
1623 $$->set_location(asn1_infile, @1.first_line);
1625 | TOK_LowerIdentifier "(" DefinedValue ")"
1627 $$=new NamedValue($1, $3);
1628 $$->set_location(asn1_infile, @1.first_line);
1632 /* used in bitstring values */
1636 $$=new Value(Value::V_NAMEDBITS);
1637 $$->set_location(asn1_infile);
1639 | IdentifierList1 {$$=$1;}
1645 $$=new Value(Value::V_NAMEDBITS);
1647 $$->set_location(asn1_infile, @1.first_line);
1649 | IdentifierList1 "," TOK_LowerIdentifier
1653 $$->set_location(asn1_infile, @1.first_line);
1655 | error TOK_LowerIdentifier
1657 $$=new Value(Value::V_NAMEDBITS);
1659 $$->set_location(asn1_infile, @2.first_line);
1661 | IdentifierList1 error
1666 KW_OCTET KW_STRING {$$=new Type(Type::T_OSTR);}
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);}
1676 KW_NULL {$$=new Type(Type::T_NULL);}
1682 $$=new Value(Value::V_NULL);
1683 $$->set_location(asn1_infile, @1.first_line);
1690 | KW_SEQUENCE '{' ExtensionAndException OptionalExtensionMarker '}'
1691 | KW_SEQUENCE '{' ComponentTypeLists '}'
1696 KW_SEQUENCE TOK_Block
1697 {$$=new Type(Type::T_SEQ_A, $2);}
1700 ExtensionAndException:
1701 TOK_Ellipsis ExceptionSpec
1702 {$$=new ExtAndExc($2);}
1705 --> ExceptionSpec can be empty, so this is surplus
1711 {$$=new CTs_EE_CTs(0, 0, 0);}
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
1720 $$=new CTs_EE_CTs($1, $3, 0);
1722 | ComponentTypeList "," ExtensionAndException "," ExtensionAdditionList
1723 ExtensionEndMarker "," ComponentTypeList
1726 $$=new CTs_EE_CTs($1, $3, $8);
1728 | ComponentTypeList "," ExtensionAndException ExtensionEndMarker ","
1731 $$=new CTs_EE_CTs($1, $3, $6);
1733 | ExtensionAndException "," ExtensionAdditionList ExtensionEndMarker ","
1737 $$=new CTs_EE_CTs(0, $1, $6);
1739 | ExtensionAndException "," ExtensionEndMarker "," ComponentTypeList
1740 {$$=new CTs_EE_CTs(0, $1, $5);}
1741 | ExtensionAndException "," ExtensionAdditionList OptionalExtensionMarker
1744 $$ = new CTs_EE_CTs(0, $1, 0);
1746 | ExtensionAndException OptionalExtensionMarker
1747 {$$=new CTs_EE_CTs(0, $1, 0);}
1754 ',' ExtensionAdditionList
1759 ExtensionAdditionList:
1765 | ExtensionAdditionList "," ExtensionAddition
1770 | error ExtensionAddition
1775 | ExtensionAdditionList error
1783 OptionalExtensionMarker:
1789 ComponentType {$$=$1;}
1790 | ExtensionAdditionGroup {$$=$1;}
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());}
1806 | ComponentTypeList "," ComponentType
1811 | error ComponentType
1816 | ComponentTypeList error
1824 $$->set_location(asn1_infile, @1.first_line);
1826 | KW_COMPONENTS KW_OF Type
1828 $$=new CT_CompsOf($3);
1829 $$->set_location(asn1_infile, @1.first_line);
1836 $$=new CompField($1.name, $1.type, false, 0);
1837 $$->set_location(asn1_infile, @1.first_line);
1839 | NamedType KW_OPTIONAL
1841 $$=new CompField($1.name, $1.type, true, 0);
1842 $$->set_location(asn1_infile, @1.first_line);
1844 | NamedType KW_DEFAULT Value
1846 if (default_as_optional) { /* optional should not have a default value */
1849 $$=new CompField($1.name, $1.type, default_as_optional,
1850 default_as_optional ? NULL : $3);
1851 $$->set_location(asn1_infile, @1.first_line);
1858 $$=new Value(Value::V_SEQ, $1);
1859 $$->set_location(asn1_infile, @1.first_line);
1863 $$=new Value(Value::V_SEQ, new NamedValues());
1864 $$->set_location(asn1_infile, @0.first_line);
1871 $$=new Value(Value::V_SET, $1);
1872 $$->set_location(asn1_infile, @1.first_line);
1876 $$=new Value(Value::V_SET, new NamedValues());
1877 $$->set_location(asn1_infile, @0.first_line);
1884 $$=new NamedValues();
1887 | ComponentValueList "," NamedValue
1894 $$=new NamedValues();
1897 | ComponentValueList error
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);}
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);}
1914 $$=new Value(Value::V_SEQOF, $1);
1915 $$->set_location(asn1_infile, @1.first_line);
1922 $$=new Value(Value::V_SETOF, $1);
1923 $$->set_location(asn1_infile, @1.first_line);
1928 /* empty */ {$$ = new Values();}
1929 | ValueList {$$ = $1;}
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;}
1942 | KW_SET '{' ExtensionAndException OptionalExtensionMarker '}'
1943 | KW_SET '{' ComponentTypeLists '}'
1949 {$$=new Type(Type::T_SET_A, $2);}
1953 KW_CHOICE TOK_Block {$$=new Type(Type::T_CHOICE_A, $2);}
1956 AlternativeTypeLists:
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
1965 $$=new CTs_EE_CTs($1, $3, 0);
1971 ExtensionAdditionAlternativesList:
1972 ExtensionAdditionAlternative
1977 | ExtensionAdditionAlternativesList "," ExtensionAdditionAlternative
1982 | error ExtensionAdditionAlternative
1987 | ExtensionAdditionAlternativesList error
1991 ExtensionAdditionAlternative:
1992 TOK_LeftVersionBrackets AlternativeTypeList TOK_RightVersionBrackets
1993 {$$=new ExtAddGrp(0, $2);}
1996 CompField *cf = new CompField($1.name, $1.type, false, 0);
1997 cf->set_location(asn1_infile, @1.first_line);
2000 | TOK_LeftVersionBrackets error TOK_RightVersionBrackets
2001 {$$=new ExtAddGrp(0, new CTs());}
2004 AlternativeTypeList:
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));
2012 | AlternativeTypeList "," NamedType
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));
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));
2026 | AlternativeTypeList error
2031 TOK_LowerIdentifier ":" Value
2032 {$$=new Value(Value::V_CHOICE, $1, $3);}
2037 TOK_LowerIdentifier "<" Type
2042 ReferencedType {$$=$1;}
2043 | ChoiceType {$$=$1;}
2044 | SelectionType {$$=$1;}
2045 | Tag SelectionTypeType
2048 $$->set_location(asn1_infile, @2.first_line);
2054 TOK_LowerIdentifier "<" SelectionTypeType
2056 $$=new Type(Type::T_SELTYPE, $1, $3);
2057 $$->set_location(asn1_infile, @1.first_line);
2061 ObjectIdentifierType:
2062 KW_OBJECT KW_IDENTIFIER {$$=new Type(Type::T_OID);}
2066 KW_RELATIVE_OID {$$=new Type(Type::T_ROID);}
2069 ObjectIdentifierValue:
2070 ObjIdComponentList {$$=$1;}
2072 | '{' DefinedValue ObjIdComponentList '}'
2073 --> it must be checked if the ObjIdComponentList's first component
2074 is a DefinedValue to a type OBJECT IDENTIFIER
2079 RelativeOIDComponentList {$$=$1;}
2085 $$=new Value(Value::V_OID);
2086 $$->set_location(asn1_infile, @1.first_line);
2087 $$->add_oid_comp($1);
2089 | ObjIdComponentList ObjIdComponent
2092 $$->add_oid_comp($2);
2094 | ObjIdComponentList error
2098 RelativeOIDComponentList:
2099 RelativeOIDComponent
2101 $$=new Value(Value::V_ROID);
2102 $$->set_location(asn1_infile, @1.first_line);
2103 $$->add_oid_comp($1);
2105 | RelativeOIDComponentList RelativeOIDComponent
2108 $$->add_oid_comp($2);
2110 | RelativeOIDComponentList error
2123 ObjIdComponentNumber {$$=$1;}
2124 | TOK_LowerIdentifier /* NameForm or reference */
2126 $$=new OID_comp($1, 0);
2127 $$->set_location(asn1_infile, @1.first_line);
2131 $$=new OID_comp($1);
2132 $$->set_location(asn1_infile, @1.first_line);
2136 RelativeOIDComponent:
2137 ObjIdComponentNumber {$$=$1;}
2140 $$=new OID_comp($1);
2141 $$->set_location(asn1_infile, @1.first_line);
2145 ObjIdComponentNumber:
2146 NameAndNumberForm {$$=$1;}
2149 $1->set_location(asn1_infile, @1.first_line);
2150 $$=new OID_comp(0, $1);
2151 $$->set_location(asn1_infile, @1.first_line);
2156 DefinitiveNameAndNumberForm {$$=$1;}
2157 | TOK_LowerIdentifier "(" DefinedValue ")"
2159 $$=new OID_comp($1, $3);
2160 $$->set_location(asn1_infile, @1.first_line);
2164 DefinitiveNameAndNumberForm:
2165 TOK_LowerIdentifier "(" Val_Number ")"
2167 $3->set_location(asn1_infile, @3.first_line);
2168 $$=new OID_comp($1, $3);
2169 $$->set_location(asn1_infile, @1.first_line);
2174 KW_EMBEDDED KW_PDV {$$=new Type(Type::T_EMBEDDED_PDV);}
2184 KW_EXTERNAL {$$=new Type(Type::T_EXTERNAL);}
2193 /*********************************************************************
2194 * Character string stuff
2195 *********************************************************************/
2198 CharacterStringType:
2199 RestrictedCharacterStringType {$$=$1;}
2200 | UnrestrictedCharacterStringType {$$=$1;}
2204 CharacterStringValue:
2205 RestrictedCharacterStringValue
2206 | UnrestrictedCharacterStringValue
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;}
2228 {$$=new Type(Type::T_GENERALSTRING);}
2233 {$$=new Type(Type::T_BMPSTRING);}
2238 {$$=new Type(Type::T_GRAPHICSTRING);}
2243 {$$=new Type(Type::T_IA5STRING);}
2248 {$$=new Type(Type::T_NUMERICSTRING);}
2253 {$$=new Type(Type::T_PRINTABLESTRING);}
2258 {$$=new Type(Type::T_TELETEXSTRING);}
2260 {$$=new Type(Type::T_TELETEXSTRING);}
2265 {$$=new Type(Type::T_UNIVERSALSTRING);}
2270 {$$=new Type(Type::T_UTF8STRING);}
2275 {$$=new Type(Type::T_VIDEOTEXSTRING);}
2280 {$$=new Type(Type::T_VISIBLESTRING);}
2282 {$$=new Type(Type::T_VISIBLESTRING);}
2286 RestrictedCharacterStringValue:
2287 TOK_CString {$$=$1;}
2288 | CharacterStringList
2293 CharacterStringList:
2312 $$->set_location(asn1_infile, @1.first_line);
2314 | CharSyms "," CharsDefn
2323 $$->set_location(asn1_infile, @1.first_line);
2343 $$=new CharsDefn($1);
2344 $$->set_location(asn1_infile, @1.first_line);
2348 $$=new CharsDefn($1);
2349 $$->set_location(asn1_infile, @1.first_line);
2353 $$=new CharsDefn($1);
2354 $$->set_location(asn1_infile, @1.first_line);
2359 QuadrupleOrTuple0 {$$=$1;}
2360 | QuadrupleOrTuple0 error {$$=$1;}
2363 $$=new CharsDefn(0, 0, 0, 0);
2364 $$->set_location(asn1_infile, @1.first_line);
2369 TOK_Number "," TOK_Number "," TOK_Number "," TOK_Number
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());
2377 group = $1->get_val();
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());
2384 plane = $3->get_val();
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());
2391 row = $5->get_val();
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());
2398 cell = $7->get_val();
2400 $$=new CharsDefn(group, plane, row, cell);
2401 $$->set_location(asn1_infile, @1.first_line);
2407 | TOK_Number "," TOK_Number
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());
2415 table_column = $1->get_val();
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());
2422 table_row = $3->get_val();
2424 $$=new CharsDefn(table_column, table_row);
2425 $$->set_location(asn1_infile, @1.first_line);
2433 '{' Group ',' Plane ',' Row ',' Cell '}'
2453 '{' TableColumn ',' TableRow '}'
2465 UnrestrictedCharacterStringType:
2466 KW_CHARACTER KW_STRING {$$=new Type(Type::T_UNRESTRICTEDSTRING);}
2470 UnrestrictedCharacterStringValue:
2477 {$$=new Type(Type::T_GENERALIZEDTIME);}
2479 {$$=new Type(Type::T_UTCTIME);}
2480 | KW_ObjectDescriptor
2481 {$$=new Type(Type::T_OBJECTDESCRIPTOR);}
2484 /*********************************************************************
2486 *********************************************************************/
2491 | TypeWithConstraint
2495 SeqOfSetOfWithConstraint:
2496 KW_SET Constraint KW_OF Type
2498 $$=new Type(Type::T_SETOF, $4);
2499 Constraints *cons = new Constraints();
2500 if ($2) cons->add_con($2);
2501 $$->add_constraints(cons);
2503 | KW_SET Constraint KW_OF NamedType
2506 $$=new Type(Type::T_SETOF, $4.type);
2507 Constraints *cons = new Constraints();
2508 if ($2) cons->add_con($2);
2509 $$->add_constraints(cons);
2511 | KW_SET SizeConstraint KW_OF Type
2513 $$=new Type(Type::T_SETOF, $4);
2514 Constraints *cons = new Constraints();
2515 if ($2) cons->add_con($2);
2516 $$->add_constraints(cons);
2518 | KW_SET SizeConstraint KW_OF NamedType
2521 $$=new Type(Type::T_SETOF, $4.type);
2522 Constraints *cons = new Constraints();
2523 if ($2) cons->add_con($2);
2524 $$->add_constraints(cons);
2526 | KW_SEQUENCE Constraint KW_OF Type
2528 $$=new Type(Type::T_SEQOF, $4);
2529 Constraints *cons = new Constraints();
2530 if ($2) cons->add_con($2);
2531 $$->add_constraints(cons);
2533 | KW_SEQUENCE Constraint KW_OF NamedType
2536 $$=new Type(Type::T_SEQOF, $4.type);
2537 Constraints *cons = new Constraints();
2538 if ($2) cons->add_con($2);
2539 $$->add_constraints(cons);
2541 | KW_SEQUENCE SizeConstraint KW_OF Type
2543 $$=new Type(Type::T_SEQOF, $4);
2544 Constraints *cons = new Constraints();
2545 if ($2) cons->add_con($2);
2546 $$->add_constraints(cons);
2548 | KW_SEQUENCE SizeConstraint KW_OF NamedType
2551 $$=new Type(Type::T_SEQOF, $4.type);
2552 Constraints *cons = new Constraints();
2553 if ($2) cons->add_con($2);
2554 $$->add_constraints(cons);
2561 $$ = new Constraints();
2562 if ($1) $$->add_con($1);
2564 | Constraints Constraint
2567 if ($2) $$->add_con($2);
2572 "(" ConstraintSpec ExceptionSpec ")"
2579 $$ = new IgnoredConstraint("invalid constraint");
2585 SubtypeConstraint { $$ = $1; }
2586 | GeneralConstraint { $$ = $1; }
2591 ElementSetSpecs { $$ = $1; }
2596 "!" ExceptionIdentification {$$=$2;}
2597 | /* empty */ {$$=0;}
2602 ExceptionIdentification:
2603 SignedNumber {$$=new ExcSpec(0, $1);}
2604 | DefinedValue {$$=new ExcSpec(0, $1);}
2605 | Type ":" Value {$$=new ExcSpec($1, $3);}
2614 | RootElementSetSpec "," TOK_Ellipsis
2616 $$ = new ElementSetSpecsConstraint($1, NULL);
2617 $$->set_location(asn1_infile, @1.first_line);
2619 | RootElementSetSpec "," TOK_Ellipsis "," AdditionalElementSetSpec
2621 $$ = new ElementSetSpecsConstraint($1, $5);
2622 $$->set_location(asn1_infile, @1.first_line);
2635 AdditionalElementSetSpec:
2647 $2->set_first_operand(new FullSetConstraint());
2649 $$->set_location(asn1_infile, @1.first_line);
2655 Intersections { $$ = $1; }
2656 | UElems UnionMark Intersections
2658 $$ = new SetOperationConstraint($1, SetOperationConstraint::UNION, $3);
2659 $$->set_location(asn1_infile, @1.first_line);
2673 IntersectionElements { $$ = $1; }
2674 | IElems IntersectionMark IntersectionElements
2676 $$ = new SetOperationConstraint($1, SetOperationConstraint::INTERSECTION, $3);
2677 $$->set_location(asn1_infile, @1.first_line);
2690 IntersectionElements:
2691 Elements { $$ = $1; }
2694 $2->set_first_operand($1);
2696 $$->set_location(asn1_infile, @1.first_line);
2712 $$ = new SetOperationConstraint(0, SetOperationConstraint::EXCEPT, $2);
2713 $$->set_location(asn1_infile, @1.first_line);
2731 SubtypeElements { $$ = $1; }
2735 | "(" ElementSetSpec ")"
2743 SingleValue { $$ = $1; }
2744 | ContainedSubtype { $$ = $1; }
2745 | ValueRange { $$ = $1; }
2746 | PermittedAlphabet { $$ = $1; }
2747 | SizeConstraint { $$ = $1; }
2748 | InnerTypeConstraints { $$ = $1; }
2749 | PatternConstraint { $$ = $1; }
2752 /* 47.2.1 page 70 */
2756 $$ = new SingleValueConstraint($1);
2757 $$->set_location(asn1_infile, @1.first_line);
2761 $$ = new SingleValueConstraint($1);
2762 $$->set_location(asn1_infile, @1.first_line);
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);
2772 | ReferencedValue_reg
2774 $$ = new SingleValueConstraint($1);
2775 $$->set_location(asn1_infile, @1.first_line);
2780 TypeConstraint (47.6.1 page 72) has been removed because it's conflicting
2781 with second option of ContainedSubtype rule */
2785 $$ = new ContainedSubtypeConstraint($2, true);
2786 $$->set_location(asn1_infile, @1.first_line);
2790 $$ = new ContainedSubtypeConstraint($1, false);
2791 $$->set_location(asn1_infile, @1.first_line);
2795 /* 47.4.1 page 71 */
2797 LowerEndpoint TOK_RangeSeparator UpperEndpoint
2799 $$ = new ValueRangeConstraint($1,$3);
2800 $$->set_location(asn1_infile, @1.first_line);
2812 $$->set_exclusive();
2824 $$->set_exclusive();
2831 $$ = new RangeEndpoint($1);
2832 $$->set_location(asn1_infile, @1.first_line);
2836 $$ = new RangeEndpoint(RangeEndpoint::MIN);
2837 $$->set_location(asn1_infile, @1.first_line);
2844 $$ = new RangeEndpoint($1);
2845 $$->set_location(asn1_infile, @1.first_line);
2849 $$ = new RangeEndpoint(RangeEndpoint::MAX);
2850 $$->set_location(asn1_infile, @1.first_line);
2854 /* 47.5.1 page 71 */
2858 $$ = new SizeConstraint($2);
2859 $$->set_location(asn1_infile, @1.first_line);
2863 /* 47.7.1 page 72 */
2867 $$ = new PermittedAlphabetConstraint($2);
2868 $$->set_location(asn1_infile, @1.first_line);
2872 /* 47.8.1 page 72 */
2873 InnerTypeConstraints:
2874 KW_WITH KW_COMPONENT SingleTypeConstraint
2877 $$->set_location(asn1_infile, @1.first_line);
2879 | KW_WITH KW_COMPONENTS TOK_Block
2881 $$ = new UnparsedMultipleInnerTypeConstraint($3);
2882 $$->set_location(asn1_infile, @1.first_line);
2886 /* 47.8.3 page 72 */
2887 SingleTypeConstraint:
2890 $$ = new SingleInnerTypeConstraint($1);
2891 $$->set_location(asn1_infile, @1.first_line);
2895 /* 47.8.4 page 72 */
2896 MultipleTypeConstraints:
2900 $$->set_partial(false);
2901 $$->set_location(asn1_infile, @1.first_line);
2903 | TOK_Ellipsis "," TypeConstraints
2906 $$->set_partial(true);
2907 $$->set_location(asn1_infile, @1.first_line);
2914 $$ = new MultipleInnerTypeConstraint();
2915 $$->addNamedConstraint($1);
2917 | TypeConstraints "," NamedConstraint
2920 $$->addNamedConstraint($3);
2922 | error NamedConstraint
2924 $$ = new MultipleInnerTypeConstraint();
2925 $$->addNamedConstraint($2);
2927 | TypeConstraints error
2934 TOK_LowerIdentifier ValueConstraint PresenceConstraint
2936 $$ = new NamedConstraint($1, $2, $3);
2937 $$->set_location(asn1_infile, @1.first_line);
2953 KW_PRESENT { $$ = NamedConstraint::PC_PRESENT; }
2954 | KW_ABSENT { $$ = NamedConstraint::PC_ABSENT; }
2955 | KW_OPTIONAL { $$ = NamedConstraint::PC_OPTIONAL; }
2956 | /* empty */ { $$ = NamedConstraint::PC_NONE; }
2959 /* 47.9.1 page 73 */
2963 $$ = new PatternConstraint($2);
2964 $$->set_location(asn1_infile, @1.first_line);
2968 /* X.682 clause 8.1 */
2970 UserDefinedConstraint
2972 $$ = new IgnoredConstraint("user defined constraint");
2973 $$->set_location(asn1_infile, @1.first_line);
2979 | ContentsConstraint /* TODO? */
2981 $$ = new IgnoredConstraint("content constraint");
2982 $$->set_location(asn1_infile, @1.first_line);
2986 /* X.682 clause 9.1 */
2987 UserDefinedConstraint:
2988 KW_CONSTRAINED KW_BY TOK_Block {delete $3;}
2991 /* X.682 clause 11.1 */
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;}
2998 /* X.682 clause 10.3 */
3000 /* SimpleTableConstraint
3002 ComponentRelationConstraint { $$ = $1; }
3005 /* commented out to eliminate reduce/reduce conflicts:
3006 SimpleTableConstraint containing TOK_Block is reachable by path
3007 Constraint->SubtypeConstraint->...->SingleValue->Value->TOK_Block
3009 SimpleTableConstraint:
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);}
3020 DefinedObjectSetBlock:
3021 RefdUpper {$$=new OS_refd($1);}
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;}
3032 // No `BIGNUM' for Levels.
3033 "@" Levels ComponentIdList {$$=new AtNotation($2, $3);}
3043 | TOK_RangeSeparator {$$=2;} /* ".." */
3044 | TOK_Ellipsis {$$=3;} /* "..." */
3045 | Level "." {$$=$1+1;}
3046 | Level TOK_RangeSeparator {$$=$1+2;}
3047 | Level TOK_Ellipsis {$$=$1+3;}
3051 TOK_LowerIdentifier {$$=new FieldName(); $$->add_field($1);}
3052 | ComponentIdList "." TOK_LowerIdentifier {$$=$1; $$->add_field($3);}
3056 /*********************************************************************
3058 *********************************************************************/
3061 // DefinedObjectClass {$$=$1;}
3062 //| ObjectClassDefn {$$=$1;}
3064 //| ParameterizedObjectClass
3068 //DefinedObjectClass:
3071 // $$=new OC_refd($1);
3072 // $$->set_location(asn1_infile, @1.first_line);
3077 UsefulObjectClassReference:
3079 | KW_ABSTRACT_SYNTAX
3083 /* X.681 clause 9.3 */
3085 KW_CLASS TOK_Block WithSyntaxSpec_opt
3087 $$=new OC_defn($2, $3);
3088 $$->set_location(asn1_infile, @1.first_line);
3095 $$=new FieldSpecs(); $$->add_fs($1);
3096 $1->set_location(asn1_infile, @1.first_line);
3098 | FieldSpecList "," FieldSpec
3100 $$=$1; $$->add_fs($3);
3101 $3->set_location(asn1_infile, @3.first_line);
3105 $$=new FieldSpecs(); $$->add_fs($2);
3106 $2->set_location(asn1_infile, @2.first_line);
3108 | FieldSpecList error
3112 /* X.681 clause 9.4 */
3113 /** \todo add support for ValueSet and VariableType FieldSpecs
3114 * (new AST nodes are required) */
3116 TypeFieldSpec {$$=$1;}
3117 | FixedTypeValueFieldSpec {$$=$1;}
3119 | VariableTypeValueFieldSpec {$$=$1;}
3120 | FixedTypeValueSetFieldSpec {$$=$1;}
3121 | VariableTypeValueSetFieldSpec {$$=$1;}
3122 | ObjectFieldSpec {$$=$1;}
3123 | ObjectSetFieldSpec {$$=$1;}
3125 | UndefFieldSpec {$$=$1;}
3129 KW_UNIQUE {$$=true;}
3130 | /* empty */ {$$=false;}
3134 KW_DEFAULT Type {$$=$2;}
3138 KW_DEFAULT Value {$$=$2;}
3142 KW_DEFAULT Value_reg {$$=$2;}
3146 KW_DEFAULT NullValue {$$=$2;}
3150 KW_DEFAULT TOK_Block {$$=$2;}
3154 KW_DEFAULT RefdLower {$$=$2;}
3158 KW_DEFAULT RefdLower_reg {$$=$2;}
3162 KW_DEFAULT TOK_LowerIdentifier {$$=$2;}
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);}
3174 FixedTypeValueFieldSpec:
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);}
3184 | TOK_ampLowerIdentifier UpperFromObj UNIQ_opt
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);
3190 | TOK_ampLowerIdentifier UpperFromObj UNIQ_opt KW_OPTIONAL
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);
3196 | TOK_ampLowerIdentifier UpperFromObj UNIQ_opt Dflt_Value
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);
3204 | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE
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);
3210 | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE KW_OPTIONAL
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);
3217 | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_Value_reg
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);
3223 | TOK_ampLowerIdentifier SimplDefdUpper Dflt_Value_reg
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);
3229 | TOK_ampLowerIdentifier PardUpper Dflt_Value_reg
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);
3237 | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_NullValue
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);
3243 | TOK_ampLowerIdentifier SimplDefdUpper Dflt_NullValue
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);
3249 | TOK_ampLowerIdentifier PardUpper Dflt_NullValue
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);
3257 | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_Block
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);
3267 | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_LowerId
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);
3277 | TOK_ampLowerIdentifier DefdUpper KW_UNIQUE Dflt_RefdLower_reg
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);
3287 | TOK_ampLowerIdentifier PardUpper
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);
3293 | TOK_ampLowerIdentifier PardUpper KW_OPTIONAL
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);
3299 | TOK_ampLowerIdentifier PardUpper Dflt_Block
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);
3307 | TOK_ampLowerIdentifier PardUpper Dflt_LowerId
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);
3315 | TOK_ampLowerIdentifier PardUpper Dflt_RefdLower_reg
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);
3324 /* ObjectClassFieldType */
3325 /* UpperFromObjs szetbombazva */
3326 | TOK_ampLowerIdentifier PardUpper_FromObjs UNIQ_opt
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);
3332 /* SimplUpper_FromObjs szetbombazva */
3333 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameLower UNIQ_opt
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);
3341 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUpper UNIQ_opt
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);
3349 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUppers UNIQ_opt
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);
3357 /* UpperFromObjs szetbombazva */
3358 | TOK_ampLowerIdentifier PardUpper_FromObjs UNIQ_opt KW_OPTIONAL
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);
3364 /* SimplUpper_FromObjs szetbombazva */
3365 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameLower UNIQ_opt KW_OPTIONAL
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);
3373 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUpper UNIQ_opt KW_OPTIONAL
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);
3381 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUppers UNIQ_opt
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);
3390 /* UpperFromObjs szetbombazva */
3391 | TOK_ampLowerIdentifier PardUpper_FromObjs UNIQ_opt Dflt_Value
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);
3397 /* SimplUpper_FromObjs szetbombazva */
3398 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameLower UNIQ_opt Dflt_Value
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);
3406 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUpper UNIQ_opt Dflt_Value
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);
3414 | TOK_ampLowerIdentifier SimplDefdUpper "." FieldNameUppers UNIQ_opt Dflt_Value
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);
3424 /** \todo PardUpper as governor can be either Type or OC reference
3425 * the respective rules of FixedTypeValueFieldSpec should be moved here */
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);}
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);}
3446 VariableTypeValueFieldSpec:
3447 TOK_ampLowerIdentifier FieldName {}
3450 FixedTypeValueSetFieldSpec:
3451 TOK_ampUpperIdentifier Type ValueSetOptionalitySpec {}
3454 ValueSetOptionalitySpec:
3456 | KW_DEFAULT ValueSet {}
3460 VariableTypeValueSetFieldSpec:
3461 TOK_ampUpperIdentifier FieldName ValueSetOptionalitySpec {}
3465 TOK_ampLowerIdentifier DefinedObjectClass ObjectOptionalitySpec {}
3468 ObjectOptionalitySpec:
3470 | KW_DEFAULT Object {}
3475 TOK_ampUpperIdentifier DefinedObjectClass ObjectSetOptionalitySpec {}
3478 ObjectSetOptionalitySpec:
3480 | KW_DEFAULT ObjectSet {}
3486 KW_WITH KW_SYNTAX TOK_Block {$$=$3;}
3487 | /* empty */ {$$=0;}
3491 DefinedObject {$$=$1;}
3492 | ObjectDefn {$$=$1;}
3495 | ParameterizedObject
3502 $$=new Obj_refd($1);
3503 $$->set_location(asn1_infile, @1.first_line);
3510 $$=new Obj_defn($1);
3511 $$->set_location(asn1_infile, @1.first_line);
3519 $$->set_location(asn1_infile, @1.first_line);
3527 OS_refd *os_refd=new OS_refd($1);
3528 os_refd->set_location(asn1_infile, @1.first_line);
3534 ObjectSetSpec0 {$$=$1;}
3535 | ObjectSetSpec0 "," TOK_Ellipsis {$$=$1;}
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);}
3544 this is a temporary solution. only unions are supported
3545 (intersections, and except are not...)
3551 $$->set_location(asn1_infile, @1.first_line);
3554 | ObjectSetSpec0 UnionMark ObjectSetElements {$$=$1; $$->add_ose($3);}
3555 | error ObjectSetElements
3558 $$->set_location(asn1_infile, @2.first_line);
3561 | ObjectSetSpec0 error {$$=$1;}
3564 /*********************************************************************
3566 *********************************************************************/
3570 RefdUpper {$$=new Type(Type::T_REFD, $1);}
3572 includes TypeFromObject, ValueSetFromObjects and DefinedType
3575 | SelectionType {$$=$1;}
3580 // DefdUpper {$$=new Type_refd($1);}
3582 //| ParameterizedType
3583 //| ParameterizedValueSetType
3587 /*********************************************************************
3589 *********************************************************************/
3593 ObjectClassFieldValue
3594 {$$=$1; $$->set_location(asn1_infile, @1.first_line);}
3598 ObjectClassFieldValue_reg
3599 {$$=$1; $$->set_location(asn1_infile, @1.first_line);}
3602 ObjectClassFieldValue:
3603 FixedTypeFieldValue {$$=$1;}
3605 | OpenTypeFieldValue
3609 ObjectClassFieldValue_reg:
3610 FixedTypeFieldValue_reg {$$=$1;}
3612 | OpenTypeFieldValue
3616 FixedTypeFieldValue:
3617 BuiltinValue {$$=$1;}
3618 | ReferencedValue_reg {$$=$1;}
3621 FixedTypeFieldValue_reg:
3622 BuiltinValue_reg {$$=$1;}
3628 $$=new Value(Value::V_REFD, $1);
3629 $$->set_location(asn1_infile, @1.first_line);
3636 ReferencedValue_reg:
3639 $$=new Value(Value::V_REFD, $1);
3640 $$->set_location(asn1_infile, @1.first_line);
3650 $$=new Value(Value::V_REFD, $1);
3651 $$->set_location(asn1_infile, @1.first_line);
3658 $$=new Value(Value::V_REFD, $1);
3659 $$->set_location(asn1_infile, @1.first_line);
3662 | ParameterizedValue
3667 TOK_Number {$$=new Value(Value::V_INT, $1);}
3671 TOK_CString {$$=new Value(Value::V_CSTR, $1);}
3674 /*********************************************************************
3676 *********************************************************************/
3679 TOK_LowerIdentifier Type
3687 TOK_LowerIdentifier Value
3689 $$=new NamedValue($1, $2);
3690 $$->set_location(asn1_infile, @1.first_line);
3694 /*********************************************************************
3696 *********************************************************************/
3700 PrimitiveFieldNameList {}
3703 PrimitiveFieldNameList:
3704 PrimitiveFieldName {}
3705 | PrimitiveFieldNameList "." PrimitiveFieldName {}
3709 TOK_ampUpperIdentifier {}
3710 | TOK_ampLowerIdentifier {}
3715 TOK_ampLowerIdentifier {$$=new FieldName(); $$->add_field($1);}
3716 | FieldNameLower "." TOK_ampLowerIdentifier {$$=$1; $$->add_field($3);}
3720 TOK_ampUpperIdentifier {$$=new FieldName(); $$->add_field($1);}
3721 | FieldNameLower "." TOK_ampUpperIdentifier {$$=$1; $$->add_field($3);}
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);}
3731 /*********************************************************************
3732 * Referenced upper stuff
3733 *********************************************************************/
3737 | UpperFromObj {$$=$1;}
3742 DefdLower "." FieldNameUpper
3744 $$=new FromObj($1, $3);
3745 $$->set_location(asn1_infile, @1.first_line);
3750 Upper_FromObjs {$$=$1;}
3751 | Lower_FromObjs {$$=$1;}
3756 DefdUpper "." FieldNameLower
3758 $$=new FromObj($1, $3);
3759 $$->set_location(asn1_infile, @1.first_line);
3761 | DefdUpper "." FieldNameUpper
3763 $$=new FromObj($1, $3);
3764 $$->set_location(asn1_infile, @1.first_line);
3766 | DefdUpper "." FieldNameUppers
3768 $$=new FromObj($1, $3);
3769 $$->set_location(asn1_infile, @1.first_line);
3775 SimplUpper_FromObjs {$$=$1;}
3776 | PardUpper_FromObjs {$$=$1;}
3779 SimplUpper_FromObjs:
3780 SimplDefdUpper "." FieldNameLower
3782 $$=new FromObj($1, $3);
3783 $$->set_location(asn1_infile, @1.first_line);
3785 | SimplDefdUpper "." FieldNameUpper
3787 $$=new FromObj($1, $3);
3788 $$->set_location(asn1_infile, @1.first_line);
3790 | SimplDefdUpper "." FieldNameUppers
3792 $$=new FromObj($1, $3);
3793 $$->set_location(asn1_infile, @1.first_line);
3798 PardUpper "." FieldNameLower
3800 $$=new FromObj($1, $3);
3801 $$->set_location(asn1_infile, @1.first_line);
3803 | PardUpper "." FieldNameUpper
3805 $$=new FromObj($1, $3);
3806 $$->set_location(asn1_infile, @1.first_line);
3808 | PardUpper "." FieldNameUppers
3810 $$=new FromObj($1, $3);
3811 $$->set_location(asn1_infile, @1.first_line);
3816 DefdLower "." FieldNameUppers
3818 $$=new FromObj($1, $3);
3819 $$->set_location(asn1_infile, @1.first_line);
3824 SimplDefdUpper {$$=$1;}
3825 | PardUpper {$$=$1;}
3829 SimplDefdUpper TOK_Block
3831 $$=new Ref_pard($1, $2);
3832 $$->set_location(asn1_infile, @1.first_line);
3837 ExtUpperRef {$$=$1;}
3842 TOK_UpperIdentifier "." TOK_UpperIdentifier
3844 $$=new Ref_defd_simple($1, $3);
3845 $$->set_location(asn1_infile, @1.first_line);
3852 $$=new Ref_defd_simple(0, $1);
3853 $$->set_location(asn1_infile, @1.first_line);
3857 /*********************************************************************
3858 * Referenced lower stuff
3859 *********************************************************************/
3862 DefdLower_reg {$$=$1;}
3863 | LowerFromObj {$$=$1;}
3868 | LowerFromObj {$$=$1;}
3872 DefdLower "." FieldNameLower
3874 $$=new FromObj($1, $3);
3875 $$->set_location(asn1_infile, @1.first_line);
3880 SimplDefdLower_reg {$$=$1;}
3881 | PardLower {$$=$1;}
3885 SimplDefdLower {$$=$1;}
3886 | PardLower {$$=$1;}
3890 SimplDefdLower TOK_Block
3892 $$=new Ref_pard($1, $2);
3893 $$->set_location(asn1_infile, @1.first_line);
3898 ExtLowerRef {$$=$1;}
3902 ExtLowerRef {$$=$1;}
3907 TOK_UpperIdentifier "." TOK_LowerIdentifier
3909 $$=new Ref_defd_simple($1, $3);
3910 $$->set_location(asn1_infile, @1.first_line);
3917 $$=new Ref_defd_simple(0, $1);
3918 $$->set_location(asn1_infile, @1.first_line);
3924 /*********************************************************************
3926 *********************************************************************/
3928 int asn1_parse_file(const char* filename, boolean generate_code)
3930 asn1_yy_parse_internal=false;
3932 asn1la_newfile(filename);
3933 yyin=fopen(filename, "r");
3935 ERROR("Cannot open input file `%s': %s",
3936 filename, strerror(errno));
3939 yy_buffer_state *flex_buffer = asn1_yy_create_buffer(yyin, YY_BUF_SIZE);
3940 asn1_yy_switch_to_buffer(flex_buffer);
3942 NOTIFY("Parsing ASN.1 module `%s'...", filename);
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);
3956 * This functions is used to parse internal stuff. :)
3958 int asn1_parse_string(const char* p_str)
3960 unsigned verb_level_backup=verb_level;
3961 verb_level=0; // be vewy, vewy quiet
3962 asn1la_newfile("<internal>");
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;
3971 int retval=yyparse();
3972 asn1_yylex_destroy();
3973 verb_level=verb_level_backup;