📄 asn_grammar.y
字号:
DefinedType : ExternalTypeReference { $$ = new DefinedType($1, FALSE); } | TYPEREFERENCE { $$ = new DefinedType($1, DummyParameters != NULL && DummyParameters->GetValuesIndex(*$1) != P_MAX_INDEX); } | ParameterizedType/*| ParameterizedValueSetType synonym for ParameterizedType */ ;ExternalTypeReference : MODULEREFERENCE '.' TYPEREFERENCE { *$1 += *$3; delete $3; } ;BitStringType : BIT STRING { $$ = new BitStringType; } | BIT STRING '{' NamedBitList '}' { $$ = new BitStringType($4); } ;NamedBitList : NamedBit { $$ = new NamedNumberList; $$->Append($1); } | NamedBitList ',' NamedBit { $1->InsertAt(0, $3); } ;NamedBit : IDENTIFIER '(' INTEGER ')' { $$ = new NamedNumber($1, (int)$3); } | IDENTIFIER '(' DefinedValue ')' { $$ = new NamedNumber($1, ((DefinedValue*)$3)->GetReference()); delete $3; } ;BooleanType : BOOLEAN_t { $$ = new BooleanType; } ;CharacterStringType : RestrictedCharacterStringType | UnrestrictedCharacterStringType ;RestrictedCharacterStringType : BMPString { $$ = new BMPStringType; } | GeneralString { $$ = new GeneralStringType; } | GraphicString { $$ = new GraphicStringType; } | IA5String { $$ = new IA5StringType; } | ISO646String { $$ = new ISO646StringType; } | NumericString { $$ = new NumericStringType; } | PrintableString { $$ = new PrintableStringType; } | TeletexString { $$ = new TeletexStringType; } | T61String { $$ = new T61StringType; } | UniversalString { $$ = new UniversalStringType; } | VideotexString { $$ = new VideotexStringType; } | VisibleString { $$ = new VisibleStringType; } ;UnrestrictedCharacterStringType : CHARACTER STRING { $$ = new UnrestrictedCharacterStringType; } ;ChoiceType : CHOICE '{' AlternativeTypeLists '}' { $$ = $3; } ;AlternativeTypeLists : AlternativeTypeList { $$ = new ChoiceType($1); } | AlternativeTypeList ',' ExtensionAndException { $$ = new ChoiceType($1, TRUE); } | AlternativeTypeList ',' ExtensionAndException ',' AlternativeTypeList { $$ = new ChoiceType($1, TRUE, $5); } ;AlternativeTypeList : NamedType { $$ = new TypesList; $$->Append($1); } | AlternativeTypeList ',' NamedType { $1->Append($3); } ;ExtensionAndException : '.' '.' '.' ExceptionSpec ;NamedType : IDENTIFIER Type { $2->SetName($1); $$ = $2; } | Type /* ITU-T Rec. X.680 Appendix H.1 */ { PError << StdError(Warning) << "unnamed field." << endl; $1->SetName(new PString(PString::Printf, "_unnamed%u", UnnamedFieldCount++)); }/*| SelectionType /* Unnecessary as have rule in Type for this */ ;EmbeddedPDVType : EMBEDDED PDV { $$ = new EmbeddedPDVType; } ;EnumeratedType : ENUMERATED '{' Enumerations '}' { $$ = $3; } ;Enumerations : Enumeration { $$ = new EnumeratedType($1, FALSE, NULL); } | Enumeration ',' '.' '.' '.' { $$ = new EnumeratedType($1, TRUE, NULL); } | Enumeration ',' '.' '.' '.' ',' Enumeration { $$ = new EnumeratedType($1, TRUE, $7); } ;Enumeration : EnumerationItem { $$ = new NamedNumberList; $$->Append($1); } | Enumeration ',' EnumerationItem { $1->Append($3); PINDEX sz = $1->GetSize(); if (sz > 1) $3->SetAutoNumber((*$1)[sz-2]); $$ = $1; } ;EnumerationItem : IDENTIFIER { $$ = new NamedNumber($1); } | NamedNumber ;ExternalType : EXTERNAL { $$ = new ExternalType; } ;AnyType : ANY { $$ = new AnyType(NULL); } | ANY DEFINED BY IDENTIFIER { $$ = new AnyType($4); } ;InstanceOfType : INSTANCE OF_t DefinedObjectClass ;IntegerType : INTEGER_t { $$ = new IntegerType; } | INTEGER_t '{' NamedNumberList '}' { $$ = new IntegerType($3); } ;NullType : NULL_TYPE { $$ = new NullType; } ;ObjectClassFieldType : DefinedObjectClass '.' FieldName { $$ = new ObjectClassFieldType($1, $3); } ;ObjectIdentifierType : OBJECT IDENTIFIER_t { $$ = new ObjectIdentifierType; } ;OctetStringType : OCTET STRING { $$ = new OctetStringType; } ;RealType : REAL { $$ = new RealType; } ;SequenceType : SEQUENCE '{' ComponentTypeLists '}' { $$ = $3; } | SEQUENCE '{' '}' { $$ = new SequenceType(NULL, FALSE, NULL); } | SEQUENCE '{' ExtensionAndException '}' { $$ = new SequenceType(NULL, TRUE, NULL); } ;ComponentTypeLists : ComponentTypeList { $$ = new SequenceType($1, FALSE, NULL); } | ComponentTypeList ',' ExtensionAndException { $$ = new SequenceType($1, TRUE, NULL); } | ComponentTypeList ',' ExtensionAndException ',' ComponentTypeList { $$ = new SequenceType($1, TRUE, $5); } | ExtensionAndException ',' ComponentTypeList { $$ = new SequenceType(NULL, TRUE, $3); } ;ComponentTypeList : ComponentType { $$ = new TypesList; $$->Append($1); } | ComponentTypeList ',' ComponentType { $1->Append($3); } ;ComponentType : NamedType | NamedType OPTIONAL_t { $1->SetOptional(); } | NamedType DEFAULT { IdentifierTokenContext = $1->GetIdentifierTokenContext(); } Value { IdentifierTokenContext = IDENTIFIER; $1->SetDefaultValue($4); } | COMPONENTS OF_t Type { $$ = $3; } ;SequenceOfType : SEQUENCE OF_t Type { $$ = new SequenceOfType($3, NULL); } ;SetType : SET '{' ComponentTypeLists '}' { $$ = new SetType((SequenceType*)$3); } | SET '{' '}' { $$ = new SetType; } ;SetOfType : SET OF_t Type { $$ = new SetOfType($3, NULL); } ;TaggedType : Tag Type { $2->SetTag($1.tagClass, $1.tagNumber, Module->GetDefaultTagMode()); $$ = $2; } | Tag IMPLICIT Type { $3->SetTag($1.tagClass, $1.tagNumber, Tag::Implicit); $$ = $3; } | Tag EXPLICIT Type { $3->SetTag($1.tagClass, $1.tagNumber, Tag::Explicit); $$ = $3; } ;Tag : '[' Class ClassNumber ']' { $$.tagClass = (Tag::Type)$2; $$.tagNumber = (int)$3; } ;ClassNumber : INTEGER | DefinedValue { if (PIsDescendant($1, IntegerValue)) $$ = *(IntegerValue*)$1; else PError << StdError(Fatal) << "incorrect value type." << endl; } ;Class : UNIVERSAL { $$ = Tag::Universal; } | APPLICATION { $$ = Tag::Application; } | PRIVATE { $$ = Tag::Private; } | /* empty */ { $$ = Tag::ContextSpecific; } ;SelectionType : IDENTIFIER '<' Type { $$ = new SelectionType($1, $3); } ;UsefulType : GeneralizedTime { $$ = new GeneralizedTimeType; } | UTCTime { $$ = new UTCTimeType; } | ObjectDescriptor_t { $$ = new ObjectDescriptorType; } ;TypeFromObject : ReferencedObjects '.' FieldName { } ;/*!!!ValueSetFromObjects : ReferencedObjects '.' FieldName ;*/ReferencedObjects : DefinedObject | ParameterizedObject | DefinedObjectSet { } | ParameterizedObjectSet { } ;ParameterizedObject : DefinedObject ActualParameterList ;/********/ConstrainedType : Type Constraint { $1->AddConstraint($2); } | TypeWithConstraint ;TypeWithConstraint : SET Constraint OF_t Type { $$ = new SetOfType($4, $2); } | SET SizeConstraint OF_t Type { $$ = new SetOfType($4, new Constraint($2)); } | SEQUENCE Constraint OF_t Type { $$ = new SequenceOfType($4, $2); } | SEQUENCE SizeConstraint OF_t Type { $$ = new SequenceOfType($4, new Constraint($2)); } ;Constraint : '(' ConstraintSpec ExceptionSpec ')' { $$ = $2; } ;ConstraintSpec : ElementSetSpecs | GeneralConstraint ;ExceptionSpec : '!' ExceptionIdentification { $$ = $2; } | /* empty */ { $$ = NULL; } ;ExceptionIdentification : SignedNumber { $$ = new IntegerValue($1); } | DefinedValue | Type ':' Value { delete $1; PError << StdError(Warning) << "Typed exception unsupported" << endl; $$ = $3; } ;ElementSetSpecs : ElementSetSpec { $$ = new Constraint($1, FALSE, NULL); } | ElementSetSpec ',' '.' '.' '.' { $$ = new Constraint($1, TRUE, NULL); } | '.' '.' '.' ',' ElementSetSpec { $$ = new Constraint(NULL, TRUE, $5); } | ElementSetSpec ',' '.' '.' '.' ElementSetSpec { $$ = new Constraint($1, TRUE, $6); } ;ElementSetSpec : Unions | ALL Exclusions { $$ = new ConstraintElementList; $$->Append(new ConstrainAllConstraintElement($2)); } ;Unions : Intersections { $$ = new ConstraintElementList; $$->Append(new ElementListConstraintElement($1)); } | Unions UnionMark Intersections { $1->Append(new ElementListConstraintElement($3)); } ;Intersections : IntersectionElements { $$ = new ConstraintElementList; $$->Append($1); } | Intersections IntersectionMark IntersectionElements { $1->Append($3); } ;IntersectionElements : Elements | Elements Exclusions { $1->SetExclusions($2); } ;Exclusions : EXCEPT Elements { $$ = $2; } ;UnionMark : '|' | UNION ;IntersectionMark : '^' | INTERSECTION ;Elements : SubtypeElements | ObjectSetElements | '(' ElementSetSpec ')' { $$ = new ElementListConstraintElement($2); } ;SubtypeElements : Value { $$ = new SingleValueConstraintElement($1); } | ContainedSubtype { $$ = new SubTypeConstraintElement($1); } | ValueRange | PermittedAlphabet | SizeConstraint/*| TypeConstraint This is really Type and causes ambiguity with ContainedSubtype */ | InnerTypeConstraints ;ValueRange : LowerEndpoint '.' '.' UpperEndpoint { $$ = new ValueRangeConstraintElement($1, $4); } ;LowerEndpoint : LowerEndValue | LowerEndValue '<' ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -