2 * compiler/core/parse-asn1.y
4 * yacc source for ASN.1 '88 Parser
5 * As interpreted from Appendix II of CCITT recomendation X.208
7 * Parses ASN.1 into a monster data structure
9 * Some old versions of yacc will croak due the length
10 * of some of the symbols (use -Nc10000 with other versions)
14 * 91/09/02 Rewritten with "ASN.1" generated data struct
16 * Copyright (C) 1990, 1991, 1992 Michael Sample
17 * and the University of British Columbia
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/core/parse-asn1.y,v 1.1 2001/06/20 21:27:58 dmitch Exp $
25 * $Log: parse-asn1.y,v $
26 * Revision 1.1 2001/06/20 21:27:58 dmitch
27 * Adding missing snacc compiler files.
29 * Revision 1.1.1.1 1999/03/16 18:06:51 aram
30 * Originals from SMIME Free Library.
32 * Revision 1.11 1997/08/28 09:46:41 wan
33 * Reworked number range checking, only gives warning now.
35 * Revision 1.10 1997/06/19 09:17:17 wan
36 * Added isPdu flag to tables. Added value range checks during parsing.
38 * Revision 1.9 1997/03/13 14:48:28 wan
39 * Parsed SEQUENCE SIZE(..) OF as SET, corrected.
41 * Revision 1.8 1997/03/03 11:58:34 wan
42 * Final pre-delivery stuff (I hope).
44 * Revision 1.7 1997/02/28 13:39:55 wan
45 * Modifications collected for new version 1.3: Bug fixes, tk4.2.
47 * Revision 1.6 1995/07/25 19:17:55 rj
48 * use memzero that is defined in .../snacc.h to use either memset or bzero.
50 * changed `_' to `-' in file names.
52 * Revision 1.5 1995/02/18 12:52:21 rj
53 * portablity fix (string(s).h)
55 * Revision 1.4 1995/02/17 20:13:21 rj
56 * portablity fix (string(s).h)
58 * Revision 1.3 1994/10/08 03:42:46 rj
59 * renamed the FLEX cpp define to FLEX_SCANNER since that's what flex defines.
61 * Revision 1.2 1994/09/01 00:42:03 rj
62 * snacc_config.h removed.
64 * Revision 1.1 1994/08/28 09:49:29 rj
65 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
73 #if STDC_HEADERS || HAVE_STRING_H
82 #include "asn1module.h"
83 #include "lib-types.h"
84 #include "snacc-util.h"
87 #include "lex-stuff.h"
91 * used for small errors that should prevent code generation but not
92 * prevent the later error checking passes
94 int smallErrG = FALSE;
98 * used incase the asn1.lex was compiled with flex in which
99 * case the lexical analyzer must be reset for every ASN.1 file
100 * parsed, except the first
102 static int firstTimeThroughG = TRUE;
106 * used to hold the parsed value. The root of the parse tree.
113 * used to hold integer values that are defined as arc numbers
114 * the modules object identifiers.
115 * eg. FOO-MODULE { joint-iso-ccitt dod (2) foo (2) 3 2 } DEFINITIONS ::=
116 * would put dod/2 and foo/2 in the oidElmtValDefsG list
117 * Note: only some oid's (modules name/import list module names)
118 * are parsed by the yacc code. The rest are parsed later
119 * due to ambiguities that arise without type info.
121 ValueDefList *oidElmtValDefsG = NULL;
126 * used to hold APPLICATION tags that have been defined in
127 * a module. This permits checking for the the error of
128 * using the same APPLICATION tag in 1 module. The
129 * ApplTags list (appTagsG) is emptied for each module.
131 typedef struct ApplTag
133 unsigned long int lineNo;
134 unsigned long int tagCode;
135 struct ApplTag *next;
138 ApplTag *applTagsG = NULL;
141 * Protos for ApplTag related stuff. These are defined at the
144 void PushApplTag PROTO ((unsigned long int tagCode, unsigned long int lineNo));
150 * the following are globals to simplify disparity between
151 * productions and produced data structure
155 * these are used in the ValueRange subtype production
157 static int valueRangeUpperEndInclusiveG;
158 static int valueRangeLowerEndInclusiveG;
161 * used to set exports flag in Type/value defs
162 * exportListG holds the explicitly exported elements.
163 * see SetExports routine in export.c
165 ExportElmt *exportListG = NULL;
170 * globals for the APPLICATION-CONTEXT macro productions
172 static ValueList *rosAcSymmetricAsesG;
173 static ValueList *rosAcResponderConsumerOfG;
174 static ValueList *rosAcInitiatorConsumerOfG;
177 * used with MTSAS Extension macro
178 * set to NULL for the initial parse.
180 static AsnBool *mtsasCriticalForSubmissionG = NULL;
181 static AsnBool *mtsasCriticalForTransferG = NULL;
182 static AsnBool *mtsasCriticalForDeliveryG = NULL;
185 * Asn PORT macro globals
187 static TypeOrValueList *asnConsumerG;
188 static TypeOrValueList *asnSupplierG;
193 * used to prevent too many cascade errors
195 int parseErrCountG = 0;
197 #define PARSE_ERROR()\
199 modulePtrG->status = MOD_ERROR;\
200 if (parseErrCountG > MAX_ERR)\
202 fprintf (stderr, "Ackkkkk! too many errors - bye!\n");\
211 * Union structure. A terminal or non-terminal can have
212 * one of these type values.
218 unsigned int uintVal;
221 NamedType *namedTypePtr;
222 NamedTypeList *namedTypeListPtr;
224 NamedValue *namedValuePtr;
225 SubtypeValue *subtypeValuePtr;
231 TypeDefList *typeDefListPtr;
232 ValueDef *valueDefPtr;
233 ValueDefList *valueDefListPtr;
234 ExportElmt *exportList;
235 ImportModule *importModulePtr;
236 ImportModuleList *importModuleListPtr;
237 ImportElmt *importElmtPtr;
238 ImportElmtList *importElmtListPtr;
241 Constraint *constraintPtr;
242 ConstraintList *constraintListPtr;
243 InnerSubtype *innerSubtypePtr;
244 ValueList *valueListPtr;
245 TypeOrValueList *typeOrValueListPtr;
246 TypeOrValue *typeOrValuePtr;
248 AsnPortList *asnPortListPtr;
249 AttributeList *attrList;
253 * Terminals. Definitions can be found in input.lex.
257 * these tokens (literals) have attributes (set in asn1.lex)
259 %token <charPtr> BSTRING_SYM HSTRING_SYM CSTRING_SYM
260 UCASEFIRST_IDENT_SYM LCASEFIRST_IDENT_SYM
261 NAMEDMACRO_SYM MACRODEFBODY_SYM
262 BRACEBAL_SYM NUMBER_ERANGE
264 %token <uintVal> NUMBER_SYM
266 %token <charPtr> SNACC_ATTRIBUTES
269 * these tokens have no attributes
271 %token DOT_SYM COMMA_SYM LEFTBRACE_SYM RIGHTBRACE_SYM LEFTPAREN_SYM
272 RIGHTPAREN_SYM LEFTBRACKET_SYM RIGHTBRACKET_SYM LESSTHAN_SYM
273 MINUS_SYM GETS_SYM BAR_SYM TAGS_SYM BOOLEAN_SYM INTEGER_SYM
274 BIT_SYM STRING_SYM OCTET_SYM NULL_SYM SEQUENCE_SYM OF_SYM
275 SET_SYM IMPLICIT_SYM CHOICE_SYM ANY_SYM
276 OBJECT_IDENTIFIER_SYM OPTIONAL_SYM DEFAULT_SYM COMPONENTS_SYM
277 UNIVERSAL_SYM APPLICATION_SYM PRIVATE_SYM TRUE_SYM FALSE_SYM
278 BEGIN_SYM END_SYM DEFINITIONS_SYM EXPLICIT_SYM ENUMERATED_SYM
279 EXPORTS_SYM IMPORTS_SYM REAL_SYM INCLUDES_SYM MIN_SYM MAX_SYM
280 SIZE_SYM FROM_SYM WITH_SYM COMPONENT_SYM PRESENT_SYM ABSENT_SYM
281 DEFINED_SYM BY_SYM PLUS_INFINITY_SYM MINUS_INFINITY_SYM
282 SEMI_COLON_SYM IA5STRING_SYM PRINTABLESTRING_SYM
283 NUMERICSTRING_SYM TELETEXSTRING_SYM T61STRING_SYM
284 VIDEOTEXSTRING_SYM VISIBLESTRING_SYM ISO646STRING_SYM
285 GRAPHICSTRING_SYM GENERALSTRING_SYM
286 GENERALIZEDTIME_SYM UTCTIME_SYM EXTERNAL_SYM
288 /* the following are used in macros */
289 OPERATION_SYM ARGUMENT_SYM RESULT_SYM ERRORS_SYM LINKED_SYM
290 ERROR_SYM PARAMETER_SYM
291 BIND_SYM BINDERROR_SYM UNBIND_SYM UNBINDERROR_SYM
292 ASE_SYM OPERATIONS_SYM CONSUMERINVOKES_SYM
294 AC_SYM ASES_SYM REMOTE_SYM INITIATOR_SYM RESPONDER_SYM
295 ABSTRACTSYNTAXES_SYM CONSUMER_SYM
296 EXTENSIONS_SYM CHOSEN_SYM
297 EXTENSION_SYM CRITICAL_SYM FOR_SYM DELIVERY_SYM SUBMISSION_SYM
298 TRANSFER_SYM EXTENSIONATTRIBUTE_SYM
299 TOKEN_SYM TOKENDATA_SYM
301 OBJECT_SYM PORTS_SYM BOXC_SYM BOXS_SYM
302 PORT_SYM ABSTRACTOPS_SYM
303 REFINE_SYM AS_SYM RECURRING_SYM VISIBLE_SYM PAIRED_SYM
304 ABSTRACTBIND_SYM ABSTRACTUNBIND_SYM TO_SYM
305 ABSTRACTERROR_SYM ABSTRACTOPERATION_SYM
306 ALGORITHM_SYM ENCRYPTED_SYM SIGNED_SYM
307 SIGNATURE_SYM PROTECTED_SYM
308 OBJECTTYPE_SYM SYNTAX_SYM ACCESS_SYM STATUS_SYM
309 DESCRIPTION_SYM REFERENCE_SYM INDEX_SYM
313 * Type definitions of non-terminal symbols
316 %type <intVal> LineNo SetOpening SequenceOpening
318 %type <intVal> TagDefault
320 %type <importElmtListPtr> SymbolList
322 %type <importModuleListPtr> SymbolsFromModuleList
324 %type <importModulePtr> SymbolsFromModule
326 %type <typeDefPtr> TypeAssignment
328 %type <valueDefPtr> ValueAssignment
330 %type <charPtr> BinaryString HexString CharString
332 %type <intVal> number Class
334 %type <intVal> SignedNumber
336 %type <charPtr> modulereference typereference identifier Symbol
339 %type <valuePtr> ExternalValueReference
340 %type <valuePtr> Value DefinedValue BuiltinValue BooleanValue
341 NullValue SpecialRealValue
343 %type <namedValuePtr> NamedValue
345 %type <moduleId> ModuleIdentifier
347 %type <oidPtr> ObjectIdentifierValue AssignedIdentifier
348 ObjIdComponent NumberForm NameAndNumberForm
350 %type <charPtr> NameForm
351 %type <typePtr> BuiltinType DefinedType Subtype BooleanType IntegerType
352 BitStringType NullType SequenceType
353 SequenceOfType SetType SetOfType ChoiceType SelectionType
354 TaggedType AnyType ObjectIdentifierType
355 EnumeratedType RealType Type ExternalTypeReference
359 %type <namedTypePtr> NamedType ElementType
361 %type <namedTypeListPtr> AlternativeTypes AlternativeTypeList
362 ElementTypes ElementTypeList
364 %type <subtypeValuePtr> SubtypeValueSet SingleValue ContainedSubtype ValueRange
365 PermittedAlphabet SizeConstraint InnerTypeConstraints
367 %type <subtypePtr> SubtypeSpec SubtypeValueSetList
369 %type <constraintPtr> NamedConstraint Constraint
371 %type <constraintListPtr> TypeConstraints
373 %type <innerSubtypePtr> FullSpecification PartialSpecification
374 SingleTypeConstraint MultipleTypeConstraints
376 %type <valuePtr> LowerEndPoint UpperEndPoint LowerEndValue UpperEndValue
378 %type <intVal> PresenceConstraint
380 %type <subtypePtr> ValueConstraint
382 %type <exportList> ExportSymbolList
384 %type <valueDefPtr> NamedNumber
386 %type <valueDefListPtr> NamedNumberList NamedBitList
388 %type <tagPtr> Tag ClassNumber
390 %type <attrList> SnaccAttributes SnaccAttributeCommentList
392 %type <charPtr> DefinedMacroName MacroReference
394 %type <typePtr> DefinedMacroType
396 %type <valueListPtr> PossiblyEmptyValueList ValueList
398 %type <typeOrValueListPtr> PossiblyEmptyTypeOrValueList TypeOrValueList
400 %type <typeOrValuePtr> TypeOrValue
402 %type <typePtr> RosOperationMacroType RosOperationMacroBody RosErrorMacroType
403 RosBindMacroType RosUnbindMacroType
404 RosAseMacroType RosAcMacroType
406 %type <namedTypePtr> RosOpArgument RosOpResult RosOpResultType
408 %type <typeOrValueListPtr> RosOpErrors RosOpLinkedOps
410 %type <namedTypePtr> RosErrParameter
412 %type <namedTypePtr> RosBindArgument RosBindResult RosBindError RosUnbindError
414 %type <valueListPtr> RosAseSymmetricAse RosAseConsumerInvokes
415 RosAseSupplierInvokes RosAseOperationList
417 %type <valueListPtr> RosAcNonRoElements
419 %type <valuePtr> RosAcRoElements
421 %type <oidListPtr> OidList RosAcAbstractSyntaxes
423 %type <typePtr> MtsasExtensionsMacroType MtsasExtensionMacroType
424 MtsasExtensionAttributeMacroType MtsasTokenMacroType
425 MtsasTokenDataMacroType MtsasSecurityCategoryMacroType
427 %type <valuePtr> MtsasExtDefaultVal
429 %type <typePtr> AsnObjectMacroType AsnPortMacroType AsnRefineMacroType
430 AsnAbstractBindMacroType AsnAbstractUnbindMacroType
431 AsnAbstractOperationMacroType AsnAbstractErrorMacroType
433 %type <asnPortListPtr> AsnPorts AsnPortList
435 %type <asnPortPtr> AsnPort
437 %type <intVal> AsnPortType
439 %type <intVal> AsnObject AsnObjectList AsnPortSpec AsnPortSpecList
440 AsnObjectSpec AsnComponent AsnComponentList
442 %type <typeOrValueListPtr> AsnOperations AsnConsumer AsnSupplier
444 %type <asnPortListPtr> AsnAbstractBindPorts AsnAbstractUnbindPorts
446 %type <typePtr> AfAlgorithmMacroType AfEncryptedMacroType
447 AfSignedMacroType AfSignatureMacroType
450 %type <typePtr> SnmpObjectTypeMacroType
451 %type <intVal> SnmpStatus SnmpAccess
452 %type <valuePtr> SnmpDescrPart SnmpReferPart SnmpDefValPart
453 %type <typeOrValueListPtr> SnmpIndexPart
455 %start ModuleDefinition
460 /*-----------------------------------------------------------------------*/
461 /* Module def/import/export productions */
462 /*-----------------------------------------------------------------------*/
464 LineNo: { $$ = myLineNoG; }
469 TagDefault { modulePtrG->tagDefault = $3; }
475 modulePtrG->modId = $1;
478 * Set exported flags in type/value defs as appropriate
480 SetExports (modulePtrG, exportListG, exportsParsedG);
484 /* Free Application tag list */
488 * Add values defined in any parsed object identifiers.
489 * Only the Module name and some macro oids have been parsed,
490 * the rest are just "{...}" strings at this point
491 * (they will be parsed in later)
493 modulePtrG->valueDefs =
494 AsnListConcat (modulePtrG->valueDefs, oidElmtValDefsG);
497 * free list head only
499 Free (oidElmtValDefsG);
504 EXPLICIT_SYM TAGS_SYM { $$ = EXPLICIT_TAGS; }
505 | IMPLICIT_SYM TAGS_SYM { $$ = IMPLICIT_TAGS; }
508 /* default is EXPLICIT TAGS */
514 modulereference AssignedIdentifier
523 ObjectIdentifierValue
524 | empty { $$ = NULL; }
528 Exports Imports AssignmentList
533 EXPORTS_SYM SymbolsExported SEMI_COLON_SYM
536 * allows differentiation between "EXPORTS;"
537 * (in which no exports allowed)
538 * and when the EXPORTS symbol does not appear
539 * (then all are exported)
541 exportsParsedG = TRUE;
543 | EXPORTS_SYM error SEMI_COLON_SYM
546 exportsParsedG = FALSE;
550 | empty { exportsParsedG = FALSE; }
554 ExportSymbolList { exportListG = $1; }
555 | empty { exportListG = NULL; }
561 $$ = MT (ExportElmt);
563 $$->lineNo = myLineNoG;
566 | ExportSymbolList COMMA_SYM LineNo Symbol
568 $$ = MT (ExportElmt);
576 IMPORTS_SYM SymbolsImported SEMI_COLON_SYM
577 | IMPORTS_SYM error SEMI_COLON_SYM
586 SymbolsFromModuleList { modulePtrG->imports = $1; }
590 SymbolsFromModuleList:
591 SymbolsFromModuleList SymbolsFromModule
603 SymbolList FROM_SYM LineNo ModuleIdentifier
605 $$ = MT (ImportModule);
608 $$->importElmts = $1;
614 SymbolList COMMA_SYM Symbol
618 ie = MT (ImportElmt);
620 ie->lineNo = myLineNoG;
628 /* called for the first element only, so create list head */
630 ie = MT (ImportElmt);
632 ie->lineNo = myLineNoG;
640 | DefinedMacroName /* This solves macro "keyword" problem */
643 * hack to make DefinedMacroNames "freeable"
644 * like idents and typeref
646 $$ = Malloc (strlen ($1)+1);
654 AssignmentList AssignmentOrError
660 | Assignment SEMI_COLON_SYM
661 | error SEMI_COLON_SYM
672 * a macro may produce a null type
677 * add to head of type def list
679 APPEND ($1, modulePtrG->typeDefs);
686 * a macro may produce a null value
691 * add to head of value def list
693 APPEND ($1, modulePtrG->valueDefs);
696 | NAMEDMACRO_SYM GETS_SYM BEGIN_SYM LineNo { LexBeginMacroDefContext(); }
703 * create macro type to eliminate import resolution
704 * errors msgs from other modules importing the macro.
705 * (hopefully) Only the import list will link with
707 * keeps macro def around incase of future processing needs
709 * NOTE: MACRODEFBODY_SYM returns the macro def body with
710 * with "BEGIN" at the begininning and "END" at the end
714 * put lexical analyzer back in normal state
716 /* BEGIN (INITIAL); */
717 LexBeginInitialContext();
719 tmpTypeDef = MT (TypeDef);
720 SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, $4);
721 tmpTypeDef->definedName = $1;
724 * keeps the macro def body
725 * (all text between & including the BEGIN and END)
726 * as a simple string - incase you want to fart around with
729 tmpTypeDef->type->basicType->a.macroDef = $6;
734 APPEND (tmpTypeDef, modulePtrG->typeDefs);
737 | NAMEDMACRO_SYM GETS_SYM MacroReference
741 tmpTypeDef = MT (TypeDef);
742 SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG);
743 tmpTypeDef->definedName = $1;
745 tmpTypeDef->type->basicType->a.macroDef = $3;
750 APPEND (tmpTypeDef, modulePtrG->typeDefs);
753 | NAMEDMACRO_SYM GETS_SYM modulereference DOT_SYM MacroReference
757 tmpTypeDef = MT (TypeDef);
758 SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG);
759 tmpTypeDef->definedName = $1;
761 tmpTypeDef->type->basicType->a.macroDef =
762 (MyString) Malloc (strlen ($3) + strlen ($5) + 2);
764 strcpy (tmpTypeDef->type->basicType->a.macroDef, $3);
765 strcat (tmpTypeDef->type->basicType->a.macroDef, ".");
766 strcat (tmpTypeDef->type->basicType->a.macroDef, $5);
771 APPEND (tmpTypeDef, modulePtrG->typeDefs);
783 /*-----------------------------------------------------------------------*/
784 /* Type Notation Productions */
785 /*-----------------------------------------------------------------------*/
788 typereference GETS_SYM SnaccAttributes LineNo Type SnaccAttributes
791 * a macro type may produce a null type
797 $$->type->lineNo = $4;
798 $$->type->attrList = $6;
799 $$->definedName = $1;
808 ExternalTypeReference:
809 modulereference DOT_SYM LineNo typereference
811 /* allocate a Type with basic type of ImportTypeRef */
812 SetupType (&$$, BASICTYPE_IMPORTTYPEREF, $3);
813 $$->basicType->a.importTypeRef = MT (TypeRef);
814 $$->basicType->a.importTypeRef->typeName = $4;
815 $$->basicType->a.importTypeRef->moduleName = $1;
817 /* add entry to this module's import list */
818 AddPrivateImportElmt (modulePtrG, $4, $1, $3);
823 DefinedType: /* could by CharacterString or Useful types too */
824 ExternalTypeReference { $$ = $1; }
827 SetupType (&$$, BASICTYPE_LOCALTYPEREF, myLineNoG);
828 $$->basicType->a.localTypeRef = MT (TypeRef);
829 $$->basicType->a.localTypeRef->typeName = $1;
855 | ObjectIdentifierType
858 | OCTET_SYM STRING_SYM
860 SetupType (&$$, BASICTYPE_OCTETSTRING, myLineNoG);
871 | Type /* this handles selectionType as well */
881 SetupType (&$$, BASICTYPE_BOOLEAN, myLineNoG);
888 SetupType (&$$, BASICTYPE_INTEGER, myLineNoG);
889 $$->basicType->a.integer = NEWLIST(); /* empty list */
891 | INTEGER_SYM LEFTBRACE_SYM NamedNumberList RIGHTBRACE_SYM
893 SetupType (&$$, BASICTYPE_INTEGER, myLineNoG);
894 $$->basicType->a.integer = $3;
905 | NamedNumberList COMMA_SYM NamedNumber
913 identifier LEFTPAREN_SYM SignedNumber RIGHTPAREN_SYM
916 $$->definedName = $1;
917 SetupValue (&$$->value, BASICVALUE_INTEGER, myLineNoG);
918 $$->value->basicValue->a.integer = $3;
920 | identifier LEFTPAREN_SYM DefinedValue RIGHTPAREN_SYM
923 $$->definedName = $1;
932 yyerror("Warning: positive signed number out of range");
938 yyerror ("Warning: positive signed number out of range");
940 /* modulePtrG->status = MOD_ERROR; */
942 | MINUS_SYM NUMBER_SYM
945 yyerror("Warning: negative signed number out of range");
947 } else if ($2==0x80000000) {
953 | MINUS_SYM NUMBER_ERANGE
955 yyerror ("Warning: negative signed number out of range");
957 /* modulePtrG->status = MOD_ERROR; */
962 ENUMERATED_SYM LEFTBRACE_SYM NamedNumberList RIGHTBRACE_SYM
964 SetupType (&$$, BASICTYPE_ENUMERATED, myLineNoG);
965 $$->basicType->a.enumerated = $3;
973 SetupType (&$$, BASICTYPE_REAL, myLineNoG);
980 SetupType (&$$, BASICTYPE_BITSTRING, myLineNoG);
981 $$->basicType->a.bitString = NEWLIST(); /* empty list */
983 | BIT_SYM STRING_SYM LEFTBRACE_SYM NamedBitList RIGHTBRACE_SYM
985 SetupType (&$$, BASICTYPE_BITSTRING, myLineNoG);
986 $$->basicType->a.bitString = $4;
999 SetupType (&$$, BASICTYPE_NULL, myLineNoG);
1004 SEQUENCE_SYM LineNo LEFTBRACE_SYM
1009 SequenceOpening ElementTypes RIGHTBRACE_SYM
1013 SetupType (&$$, BASICTYPE_SEQUENCE, $1);
1015 if (AsnListCount ((AsnList*)$2) != 0)
1017 n = (NamedType*) FIRST_LIST_ELMT ((AsnList*)$2);
1018 n->type->lineNo = $1;
1021 $$->basicType->a.sequence = $2;
1024 | SequenceOpening RIGHTBRACE_SYM
1026 SetupType (&$$, BASICTYPE_SEQUENCE, $1);
1028 /* set up empty list for SEQ with no elmts */
1029 $$->basicType->a.sequence = AsnListNew (sizeof (void*));
1031 /* | SEQUENCE_SYM LEFTBRACE_SYM error RIGHTBRACE_SYM
1039 ElementTypeList SnaccAttributes
1041 NamedType *lastElmt;
1045 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1046 lastElmt->type->attrList = $2;
1058 | ElementTypeList COMMA_SYM SnaccAttributes LineNo ElementType
1060 NamedType *lastElmt;
1064 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1065 lastElmt->type->attrList = $3;
1069 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1070 lastElmt->type->lineNo = $4;
1077 | NamedType OPTIONAL_SYM
1080 $$->type->optional = TRUE;
1082 | NamedType DEFAULT_SYM NamedValue
1085 * this rules uses NamedValue instead of Value
1086 * for the stupid choice value syntax (fieldname value)
1087 * it should be like a set/seq value (ie with
1091 $$->type->defaultVal = $3;
1093 * could link value to the elmt type here (done in link_types.c)
1096 | COMPONENTS_SYM OF_SYM Type
1098 $$ = MT (NamedType);
1099 SetupType (&$$->type, BASICTYPE_COMPONENTSOF, myLineNoG);
1100 $$->type->basicType->a.componentsOf = $3;
1102 | identifier COMPONENTS_SYM OF_SYM Type
1104 $$ = MT (NamedType);
1105 SetupType (&$$->type, BASICTYPE_COMPONENTSOF, myLineNoG);
1107 $$->type->basicType->a.componentsOf = $4;
1114 SEQUENCE_SYM OF_SYM Type
1118 /* does not use SEQUENCE == SEQ OF ANY abrev*/
1119 SetupType (&$$, BASICTYPE_SEQUENCEOF, myLineNoG);
1121 /* grab line number from first elmt */
1123 $$->lineNo = $3->lineNo - 1;
1125 $$->basicType->a.sequenceOf = $3;
1130 SET_SYM LineNo LEFTBRACE_SYM { $$ = $2; }
1134 SetOpening ElementTypes RIGHTBRACE_SYM
1138 SetupType (&$$, BASICTYPE_SET, $1);
1140 /* reset first elmt's line number */
1141 if (AsnListCount ((AsnList*)$2) != 0)
1143 n = (NamedType*)FIRST_LIST_ELMT ((AsnList*)$2);
1144 n->type->lineNo = $1;
1146 $$->basicType->a.set = $2;
1148 | SetOpening RIGHTBRACE_SYM
1150 SetupType (&$$, BASICTYPE_SET, $1);
1152 /* set up empty elmt list for SET */
1153 $$->basicType->a.set = AsnListNew (sizeof (void*));
1155 /* | SET_SYM LEFTBRACE_SYM error RIGHTBRACE_SYM
1166 /* does not allow SET == SET OF ANY Abrev */
1167 SetupType (&$$, BASICTYPE_SETOF, myLineNoG);
1170 $$->lineNo = $3->lineNo;
1172 $$->basicType->a.setOf = $3;
1178 CHOICE_SYM LineNo LEFTBRACE_SYM AlternativeTypes RIGHTBRACE_SYM
1182 SetupType (&$$, BASICTYPE_CHOICE, $2);
1184 $$->basicType->a.choice = $4;
1186 if (AsnListCount ($4) != 0)
1188 n = (NamedType*)FIRST_LIST_ELMT ($4);
1189 n->type->lineNo = $2;
1195 AlternativeTypeList SnaccAttributes
1197 NamedType *lastElmt;
1200 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1201 lastElmt->type->attrList = $2;
1207 AlternativeTypeList:
1213 | AlternativeTypeList COMMA_SYM SnaccAttributes NamedType
1215 NamedType *lastElmt;
1219 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1220 lastElmt->type->attrList = $3;
1229 identifier LESSTHAN_SYM Type
1232 * the selection type should be replaced after
1233 * link with actual type
1235 SetupType (&$$, BASICTYPE_SELECTION, myLineNoG);
1237 $$->basicType->a.selection = MT (SelectionType);
1238 $$->basicType->a.selection->typeRef = $3;
1239 $$->basicType->a.selection->fieldName = $1;
1248 /* remove next tag if any && IMPLICIT_TAGS */
1249 if ((modulePtrG->tagDefault == IMPLICIT_TAGS) &&
1250 ($2->tags != NULL) && !LIST_EMPTY ($2->tags))
1252 tag = (Tag*)FIRST_LIST_ELMT ($2->tags); /* set curr to first */
1253 AsnListFirst ($2->tags); /* set curr to first elmt */
1254 AsnListRemove ($2->tags); /* remove first elmt */
1257 * set implicit if implicitly tagged built in type (ie not ref)
1258 * (this simplifies the module ASN.1 printer (print.c))
1260 if (tag->tclass == UNIV)
1261 $2->implicit = TRUE;
1266 PREPEND ($1, $2->tags);
1269 | Tag IMPLICIT_SYM Type
1273 /* remove next tag if any */
1274 if (($3->tags != NULL) && !LIST_EMPTY ($3->tags))
1276 tag = (Tag*)FIRST_LIST_ELMT ($3->tags); /* set curr to first */
1277 AsnListFirst ($3->tags); /* set curr to first elmt */
1278 AsnListRemove ($3->tags); /* remove first elmt */
1280 if (tag->tclass == UNIV)
1281 $3->implicit = TRUE;
1287 * must check after linking that implicitly tagged
1288 * local/import type refs are not untagged choice/any etc
1290 else if (($3->basicType->choiceId == BASICTYPE_IMPORTTYPEREF) ||
1291 ($3->basicType->choiceId == BASICTYPE_LOCALTYPEREF) ||
1292 ($3->basicType->choiceId == BASICTYPE_SELECTION))
1293 $3->implicit = TRUE;
1296 * all other implicitly tagable types should have tags
1297 * to remove - if this else clause fires then it is
1298 * probably a CHOICE or ANY type
1302 PrintErrLoc (modulePtrG->asn1SrcFileName, $3->lineNo);
1303 fprintf (stderr, "ERROR - attempt to implicitly reference untagged type\n");
1307 PREPEND ($1, $3->tags);
1310 | Tag EXPLICIT_SYM Type
1312 /* insert tag at head of list */
1313 $1->explicit = TRUE;
1314 PREPEND ($1, $3->tags);
1320 LEFTBRACKET_SYM Class ClassNumber RIGHTBRACKET_SYM
1324 $$->explicit = FALSE; /* default to false */
1327 * keep track of APPLICATION Tags per module
1328 * should only be used once
1332 PushApplTag ($$->code, myLineNoG);
1346 $$->code = NO_TAG_CODE;
1352 UNIVERSAL_SYM { $$ = UNIV; }
1353 | APPLICATION_SYM { $$ = APPL; }
1354 | PRIVATE_SYM { $$ = PRIV; }
1355 | empty { $$ = CNTX; }
1362 SetupType (&$$, BASICTYPE_ANY, myLineNoG);
1364 | ANY_SYM DEFINED_SYM BY_SYM identifier
1366 SetupType (&$$, BASICTYPE_ANYDEFINEDBY, myLineNoG);
1367 $$->basicType->a.anyDefinedBy = MT (AnyDefinedByType);
1368 $$->basicType->a.anyDefinedBy->fieldName = $4;
1373 ObjectIdentifierType:
1374 OBJECT_IDENTIFIER_SYM
1376 SetupType (&$$, BASICTYPE_OID, myLineNoG);
1385 * append new subtype list to existing one (s) if any
1388 AppendSubtype (&$1->subtypes, $2, SUBTYPE_AND);
1391 | SET_SYM SizeConstraint OF_SYM Type
1395 SetupType (&$$, BASICTYPE_SETOF, myLineNoG);
1396 $$->basicType->a.setOf = $4;
1398 /* add size constraint */
1400 s->choiceId = SUBTYPE_SINGLE;
1402 AppendSubtype (&$$->subtypes, s, SUBTYPE_AND);
1404 | SEQUENCE_SYM SizeConstraint OF_SYM Type
1408 SetupType (&$$, BASICTYPE_SEQUENCEOF, myLineNoG);
1409 $$->basicType->a.sequenceOf = $4;
1411 /* add size constraint */
1413 s->choiceId = SUBTYPE_SINGLE;
1415 AppendSubtype (&$$->subtypes, s, SUBTYPE_AND);
1421 LEFTPAREN_SYM SubtypeValueSetList RIGHTPAREN_SYM
1427 SubtypeValueSetList:
1432 /* OR relation between all elmts of in ValueSetList */
1435 $$->choiceId = SUBTYPE_OR;
1436 $$->a.or = NEWLIST();
1439 s->choiceId = SUBTYPE_SINGLE;
1441 APPEND (s, $$->a.or);
1443 | SubtypeValueSetList BAR_SYM SubtypeValueSet
1447 s->choiceId = SUBTYPE_SINGLE;
1449 APPEND (s, $1->a.or);
1461 | InnerTypeConstraints
1467 $$ = MT (SubtypeValue);
1468 $$->choiceId = SUBTYPEVALUE_SINGLEVALUE;
1469 $$->a.singleValue = $1;
1475 $$ = MT (SubtypeValue);
1476 $$->choiceId = SUBTYPEVALUE_CONTAINED;
1477 $$->a.contained = $2;
1482 LowerEndPoint DOT_SYM DOT_SYM UpperEndPoint
1484 $$ = MT (SubtypeValue);
1485 $$->choiceId = SUBTYPEVALUE_VALUERANGE;
1486 $$->a.valueRange = MT (ValueRangeSubtype);
1487 $$->a.valueRange->lowerEndInclusive =
1488 valueRangeLowerEndInclusiveG;
1489 $$->a.valueRange->upperEndInclusive =
1490 valueRangeUpperEndInclusiveG;
1491 $$->a.valueRange->lowerEndValue = $1;
1492 $$->a.valueRange->upperEndValue = $4;
1500 valueRangeLowerEndInclusiveG = TRUE;
1502 | LowerEndValue LESSTHAN_SYM
1505 valueRangeLowerEndInclusiveG = FALSE;
1513 valueRangeUpperEndInclusiveG = TRUE;
1515 | LESSTHAN_SYM UpperEndValue
1518 valueRangeUpperEndInclusiveG = FALSE;
1526 SetupValue (&$$, BASICVALUE_SPECIALINTEGER, myLineNoG);
1527 $$->basicValue->a.specialInteger = MIN_INT;
1535 SetupValue (&$$, BASICVALUE_SPECIALINTEGER, myLineNoG);
1536 $$->basicValue->a.specialInteger = MAX_INT;
1541 SIZE_SYM SubtypeSpec
1543 $$ = MT (SubtypeValue);
1544 $$->choiceId = SUBTYPEVALUE_SIZECONSTRAINT;
1545 $$->a.sizeConstraint = $2;
1551 FROM_SYM SubtypeSpec
1553 $$ = MT (SubtypeValue);
1554 $$->choiceId = SUBTYPEVALUE_PERMITTEDALPHABET;
1555 $$->a.permittedAlphabet = $2;
1559 InnerTypeConstraints:
1560 WITH_SYM COMPONENT_SYM SingleTypeConstraint
1562 $$ = MT (SubtypeValue);
1563 $$->choiceId = SUBTYPEVALUE_INNERSUBTYPE;
1564 $$->a.innerSubtype = $3;
1566 | WITH_SYM COMPONENTS_SYM MultipleTypeConstraints
1568 $$ = MT (SubtypeValue);
1569 $$->choiceId = SUBTYPEVALUE_INNERSUBTYPE;
1570 $$->a.innerSubtype = $3;
1574 SingleTypeConstraint:
1577 Constraint *constraint;
1579 /* this constrains the elmt of setof or seq of */
1580 $$ = MT (InnerSubtype);
1581 $$->constraintType = SINGLE_CT;
1582 $$->constraints = NEWLIST();
1583 constraint = MT (Constraint);
1584 APPEND (constraint, $$->constraints);
1585 constraint->valueConstraints = $1;
1589 MultipleTypeConstraints:
1591 | PartialSpecification
1595 LEFTBRACE_SYM TypeConstraints RIGHTBRACE_SYM
1597 $$ = MT (InnerSubtype);
1598 $$->constraintType = FULL_CT;
1599 $$->constraints = $2;
1603 PartialSpecification:
1604 LEFTBRACE_SYM DOT_SYM DOT_SYM DOT_SYM COMMA_SYM TypeConstraints RIGHTBRACE_SYM
1606 $$ = MT (InnerSubtype);
1607 $$->constraintType = PARTIAL_CT;
1608 $$->constraints = $6;
1619 | TypeConstraints COMMA_SYM NamedConstraint
1627 identifier Constraint
1637 ValueConstraint PresenceConstraint
1639 $$ = MT (Constraint);
1640 $$->presenceConstraint = $2;
1641 $$->valueConstraints = $1;
1646 SubtypeSpec { $$ = $1; }
1647 | empty { $$ = NULL; }
1651 PRESENT_SYM { $$ = PRESENT_CT; }
1652 | ABSENT_SYM { $$ = ABSENT_CT; }
1653 | empty { $$ = EMPTY_CT; }
1654 | OPTIONAL_SYM { $$ = OPTIONAL_CT; }
1662 /*-----------------------------------------------------------------------*/
1663 /* Value Notation Productions */
1664 /*-----------------------------------------------------------------------*/
1667 identifier Type GETS_SYM LineNo Value
1670 $$->definedName = $1;
1672 $$->value->lineNo = $4;
1673 $$->value->type = $2;
1684 ExternalValueReference { $$ = $1; }
1685 | identifier /* a defined value or a named elmt ref */
1688 * for parse, may be set to BASICVALUE_IMPORTEDTYPEREF
1691 SetupValue (&$$, BASICVALUE_LOCALVALUEREF, myLineNoG);
1692 $$->basicValue->a.localValueRef = MT (ValueRef);
1693 $$->basicValue->a.localValueRef->valueName = $1;
1694 $$->valueType = BASICTYPE_UNKNOWN;
1698 ExternalValueReference:
1699 modulereference DOT_SYM LineNo identifier
1701 /* Alloc value with basicValue of importValueRef */
1702 SetupValue (&$$, BASICVALUE_IMPORTVALUEREF, $3);
1703 $$->valueType = BASICTYPE_UNKNOWN;
1704 $$->basicValue->a.importValueRef = MT (ValueRef);
1705 $$->basicValue->a.importValueRef->valueName = $4;
1706 $$->basicValue->a.importValueRef->moduleName = $1;
1708 /* add entry to this module's import list */
1709 AddPrivateImportElmt (modulePtrG, $4, $1, $3);
1717 | SignedNumber /* IntegerValue or "0" real val*/
1719 SetupValue (&$$, BASICVALUE_INTEGER, myLineNoG);
1720 $$->valueType = BASICTYPE_UNKNOWN;
1721 $$->basicValue->a.integer = $1;
1723 | HexString /* OctetStringValue or BinaryStringValue */
1725 SetupValue (&$$, BASICVALUE_ASCIIHEX, myLineNoG);
1726 $$->valueType = BASICTYPE_UNKNOWN;
1727 $$->basicValue->a.asciiHex = MT (AsnOcts);
1728 $$->basicValue->a.asciiHex->octs = $1;
1729 $$->basicValue->a.asciiHex->octetLen = strlen ($1);
1731 | BinaryString /* BinaryStringValue */
1733 SetupValue (&$$, BASICVALUE_ASCIIBITSTRING, myLineNoG);
1734 $$->valueType = BASICTYPE_UNKNOWN;
1735 $$->basicValue->a.asciiBitString = MT (AsnOcts);
1736 $$->basicValue->a.asciiBitString->octs = $1;
1737 $$->basicValue->a.asciiBitString->octetLen = strlen ($1);
1741 SetupValue (&$$, BASICVALUE_ASCIITEXT, myLineNoG);
1742 $$->valueType = BASICTYPE_UNKNOWN;
1743 $$->basicValue->a.asciiText = MT (AsnOcts);
1744 $$->basicValue->a.asciiText->octs = $1;
1745 $$->basicValue->a.asciiText->octetLen = strlen ($1);
1747 | LEFTBRACE_SYM { LexBeginBraceBalContext(); } BRACEBAL_SYM
1751 * string returned by BRACEBAL_SYM has
1752 * the $1 '{' prepended and includes everything
1753 * upto and including '}' that balances $1
1755 LexBeginInitialContext();
1756 SetupValue (&$$, BASICVALUE_VALUENOTATION, myLineNoG);
1757 $$->basicValue->a.valueNotation = MT (AsnOcts);
1758 $$->basicValue->a.valueNotation->octs = $3;
1759 $$->basicValue->a.valueNotation->octetLen = strlen ($3);
1760 $$->valueType = BASICTYPE_UNKNOWN;
1767 SetupValue (&$$, BASICVALUE_BOOLEAN, myLineNoG);
1768 $$->valueType = BASICTYPE_UNKNOWN;
1769 $$->basicValue->a.boolean = TRUE;
1773 SetupValue (&$$, BASICVALUE_BOOLEAN, myLineNoG);
1774 $$->valueType = BASICTYPE_UNKNOWN;
1775 $$->basicValue->a.boolean = FALSE;
1783 SetupValue (&$$, BASICVALUE_SPECIALREAL, myLineNoG);
1784 $$->valueType = BASICTYPE_UNKNOWN;
1785 $$->basicValue->a.specialReal = PLUS_INFINITY_REAL;
1787 | MINUS_INFINITY_SYM
1789 SetupValue (&$$, BASICVALUE_SPECIALREAL, myLineNoG);
1790 $$->valueType = BASICTYPE_UNKNOWN;
1791 $$->basicValue->a.specialReal = MINUS_INFINITY_REAL;
1800 /* create a NULL value */
1801 SetupValue (&$$, BASICVALUE_NULL, myLineNoG);
1802 $$->valueType = BASICTYPE_UNKNOWN;
1810 $$ = MT (NamedValue);
1815 $$ = MT (NamedValue);
1822 ObjectIdentifierValue:
1823 LEFTBRACE_SYM ObjIdComponentList RIGHTBRACE_SYM
1828 * for { ccitt foo (1) bar bell (bunt) 2 }
1831 * - arcnum is set to number from oid table (oid.c)
1833 * - sets up a new value def foo defined as 1
1834 * - makes oid valueref a value ref to foo (doesn't link it tho)
1836 * - makes oid valueref a value ref to bar (doesn't link it tho)
1838 * - sets up a new value def bell defined as a val ref to bunt
1839 * - makes oid valueref a value ref to bell (doesn't link it tho)
1841 * - arcnum is set to 2
1850 ObjIdComponentList ObjIdComponent
1853 /* append component */
1854 for (o = $1; o->next != NULL; o = o->next)
1870 * if the arcName is a defined arc name like
1871 * ccitt or iso etc, fill in the arc number.
1872 * otherwise make a value ref to that named value
1876 $$->arcNum = OidArcNameToNum ($1);
1877 if ($$->arcNum == NULL_OID_ARCNUM)
1879 /* set up value ref to named value */
1880 SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG);
1881 newVal->basicValue->a.localValueRef = MT (ValueRef);
1882 newVal->valueType = BASICTYPE_INTEGER;
1883 newVal->basicValue->a.localValueRef->valueName = $1;
1884 $$->valueRef = newVal;
1905 identifier LEFTPAREN_SYM NumberForm RIGHTPAREN_SYM
1911 /* shared refs to named numbers name */
1912 SetupValue (&newVal, BASICVALUE_INTEGER, myLineNoG);
1913 newVal->basicValue->a.integer = $$->arcNum;
1914 newVal->valueType = BASICTYPE_INTEGER;
1915 AddNewValueDef (oidElmtValDefsG, $1, newVal);
1917 SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG);
1918 newVal->basicValue->a.localValueRef = MT (ValueRef);
1919 newVal->basicValue->a.localValueRef->valueName = $1;
1921 $$->valueRef = newVal;
1923 | identifier LEFTPAREN_SYM DefinedValue RIGHTPAREN_SYM
1927 /* shared refs to named numbers name */
1929 $$->arcNum = NULL_OID_ARCNUM;
1931 AddNewValueDef (oidElmtValDefsG, $1, $3);
1933 SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG);
1934 newVal->basicValue->a.localValueRef = MT (ValueRef);
1935 newVal->basicValue->a.localValueRef->valueName = $1;
1937 $$->valueRef = newVal;
1959 if ($1>0x7FFFFFFF) {
1960 yyerror("Warning: number out of range");
1966 yyerror ("Warning: number out of range");
1968 /* modulePtrG->status = MOD_ERROR; */
1973 LCASEFIRST_IDENT_SYM
1977 UCASEFIRST_IDENT_SYM
1981 UCASEFIRST_IDENT_SYM
1988 /* Snacc attributes/extra type info
1989 * - encapsulated in special comments
1992 SnaccAttributeCommentList
1993 | empty {$$ = NULL;}
1996 SnaccAttributeCommentList:
2002 | SnaccAttributeCommentList SNACC_ATTRIBUTES
2010 * Macro Syntax definitions
2011 **************************/
2014 RosOperationMacroType
2017 | RosUnbindMacroType
2020 | MtsasExtensionMacroType
2021 | MtsasExtensionsMacroType
2022 | MtsasExtensionAttributeMacroType
2023 | MtsasTokenMacroType
2024 | MtsasTokenDataMacroType
2025 | MtsasSecurityCategoryMacroType
2026 | AsnObjectMacroType
2028 | AsnRefineMacroType
2029 | AsnAbstractBindMacroType
2030 | AsnAbstractUnbindMacroType
2031 | AsnAbstractOperationMacroType
2032 | AsnAbstractErrorMacroType
2033 | AfAlgorithmMacroType
2034 | AfEncryptedMacroType
2035 | AfProtectedMacroType
2036 | AfSignatureMacroType
2038 | SnmpObjectTypeMacroType
2042 OPERATION_SYM { $$ = "OPERATION"; }
2043 | ERROR_SYM { $$ = "ERROR"; }
2044 | BIND_SYM { $$ = "BIND"; }
2045 | UNBIND_SYM { $$ = "UNBIND"; }
2046 | ASE_SYM { $$ = "APPLICATION-SERVICE-ELEMENT"; }
2047 | AC_SYM { $$ = "APPLICATION-CONTEXT"; }
2048 | EXTENSION_SYM { $$ = "EXTENSION"; }
2049 | EXTENSIONS_SYM { $$ = "EXTENSIONS"; }
2050 | EXTENSIONATTRIBUTE_SYM { $$ = "EXTENSION-ATTRIBUTE"; }
2051 | TOKEN_SYM { $$ = "TOKEN"; }
2052 | TOKENDATA_SYM { $$ = "TOKEN-DATA"; }
2053 | SECURITYCATEGORY_SYM { $$ = "SECURITY-CATEGORY"; }
2054 | OBJECT_SYM { $$ = "OBJECT"; }
2055 | PORT_SYM { $$ = "PORT"; }
2056 | REFINE_SYM { $$ = "REFINE"; }
2057 | ABSTRACTBIND_SYM { $$ = "ABSTRACT-BIND"; }
2058 | ABSTRACTUNBIND_SYM { $$ = "ABSTRACT-UNBIND"; }
2059 | ABSTRACTOPERATION_SYM { $$ = "ABSTRACT-OPERATION"; }
2060 | ABSTRACTERROR_SYM { $$ = "ABSTRACT-ERROR"; }
2061 | ALGORITHM_SYM { $$ = "ALGORITHM"; }
2062 | ENCRYPTED_SYM { $$ = "ENCRYPTED"; }
2063 | SIGNED_SYM { $$ = "SIGNED"; }
2064 | SIGNATURE_SYM { $$ = "SIGNATURE"; }
2065 | PROTECTED_SYM { $$ = "PROTECTED"; }
2066 | OBJECTTYPE_SYM { $$ = "OBJECT-TYPE"; }
2071 * Operation Macro (ROS) added by MS 91/08/27
2074 RosOperationMacroType:
2075 OPERATION_SYM RosOperationMacroBody { $$ = $2; }
2078 RosOperationMacroBody:
2079 RosOpArgument RosOpResult RosOpErrors RosOpLinkedOps
2081 RosOperationMacroType *r;
2083 SetupMacroType (&$$, MACROTYPE_ROSOPERATION, myLineNoG);
2084 r = $$->basicType->a.macroType->a.rosOperation =
2085 MT (RosOperationMacroType);
2095 ARGUMENT_SYM NamedType { $$ = $2; }
2096 | empty { $$ = NULL; }
2100 RESULT_SYM RosOpResultType { $$ = $2; }
2101 | empty { $$ = NULL; }
2107 | empty { $$ = NULL; }
2112 ERRORS_SYM LEFTBRACE_SYM PossiblyEmptyTypeOrValueList RIGHTBRACE_SYM
2116 | empty { $$ = NULL; }
2122 LINKED_SYM LEFTBRACE_SYM PossiblyEmptyTypeOrValueList RIGHTBRACE_SYM
2126 | empty { $$ = NULL; }
2133 * ROS ERROR macro - ms 91/08/27
2138 ERROR_SYM RosErrParameter
2140 RosErrorMacroType *r;
2142 * defines error macro type
2144 SetupMacroType (&$$, MACROTYPE_ROSERROR, myLineNoG);
2145 r = $$->basicType->a.macroType->a.rosError = MT (RosErrorMacroType);
2152 PARAMETER_SYM NamedType { $$ = $2; }
2153 | empty { $$ = NULL; }
2158 * ROS BIND macro - ms 91/09/13
2162 BIND_SYM RosBindArgument RosBindResult RosBindError
2164 RosBindMacroType *r;
2166 SetupMacroType (&$$, MACROTYPE_ROSBIND, myLineNoG);
2168 r = $$->basicType->a.macroType->a.rosBind = MT (RosBindMacroType);
2176 ARGUMENT_SYM NamedType { $$ = $2; }
2177 | empty { $$ = NULL; }
2182 RESULT_SYM NamedType { $$ = $2; }
2183 | empty { $$ = NULL; }
2188 BINDERROR_SYM NamedType { $$ = $2; }
2189 | empty { $$ = NULL; }
2194 * ROS UNBIND ms 91/09/13
2198 UNBIND_SYM RosBindArgument RosBindResult RosUnbindError
2200 RosBindMacroType *r;
2202 SetupMacroType (&$$, MACROTYPE_ROSUNBIND, myLineNoG);
2204 r = $$->basicType->a.macroType->a.rosUnbind = MT (RosBindMacroType);
2213 UNBINDERROR_SYM NamedType { $$ = $2; }
2214 | empty { $$ = NULL; }
2219 * ROS APPLICATION-SERVICE-ELEMENT macro ms 91/09/13
2223 ASE_SYM RosAseSymmetricAse
2227 SetupMacroType (&$$, MACROTYPE_ROSASE, myLineNoG);
2228 r = $$->basicType->a.macroType->a.rosAse = MT (RosAseMacroType);
2231 | ASE_SYM RosAseConsumerInvokes RosAseSupplierInvokes
2235 SetupMacroType (&$$, MACROTYPE_ROSASE, myLineNoG);
2236 r = $$->basicType->a.macroType->a.rosAse = MT (RosAseMacroType);
2237 r->consumerInvokes = $2;
2238 r->supplierInvokes = $3;
2244 OPERATIONS_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM
2251 RosAseConsumerInvokes:
2252 CONSUMERINVOKES_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM
2256 | empty { $$ = NULL; }
2260 RosAseSupplierInvokes:
2261 SUPPLIERINVOKES_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM
2265 | empty { $$ = NULL; }
2269 RosAseOperationList:
2275 * ROS APPLICATION-CONTEXT macro ms 91/09/13
2284 RosAcAbstractSyntaxes
2288 SetupMacroType (&$$, MACROTYPE_ROSAC, myLineNoG);
2289 r = $$->basicType->a.macroType->a.rosAc = MT (RosAcMacroType);
2290 r->nonRoElements = $2;
2291 r->bindMacroType = $4;
2292 r->unbindMacroType = $6;
2293 r->remoteOperations = $7;
2294 r->operationsOf = rosAcSymmetricAsesG;
2295 r->initiatorConsumerOf = rosAcInitiatorConsumerOfG;
2296 r->responderConsumerOf = rosAcResponderConsumerOfG;
2297 r->abstractSyntaxes = $8;
2303 ASES_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2311 REMOTE_SYM OPERATIONS_SYM LEFTBRACE_SYM Value RIGHTBRACE_SYM
2312 RosAcSymmetricAses RosAcAsymmetricAses
2319 rosAcSymmetricAsesG = NULL;
2320 rosAcInitiatorConsumerOfG = NULL;
2321 rosAcResponderConsumerOfG = NULL;
2326 OPERATIONS_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2328 rosAcSymmetricAsesG = $4;
2330 | empty { rosAcSymmetricAsesG = NULL; }
2333 RosAcAsymmetricAses:
2334 RosAcInitiatorConsumerOf RosAcResponderConsumerOf
2337 RosAcInitiatorConsumerOf:
2338 INITIATOR_SYM CONSUMER_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2340 rosAcInitiatorConsumerOfG = $5;
2342 | empty { rosAcInitiatorConsumerOfG = NULL; }
2345 RosAcResponderConsumerOf:
2346 RESPONDER_SYM CONSUMER_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2348 rosAcResponderConsumerOfG = $5;
2350 | empty { rosAcResponderConsumerOfG = NULL; }
2353 RosAcAbstractSyntaxes:
2354 ABSTRACTSYNTAXES_SYM LEFTBRACE_SYM OidList RIGHTBRACE_SYM
2358 | empty { $$ = NULL; }
2363 ObjectIdentifierValue
2368 | OidList COMMA_SYM ObjectIdentifierValue
2377 * MTSAbstractSvc EXTENSIONS macro
2380 MtsasExtensionsMacroType:
2381 EXTENSIONS_SYM CHOSEN_SYM FROM_SYM
2382 LEFTBRACE_SYM PossiblyEmptyValueList RIGHTBRACE_SYM
2384 MtsasExtensionsMacroType *m;
2386 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONS, myLineNoG);
2387 m = $$->basicType->a.macroType->a.mtsasExtensions =
2388 MT (MtsasExtensionsMacroType);
2394 PossiblyEmptyValueList:
2396 | empty { $$ = NULL; }
2405 | ValueList COMMA_SYM Value
2412 PossiblyEmptyTypeOrValueList:
2414 | empty { $$ = NULL; }
2423 | TypeOrValueList COMMA_SYM TypeOrValue
2433 $$ = MT (TypeOrValue);
2434 $$->choiceId = TYPEORVALUE_TYPE;
2439 $$ = MT (TypeOrValue);
2440 $$->choiceId = TYPEORVALUE_VALUE;
2446 * MTSAbstractSvc EXTENSION macro
2449 MtsasExtensionMacroType:
2450 EXTENSION_SYM NamedType MtsasExtDefaultVal MtsasExtCritical
2452 MtsasExtensionMacroType *m;
2454 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSION, myLineNoG);
2455 m = $$->basicType->a.macroType->a.mtsasExtension =
2456 MT (MtsasExtensionMacroType);
2458 m->defaultValue = $3;
2459 m->criticalForSubmission = mtsasCriticalForSubmissionG;
2460 m->criticalForTransfer = mtsasCriticalForTransferG;
2461 m->criticalForDelivery = mtsasCriticalForDeliveryG;
2463 mtsasCriticalForSubmissionG = NULL; /* set up for next parse */
2464 mtsasCriticalForTransferG = NULL;
2465 mtsasCriticalForDeliveryG = NULL;
2469 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSION, myLineNoG);
2470 $$->basicType->a.macroType->a.mtsasExtension =
2471 MT (MtsasExtensionMacroType);
2473 * all fields are NULL in the MtsasExtensionsMacroType
2474 * for this production
2480 DEFAULT_SYM Value { $$ = $2; }
2481 | empty { $$ = NULL; }
2485 CRITICAL_SYM FOR_SYM MtsasExtCriticalityList
2490 MtsasExtCriticalityList:
2492 | MtsasExtCriticalityList COMMA_SYM MtsasExtCriticality
2495 MtsasExtCriticality:
2498 mtsasCriticalForSubmissionG = MT (AsnBool);
2499 *mtsasCriticalForSubmissionG = TRUE;
2503 mtsasCriticalForTransferG = MT (AsnBool);
2504 *mtsasCriticalForTransferG = TRUE;
2508 mtsasCriticalForDeliveryG = MT (AsnBool);
2509 *mtsasCriticalForDeliveryG = TRUE;
2516 * MTSAbstractSvc X.411 EXTENSION-ATTRIBUTE macro
2519 MtsasExtensionAttributeMacroType:
2520 EXTENSIONATTRIBUTE_SYM
2522 MtsasExtensionAttributeMacroType *m;
2524 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG);
2525 m = $$->basicType->a.macroType->a.mtsasExtensionAttribute =
2526 MT (MtsasExtensionAttributeMacroType);
2529 | EXTENSIONATTRIBUTE_SYM Type
2531 MtsasExtensionAttributeMacroType *m;
2533 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG);
2534 m = $$->basicType->a.macroType->a.mtsasExtensionAttribute =
2535 MT (MtsasExtensionAttributeMacroType);
2542 * X.411 MTSAbstractSvc TOKEN macro
2544 MtsasTokenMacroType:
2547 MtsasTokenMacroType *m;
2549 SetupMacroType (&$$, MACROTYPE_MTSASTOKEN, myLineNoG);
2550 m = $$->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType);
2555 MtsasTokenMacroType *m;
2557 SetupMacroType (&$$, MACROTYPE_MTSASTOKEN, myLineNoG);
2558 m = $$->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType);
2565 * X.411 MTSAS TOKEN-DATA macro type
2567 MtsasTokenDataMacroType:
2570 MtsasTokenDataMacroType *m;
2572 SetupMacroType (&$$, MACROTYPE_MTSASTOKENDATA, myLineNoG);
2573 m = $$->basicType->a.macroType->a.mtsasTokenData =
2574 MT (MtsasTokenDataMacroType);
2577 | TOKENDATA_SYM Type
2579 MtsasTokenDataMacroType *m;
2581 SetupMacroType (&$$, MACROTYPE_MTSASTOKENDATA, myLineNoG);
2582 m = $$->basicType->a.macroType->a.mtsasTokenData =
2583 MT (MtsasTokenDataMacroType);
2590 * X.411 MTSAS SECURITY-CATEGORY
2592 MtsasSecurityCategoryMacroType:
2593 SECURITYCATEGORY_SYM
2595 MtsasSecurityCategoryMacroType *m;
2597 SetupMacroType (&$$, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG);
2598 m = $$->basicType->a.macroType->a.mtsasSecurityCategory =
2599 MT (MtsasSecurityCategoryMacroType);
2602 | SECURITYCATEGORY_SYM Type
2604 MtsasSecurityCategoryMacroType *m;
2606 SetupMacroType (&$$, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG);
2607 m = $$->basicType->a.macroType->a.mtsasSecurityCategory =
2608 MT (MtsasSecurityCategoryMacroType);
2615 * X.407 Abstract Service Notation Macro Type productions
2621 * OBJECT Macro X.407
2626 AsnObjectMacroType *a;
2627 SetupMacroType (&$$, MACROTYPE_ASNOBJECT, myLineNoG);
2628 a = $$->basicType->a.macroType->a.asnObject = MT (AsnObjectMacroType);
2634 PORTS_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM
2638 | empty { $$ = NULL; }
2647 | AsnPortList COMMA_SYM AsnPort
2677 $$ = SYMMETRIC_PORT;
2687 PORT_SYM AsnOperations
2689 AsnPortMacroType *a;
2691 SetupMacroType (&$$, MACROTYPE_ASNPORT, myLineNoG);
2692 a = $$->basicType->a.macroType->a.asnPort = MT (AsnPortMacroType);
2693 a->abstractOps = $2;
2694 a->consumerInvokes = asnConsumerG;
2695 a->supplierInvokes = asnSupplierG;
2699 SetupMacroType (&$$, MACROTYPE_ASNPORT, myLineNoG);
2700 $$->basicType->a.macroType->a.asnPort = MT (AsnPortMacroType);
2706 ABSTRACTOPS_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
2714 asnSupplierG = NULL;
2720 asnSupplierG = NULL;
2722 | AsnConsumer AsnSupplier
2726 asnSupplierG = NULL;
2728 | AsnSupplier AsnConsumer
2732 asnSupplierG = NULL;
2737 CONSUMERINVOKES_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
2744 SUPPLIERINVOKES_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
2755 * REFINE Macro X.407
2757 * just parse it - don't keep any info at the moment
2760 REFINE_SYM AsnObject AS_SYM AsnComponentList
2762 SetupType (&$$, BASICTYPE_UNKNOWN, myLineNoG);
2768 | AsnComponentList COMMA_SYM AsnComponent
2772 AsnObjectSpec AsnPortSpecList
2777 | AsnObject RECURRING_SYM
2782 | AsnPortSpecList COMMA_SYM AsnPortSpec
2786 Value AsnPortType AsnPortStatus
2788 $$ = 0; /* just to quiet yacc warning */
2794 | PAIRED_SYM WITH_SYM AsnObjectList
2800 | AsnObjectList COMMA_SYM AsnObject
2806 $$ = 0; /* just to quiet yacc warning */
2814 * ABSTRACT-BIND Macro X.407
2816 AsnAbstractBindMacroType:
2817 ABSTRACTBIND_SYM AsnAbstractBindPorts
2819 AsnAbstractBindMacroType *a;
2821 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTBIND, myLineNoG);
2822 a = $$->basicType->a.macroType->a.asnAbstractBind =
2823 MT (AsnAbstractBindMacroType);
2826 | ABSTRACTBIND_SYM AsnAbstractBindPorts Type
2828 AsnAbstractBindMacroType *a;
2830 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTBIND, myLineNoG);
2831 a = $$->basicType->a.macroType->a.asnAbstractBind =
2832 MT (AsnAbstractBindMacroType);
2838 AsnAbstractBindPorts:
2839 TO_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM
2843 | empty { $$ = NULL; }
2850 * ABSTRACT-UNBIND Macro X.407
2852 AsnAbstractUnbindMacroType:
2853 ABSTRACTUNBIND_SYM AsnAbstractUnbindPorts
2855 AsnAbstractBindMacroType *a;
2857 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG);
2858 a = $$->basicType->a.macroType->a.asnAbstractUnbind =
2859 MT (AsnAbstractBindMacroType);
2863 | ABSTRACTUNBIND_SYM AsnAbstractUnbindPorts Type
2865 AsnAbstractBindMacroType *a;
2867 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG);
2868 a = $$->basicType->a.macroType->a.asnAbstractUnbind =
2869 MT (AsnAbstractBindMacroType);
2876 AsnAbstractUnbindPorts:
2877 FROM_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM
2881 | empty { $$ = NULL; }
2887 * ABSTRACT-OPERATION Macro X.407 (same as ROS Operation)
2889 AsnAbstractOperationMacroType:
2890 ABSTRACTOPERATION_SYM RosOperationMacroBody
2893 $2->basicType->a.macroType->choiceId = MACROTYPE_ASNABSTRACTOPERATION;
2899 * ABSTRACT-ERROR Macro X.407 (same as ROS Error)
2901 AsnAbstractErrorMacroType:
2902 ABSTRACTERROR_SYM RosErrParameter
2904 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTERROR, myLineNoG);
2905 $$->basicType->a.macroType->a.asnAbstractError = MT (RosErrorMacroType);
2906 $$->basicType->a.macroType->a.asnAbstractError->parameter = $2;
2912 * X.509 Authentication Framework ALGORITHM macro type
2914 AfAlgorithmMacroType:
2915 ALGORITHM_SYM PARAMETER_SYM Type
2917 SetupMacroType (&$$, MACROTYPE_AFALGORITHM, myLineNoG);
2918 $$->basicType->a.macroType->a.afAlgorithm = $3;
2923 * X.509 Authentication Framework ENCRYPTED macro type
2925 AfEncryptedMacroType:
2928 SetupMacroType (&$$, MACROTYPE_AFENCRYPTED, myLineNoG);
2929 $$->basicType->a.macroType->a.afEncrypted = $2;
2935 * X.509 Authentication Framework SIGNED macro type
2940 SetupMacroType (&$$, MACROTYPE_AFSIGNED, myLineNoG);
2941 $$->basicType->a.macroType->a.afSigned = $2;
2946 * X.509 Authentication Framework SIGNATURE macro type
2948 AfSignatureMacroType:
2951 SetupMacroType (&$$, MACROTYPE_AFSIGNATURE, myLineNoG);
2952 $$->basicType->a.macroType->a.afSignature = $2;
2959 * X.509 Authentication Framework PROTECTED macro type
2960 * (same as SIGNATURE except for key word)
2962 AfProtectedMacroType:
2965 SetupMacroType (&$$, MACROTYPE_AFPROTECTED, myLineNoG);
2966 $$->basicType->a.macroType->a.afProtected = $2;
2972 SnmpObjectTypeMacroType:
2975 ACCESS_SYM SnmpAccess
2976 STATUS_SYM SnmpStatus
2982 SnmpObjectTypeMacroType *s;
2984 SetupMacroType (&$$, MACROTYPE_SNMPOBJECTTYPE, myLineNoG);
2985 s = $$->basicType->a.macroType->a.snmpObjectType =
2986 MT (SnmpObjectTypeMacroType);
2991 s->description = $8;
3001 if (strcmp ($1, "read-only") == 0)
3002 $$ = SNMP_READ_ONLY;
3003 else if (strcmp ($1, "read-write") == 0)
3004 $$ = SNMP_READ_WRITE;
3005 else if (strcmp ($1, "write-only") == 0)
3006 $$ = SNMP_WRITE_ONLY;
3007 else if (strcmp ($1, "not-accessible") == 0)
3008 $$ = SNMP_NOT_ACCESSIBLE;
3011 yyerror ("ACCESS field of SNMP OBJECT-TYPE MACRO can only be one of \"read-write\", \"write-only\" or \"not-accessible\"");
3013 modulePtrG->status = MOD_ERROR;
3023 if (strcmp ($1, "mandatory") == 0)
3024 $$ = SNMP_MANDATORY;
3025 else if (strcmp ($1, "optional") == 0)
3027 else if (strcmp ($1, "obsolete") == 0)
3029 else if (strcmp ($1, "deprecated") == 0)
3030 $$ = SNMP_DEPRECATED;
3033 yyerror ("STATUS field of SNMP OBJECT-TYPE MACRO can only be one of \"optional\", \"obsolete\" or \"deprecated\"");
3035 modulePtrG->status = MOD_ERROR;
3042 DESCRIPTION_SYM Value { $$ = $2; }
3047 REFERENCE_SYM Value { $$ = $2; }
3052 INDEX_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
3060 DEFVAL_SYM LEFTBRACE_SYM Value RIGHTBRACE_SYM
3072 fprintf (stderr,"file \"%s\", line %d: %s at symbol \"%s\"\n\n", modulePtrG->asn1SrcFileName, myLineNoG, s, yytext);
3077 * given a Module*, the file name associated witht the open
3078 * FILE *fPtr, InitAsn1Parser sets up the yacc/lex parser
3079 * to parse an ASN.1 module read from fPtr and write the
3080 * parse results into the given Module *mod.
3083 InitAsn1Parser PARAMS ((mod, fileName, fPtr),
3085 char *fileName _AND_
3091 * reset lexical analyzer input file ptr
3092 * (only do this on succesive calls ow yyrestart seg faults
3095 if (!firstTimeThroughG)
3098 firstTimeThroughG = FALSE;
3105 memzero (mod, sizeof (Module));
3107 mod->asn1SrcFileName = fileName;
3108 mod->status = MOD_NOT_LINKED;
3109 mod->hasAnys = FALSE;
3111 /* init lists to empty */
3112 mod->typeDefs = AsnListNew (sizeof (void*));
3113 mod->valueDefs = AsnListNew (sizeof (void*));
3116 * init export list stuff
3119 exportsParsedG = FALSE;
3122 * reset line number to 1
3132 * set up list to hold values defined in parsed oids
3134 oidElmtValDefsG = AsnListNew (sizeof (void *));
3140 } /* InitAsn1Parser */
3144 * puts the applicatin tag code, tagCode, and line number it was
3145 * parsed at into the applTagsG list. If the APPLICATION tag code
3146 * is already in the applTagsG list then an error is printed.
3147 * and the smallErrG flag set to prevent code production.
3150 PushApplTag PARAMS ((tagCode, lineNo),
3151 unsigned long int tagCode _AND_
3152 unsigned long int lineNo)
3158 /* make sure not already in list */
3159 for (l = applTagsG; l != NULL; l = l->next)
3161 if (l->tagCode == tagCode)
3163 PrintErrLoc (modulePtrG->asn1SrcFileName, lineNo);
3164 fprintf (stderr,"ERROR - APPLICATION tags can be used only once per ASN.1 module. The tag \"[APPLICATION %d]\" was previously used on line %d.\n", tagCode, l->lineNo);
3172 new->lineNo = lineNo;
3173 new->tagCode = tagCode;
3174 new->next = applTagsG;
3181 * Empties the applTagsG list. Usually done between modules.
3189 for (l = applTagsG; l != NULL; )
3196 } /* FreeApplTags */