]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/compiler/core/parse-asn1.y
Security-54.tar.gz
[apple/security.git] / SecuritySNACCRuntime / compiler / core / parse-asn1.y
1 /*
2 * compiler/core/parse-asn1.y
3 *
4 * yacc source for ASN.1 '88 Parser
5 * As interpreted from Appendix II of CCITT recomendation X.208
6 *
7 * Parses ASN.1 into a monster data structure
8 *
9 * Some old versions of yacc will croak due the length
10 * of some of the symbols (use -Nc10000 with other versions)
11 *
12 * Mike Sample
13 * 90/05/03
14 * 91/09/02 Rewritten with "ASN.1" generated data struct
15 *
16 * Copyright (C) 1990, 1991, 1992 Michael Sample
17 * and the University of British Columbia
18 *
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.
23 *
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.
28 *
29 * Revision 1.1.1.1 1999/03/16 18:06:51 aram
30 * Originals from SMIME Free Library.
31 *
32 * Revision 1.11 1997/08/28 09:46:41 wan
33 * Reworked number range checking, only gives warning now.
34 *
35 * Revision 1.10 1997/06/19 09:17:17 wan
36 * Added isPdu flag to tables. Added value range checks during parsing.
37 *
38 * Revision 1.9 1997/03/13 14:48:28 wan
39 * Parsed SEQUENCE SIZE(..) OF as SET, corrected.
40 *
41 * Revision 1.8 1997/03/03 11:58:34 wan
42 * Final pre-delivery stuff (I hope).
43 *
44 * Revision 1.7 1997/02/28 13:39:55 wan
45 * Modifications collected for new version 1.3: Bug fixes, tk4.2.
46 *
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.
49 *
50 * changed `_' to `-' in file names.
51 *
52 * Revision 1.5 1995/02/18 12:52:21 rj
53 * portablity fix (string(s).h)
54 *
55 * Revision 1.4 1995/02/17 20:13:21 rj
56 * portablity fix (string(s).h)
57 *
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.
60 *
61 * Revision 1.2 1994/09/01 00:42:03 rj
62 * snacc_config.h removed.
63 *
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.
66 *
67 */
68
69 %{
70
71 #include "snacc.h"
72
73 #if STDC_HEADERS || HAVE_STRING_H
74 #include <string.h>
75 #else
76 #include <strings.h>
77 #endif
78 #include <stdio.h>
79
80 #include "asn-incl.h"
81 #include "mem.h"
82 #include "asn1module.h"
83 #include "lib-types.h"
84 #include "snacc-util.h"
85 #include "exports.h"
86 #include "parser.h"
87 #include "lex-stuff.h"
88
89 /*
90 * smallErrG
91 * used for small errors that should prevent code generation but not
92 * prevent the later error checking passes
93 */
94 int smallErrG = FALSE;
95
96 /*
97 * firstTimeThroughG
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
101 */
102 static int firstTimeThroughG = TRUE;
103
104 /*
105 * modulePtrG
106 * used to hold the parsed value. The root of the parse tree.
107 */
108 Module *modulePtrG;
109
110
111 /*
112 * oidElmtValDefsG
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.
120 */
121 ValueDefList *oidElmtValDefsG = NULL;
122
123
124 /*
125 * ApplTag
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.
130 */
131 typedef struct ApplTag
132 {
133 unsigned long int lineNo;
134 unsigned long int tagCode;
135 struct ApplTag *next;
136 } ApplTag;
137
138 ApplTag *applTagsG = NULL;
139
140 /*
141 * Protos for ApplTag related stuff. These are defined at the
142 * end of this file
143 */
144 void PushApplTag PROTO ((unsigned long int tagCode, unsigned long int lineNo));
145 void FreeApplTags();
146
147
148
149 /*
150 * the following are globals to simplify disparity between
151 * productions and produced data structure
152 */
153
154 /*
155 * these are used in the ValueRange subtype production
156 */
157 static int valueRangeUpperEndInclusiveG;
158 static int valueRangeLowerEndInclusiveG;
159
160 /*
161 * used to set exports flag in Type/value defs
162 * exportListG holds the explicitly exported elements.
163 * see SetExports routine in export.c
164 */
165 ExportElmt *exportListG = NULL;
166 int exportsParsedG;
167
168
169 /*
170 * globals for the APPLICATION-CONTEXT macro productions
171 */
172 static ValueList *rosAcSymmetricAsesG;
173 static ValueList *rosAcResponderConsumerOfG;
174 static ValueList *rosAcInitiatorConsumerOfG;
175
176 /*
177 * used with MTSAS Extension macro
178 * set to NULL for the initial parse.
179 */
180 static AsnBool *mtsasCriticalForSubmissionG = NULL;
181 static AsnBool *mtsasCriticalForTransferG = NULL;
182 static AsnBool *mtsasCriticalForDeliveryG = NULL;
183
184 /*
185 * Asn PORT macro globals
186 */
187 static TypeOrValueList *asnConsumerG;
188 static TypeOrValueList *asnSupplierG;
189
190
191 /*
192 * parseErrCountG
193 * used to prevent too many cascade errors
194 */
195 int parseErrCountG = 0;
196 #define MAX_ERR 50
197 #define PARSE_ERROR()\
198 parseErrCountG++;\
199 modulePtrG->status = MOD_ERROR;\
200 if (parseErrCountG > MAX_ERR)\
201 {\
202 fprintf (stderr, "Ackkkkk! too many errors - bye!\n");\
203 exit (1);\
204 }
205
206
207 %}
208
209
210 /*
211 * Union structure. A terminal or non-terminal can have
212 * one of these type values.
213 */
214
215 %union
216 {
217 int intVal;
218 unsigned int uintVal;
219 char *charPtr;
220 Type *typePtr;
221 NamedType *namedTypePtr;
222 NamedTypeList *namedTypeListPtr;
223 Value *valuePtr;
224 NamedValue *namedValuePtr;
225 SubtypeValue *subtypeValuePtr;
226 Subtype *subtypePtr;
227 ModuleId *moduleId;
228 OID *oidPtr;
229 OidList *oidListPtr;
230 TypeDef *typeDefPtr;
231 TypeDefList *typeDefListPtr;
232 ValueDef *valueDefPtr;
233 ValueDefList *valueDefListPtr;
234 ExportElmt *exportList;
235 ImportModule *importModulePtr;
236 ImportModuleList *importModuleListPtr;
237 ImportElmt *importElmtPtr;
238 ImportElmtList *importElmtListPtr;
239 Tag *tagPtr;
240 TagList *tagListPtr;
241 Constraint *constraintPtr;
242 ConstraintList *constraintListPtr;
243 InnerSubtype *innerSubtypePtr;
244 ValueList *valueListPtr;
245 TypeOrValueList *typeOrValueListPtr;
246 TypeOrValue *typeOrValuePtr;
247 AsnPort *asnPortPtr;
248 AsnPortList *asnPortListPtr;
249 AttributeList *attrList;
250 }
251
252 /*
253 * Terminals. Definitions can be found in input.lex.
254 */
255
256 /*
257 * these tokens (literals) have attributes (set in asn1.lex)
258 */
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
263
264 %token <uintVal> NUMBER_SYM
265
266 %token <charPtr> SNACC_ATTRIBUTES
267
268 /*
269 * these tokens have no attributes
270 */
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
287 OBJECTDESCRIPTOR_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
293 SUPPLIERINVOKES_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
300 SECURITYCATEGORY_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
310 DEFVAL_SYM
311
312 /*
313 * Type definitions of non-terminal symbols
314 */
315
316 %type <intVal> LineNo SetOpening SequenceOpening
317
318 %type <intVal> TagDefault
319
320 %type <importElmtListPtr> SymbolList
321
322 %type <importModuleListPtr> SymbolsFromModuleList
323
324 %type <importModulePtr> SymbolsFromModule
325
326 %type <typeDefPtr> TypeAssignment
327
328 %type <valueDefPtr> ValueAssignment
329
330 %type <charPtr> BinaryString HexString CharString
331
332 %type <intVal> number Class
333
334 %type <intVal> SignedNumber
335
336 %type <charPtr> modulereference typereference identifier Symbol
337
338
339 %type <valuePtr> ExternalValueReference
340 %type <valuePtr> Value DefinedValue BuiltinValue BooleanValue
341 NullValue SpecialRealValue
342
343 %type <namedValuePtr> NamedValue
344
345 %type <moduleId> ModuleIdentifier
346
347 %type <oidPtr> ObjectIdentifierValue AssignedIdentifier
348 ObjIdComponent NumberForm NameAndNumberForm
349 ObjIdComponentList
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
356
357
358
359 %type <namedTypePtr> NamedType ElementType
360
361 %type <namedTypeListPtr> AlternativeTypes AlternativeTypeList
362 ElementTypes ElementTypeList
363
364 %type <subtypeValuePtr> SubtypeValueSet SingleValue ContainedSubtype ValueRange
365 PermittedAlphabet SizeConstraint InnerTypeConstraints
366
367 %type <subtypePtr> SubtypeSpec SubtypeValueSetList
368
369 %type <constraintPtr> NamedConstraint Constraint
370
371 %type <constraintListPtr> TypeConstraints
372
373 %type <innerSubtypePtr> FullSpecification PartialSpecification
374 SingleTypeConstraint MultipleTypeConstraints
375
376 %type <valuePtr> LowerEndPoint UpperEndPoint LowerEndValue UpperEndValue
377
378 %type <intVal> PresenceConstraint
379
380 %type <subtypePtr> ValueConstraint
381
382 %type <exportList> ExportSymbolList
383
384 %type <valueDefPtr> NamedNumber
385
386 %type <valueDefListPtr> NamedNumberList NamedBitList
387
388 %type <tagPtr> Tag ClassNumber
389
390 %type <attrList> SnaccAttributes SnaccAttributeCommentList
391
392 %type <charPtr> DefinedMacroName MacroReference
393
394 %type <typePtr> DefinedMacroType
395
396 %type <valueListPtr> PossiblyEmptyValueList ValueList
397
398 %type <typeOrValueListPtr> PossiblyEmptyTypeOrValueList TypeOrValueList
399
400 %type <typeOrValuePtr> TypeOrValue
401
402 %type <typePtr> RosOperationMacroType RosOperationMacroBody RosErrorMacroType
403 RosBindMacroType RosUnbindMacroType
404 RosAseMacroType RosAcMacroType
405
406 %type <namedTypePtr> RosOpArgument RosOpResult RosOpResultType
407
408 %type <typeOrValueListPtr> RosOpErrors RosOpLinkedOps
409
410 %type <namedTypePtr> RosErrParameter
411
412 %type <namedTypePtr> RosBindArgument RosBindResult RosBindError RosUnbindError
413
414 %type <valueListPtr> RosAseSymmetricAse RosAseConsumerInvokes
415 RosAseSupplierInvokes RosAseOperationList
416
417 %type <valueListPtr> RosAcNonRoElements
418
419 %type <valuePtr> RosAcRoElements
420
421 %type <oidListPtr> OidList RosAcAbstractSyntaxes
422
423 %type <typePtr> MtsasExtensionsMacroType MtsasExtensionMacroType
424 MtsasExtensionAttributeMacroType MtsasTokenMacroType
425 MtsasTokenDataMacroType MtsasSecurityCategoryMacroType
426
427 %type <valuePtr> MtsasExtDefaultVal
428
429 %type <typePtr> AsnObjectMacroType AsnPortMacroType AsnRefineMacroType
430 AsnAbstractBindMacroType AsnAbstractUnbindMacroType
431 AsnAbstractOperationMacroType AsnAbstractErrorMacroType
432
433 %type <asnPortListPtr> AsnPorts AsnPortList
434
435 %type <asnPortPtr> AsnPort
436
437 %type <intVal> AsnPortType
438
439 %type <intVal> AsnObject AsnObjectList AsnPortSpec AsnPortSpecList
440 AsnObjectSpec AsnComponent AsnComponentList
441
442 %type <typeOrValueListPtr> AsnOperations AsnConsumer AsnSupplier
443
444 %type <asnPortListPtr> AsnAbstractBindPorts AsnAbstractUnbindPorts
445
446 %type <typePtr> AfAlgorithmMacroType AfEncryptedMacroType
447 AfSignedMacroType AfSignatureMacroType
448 AfProtectedMacroType
449
450 %type <typePtr> SnmpObjectTypeMacroType
451 %type <intVal> SnmpStatus SnmpAccess
452 %type <valuePtr> SnmpDescrPart SnmpReferPart SnmpDefValPart
453 %type <typeOrValueListPtr> SnmpIndexPart
454
455 %start ModuleDefinition
456 %%
457
458
459
460 /*-----------------------------------------------------------------------*/
461 /* Module def/import/export productions */
462 /*-----------------------------------------------------------------------*/
463
464 LineNo: { $$ = myLineNoG; }
465
466 ModuleDefinition:
467 ModuleIdentifier
468 DEFINITIONS_SYM
469 TagDefault { modulePtrG->tagDefault = $3; }
470 GETS_SYM
471 BEGIN_SYM
472 ModuleBody
473 END_SYM
474 {
475 modulePtrG->modId = $1;
476
477 /*
478 * Set exported flags in type/value defs as appropriate
479 */
480 SetExports (modulePtrG, exportListG, exportsParsedG);
481
482 /* clean up */
483
484 /* Free Application tag list */
485 FreeApplTags();
486
487 /*
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)
492 */
493 modulePtrG->valueDefs =
494 AsnListConcat (modulePtrG->valueDefs, oidElmtValDefsG);
495
496 /*
497 * free list head only
498 */
499 Free (oidElmtValDefsG);
500 }
501 ;
502
503 TagDefault:
504 EXPLICIT_SYM TAGS_SYM { $$ = EXPLICIT_TAGS; }
505 | IMPLICIT_SYM TAGS_SYM { $$ = IMPLICIT_TAGS; }
506 | empty
507 {
508 /* default is EXPLICIT TAGS */
509 $$ = EXPLICIT_TAGS;
510 }
511 ;
512
513 ModuleIdentifier:
514 modulereference AssignedIdentifier
515 {
516 $$ = MT (ModuleId);
517 $$->name = $1;
518 $$->oid = $2;
519 }
520 ;
521
522 AssignedIdentifier:
523 ObjectIdentifierValue
524 | empty { $$ = NULL; }
525 ;
526
527 ModuleBody:
528 Exports Imports AssignmentList
529 | empty
530 ;
531
532 Exports:
533 EXPORTS_SYM SymbolsExported SEMI_COLON_SYM
534 {
535 /*
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)
540 */
541 exportsParsedG = TRUE;
542 }
543 | EXPORTS_SYM error SEMI_COLON_SYM
544 {
545 PARSE_ERROR();
546 exportsParsedG = FALSE;
547 exportListG = NULL;
548 yyerrok;
549 }
550 | empty { exportsParsedG = FALSE; }
551 ;
552
553 SymbolsExported:
554 ExportSymbolList { exportListG = $1; }
555 | empty { exportListG = NULL; }
556 ;
557
558 ExportSymbolList:
559 Symbol
560 {
561 $$ = MT (ExportElmt);
562 $$->name = $1;
563 $$->lineNo = myLineNoG;
564 $$->next = NULL;
565 }
566 | ExportSymbolList COMMA_SYM LineNo Symbol
567 {
568 $$ = MT (ExportElmt);
569 $$->name = $4;
570 $$->next = $1;
571 $$->lineNo = $3;
572 }
573 ;
574
575 Imports:
576 IMPORTS_SYM SymbolsImported SEMI_COLON_SYM
577 | IMPORTS_SYM error SEMI_COLON_SYM
578 {
579 PARSE_ERROR();
580 yyerrok;
581 }
582 | empty
583 ;
584
585 SymbolsImported:
586 SymbolsFromModuleList { modulePtrG->imports = $1; }
587 | empty
588 ;
589
590 SymbolsFromModuleList:
591 SymbolsFromModuleList SymbolsFromModule
592 {
593 APPEND ($2,$1);
594 }
595 | SymbolsFromModule
596 {
597 $$ = NEWLIST();
598 APPEND ($1, $$);
599 }
600 ;
601
602 SymbolsFromModule:
603 SymbolList FROM_SYM LineNo ModuleIdentifier
604 {
605 $$ = MT (ImportModule);
606 $$->modId = $4;
607 $$->lineNo = $3;
608 $$->importElmts = $1;
609 }
610 ;
611
612
613 SymbolList:
614 SymbolList COMMA_SYM Symbol
615 {
616 ImportElmt *ie;
617
618 ie = MT (ImportElmt);
619 ie->name = $3;
620 ie->lineNo = myLineNoG;
621 APPEND (ie, $1);
622 $$ = $1;
623 }
624 | Symbol
625 {
626 ImportElmt *ie;
627
628 /* called for the first element only, so create list head */
629 $$ = NEWLIST();
630 ie = MT (ImportElmt);
631 ie->name = $1;
632 ie->lineNo = myLineNoG;
633 APPEND (ie, $$);
634 }
635 ;
636
637 Symbol:
638 typereference
639 | identifier
640 | DefinedMacroName /* This solves macro "keyword" problem */
641 {
642 /*
643 * hack to make DefinedMacroNames "freeable"
644 * like idents and typeref
645 */
646 $$ = Malloc (strlen ($1)+1);
647 strcpy ($$, $1);
648 }
649 ;
650
651
652
653 AssignmentList:
654 AssignmentList AssignmentOrError
655 | AssignmentOrError
656 ;
657
658 AssignmentOrError:
659 Assignment
660 | Assignment SEMI_COLON_SYM
661 | error SEMI_COLON_SYM
662 {
663 PARSE_ERROR();
664 yyerrok;
665 }
666 ;
667
668 Assignment:
669 TypeAssignment
670 {
671 /*
672 * a macro may produce a null type
673 */
674 if ($1 != NULL)
675 {
676 /*
677 * add to head of type def list
678 */
679 APPEND ($1, modulePtrG->typeDefs);
680 }
681
682 }
683 | ValueAssignment
684 {
685 /*
686 * a macro may produce a null value
687 */
688 if ($1 != NULL)
689 {
690 /*
691 * add to head of value def list
692 */
693 APPEND ($1, modulePtrG->valueDefs);
694 }
695 }
696 | NAMEDMACRO_SYM GETS_SYM BEGIN_SYM LineNo { LexBeginMacroDefContext(); }
697 MACRODEFBODY_SYM
698 {
699 TypeDef *tmpTypeDef;
700
701 /*
702 * LEXICAL TIE IN!!
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
706 * these type defs.
707 * keeps macro def around incase of future processing needs
708 *
709 * NOTE: MACRODEFBODY_SYM returns the macro def body with
710 * with "BEGIN" at the begininning and "END" at the end
711 */
712
713 /*
714 * put lexical analyzer back in normal state
715 */
716 /* BEGIN (INITIAL); */
717 LexBeginInitialContext();
718
719 tmpTypeDef = MT (TypeDef);
720 SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, $4);
721 tmpTypeDef->definedName = $1;
722
723 /*
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
727 * it.
728 */
729 tmpTypeDef->type->basicType->a.macroDef = $6;
730
731 /*
732 * put in type list
733 */
734 APPEND (tmpTypeDef, modulePtrG->typeDefs);
735
736 }
737 | NAMEDMACRO_SYM GETS_SYM MacroReference
738 {
739 TypeDef *tmpTypeDef;
740
741 tmpTypeDef = MT (TypeDef);
742 SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG);
743 tmpTypeDef->definedName = $1;
744
745 tmpTypeDef->type->basicType->a.macroDef = $3;
746
747 /*
748 * put in type list
749 */
750 APPEND (tmpTypeDef, modulePtrG->typeDefs);
751
752 }
753 | NAMEDMACRO_SYM GETS_SYM modulereference DOT_SYM MacroReference
754 {
755 TypeDef *tmpTypeDef;
756
757 tmpTypeDef = MT (TypeDef);
758 SetupType (&tmpTypeDef->type, BASICTYPE_MACRODEF, myLineNoG);
759 tmpTypeDef->definedName = $1;
760
761 tmpTypeDef->type->basicType->a.macroDef =
762 (MyString) Malloc (strlen ($3) + strlen ($5) + 2);
763
764 strcpy (tmpTypeDef->type->basicType->a.macroDef, $3);
765 strcat (tmpTypeDef->type->basicType->a.macroDef, ".");
766 strcat (tmpTypeDef->type->basicType->a.macroDef, $5);
767
768 /*
769 * put in type list
770 */
771 APPEND (tmpTypeDef, modulePtrG->typeDefs);
772
773 Free ($3);
774 Free ($5);
775 }
776 ;
777
778 MacroReference:
779 typereference
780 | DefinedMacroName
781 ;
782
783 /*-----------------------------------------------------------------------*/
784 /* Type Notation Productions */
785 /*-----------------------------------------------------------------------*/
786
787 TypeAssignment:
788 typereference GETS_SYM SnaccAttributes LineNo Type SnaccAttributes
789 {
790 /*
791 * a macro type may produce a null type
792 */
793 if ($5 != NULL)
794 {
795 $$ = MT (TypeDef);
796 $$->type = $5;
797 $$->type->lineNo = $4;
798 $$->type->attrList = $6;
799 $$->definedName = $1;
800 $$->attrList = $3;
801 }
802 else
803 $$ = NULL;
804 }
805 ;
806
807
808 ExternalTypeReference:
809 modulereference DOT_SYM LineNo typereference
810 {
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;
816
817 /* add entry to this module's import list */
818 AddPrivateImportElmt (modulePtrG, $4, $1, $3);
819 }
820 ;
821
822
823 DefinedType: /* could by CharacterString or Useful types too */
824 ExternalTypeReference { $$ = $1; }
825 | typereference
826 {
827 SetupType (&$$, BASICTYPE_LOCALTYPEREF, myLineNoG);
828 $$->basicType->a.localTypeRef = MT (TypeRef);
829 $$->basicType->a.localTypeRef->typeName = $1;
830 }
831 ;
832
833
834
835 Type:
836 DefinedMacroType
837 | BuiltinType
838 | DefinedType
839 | Subtype
840 ;
841
842 BuiltinType:
843 BooleanType
844 | IntegerType
845 | BitStringType
846 | NullType
847 | SequenceType
848 | SequenceOfType
849 | SetType
850 | SetOfType
851 | ChoiceType
852 | SelectionType
853 | TaggedType
854 | AnyType
855 | ObjectIdentifierType
856 | EnumeratedType
857 | RealType
858 | OCTET_SYM STRING_SYM
859 {
860 SetupType (&$$, BASICTYPE_OCTETSTRING, myLineNoG);
861 }
862 ;
863
864 NamedType:
865 identifier Type
866 {
867 $$ = MT (NamedType);
868 $$->type = $2;
869 $$->fieldName = $1;
870 }
871 | Type /* this handles selectionType as well */
872 {
873 $$ = MT (NamedType);
874 $$->type = $1;
875 }
876 ;
877
878 BooleanType:
879 BOOLEAN_SYM
880 {
881 SetupType (&$$, BASICTYPE_BOOLEAN, myLineNoG);
882 }
883 ;
884
885 IntegerType:
886 INTEGER_SYM
887 {
888 SetupType (&$$, BASICTYPE_INTEGER, myLineNoG);
889 $$->basicType->a.integer = NEWLIST(); /* empty list */
890 }
891 | INTEGER_SYM LEFTBRACE_SYM NamedNumberList RIGHTBRACE_SYM
892 {
893 SetupType (&$$, BASICTYPE_INTEGER, myLineNoG);
894 $$->basicType->a.integer = $3;
895 }
896 ;
897
898
899 NamedNumberList:
900 NamedNumber
901 {
902 $$ = NEWLIST();
903 APPEND ($1, $$);
904 }
905 | NamedNumberList COMMA_SYM NamedNumber
906 {
907 APPEND ($3,$1);
908 $$ = $1;
909 }
910 ;
911
912 NamedNumber:
913 identifier LEFTPAREN_SYM SignedNumber RIGHTPAREN_SYM
914 {
915 $$ = MT (ValueDef);
916 $$->definedName = $1;
917 SetupValue (&$$->value, BASICVALUE_INTEGER, myLineNoG);
918 $$->value->basicValue->a.integer = $3;
919 }
920 | identifier LEFTPAREN_SYM DefinedValue RIGHTPAREN_SYM
921 {
922 $$ = MT (ValueDef);
923 $$->definedName = $1;
924 $$->value = $3;
925 }
926 ;
927
928 SignedNumber:
929 NUMBER_SYM
930 {
931 if ($1>0x7FFFFFFF) {
932 yyerror("Warning: positive signed number out of range");
933 $$ = 0x7FFFFFFF;
934 }
935 }
936 | NUMBER_ERANGE
937 {
938 yyerror ("Warning: positive signed number out of range");
939 $$ = 0x7FFFFFFF;
940 /* modulePtrG->status = MOD_ERROR; */
941 }
942 | MINUS_SYM NUMBER_SYM
943 {
944 if ($2>0x80000000) {
945 yyerror("Warning: negative signed number out of range");
946 $$ = -0x80000000;
947 } else if ($2==0x80000000) {
948 $$ = -0x80000000;
949 } else {
950 $$ = -$2;
951 }
952 }
953 | MINUS_SYM NUMBER_ERANGE
954 {
955 yyerror ("Warning: negative signed number out of range");
956 $$ = -0x80000000;
957 /* modulePtrG->status = MOD_ERROR; */
958 }
959 ;
960
961 EnumeratedType:
962 ENUMERATED_SYM LEFTBRACE_SYM NamedNumberList RIGHTBRACE_SYM
963 {
964 SetupType (&$$, BASICTYPE_ENUMERATED, myLineNoG);
965 $$->basicType->a.enumerated = $3;
966 }
967 ;
968
969
970 RealType:
971 REAL_SYM
972 {
973 SetupType (&$$, BASICTYPE_REAL, myLineNoG);
974 }
975 ;
976
977 BitStringType:
978 BIT_SYM STRING_SYM
979 {
980 SetupType (&$$, BASICTYPE_BITSTRING, myLineNoG);
981 $$->basicType->a.bitString = NEWLIST(); /* empty list */
982 }
983 | BIT_SYM STRING_SYM LEFTBRACE_SYM NamedBitList RIGHTBRACE_SYM
984 {
985 SetupType (&$$, BASICTYPE_BITSTRING, myLineNoG);
986 $$->basicType->a.bitString = $4;
987 }
988 ;
989
990 NamedBitList:
991 NamedNumberList
992 ;
993
994
995
996 NullType:
997 NULL_SYM
998 {
999 SetupType (&$$, BASICTYPE_NULL, myLineNoG);
1000 }
1001 ;
1002
1003 SequenceOpening:
1004 SEQUENCE_SYM LineNo LEFTBRACE_SYM
1005 { $$ = $2; }
1006 ;
1007
1008 SequenceType:
1009 SequenceOpening ElementTypes RIGHTBRACE_SYM
1010 {
1011 NamedType *n;
1012
1013 SetupType (&$$, BASICTYPE_SEQUENCE, $1);
1014
1015 if (AsnListCount ((AsnList*)$2) != 0)
1016 {
1017 n = (NamedType*) FIRST_LIST_ELMT ((AsnList*)$2);
1018 n->type->lineNo = $1;
1019 }
1020
1021 $$->basicType->a.sequence = $2;
1022
1023 }
1024 | SequenceOpening RIGHTBRACE_SYM
1025 {
1026 SetupType (&$$, BASICTYPE_SEQUENCE, $1);
1027
1028 /* set up empty list for SEQ with no elmts */
1029 $$->basicType->a.sequence = AsnListNew (sizeof (void*));
1030 }
1031 /* | SEQUENCE_SYM LEFTBRACE_SYM error RIGHTBRACE_SYM
1032 {
1033 PARSE_ERROR();
1034 yyerrok;
1035 } */
1036 ;
1037
1038 ElementTypes:
1039 ElementTypeList SnaccAttributes
1040 {
1041 NamedType *lastElmt;
1042
1043 if ($2 != NULL)
1044 {
1045 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1046 lastElmt->type->attrList = $2;
1047 }
1048 $$ = $1;
1049 }
1050 ;
1051
1052 ElementTypeList:
1053 ElementType
1054 {
1055 $$ = NEWLIST();
1056 APPEND ($1,$$);
1057 }
1058 | ElementTypeList COMMA_SYM SnaccAttributes LineNo ElementType
1059 {
1060 NamedType *lastElmt;
1061
1062 if ($3 != NULL)
1063 {
1064 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1065 lastElmt->type->attrList = $3;
1066 }
1067
1068 APPEND ($5, $1);
1069 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1070 lastElmt->type->lineNo = $4;
1071 $$ = $1;
1072 }
1073 ;
1074
1075 ElementType:
1076 NamedType
1077 | NamedType OPTIONAL_SYM
1078 {
1079 $$ = $1;
1080 $$->type->optional = TRUE;
1081 }
1082 | NamedType DEFAULT_SYM NamedValue
1083 {
1084 /*
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
1088 * enclosing { }
1089 */
1090 $$ = $1;
1091 $$->type->defaultVal = $3;
1092 /*
1093 * could link value to the elmt type here (done in link_types.c)
1094 */
1095 }
1096 | COMPONENTS_SYM OF_SYM Type
1097 {
1098 $$ = MT (NamedType);
1099 SetupType (&$$->type, BASICTYPE_COMPONENTSOF, myLineNoG);
1100 $$->type->basicType->a.componentsOf = $3;
1101 }
1102 | identifier COMPONENTS_SYM OF_SYM Type
1103 {
1104 $$ = MT (NamedType);
1105 SetupType (&$$->type, BASICTYPE_COMPONENTSOF, myLineNoG);
1106 $$->fieldName = $1;
1107 $$->type->basicType->a.componentsOf = $4;
1108 }
1109 ;
1110
1111
1112
1113 SequenceOfType:
1114 SEQUENCE_SYM OF_SYM Type
1115 {
1116 NamedType *n;
1117
1118 /* does not use SEQUENCE == SEQ OF ANY abrev*/
1119 SetupType (&$$, BASICTYPE_SEQUENCEOF, myLineNoG);
1120
1121 /* grab line number from first elmt */
1122 if ($3 != NULL)
1123 $$->lineNo = $3->lineNo - 1;
1124
1125 $$->basicType->a.sequenceOf = $3;
1126 }
1127 ;
1128
1129 SetOpening:
1130 SET_SYM LineNo LEFTBRACE_SYM { $$ = $2; }
1131 ;
1132
1133 SetType:
1134 SetOpening ElementTypes RIGHTBRACE_SYM
1135 {
1136 NamedType *n;
1137
1138 SetupType (&$$, BASICTYPE_SET, $1);
1139
1140 /* reset first elmt's line number */
1141 if (AsnListCount ((AsnList*)$2) != 0)
1142 {
1143 n = (NamedType*)FIRST_LIST_ELMT ((AsnList*)$2);
1144 n->type->lineNo = $1;
1145 }
1146 $$->basicType->a.set = $2;
1147 }
1148 | SetOpening RIGHTBRACE_SYM
1149 {
1150 SetupType (&$$, BASICTYPE_SET, $1);
1151
1152 /* set up empty elmt list for SET */
1153 $$->basicType->a.set = AsnListNew (sizeof (void*));
1154 }
1155 /* | SET_SYM LEFTBRACE_SYM error RIGHTBRACE_SYM
1156 {
1157 PARSE_ERROR();
1158 yyerrok;
1159 } */
1160 ;
1161
1162
1163 SetOfType:
1164 SET_SYM OF_SYM Type
1165 {
1166 /* does not allow SET == SET OF ANY Abrev */
1167 SetupType (&$$, BASICTYPE_SETOF, myLineNoG);
1168
1169 if ($3 != NULL)
1170 $$->lineNo = $3->lineNo;
1171
1172 $$->basicType->a.setOf = $3;
1173 }
1174 ;
1175
1176
1177 ChoiceType:
1178 CHOICE_SYM LineNo LEFTBRACE_SYM AlternativeTypes RIGHTBRACE_SYM
1179 {
1180 NamedType *n;
1181
1182 SetupType (&$$, BASICTYPE_CHOICE, $2);
1183
1184 $$->basicType->a.choice = $4;
1185
1186 if (AsnListCount ($4) != 0)
1187 {
1188 n = (NamedType*)FIRST_LIST_ELMT ($4);
1189 n->type->lineNo = $2;
1190 }
1191 }
1192 ;
1193
1194 AlternativeTypes:
1195 AlternativeTypeList SnaccAttributes
1196 {
1197 NamedType *lastElmt;
1198 if ($2 != NULL)
1199 {
1200 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1201 lastElmt->type->attrList = $2;
1202 }
1203 $$ = $1;
1204 }
1205 ;
1206
1207 AlternativeTypeList:
1208 NamedType
1209 {
1210 $$ = NEWLIST();
1211 APPEND ($1, $$);
1212 }
1213 | AlternativeTypeList COMMA_SYM SnaccAttributes NamedType
1214 {
1215 NamedType *lastElmt;
1216
1217 if ($3 != NULL)
1218 {
1219 lastElmt = (NamedType*)LAST_LIST_ELMT ($1);
1220 lastElmt->type->attrList = $3;
1221 }
1222 APPEND ($4,$1);
1223 $$ = $1;
1224 }
1225 ;
1226
1227
1228 SelectionType:
1229 identifier LESSTHAN_SYM Type
1230 {
1231 /*
1232 * the selection type should be replaced after
1233 * link with actual type
1234 */
1235 SetupType (&$$, BASICTYPE_SELECTION, myLineNoG);
1236
1237 $$->basicType->a.selection = MT (SelectionType);
1238 $$->basicType->a.selection->typeRef = $3;
1239 $$->basicType->a.selection->fieldName = $1;
1240 }
1241 ;
1242
1243 TaggedType:
1244 Tag Type
1245 {
1246 Tag *tag;
1247
1248 /* remove next tag if any && IMPLICIT_TAGS */
1249 if ((modulePtrG->tagDefault == IMPLICIT_TAGS) &&
1250 ($2->tags != NULL) && !LIST_EMPTY ($2->tags))
1251 {
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 */
1255
1256 /*
1257 * set implicit if implicitly tagged built in type (ie not ref)
1258 * (this simplifies the module ASN.1 printer (print.c))
1259 */
1260 if (tag->tclass == UNIV)
1261 $2->implicit = TRUE;
1262
1263 Free (tag);
1264 }
1265
1266 PREPEND ($1, $2->tags);
1267 $$ = $2;
1268 }
1269 | Tag IMPLICIT_SYM Type
1270 {
1271 Tag *tag;
1272
1273 /* remove next tag if any */
1274 if (($3->tags != NULL) && !LIST_EMPTY ($3->tags))
1275 {
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 */
1279
1280 if (tag->tclass == UNIV)
1281 $3->implicit = TRUE;
1282
1283 Free (tag);
1284 }
1285
1286 /*
1287 * must check after linking that implicitly tagged
1288 * local/import type refs are not untagged choice/any etc
1289 */
1290 else if (($3->basicType->choiceId == BASICTYPE_IMPORTTYPEREF) ||
1291 ($3->basicType->choiceId == BASICTYPE_LOCALTYPEREF) ||
1292 ($3->basicType->choiceId == BASICTYPE_SELECTION))
1293 $3->implicit = TRUE;
1294
1295 /*
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
1299 */
1300 else
1301 {
1302 PrintErrLoc (modulePtrG->asn1SrcFileName, $3->lineNo);
1303 fprintf (stderr, "ERROR - attempt to implicitly reference untagged type\n");
1304 smallErrG = 1;
1305 }
1306
1307 PREPEND ($1, $3->tags);
1308 $$ = $3;
1309 }
1310 | Tag EXPLICIT_SYM Type
1311 {
1312 /* insert tag at head of list */
1313 $1->explicit = TRUE;
1314 PREPEND ($1, $3->tags);
1315 $$ = $3;
1316 }
1317 ;
1318
1319 Tag:
1320 LEFTBRACKET_SYM Class ClassNumber RIGHTBRACKET_SYM
1321 {
1322 $$ = $3;
1323 $$->tclass = $2;
1324 $$->explicit = FALSE; /* default to false */
1325
1326 /*
1327 * keep track of APPLICATION Tags per module
1328 * should only be used once
1329 */
1330 if ($2 == APPL)
1331 {
1332 PushApplTag ($$->code, myLineNoG);
1333 }
1334 }
1335 ;
1336
1337 ClassNumber:
1338 number
1339 {
1340 $$ = MT (Tag);
1341 $$->code = $1;
1342 }
1343 | DefinedValue
1344 {
1345 $$ = MT (Tag);
1346 $$->code = NO_TAG_CODE;
1347 $$->valueRef = $1;
1348 }
1349 ;
1350
1351 Class:
1352 UNIVERSAL_SYM { $$ = UNIV; }
1353 | APPLICATION_SYM { $$ = APPL; }
1354 | PRIVATE_SYM { $$ = PRIV; }
1355 | empty { $$ = CNTX; }
1356 ;
1357
1358
1359 AnyType:
1360 ANY_SYM
1361 {
1362 SetupType (&$$, BASICTYPE_ANY, myLineNoG);
1363 }
1364 | ANY_SYM DEFINED_SYM BY_SYM identifier
1365 {
1366 SetupType (&$$, BASICTYPE_ANYDEFINEDBY, myLineNoG);
1367 $$->basicType->a.anyDefinedBy = MT (AnyDefinedByType);
1368 $$->basicType->a.anyDefinedBy->fieldName = $4;
1369 }
1370 ;
1371
1372
1373 ObjectIdentifierType:
1374 OBJECT_IDENTIFIER_SYM
1375 {
1376 SetupType (&$$, BASICTYPE_OID, myLineNoG);
1377 }
1378 ;
1379
1380
1381 Subtype:
1382 Type SubtypeSpec
1383 {
1384 /*
1385 * append new subtype list to existing one (s) if any
1386 * with AND relation
1387 */
1388 AppendSubtype (&$1->subtypes, $2, SUBTYPE_AND);
1389 $$ = $1;
1390 }
1391 | SET_SYM SizeConstraint OF_SYM Type
1392 {
1393 Subtype *s;
1394
1395 SetupType (&$$, BASICTYPE_SETOF, myLineNoG);
1396 $$->basicType->a.setOf = $4;
1397
1398 /* add size constraint */
1399 s = MT (Subtype);
1400 s->choiceId = SUBTYPE_SINGLE;
1401 s->a.single = $2;
1402 AppendSubtype (&$$->subtypes, s, SUBTYPE_AND);
1403 }
1404 | SEQUENCE_SYM SizeConstraint OF_SYM Type
1405 {
1406 Subtype *s;
1407
1408 SetupType (&$$, BASICTYPE_SEQUENCEOF, myLineNoG);
1409 $$->basicType->a.sequenceOf = $4;
1410
1411 /* add size constraint */
1412 s = MT (Subtype);
1413 s->choiceId = SUBTYPE_SINGLE;
1414 s->a.single = $2;
1415 AppendSubtype (&$$->subtypes, s, SUBTYPE_AND);
1416 }
1417 ;
1418
1419
1420 SubtypeSpec:
1421 LEFTPAREN_SYM SubtypeValueSetList RIGHTPAREN_SYM
1422 {
1423 $$ = $2;
1424 }
1425 ;
1426
1427 SubtypeValueSetList:
1428 SubtypeValueSet
1429 {
1430 Subtype *s;
1431
1432 /* OR relation between all elmts of in ValueSetList */
1433
1434 $$ = MT (Subtype);
1435 $$->choiceId = SUBTYPE_OR;
1436 $$->a.or = NEWLIST();
1437
1438 s = MT (Subtype);
1439 s->choiceId = SUBTYPE_SINGLE;
1440 s->a.single = $1;
1441 APPEND (s, $$->a.or);
1442 }
1443 | SubtypeValueSetList BAR_SYM SubtypeValueSet
1444 {
1445 Subtype *s;
1446 s = MT (Subtype);
1447 s->choiceId = SUBTYPE_SINGLE;
1448 s->a.single = $3;
1449 APPEND (s, $1->a.or);
1450 $$ = $1;
1451 }
1452 ;
1453
1454
1455 SubtypeValueSet:
1456 SingleValue
1457 | ContainedSubtype
1458 | ValueRange
1459 | PermittedAlphabet
1460 | SizeConstraint
1461 | InnerTypeConstraints
1462 ;
1463
1464 SingleValue:
1465 Value
1466 {
1467 $$ = MT (SubtypeValue);
1468 $$->choiceId = SUBTYPEVALUE_SINGLEVALUE;
1469 $$->a.singleValue = $1;
1470 }
1471
1472 ContainedSubtype:
1473 INCLUDES_SYM Type
1474 {
1475 $$ = MT (SubtypeValue);
1476 $$->choiceId = SUBTYPEVALUE_CONTAINED;
1477 $$->a.contained = $2;
1478 }
1479 ;
1480
1481 ValueRange:
1482 LowerEndPoint DOT_SYM DOT_SYM UpperEndPoint
1483 {
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;
1493 }
1494 ;
1495
1496 LowerEndPoint:
1497 LowerEndValue
1498 {
1499 $$ = $1;
1500 valueRangeLowerEndInclusiveG = TRUE;
1501 }
1502 | LowerEndValue LESSTHAN_SYM
1503 {
1504 $$ = $1;
1505 valueRangeLowerEndInclusiveG = FALSE;
1506 }
1507 ;
1508
1509 UpperEndPoint:
1510 UpperEndValue
1511 {
1512 $$ = $1;
1513 valueRangeUpperEndInclusiveG = TRUE;
1514 }
1515 | LESSTHAN_SYM UpperEndValue
1516 {
1517 $$ = $2;
1518 valueRangeUpperEndInclusiveG = FALSE;
1519 }
1520 ;
1521
1522 LowerEndValue:
1523 Value { $$ = $1; }
1524 | MIN_SYM
1525 {
1526 SetupValue (&$$, BASICVALUE_SPECIALINTEGER, myLineNoG);
1527 $$->basicValue->a.specialInteger = MIN_INT;
1528 }
1529 ;
1530
1531 UpperEndValue:
1532 Value { $$ = $1; }
1533 | MAX_SYM
1534 {
1535 SetupValue (&$$, BASICVALUE_SPECIALINTEGER, myLineNoG);
1536 $$->basicValue->a.specialInteger = MAX_INT;
1537 }
1538 ;
1539
1540 SizeConstraint:
1541 SIZE_SYM SubtypeSpec
1542 {
1543 $$ = MT (SubtypeValue);
1544 $$->choiceId = SUBTYPEVALUE_SIZECONSTRAINT;
1545 $$->a.sizeConstraint = $2;
1546 }
1547 ;
1548
1549
1550 PermittedAlphabet:
1551 FROM_SYM SubtypeSpec
1552 {
1553 $$ = MT (SubtypeValue);
1554 $$->choiceId = SUBTYPEVALUE_PERMITTEDALPHABET;
1555 $$->a.permittedAlphabet = $2;
1556 }
1557 ;
1558
1559 InnerTypeConstraints:
1560 WITH_SYM COMPONENT_SYM SingleTypeConstraint
1561 {
1562 $$ = MT (SubtypeValue);
1563 $$->choiceId = SUBTYPEVALUE_INNERSUBTYPE;
1564 $$->a.innerSubtype = $3;
1565 }
1566 | WITH_SYM COMPONENTS_SYM MultipleTypeConstraints
1567 {
1568 $$ = MT (SubtypeValue);
1569 $$->choiceId = SUBTYPEVALUE_INNERSUBTYPE;
1570 $$->a.innerSubtype = $3;
1571 }
1572 ;
1573
1574 SingleTypeConstraint:
1575 SubtypeSpec
1576 {
1577 Constraint *constraint;
1578
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;
1586 }
1587 ;
1588
1589 MultipleTypeConstraints:
1590 FullSpecification
1591 | PartialSpecification
1592 ;
1593
1594 FullSpecification:
1595 LEFTBRACE_SYM TypeConstraints RIGHTBRACE_SYM
1596 {
1597 $$ = MT (InnerSubtype);
1598 $$->constraintType = FULL_CT;
1599 $$->constraints = $2;
1600 }
1601 ;
1602
1603 PartialSpecification:
1604 LEFTBRACE_SYM DOT_SYM DOT_SYM DOT_SYM COMMA_SYM TypeConstraints RIGHTBRACE_SYM
1605 {
1606 $$ = MT (InnerSubtype);
1607 $$->constraintType = PARTIAL_CT;
1608 $$->constraints = $6;
1609 }
1610 ;
1611
1612
1613 TypeConstraints:
1614 NamedConstraint
1615 {
1616 $$ = NEWLIST();
1617 APPEND ($1, $$);
1618 }
1619 | TypeConstraints COMMA_SYM NamedConstraint
1620 {
1621 APPEND ($3, $1);
1622 $$ = $1;
1623 }
1624 ;
1625
1626 NamedConstraint:
1627 identifier Constraint
1628 {
1629 $$ = $2;
1630 $$->fieldRef = $1;
1631 }
1632 | Constraint
1633
1634 ;
1635
1636 Constraint:
1637 ValueConstraint PresenceConstraint
1638 {
1639 $$ = MT (Constraint);
1640 $$->presenceConstraint = $2;
1641 $$->valueConstraints = $1;
1642 }
1643 ;
1644
1645 ValueConstraint:
1646 SubtypeSpec { $$ = $1; }
1647 | empty { $$ = NULL; }
1648 ;
1649
1650 PresenceConstraint:
1651 PRESENT_SYM { $$ = PRESENT_CT; }
1652 | ABSENT_SYM { $$ = ABSENT_CT; }
1653 | empty { $$ = EMPTY_CT; }
1654 | OPTIONAL_SYM { $$ = OPTIONAL_CT; }
1655 ;
1656
1657
1658
1659
1660
1661
1662 /*-----------------------------------------------------------------------*/
1663 /* Value Notation Productions */
1664 /*-----------------------------------------------------------------------*/
1665
1666 ValueAssignment:
1667 identifier Type GETS_SYM LineNo Value
1668 {
1669 $$ = MT (ValueDef);
1670 $$->definedName = $1;
1671 $$->value = $5;
1672 $$->value->lineNo = $4;
1673 $$->value->type = $2;
1674 }
1675 ;
1676
1677
1678 Value:
1679 BuiltinValue
1680 | DefinedValue
1681 ;
1682
1683 DefinedValue:
1684 ExternalValueReference { $$ = $1; }
1685 | identifier /* a defined value or a named elmt ref */
1686 {
1687 /*
1688 * for parse, may be set to BASICVALUE_IMPORTEDTYPEREF
1689 * by linker
1690 */
1691 SetupValue (&$$, BASICVALUE_LOCALVALUEREF, myLineNoG);
1692 $$->basicValue->a.localValueRef = MT (ValueRef);
1693 $$->basicValue->a.localValueRef->valueName = $1;
1694 $$->valueType = BASICTYPE_UNKNOWN;
1695 }
1696 ;
1697
1698 ExternalValueReference:
1699 modulereference DOT_SYM LineNo identifier
1700 {
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;
1707
1708 /* add entry to this module's import list */
1709 AddPrivateImportElmt (modulePtrG, $4, $1, $3);
1710 }
1711 ;
1712
1713 BuiltinValue:
1714 BooleanValue
1715 | NullValue
1716 | SpecialRealValue
1717 | SignedNumber /* IntegerValue or "0" real val*/
1718 {
1719 SetupValue (&$$, BASICVALUE_INTEGER, myLineNoG);
1720 $$->valueType = BASICTYPE_UNKNOWN;
1721 $$->basicValue->a.integer = $1;
1722 }
1723 | HexString /* OctetStringValue or BinaryStringValue */
1724 {
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);
1730 }
1731 | BinaryString /* BinaryStringValue */
1732 {
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);
1738 }
1739 | CharString
1740 {
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);
1746 }
1747 | LEFTBRACE_SYM { LexBeginBraceBalContext(); } BRACEBAL_SYM
1748 {
1749 /*
1750 * LEXICAL TIE IN!!
1751 * string returned by BRACEBAL_SYM has
1752 * the $1 '{' prepended and includes everything
1753 * upto and including '}' that balances $1
1754 */
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;
1761 }
1762 ;
1763
1764 BooleanValue:
1765 TRUE_SYM
1766 {
1767 SetupValue (&$$, BASICVALUE_BOOLEAN, myLineNoG);
1768 $$->valueType = BASICTYPE_UNKNOWN;
1769 $$->basicValue->a.boolean = TRUE;
1770 }
1771 | FALSE_SYM
1772 {
1773 SetupValue (&$$, BASICVALUE_BOOLEAN, myLineNoG);
1774 $$->valueType = BASICTYPE_UNKNOWN;
1775 $$->basicValue->a.boolean = FALSE;
1776 }
1777 ;
1778
1779
1780 SpecialRealValue:
1781 PLUS_INFINITY_SYM
1782 {
1783 SetupValue (&$$, BASICVALUE_SPECIALREAL, myLineNoG);
1784 $$->valueType = BASICTYPE_UNKNOWN;
1785 $$->basicValue->a.specialReal = PLUS_INFINITY_REAL;
1786 }
1787 | MINUS_INFINITY_SYM
1788 {
1789 SetupValue (&$$, BASICVALUE_SPECIALREAL, myLineNoG);
1790 $$->valueType = BASICTYPE_UNKNOWN;
1791 $$->basicValue->a.specialReal = MINUS_INFINITY_REAL;
1792 }
1793 ;
1794
1795
1796
1797 NullValue:
1798 NULL_SYM
1799 {
1800 /* create a NULL value */
1801 SetupValue (&$$, BASICVALUE_NULL, myLineNoG);
1802 $$->valueType = BASICTYPE_UNKNOWN;
1803 }
1804 ;
1805
1806
1807 NamedValue:
1808 Value
1809 {
1810 $$ = MT (NamedValue);
1811 $$->value = $1;
1812 }
1813 | identifier Value
1814 {
1815 $$ = MT (NamedValue);
1816 $$->value = $2;
1817 $$->fieldName = $1;
1818 }
1819 ;
1820
1821
1822 ObjectIdentifierValue:
1823 LEFTBRACE_SYM ObjIdComponentList RIGHTBRACE_SYM
1824 {
1825 /*
1826 * example OID setup
1827 *
1828 * for { ccitt foo (1) bar bell (bunt) 2 }
1829 *
1830 * ccitt
1831 * - arcnum is set to number from oid table (oid.c)
1832 * foo (1)
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)
1835 * bar
1836 * - makes oid valueref a value ref to bar (doesn't link it tho)
1837 * bell (bunt)
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)
1840 * 2
1841 * - arcnum is set to 2
1842 */
1843
1844 $$ = $2;
1845 }
1846 ;
1847
1848
1849 ObjIdComponentList:
1850 ObjIdComponentList ObjIdComponent
1851 {
1852 OID *o;
1853 /* append component */
1854 for (o = $1; o->next != NULL; o = o->next)
1855 ;
1856 o->next = $2;
1857 $$ = $1;
1858 }
1859 | ObjIdComponent
1860
1861 ;
1862
1863
1864 ObjIdComponent:
1865 NumberForm
1866 | NameForm
1867 {
1868 Value *newVal;
1869 /*
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
1873 */
1874 $$ = MT (OID);
1875
1876 $$->arcNum = OidArcNameToNum ($1);
1877 if ($$->arcNum == NULL_OID_ARCNUM)
1878 {
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;
1885 }
1886 }
1887 | NameAndNumberForm
1888 ;
1889
1890
1891 NumberForm:
1892 number
1893 {
1894 $$ = MT (OID);
1895 $$->arcNum = $1;
1896 }
1897 ;
1898
1899 NameForm:
1900 identifier
1901 ;
1902
1903
1904 NameAndNumberForm:
1905 identifier LEFTPAREN_SYM NumberForm RIGHTPAREN_SYM
1906 {
1907 Value *newVal;
1908
1909 $$ = $3;
1910
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);
1916
1917 SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG);
1918 newVal->basicValue->a.localValueRef = MT (ValueRef);
1919 newVal->basicValue->a.localValueRef->valueName = $1;
1920
1921 $$->valueRef = newVal;
1922 }
1923 | identifier LEFTPAREN_SYM DefinedValue RIGHTPAREN_SYM
1924 {
1925 Value *newVal;
1926
1927 /* shared refs to named numbers name */
1928 $$ = MT (OID);
1929 $$->arcNum = NULL_OID_ARCNUM;
1930
1931 AddNewValueDef (oidElmtValDefsG, $1, $3);
1932
1933 SetupValue (&newVal, BASICVALUE_LOCALVALUEREF, myLineNoG);
1934 newVal->basicValue->a.localValueRef = MT (ValueRef);
1935 newVal->basicValue->a.localValueRef->valueName = $1;
1936
1937 $$->valueRef = newVal;
1938 }
1939
1940 ;
1941
1942
1943
1944 BinaryString:
1945 BSTRING_SYM
1946 ;
1947
1948 HexString:
1949 HSTRING_SYM
1950 ;
1951
1952 CharString:
1953 CSTRING_SYM
1954 ;
1955
1956 number:
1957 NUMBER_SYM
1958 {
1959 if ($1>0x7FFFFFFF) {
1960 yyerror("Warning: number out of range");
1961 $$ = 0x7FFFFFFF;
1962 }
1963 }
1964 | NUMBER_ERANGE
1965 {
1966 yyerror ("Warning: number out of range");
1967 $$ = 0x7FFFFFFF;
1968 /* modulePtrG->status = MOD_ERROR; */
1969 }
1970 ;
1971
1972 identifier:
1973 LCASEFIRST_IDENT_SYM
1974 ;
1975
1976 modulereference:
1977 UCASEFIRST_IDENT_SYM
1978 ;
1979
1980 typereference:
1981 UCASEFIRST_IDENT_SYM
1982 ;
1983
1984 empty:
1985 ;
1986
1987
1988 /* Snacc attributes/extra type info
1989 * - encapsulated in special comments
1990 */
1991 SnaccAttributes:
1992 SnaccAttributeCommentList
1993 | empty {$$ = NULL;}
1994 ;
1995
1996 SnaccAttributeCommentList:
1997 SNACC_ATTRIBUTES
1998 {
1999 $$ = NEWLIST();
2000 APPEND ($1,$$);
2001 }
2002 | SnaccAttributeCommentList SNACC_ATTRIBUTES
2003 {
2004 APPEND ($2,$1);
2005 $$ = $1;
2006 }
2007 ;
2008
2009 /*
2010 * Macro Syntax definitions
2011 **************************/
2012
2013 DefinedMacroType:
2014 RosOperationMacroType
2015 | RosErrorMacroType
2016 | RosBindMacroType
2017 | RosUnbindMacroType
2018 | RosAseMacroType
2019 | RosAcMacroType
2020 | MtsasExtensionMacroType
2021 | MtsasExtensionsMacroType
2022 | MtsasExtensionAttributeMacroType
2023 | MtsasTokenMacroType
2024 | MtsasTokenDataMacroType
2025 | MtsasSecurityCategoryMacroType
2026 | AsnObjectMacroType
2027 | AsnPortMacroType
2028 | AsnRefineMacroType
2029 | AsnAbstractBindMacroType
2030 | AsnAbstractUnbindMacroType
2031 | AsnAbstractOperationMacroType
2032 | AsnAbstractErrorMacroType
2033 | AfAlgorithmMacroType
2034 | AfEncryptedMacroType
2035 | AfProtectedMacroType
2036 | AfSignatureMacroType
2037 | AfSignedMacroType
2038 | SnmpObjectTypeMacroType
2039 ;
2040
2041 DefinedMacroName:
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"; }
2067 ;
2068
2069
2070 /*
2071 * Operation Macro (ROS) added by MS 91/08/27
2072 */
2073
2074 RosOperationMacroType:
2075 OPERATION_SYM RosOperationMacroBody { $$ = $2; }
2076 ;
2077
2078 RosOperationMacroBody:
2079 RosOpArgument RosOpResult RosOpErrors RosOpLinkedOps
2080 {
2081 RosOperationMacroType *r;
2082
2083 SetupMacroType (&$$, MACROTYPE_ROSOPERATION, myLineNoG);
2084 r = $$->basicType->a.macroType->a.rosOperation =
2085 MT (RosOperationMacroType);
2086 r->arguments = $1;
2087 r->result = $2;
2088 r->errors = $3;
2089 r->linkedOps = $4;
2090 }
2091 ;
2092
2093
2094 RosOpArgument:
2095 ARGUMENT_SYM NamedType { $$ = $2; }
2096 | empty { $$ = NULL; }
2097 ;
2098
2099 RosOpResult:
2100 RESULT_SYM RosOpResultType { $$ = $2; }
2101 | empty { $$ = NULL; }
2102 ;
2103
2104
2105 RosOpResultType:
2106 NamedType
2107 | empty { $$ = NULL; }
2108 ;
2109
2110
2111 RosOpErrors:
2112 ERRORS_SYM LEFTBRACE_SYM PossiblyEmptyTypeOrValueList RIGHTBRACE_SYM
2113 {
2114 $$ = $3;
2115 }
2116 | empty { $$ = NULL; }
2117 ;
2118
2119
2120
2121 RosOpLinkedOps:
2122 LINKED_SYM LEFTBRACE_SYM PossiblyEmptyTypeOrValueList RIGHTBRACE_SYM
2123 {
2124 $$ = $3;
2125 }
2126 | empty { $$ = NULL; }
2127 ;
2128
2129
2130
2131
2132 /*
2133 * ROS ERROR macro - ms 91/08/27
2134 */
2135
2136
2137 RosErrorMacroType:
2138 ERROR_SYM RosErrParameter
2139 {
2140 RosErrorMacroType *r;
2141 /*
2142 * defines error macro type
2143 */
2144 SetupMacroType (&$$, MACROTYPE_ROSERROR, myLineNoG);
2145 r = $$->basicType->a.macroType->a.rosError = MT (RosErrorMacroType);
2146 r->parameter = $2;
2147 }
2148 ;
2149
2150
2151 RosErrParameter:
2152 PARAMETER_SYM NamedType { $$ = $2; }
2153 | empty { $$ = NULL; }
2154 ;
2155
2156
2157 /*
2158 * ROS BIND macro - ms 91/09/13
2159 */
2160
2161 RosBindMacroType:
2162 BIND_SYM RosBindArgument RosBindResult RosBindError
2163 {
2164 RosBindMacroType *r;
2165
2166 SetupMacroType (&$$, MACROTYPE_ROSBIND, myLineNoG);
2167
2168 r = $$->basicType->a.macroType->a.rosBind = MT (RosBindMacroType);
2169 r->argument = $2;
2170 r->result = $3;
2171 r->error = $4;
2172 }
2173 ;
2174
2175 RosBindArgument:
2176 ARGUMENT_SYM NamedType { $$ = $2; }
2177 | empty { $$ = NULL; }
2178 ;
2179
2180
2181 RosBindResult:
2182 RESULT_SYM NamedType { $$ = $2; }
2183 | empty { $$ = NULL; }
2184 ;
2185
2186
2187 RosBindError:
2188 BINDERROR_SYM NamedType { $$ = $2; }
2189 | empty { $$ = NULL; }
2190 ;
2191
2192
2193 /*
2194 * ROS UNBIND ms 91/09/13
2195 */
2196
2197 RosUnbindMacroType:
2198 UNBIND_SYM RosBindArgument RosBindResult RosUnbindError
2199 {
2200 RosBindMacroType *r;
2201
2202 SetupMacroType (&$$, MACROTYPE_ROSUNBIND, myLineNoG);
2203
2204 r = $$->basicType->a.macroType->a.rosUnbind = MT (RosBindMacroType);
2205 r->argument = $2;
2206 r->result = $3;
2207 r->error = $4;
2208 }
2209 ;
2210
2211
2212 RosUnbindError:
2213 UNBINDERROR_SYM NamedType { $$ = $2; }
2214 | empty { $$ = NULL; }
2215 ;
2216
2217
2218 /*
2219 * ROS APPLICATION-SERVICE-ELEMENT macro ms 91/09/13
2220 */
2221
2222 RosAseMacroType:
2223 ASE_SYM RosAseSymmetricAse
2224 {
2225 RosAseMacroType *r;
2226
2227 SetupMacroType (&$$, MACROTYPE_ROSASE, myLineNoG);
2228 r = $$->basicType->a.macroType->a.rosAse = MT (RosAseMacroType);
2229 r->operations = $2;
2230 }
2231 | ASE_SYM RosAseConsumerInvokes RosAseSupplierInvokes
2232 {
2233 RosAseMacroType *r;
2234
2235 SetupMacroType (&$$, MACROTYPE_ROSASE, myLineNoG);
2236 r = $$->basicType->a.macroType->a.rosAse = MT (RosAseMacroType);
2237 r->consumerInvokes = $2;
2238 r->supplierInvokes = $3;
2239 }
2240 ;
2241
2242
2243 RosAseSymmetricAse:
2244 OPERATIONS_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM
2245 {
2246 $$ = $3;
2247 }
2248 ;
2249
2250
2251 RosAseConsumerInvokes:
2252 CONSUMERINVOKES_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM
2253 {
2254 $$ = $3;
2255 }
2256 | empty { $$ = NULL; }
2257 ;
2258
2259
2260 RosAseSupplierInvokes:
2261 SUPPLIERINVOKES_SYM LEFTBRACE_SYM RosAseOperationList RIGHTBRACE_SYM
2262 {
2263 $$ = $3;
2264 }
2265 | empty { $$ = NULL; }
2266 ;
2267
2268
2269 RosAseOperationList:
2270 ValueList
2271 ;
2272
2273
2274 /*
2275 * ROS APPLICATION-CONTEXT macro ms 91/09/13
2276 */
2277
2278 RosAcMacroType:
2279 AC_SYM
2280 RosAcNonRoElements
2281 BIND_SYM Type
2282 UNBIND_SYM Type
2283 RosAcRoElements
2284 RosAcAbstractSyntaxes
2285 {
2286 RosAcMacroType *r;
2287
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;
2298 }
2299 ;
2300
2301
2302 RosAcNonRoElements:
2303 ASES_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2304 {
2305 $$ = $3;
2306 }
2307 ;
2308
2309
2310 RosAcRoElements:
2311 REMOTE_SYM OPERATIONS_SYM LEFTBRACE_SYM Value RIGHTBRACE_SYM
2312 RosAcSymmetricAses RosAcAsymmetricAses
2313 {
2314 $$ = $4;
2315 }
2316 | empty
2317 {
2318 $$ = NULL;
2319 rosAcSymmetricAsesG = NULL;
2320 rosAcInitiatorConsumerOfG = NULL;
2321 rosAcResponderConsumerOfG = NULL;
2322 }
2323 ;
2324
2325 RosAcSymmetricAses:
2326 OPERATIONS_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2327 {
2328 rosAcSymmetricAsesG = $4;
2329 }
2330 | empty { rosAcSymmetricAsesG = NULL; }
2331 ;
2332
2333 RosAcAsymmetricAses:
2334 RosAcInitiatorConsumerOf RosAcResponderConsumerOf
2335 ;
2336
2337 RosAcInitiatorConsumerOf:
2338 INITIATOR_SYM CONSUMER_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2339 {
2340 rosAcInitiatorConsumerOfG = $5;
2341 }
2342 | empty { rosAcInitiatorConsumerOfG = NULL; }
2343 ;
2344
2345 RosAcResponderConsumerOf:
2346 RESPONDER_SYM CONSUMER_SYM OF_SYM LEFTBRACE_SYM ValueList RIGHTBRACE_SYM
2347 {
2348 rosAcResponderConsumerOfG = $5;
2349 }
2350 | empty { rosAcResponderConsumerOfG = NULL; }
2351 ;
2352
2353 RosAcAbstractSyntaxes:
2354 ABSTRACTSYNTAXES_SYM LEFTBRACE_SYM OidList RIGHTBRACE_SYM
2355 {
2356 $$ = $3;
2357 }
2358 | empty { $$ = NULL; }
2359 ;
2360
2361
2362 OidList:
2363 ObjectIdentifierValue
2364 {
2365 $$ = NEWLIST();
2366 APPEND ($1,$$);
2367 }
2368 | OidList COMMA_SYM ObjectIdentifierValue
2369 {
2370 APPEND ($3, $1);
2371 $$ = $1;
2372 }
2373 ;
2374
2375
2376 /*
2377 * MTSAbstractSvc EXTENSIONS macro
2378 */
2379
2380 MtsasExtensionsMacroType:
2381 EXTENSIONS_SYM CHOSEN_SYM FROM_SYM
2382 LEFTBRACE_SYM PossiblyEmptyValueList RIGHTBRACE_SYM
2383 {
2384 MtsasExtensionsMacroType *m;
2385
2386 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONS, myLineNoG);
2387 m = $$->basicType->a.macroType->a.mtsasExtensions =
2388 MT (MtsasExtensionsMacroType);
2389 m->extensions = $5;
2390 }
2391 ;
2392
2393
2394 PossiblyEmptyValueList:
2395 ValueList
2396 | empty { $$ = NULL; }
2397 ;
2398
2399 ValueList:
2400 Value
2401 {
2402 $$ = NEWLIST();
2403 APPEND ($1, $$);
2404 }
2405 | ValueList COMMA_SYM Value
2406 {
2407 APPEND ($3,$1);
2408 $$ = $1;
2409 }
2410 ;
2411
2412 PossiblyEmptyTypeOrValueList:
2413 TypeOrValueList
2414 | empty { $$ = NULL; }
2415 ;
2416
2417 TypeOrValueList:
2418 TypeOrValue
2419 {
2420 $$ = NEWLIST();
2421 APPEND ($1, $$);
2422 }
2423 | TypeOrValueList COMMA_SYM TypeOrValue
2424 {
2425 APPEND ($3,$1);
2426 $$ = $1;
2427 }
2428 ;
2429
2430 TypeOrValue:
2431 Type
2432 {
2433 $$ = MT (TypeOrValue);
2434 $$->choiceId = TYPEORVALUE_TYPE;
2435 $$->a.type = $1;
2436 }
2437 | Value
2438 {
2439 $$ = MT (TypeOrValue);
2440 $$->choiceId = TYPEORVALUE_VALUE;
2441 $$->a.value = $1;
2442 }
2443 ;
2444
2445 /*
2446 * MTSAbstractSvc EXTENSION macro
2447 */
2448
2449 MtsasExtensionMacroType:
2450 EXTENSION_SYM NamedType MtsasExtDefaultVal MtsasExtCritical
2451 {
2452 MtsasExtensionMacroType *m;
2453
2454 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSION, myLineNoG);
2455 m = $$->basicType->a.macroType->a.mtsasExtension =
2456 MT (MtsasExtensionMacroType);
2457 m->elmtType = $2;
2458 m->defaultValue = $3;
2459 m->criticalForSubmission = mtsasCriticalForSubmissionG;
2460 m->criticalForTransfer = mtsasCriticalForTransferG;
2461 m->criticalForDelivery = mtsasCriticalForDeliveryG;
2462
2463 mtsasCriticalForSubmissionG = NULL; /* set up for next parse */
2464 mtsasCriticalForTransferG = NULL;
2465 mtsasCriticalForDeliveryG = NULL;
2466 }
2467 | EXTENSION_SYM
2468 {
2469 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSION, myLineNoG);
2470 $$->basicType->a.macroType->a.mtsasExtension =
2471 MT (MtsasExtensionMacroType);
2472 /*
2473 * all fields are NULL in the MtsasExtensionsMacroType
2474 * for this production
2475 */
2476 }
2477 ;
2478
2479 MtsasExtDefaultVal:
2480 DEFAULT_SYM Value { $$ = $2; }
2481 | empty { $$ = NULL; }
2482 ;
2483
2484 MtsasExtCritical:
2485 CRITICAL_SYM FOR_SYM MtsasExtCriticalityList
2486 | empty
2487 ;
2488
2489
2490 MtsasExtCriticalityList:
2491 MtsasExtCriticality
2492 | MtsasExtCriticalityList COMMA_SYM MtsasExtCriticality
2493 ;
2494
2495 MtsasExtCriticality:
2496 SUBMISSION_SYM
2497 {
2498 mtsasCriticalForSubmissionG = MT (AsnBool);
2499 *mtsasCriticalForSubmissionG = TRUE;
2500 }
2501 | TRANSFER_SYM
2502 {
2503 mtsasCriticalForTransferG = MT (AsnBool);
2504 *mtsasCriticalForTransferG = TRUE;
2505 }
2506 | DELIVERY_SYM
2507 {
2508 mtsasCriticalForDeliveryG = MT (AsnBool);
2509 *mtsasCriticalForDeliveryG = TRUE;
2510 }
2511 ;
2512
2513
2514
2515 /*
2516 * MTSAbstractSvc X.411 EXTENSION-ATTRIBUTE macro
2517 */
2518
2519 MtsasExtensionAttributeMacroType:
2520 EXTENSIONATTRIBUTE_SYM
2521 {
2522 MtsasExtensionAttributeMacroType *m;
2523
2524 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG);
2525 m = $$->basicType->a.macroType->a.mtsasExtensionAttribute =
2526 MT (MtsasExtensionAttributeMacroType);
2527 m->type = NULL;
2528 }
2529 | EXTENSIONATTRIBUTE_SYM Type
2530 {
2531 MtsasExtensionAttributeMacroType *m;
2532
2533 SetupMacroType (&$$, MACROTYPE_MTSASEXTENSIONATTRIBUTE, myLineNoG);
2534 m = $$->basicType->a.macroType->a.mtsasExtensionAttribute =
2535 MT (MtsasExtensionAttributeMacroType);
2536 m->type = $2;
2537 }
2538 ;
2539
2540
2541 /*
2542 * X.411 MTSAbstractSvc TOKEN macro
2543 */
2544 MtsasTokenMacroType:
2545 TOKEN_SYM
2546 {
2547 MtsasTokenMacroType *m;
2548
2549 SetupMacroType (&$$, MACROTYPE_MTSASTOKEN, myLineNoG);
2550 m = $$->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType);
2551 m->type = NULL;
2552 }
2553 | TOKEN_SYM Type
2554 {
2555 MtsasTokenMacroType *m;
2556
2557 SetupMacroType (&$$, MACROTYPE_MTSASTOKEN, myLineNoG);
2558 m = $$->basicType->a.macroType->a.mtsasToken = MT (MtsasTokenMacroType);
2559 m->type = $2;
2560 }
2561 ;
2562
2563
2564 /*
2565 * X.411 MTSAS TOKEN-DATA macro type
2566 */
2567 MtsasTokenDataMacroType:
2568 TOKENDATA_SYM
2569 {
2570 MtsasTokenDataMacroType *m;
2571
2572 SetupMacroType (&$$, MACROTYPE_MTSASTOKENDATA, myLineNoG);
2573 m = $$->basicType->a.macroType->a.mtsasTokenData =
2574 MT (MtsasTokenDataMacroType);
2575 m->type = NULL;
2576 }
2577 | TOKENDATA_SYM Type
2578 {
2579 MtsasTokenDataMacroType *m;
2580
2581 SetupMacroType (&$$, MACROTYPE_MTSASTOKENDATA, myLineNoG);
2582 m = $$->basicType->a.macroType->a.mtsasTokenData =
2583 MT (MtsasTokenDataMacroType);
2584 m->type = $2;
2585 }
2586 ;
2587
2588
2589 /*
2590 * X.411 MTSAS SECURITY-CATEGORY
2591 */
2592 MtsasSecurityCategoryMacroType:
2593 SECURITYCATEGORY_SYM
2594 {
2595 MtsasSecurityCategoryMacroType *m;
2596
2597 SetupMacroType (&$$, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG);
2598 m = $$->basicType->a.macroType->a.mtsasSecurityCategory =
2599 MT (MtsasSecurityCategoryMacroType);
2600 m->type = NULL;
2601 }
2602 | SECURITYCATEGORY_SYM Type
2603 {
2604 MtsasSecurityCategoryMacroType *m;
2605
2606 SetupMacroType (&$$, MACROTYPE_MTSASSECURITYCATEGORY, myLineNoG);
2607 m = $$->basicType->a.macroType->a.mtsasSecurityCategory =
2608 MT (MtsasSecurityCategoryMacroType);
2609 m->type = $2;
2610 }
2611 ;
2612
2613
2614 /*
2615 * X.407 Abstract Service Notation Macro Type productions
2616 * MS 91/09/14
2617 */
2618
2619
2620 /*
2621 * OBJECT Macro X.407
2622 */
2623 AsnObjectMacroType:
2624 OBJECT_SYM AsnPorts
2625 {
2626 AsnObjectMacroType *a;
2627 SetupMacroType (&$$, MACROTYPE_ASNOBJECT, myLineNoG);
2628 a = $$->basicType->a.macroType->a.asnObject = MT (AsnObjectMacroType);
2629 a->ports = $2;
2630 }
2631 ;
2632
2633 AsnPorts:
2634 PORTS_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM
2635 {
2636 $$ = $3;
2637 }
2638 | empty { $$ = NULL; }
2639 ;
2640
2641 AsnPortList:
2642 AsnPort
2643 {
2644 $$ = NEWLIST();
2645 APPEND ($1, $$);
2646 }
2647 | AsnPortList COMMA_SYM AsnPort
2648 {
2649 APPEND ($3, $1);
2650 $$ = $1;
2651 }
2652 ;
2653
2654 AsnPort:
2655 Value AsnPortType
2656 {
2657 $$ = MT (AsnPort);
2658 $$->portValue = $1;
2659 $$->portType = $2;
2660 }
2661 ;
2662
2663 AsnPortType:
2664 BOXC_SYM
2665 {
2666 /* [C] consumer */
2667 $$ = CONSUMER_PORT;
2668 }
2669 | BOXS_SYM
2670 {
2671 /* [S] supplier */
2672 $$ = SUPPLIER_PORT;
2673 }
2674 | empty
2675 {
2676 /* symmetric */
2677 $$ = SYMMETRIC_PORT;
2678 }
2679 ;
2680
2681
2682
2683 /*
2684 * PORT Macro X.407
2685 */
2686 AsnPortMacroType:
2687 PORT_SYM AsnOperations
2688 {
2689 AsnPortMacroType *a;
2690
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;
2696 }
2697 | PORT_SYM
2698 {
2699 SetupMacroType (&$$, MACROTYPE_ASNPORT, myLineNoG);
2700 $$->basicType->a.macroType->a.asnPort = MT (AsnPortMacroType);
2701 }
2702 ;
2703
2704
2705 AsnOperations:
2706 ABSTRACTOPS_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
2707 {
2708 $$ = $3;
2709 }
2710 | AsnConsumer
2711 {
2712 $$ = NULL;
2713 asnConsumerG = $1;
2714 asnSupplierG = NULL;
2715 }
2716 | AsnSupplier
2717 {
2718 $$ = NULL;
2719 asnConsumerG = $1;
2720 asnSupplierG = NULL;
2721 }
2722 | AsnConsumer AsnSupplier
2723 {
2724 $$ = NULL;
2725 asnConsumerG = $1;
2726 asnSupplierG = NULL;
2727 }
2728 | AsnSupplier AsnConsumer
2729 {
2730 $$ = NULL;
2731 asnConsumerG = $1;
2732 asnSupplierG = NULL;
2733 }
2734 ;
2735
2736 AsnConsumer:
2737 CONSUMERINVOKES_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
2738 {
2739 $$ = $3;
2740 }
2741 ;
2742
2743 AsnSupplier:
2744 SUPPLIERINVOKES_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
2745 {
2746 $$ = $3;
2747 }
2748
2749 ;
2750
2751
2752
2753
2754 /*
2755 * REFINE Macro X.407
2756 *
2757 * just parse it - don't keep any info at the moment
2758 */
2759 AsnRefineMacroType:
2760 REFINE_SYM AsnObject AS_SYM AsnComponentList
2761 {
2762 SetupType (&$$, BASICTYPE_UNKNOWN, myLineNoG);
2763 }
2764 ;
2765
2766 AsnComponentList:
2767 AsnComponent
2768 | AsnComponentList COMMA_SYM AsnComponent
2769 ;
2770
2771 AsnComponent:
2772 AsnObjectSpec AsnPortSpecList
2773 ;
2774
2775 AsnObjectSpec:
2776 AsnObject
2777 | AsnObject RECURRING_SYM
2778 ;
2779
2780 AsnPortSpecList:
2781 AsnPortSpec
2782 | AsnPortSpecList COMMA_SYM AsnPortSpec
2783 ;
2784
2785 AsnPortSpec:
2786 Value AsnPortType AsnPortStatus
2787 {
2788 $$ = 0; /* just to quiet yacc warning */
2789 }
2790 ;
2791
2792 AsnPortStatus:
2793 VISIBLE_SYM
2794 | PAIRED_SYM WITH_SYM AsnObjectList
2795 ;
2796
2797
2798 AsnObjectList:
2799 AsnObject
2800 | AsnObjectList COMMA_SYM AsnObject
2801 ;
2802
2803 AsnObject:
2804 Value
2805 {
2806 $$ = 0; /* just to quiet yacc warning */
2807 }
2808 ;
2809
2810
2811
2812
2813 /*
2814 * ABSTRACT-BIND Macro X.407
2815 */
2816 AsnAbstractBindMacroType:
2817 ABSTRACTBIND_SYM AsnAbstractBindPorts
2818 {
2819 AsnAbstractBindMacroType *a;
2820
2821 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTBIND, myLineNoG);
2822 a = $$->basicType->a.macroType->a.asnAbstractBind =
2823 MT (AsnAbstractBindMacroType);
2824 a->ports = $2;
2825 }
2826 | ABSTRACTBIND_SYM AsnAbstractBindPorts Type
2827 {
2828 AsnAbstractBindMacroType *a;
2829
2830 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTBIND, myLineNoG);
2831 a = $$->basicType->a.macroType->a.asnAbstractBind =
2832 MT (AsnAbstractBindMacroType);
2833 a->ports = $2;
2834 a->type = $3;
2835 }
2836 ;
2837
2838 AsnAbstractBindPorts:
2839 TO_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM
2840 {
2841 $$ = $3;
2842 }
2843 | empty { $$ = NULL; }
2844 ;
2845
2846
2847
2848
2849 /*
2850 * ABSTRACT-UNBIND Macro X.407
2851 */
2852 AsnAbstractUnbindMacroType:
2853 ABSTRACTUNBIND_SYM AsnAbstractUnbindPorts
2854 {
2855 AsnAbstractBindMacroType *a;
2856
2857 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG);
2858 a = $$->basicType->a.macroType->a.asnAbstractUnbind =
2859 MT (AsnAbstractBindMacroType);
2860
2861 a->ports = $2;
2862 }
2863 | ABSTRACTUNBIND_SYM AsnAbstractUnbindPorts Type
2864 {
2865 AsnAbstractBindMacroType *a;
2866
2867 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTUNBIND, myLineNoG);
2868 a = $$->basicType->a.macroType->a.asnAbstractUnbind =
2869 MT (AsnAbstractBindMacroType);
2870
2871 a->ports = $2;
2872 a->type = $3;
2873 }
2874 ;
2875
2876 AsnAbstractUnbindPorts:
2877 FROM_SYM LEFTBRACE_SYM AsnPortList RIGHTBRACE_SYM
2878 {
2879 $$ = $3;
2880 }
2881 | empty { $$ = NULL; }
2882 ;
2883
2884
2885
2886 /*
2887 * ABSTRACT-OPERATION Macro X.407 (same as ROS Operation)
2888 */
2889 AsnAbstractOperationMacroType:
2890 ABSTRACTOPERATION_SYM RosOperationMacroBody
2891 {
2892 $$ = $2;
2893 $2->basicType->a.macroType->choiceId = MACROTYPE_ASNABSTRACTOPERATION;
2894 }
2895 ;
2896
2897
2898 /*
2899 * ABSTRACT-ERROR Macro X.407 (same as ROS Error)
2900 */
2901 AsnAbstractErrorMacroType:
2902 ABSTRACTERROR_SYM RosErrParameter
2903 {
2904 SetupMacroType (&$$, MACROTYPE_ASNABSTRACTERROR, myLineNoG);
2905 $$->basicType->a.macroType->a.asnAbstractError = MT (RosErrorMacroType);
2906 $$->basicType->a.macroType->a.asnAbstractError->parameter = $2;
2907 }
2908 ;
2909
2910
2911 /*
2912 * X.509 Authentication Framework ALGORITHM macro type
2913 */
2914 AfAlgorithmMacroType:
2915 ALGORITHM_SYM PARAMETER_SYM Type
2916 {
2917 SetupMacroType (&$$, MACROTYPE_AFALGORITHM, myLineNoG);
2918 $$->basicType->a.macroType->a.afAlgorithm = $3;
2919 }
2920 ;
2921
2922 /*
2923 * X.509 Authentication Framework ENCRYPTED macro type
2924 */
2925 AfEncryptedMacroType:
2926 ENCRYPTED_SYM Type
2927 {
2928 SetupMacroType (&$$, MACROTYPE_AFENCRYPTED, myLineNoG);
2929 $$->basicType->a.macroType->a.afEncrypted = $2;
2930 }
2931 ;
2932
2933
2934 /*
2935 * X.509 Authentication Framework SIGNED macro type
2936 */
2937 AfSignedMacroType:
2938 SIGNED_SYM Type
2939 {
2940 SetupMacroType (&$$, MACROTYPE_AFSIGNED, myLineNoG);
2941 $$->basicType->a.macroType->a.afSigned = $2;
2942 }
2943 ;
2944
2945 /*
2946 * X.509 Authentication Framework SIGNATURE macro type
2947 */
2948 AfSignatureMacroType:
2949 SIGNATURE_SYM Type
2950 {
2951 SetupMacroType (&$$, MACROTYPE_AFSIGNATURE, myLineNoG);
2952 $$->basicType->a.macroType->a.afSignature = $2;
2953 }
2954 ;
2955
2956
2957
2958 /*
2959 * X.509 Authentication Framework PROTECTED macro type
2960 * (same as SIGNATURE except for key word)
2961 */
2962 AfProtectedMacroType:
2963 PROTECTED_SYM Type
2964 {
2965 SetupMacroType (&$$, MACROTYPE_AFPROTECTED, myLineNoG);
2966 $$->basicType->a.macroType->a.afProtected = $2;
2967 }
2968 ;
2969
2970
2971
2972 SnmpObjectTypeMacroType:
2973 OBJECTTYPE_SYM
2974 SYNTAX_SYM Type
2975 ACCESS_SYM SnmpAccess
2976 STATUS_SYM SnmpStatus
2977 SnmpDescrPart
2978 SnmpReferPart
2979 SnmpIndexPart
2980 SnmpDefValPart
2981 {
2982 SnmpObjectTypeMacroType *s;
2983
2984 SetupMacroType (&$$, MACROTYPE_SNMPOBJECTTYPE, myLineNoG);
2985 s = $$->basicType->a.macroType->a.snmpObjectType =
2986 MT (SnmpObjectTypeMacroType);
2987
2988 s->syntax = $3;
2989 s->access = $5;
2990 s->status = $7;
2991 s->description = $8;
2992 s->reference = $9;
2993 s->index = $10;
2994 s->defVal = $11;
2995 }
2996 ;
2997
2998 SnmpAccess:
2999 identifier
3000 {
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;
3009 else
3010 {
3011 yyerror ("ACCESS field of SNMP OBJECT-TYPE MACRO can only be one of \"read-write\", \"write-only\" or \"not-accessible\"");
3012 $$ = -1;
3013 modulePtrG->status = MOD_ERROR;
3014 }
3015 Free ($1);
3016 }
3017 ;
3018
3019
3020 SnmpStatus:
3021 identifier
3022 {
3023 if (strcmp ($1, "mandatory") == 0)
3024 $$ = SNMP_MANDATORY;
3025 else if (strcmp ($1, "optional") == 0)
3026 $$ = SNMP_OPTIONAL;
3027 else if (strcmp ($1, "obsolete") == 0)
3028 $$ = SNMP_OBSOLETE;
3029 else if (strcmp ($1, "deprecated") == 0)
3030 $$ = SNMP_DEPRECATED;
3031 else
3032 {
3033 yyerror ("STATUS field of SNMP OBJECT-TYPE MACRO can only be one of \"optional\", \"obsolete\" or \"deprecated\"");
3034 $$ = -1;
3035 modulePtrG->status = MOD_ERROR;
3036 }
3037 Free ($1);
3038 }
3039 ;
3040
3041 SnmpDescrPart:
3042 DESCRIPTION_SYM Value { $$ = $2; }
3043 | { $$ = NULL; }
3044 ;
3045
3046 SnmpReferPart:
3047 REFERENCE_SYM Value { $$ = $2; }
3048 | { $$ = NULL; }
3049 ;
3050
3051 SnmpIndexPart:
3052 INDEX_SYM LEFTBRACE_SYM TypeOrValueList RIGHTBRACE_SYM
3053 {
3054 $$ = $3;
3055 }
3056 | { $$ = NULL; }
3057 ;
3058
3059 SnmpDefValPart:
3060 DEFVAL_SYM LEFTBRACE_SYM Value RIGHTBRACE_SYM
3061 {
3062 $$ = $3;
3063 }
3064 | { $$ = NULL; }
3065 ;
3066
3067 %%
3068
3069 yyerror (s)
3070 char*s;
3071 {
3072 fprintf (stderr,"file \"%s\", line %d: %s at symbol \"%s\"\n\n", modulePtrG->asn1SrcFileName, myLineNoG, s, yytext);
3073 }
3074
3075
3076 /*
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.
3081 */
3082 int
3083 InitAsn1Parser PARAMS ((mod, fileName, fPtr),
3084 Module *mod _AND_
3085 char *fileName _AND_
3086 FILE *fPtr)
3087 {
3088 yyin = fPtr;
3089
3090 /*
3091 * reset lexical analyzer input file ptr
3092 * (only do this on succesive calls ow yyrestart seg faults
3093 */
3094 #ifdef FLEX_IN_USE
3095 if (!firstTimeThroughG)
3096 yyrestart (fPtr);
3097
3098 firstTimeThroughG = FALSE;
3099 #endif
3100
3101
3102 /*
3103 * init modulePtr
3104 */
3105 memzero (mod, sizeof (Module));
3106 modulePtrG = mod;
3107 mod->asn1SrcFileName = fileName;
3108 mod->status = MOD_NOT_LINKED;
3109 mod->hasAnys = FALSE;
3110
3111 /* init lists to empty */
3112 mod->typeDefs = AsnListNew (sizeof (void*));
3113 mod->valueDefs = AsnListNew (sizeof (void*));
3114
3115 /*
3116 * init export list stuff
3117 */
3118 exportListG = NULL;
3119 exportsParsedG = FALSE;
3120
3121 /*
3122 * reset line number to 1
3123 */
3124 myLineNoG = 1;
3125
3126 /*
3127 * reset error count
3128 */
3129 parseErrCountG = 0;
3130
3131 /*
3132 * set up list to hold values defined in parsed oids
3133 */
3134 oidElmtValDefsG = AsnListNew (sizeof (void *));
3135
3136 smallErrG = 0;
3137
3138 return 0;
3139
3140 } /* InitAsn1Parser */
3141
3142
3143 /*
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.
3148 */
3149 void
3150 PushApplTag PARAMS ((tagCode, lineNo),
3151 unsigned long int tagCode _AND_
3152 unsigned long int lineNo)
3153 {
3154 ApplTag *l;
3155 ApplTag *new;
3156 int wasDefined = 0;
3157
3158 /* make sure not already in list */
3159 for (l = applTagsG; l != NULL; l = l->next)
3160 {
3161 if (l->tagCode == tagCode)
3162 {
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);
3165 wasDefined = 1;
3166 smallErrG = 1;
3167 }
3168 }
3169 if (!wasDefined)
3170 {
3171 new = MT (ApplTag);
3172 new->lineNo = lineNo;
3173 new->tagCode = tagCode;
3174 new->next = applTagsG;
3175 applTagsG = new;
3176 }
3177 } /* PushApplTag */
3178
3179
3180 /*
3181 * Empties the applTagsG list. Usually done between modules.
3182 */
3183 void
3184 FreeApplTags()
3185 {
3186 ApplTag *l;
3187 ApplTag *lTmp;
3188
3189 for (l = applTagsG; l != NULL; )
3190 {
3191 lTmp = l->next;
3192 Free (l);
3193 l = lTmp;
3194 }
3195 applTagsG = NULL;
3196 } /* FreeApplTags */