📄 asn_ref_grammar.y
字号:
%expect 12%{/* * asn_ref_grammer.y * * ASN grammar file for typereference, objectclassreference, valuereference, ... * * Copyright (c) 2001 Institute for Information Industry * (http://www.iii.org.tw/iiia/ewelcome.htm) * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is ASN Parser. * * The Initial Developer of the Original Code is Institute for Information Industry * * Contributor(s): ___________________. * * $Log: asn_ref_grammar.y,v $ * Revision 1.3 2002/07/02 02:03:25 mangelo * Remove Pwlib dependency * * Revision 1.2 2001/09/07 22:38:28 mangelo * add Log keyword substitution * * */#undef malloc#undef calloc#undef realloc#undef free#include "main.h"extern int idlex();typedef std::vector<std::string> StringList;#ifdef _MSC_VER#pragma warning(disable:4701)#define MSDOS#endif#define VALUEREFERENCE (TYPEREFERENCE+2)#define OBJECTREFERENCE (TYPEREFERENCE+3)#define OBJECTSETREFERENCE (TYPEREFERENCE+4)#define PARAMETERIZEDTYPEREFERENCE (TYPEREFERENCE+5)#define PARAMETERIZEDOBJECTCLASSREFERENCE (TYPEREFERENCE+6)#define PARAMETERIZEDVALUEREFERENCE (TYPEREFERENCE+7)#define PARAMETERIZEDOBJECTREFERENCE (TYPEREFERENCE+8)#define PARAMETERIZEDOBJECTSETREFERENCE (TYPEREFERENCE+9)#define VALUESET_BRACE (TYPEREFERENCE+10)#define OBJECT_BRACE (TYPEREFERENCE+11)#define OBJECTSET_BRACE (TYPEREFERENCE+12)%}%token MODULEREFERENCE %token TYPEREFERENCE %token OBJECTCLASSREFERENCE %token IDENTIFIER%token WOULDBE_OBJECTCLASSREFERENCE%token FIELDREFERENCE%token INTEGER%token CSTRING%token BSTRING%token HSTRING%token ABSENT %token ABSTRACT_SYNTAX %token ALL %token ANY%token APPLICATION %token ASSIGNMENT%token AUTOMATIC %token BEGIN_t%token BIT %token BMPString%token BOOLEAN_t%token BY%token CHARACTER %token CHOICE %token CLASS %token COMPONENT %token COMPONENTS %token CONSTRAINED %token DEFAULT %token DEFINED%token DEFINITIONS %token EMBEDDED %token END%token ENUMERATED %token EXCEPT %token EXPLICIT %token EXPORTS %token EXTERNAL %token FALSE_t %token FROM %token GeneralString %token GraphicString %token IA5String %token TYPE_IDENTIFIER %token IDENTIFIER_t%token IMPLICIT %token IMPORTS %token INCLUDES %token INSTANCE %token INTEGER_t %token INTERSECTION %token ISO646String%token MACRO%token MAX %token MIN %token MINUS_INFINITY%token NOTATION%token NULL_t%token NumericString %token OBJECT %token OCTET %token OF_t %token OPTIONAL_t%token PDV %token PLUS_INFINITY %token PRESENT %token PrintableString %token PRIVATE %token REAL %token SEQUENCE %token SET %token SIZE_t %token STRING %token SYNTAX %token T61String %token TAGS %token TeletexString %token TRUE_t%token TYPE_t%token UNION %token UNIQUE %token UNIVERSAL %token UniversalString %token VideotexString %token VisibleString %token GeneralizedTime%token UTCTime%token VALUE%token WITH%token ObjectDescriptor_t%type <ival> INTEGER%type <ival> TagDefault%type <sval> IDENTIFIER%type <sval> MODULEREFERENCE%type <sval> TYPEREFERENCE%type <sval> TypeReference%type <sval> OBJECTCLASSREFERENCE%type <sval> WOULDBE_OBJECTCLASSREFERENCE%type <sval> FIELDREFERENCE%type <sval> GlobalModuleReference%type <sval> Reference%type <sval> FieldName%type <sval> Symbol%type <sval> ParameterizedReference%type <sval> ParameterizedTypeReference%type <sval> ParameterizedWouldbeObjectClassReference%type <sval> ParameterizedIdentifier%type <slst> SymbolList%union { boost::int64_t ival; std::string * sval; StringList * slst; struct { Tag::Type tagClass; unsigned tagNumber; } tagv;}%%ModuleDefinitionList : ModuleDefinitionList ModuleDefinition { } | ModuleDefinition { }ModuleDefinition : TypeReference '{' '}' DEFINITIONS TagDefault ASSIGNMENT BEGIN_t { Module = new ModuleDefinition(*$1, (Tag::Mode)$5); Modules.push_back(ModuleDefinitionPtr(Module)); delete $1; } ModuleBody END { Module = NULL; } | TypeReference DEFINITIONS TagDefault ASSIGNMENT BEGIN_t { Module = new ModuleDefinition(*$1, (Tag::Mode)$3); Modules.push_back(ModuleDefinitionPtr(Module)); delete $1; } ModuleBody END { Module = NULL; } ;TagDefault : EXPLICIT TAGS { $$ = Tag::Explicit; } | IMPLICIT TAGS { $$ = Tag::Implicit; } | AUTOMATIC TAGS { $$ = Tag::Automatic; } | /* empty */ { $$ = Tag::Explicit; } ;/*************************************/ModuleBody : Exports Imports AssignmentList | /* empty */ ;Exports : EXPORTS SymbolsExported ';' | /* empty */ ;SymbolsExported : SymbolList { } | /* empty */ { } ;Imports : IMPORTS SymbolsImported ';' | /* empty */ ;SymbolsImported : SymbolsFromModuleList | /* empty */ ;SymbolsFromModuleList : SymbolsFromModule | SymbolsFromModuleList SymbolsFromModule ;SymbolsFromModule : SymbolList FROM GlobalModuleReference { Module->AddImportedIdentifiers(*$1, *$3); delete $1; delete $3; } ;GlobalModuleReference : TypeReference AssignedIdentifier { $$ = $1; } ;AssignedIdentifier : DefinedValue | ObjectIdentifierValue | /* empty */ ;SymbolList : Symbol { $$ = new StringList; $$->push_back(*$1); delete $1; } | Symbol ',' SymbolList { $3->push_back(*$1); delete $1; $$ = $3; } ;Symbol : Reference | ParameterizedReference ;ParameterizedReference : Reference '{' '}' { *$1 += "{}"; $$ = $1; } ;/*************************************/AssignmentList: Assignment | AssignmentList Assignment ;Assignment : TypeAssignment | ValueAssignment | ValueSetTypeAssignment | ObjectClassAssignment | ObjectAssignment | ObjectSetAssignment | ParameterizedAssignment ;ValueSetTypeAssignment : TYPEREFERENCE Type ASSIGNMENT '{' '}' { Module->AddIdentifier($1, TYPEREFERENCE); } | WOULDBE_OBJECTCLASSREFERENCE Type ASSIGNMENT '{' '}' { Module->AddIdentifier($1, TYPEREFERENCE); } ;/********/TypeAssignment : TYPEREFERENCE ASSIGNMENT Type { Module->AddIdentifier($1, TYPEREFERENCE); } | WOULDBE_OBJECTCLASSREFERENCE ASSIGNMENT Type { Module->AddIdentifier($1, TYPEREFERENCE); } ;Type : ConstrainedType | ReferencedType | BuiltinType ;BuiltinType : BitStringType | BooleanType | CharacterStringType | ChoiceType | EmbeddedPDVType | EnumeratedType | ExternalType | AnyType | InstanceOfType | IntegerType | NullType | ObjectClassFieldType | ObjectIdentifierType | OctetStringType | RealType | SequenceType | SequenceOfType | SetType | SetOfType | TaggedType ;ReferencedType : DefinedType | UsefulType | SelectionType | InformationFromObjects ;DefinedType : ExternalTypeReference | TypeReference { delete $1; } | ParameterizedType/*| ParameterizedValueSetType synonym for ParameterizedType */ ;ExternalTypeReference : MODULEREFERENCE '.' TypeReference { delete $1; delete $3; } ;ParameterizedType : SimpleDefinedType '{' '}' ;SimpleDefinedType : ExternalTypeReference | TypeReference { delete $1; } ;BitStringType : BIT STRING | BIT STRING '{' '}' ;BooleanType : BOOLEAN_t ;CharacterStringType : RestrictedCharacterStringType | UnrestrictedCharacterStringType ;RestrictedCharacterStringType : BMPString | GeneralString | GraphicString | IA5String | ISO646String | NumericString | PrintableString | TeletexString | T61String | UniversalString | VideotexString | VisibleString ;UnrestrictedCharacterStringType : CHARACTER STRING ;ChoiceType : CHOICE '{' '}' ;EmbeddedPDVType
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -