Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5502 lines
129 KiB

  1. #line 1 "main.ll"
  2. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  3. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  4. %{
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <ctype.h>
  8. #include "defs.h"
  9. #include "builtin.h"
  10. #include "hackdir.h"
  11. extern int pass;
  12. %}
  13. %union{
  14. char *XString;
  15. char32_t *XString32;
  16. intx_t XNumber;
  17. ASN1bool_t XBoolean;
  18. Type_t *XType;
  19. TagType_e XTagType;
  20. TagClass_e XTagClass;
  21. Tag_t *XTags;
  22. ExtensionType_e XExtensionType;
  23. NamedType_t *XNamedType;
  24. ComponentList_t XComponents;
  25. Constraint_t *XConstraints;
  26. ElementSetSpec_t *XElementSetSpec;
  27. SubtypeElement_t *XSubtypeElement;
  28. ObjectSetElement_t *XObjectSetElement;
  29. DirectiveList_t XDirectives;
  30. NamedConstraintList_t XNamedConstraints;
  31. Presence_e XPresence;
  32. NamedNumberList_t XNamedNumbers;
  33. Value_t *XValue;
  34. ValueSet_t *XValueSet;
  35. EndPoint_t XEndPoint;
  36. Tuple_t XTuple;
  37. Quadruple_t XQuadruple;
  38. NamedValueList_t XNamedValues;
  39. ModuleIdentifier_t *XModuleIdentifier;
  40. NamedObjIdValueList_t XNamedObjIdValue;
  41. ObjectClass_t *XObjectClass;
  42. ObjectSet_t *XObjectSet;
  43. Object_t *XObject;
  44. SyntaxSpecList_t XSyntaxSpecs;
  45. FieldSpecList_t XFieldSpecs;
  46. Optionality_t *XOptionality;
  47. SettingList_t XSettings;
  48. StringList_t XStrings;
  49. StringModuleList_t XStringModules;
  50. Macro_t *XMacro;
  51. MacroProduction_t *XMacroProduction;
  52. NamedMacroProductionList_t XMacroProductions;
  53. MacroLocalAssignmentList_t XMacroLocalAssignments;
  54. PrivateDirectives_t *XPrivateDirectives;
  55. }
  56. %state {
  57. AssignmentList_t Assignments;
  58. AssignedObjIdList_t AssignedObjIds;
  59. UndefinedSymbolList_t Undefined;
  60. UndefinedSymbolList_t BadlyDefined;
  61. ModuleIdentifier_t *Module;
  62. ModuleIdentifier_t *MainModule;
  63. StringModuleList_t Imported;
  64. TagType_e TagDefault;
  65. ExtensionType_e ExtensionDefault;
  66. }
  67. %token "::=" = DEF
  68. %token ".." = DDOT
  69. %token "..." = TDOT
  70. %token "TYPE-IDENTIFIER" = TYPE_IDENTIFIER
  71. %token "ABSTRACT-SYNTAX" = ABSTRACT_SYNTAX
  72. %token "--$zero-terminated--" = ZERO_TERMINATED
  73. %token "--$pointer--" = POINTER
  74. %token "--$no-pointer--" = NO_POINTER
  75. %token "--$fixed-array--" = FIXED_ARRAY
  76. %token "--$singly-linked-list--" = SINGLY_LINKED_LIST
  77. %token "--$doubly-linked-list--" = DOUBLY_LINKED_LIST
  78. %token "--$length-pointer--" = LENGTH_POINTER
  79. %token "number" = Number
  80. %token <XNumber> number
  81. %token <XString> bstring
  82. %token <XString> hstring
  83. %token <XString32> cstring
  84. %token <XString> only_uppercase_symbol
  85. %token <XString> only_uppercase_digits_symbol
  86. %token <XString> uppercase_symbol
  87. %token <XString> lcsymbol
  88. %token <XString> ampucsymbol
  89. %token <XString> amplcsymbol
  90. %prefix T_
  91. %type <XModuleIdentifier> ModuleIdentifier
  92. %type <XValue> DefinitiveIdentifier
  93. %type <XNamedObjIdValue> DefinitiveObjIdComponentList
  94. %type <XNamedObjIdValue> DefinitiveObjIdComponent
  95. %type <XNamedObjIdValue> DefinitiveNumberForm
  96. %type <XNamedObjIdValue> DefinitiveNameAndNumberForm
  97. %type <XTagType> TagDefault
  98. %type <XExtensionType> ExtensionDefault
  99. %type <XModuleIdentifier> GlobalModuleReference
  100. %type <XValue> AssignedIdentifier
  101. %type <XStrings> Exports
  102. %type <XStrings> SymbolsExported
  103. %type <XStringModules> Imports
  104. %type <XStringModules> SymbolsImported
  105. %type <XStringModules> SymbolsFromModule_ESeq
  106. %type <XStringModules> SymbolsFromModule
  107. %type <XStrings> SymbolList
  108. %type <XString> Symbol
  109. %type <XString> Reference
  110. %type <XType> typereference
  111. %type <XType> Externaltypereference
  112. %type <XValue> valuereference
  113. %type <XValue> Externalvaluereference
  114. %type <XObjectClass> objectclassreference
  115. %type <XObjectClass> ExternalObjectClassReference
  116. %type <XObject> objectreference
  117. %type <XObject> ExternalObjectReference
  118. %type <XObjectSet> objectsetreference
  119. %type <XObjectSet> ExternalObjectSetReference
  120. %type <XModuleIdentifier> modulereference
  121. %type <XMacro> macroreference
  122. %type <XMacro> Externalmacroreference
  123. %type <XString> localtypereference
  124. %type <XString> localvaluereference
  125. %type <XString> productionreference
  126. %type <XString> typefieldreference<XObjectClass>
  127. %type <XString> valuefieldreference<XObjectClass>
  128. %type <XString> valuesetfieldreference<XObjectClass>
  129. %type <XString> objectfieldreference<XObjectClass>
  130. %type <XString> objectsetfieldreference<XObjectClass>
  131. %type <XString> word
  132. %type <XString> identifier
  133. %type <XString> ucsymbol
  134. %type <XString> ocsymbol
  135. %type <XString> astring
  136. %start Main
  137. #line 1 "type.ll"
  138. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  139. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  140. %type <XType> DefinedType
  141. %type <XValueSet> ValueSet<XType>
  142. %type <XType> Type
  143. %type <XType> UndirectivedType
  144. %type <XType> UntaggedType
  145. %type <XType> ConstrainableType
  146. %type <XConstraints> Constraint_ESeq<XType>
  147. %type <XType> BuiltinType
  148. %type <XType> ReferencedType
  149. %type <XNamedType> NamedType
  150. %type <XType> BooleanType
  151. %type <XType> IntegerType
  152. %type <XNamedNumbers> NamedNumberList
  153. %type <XNamedNumbers> NamedNumber
  154. %type <XType> EnumeratedType
  155. %type <XNamedNumbers> Enumerations
  156. %type <XNamedNumbers> EnumerationExtension
  157. %type <XNamedNumbers> Enumeration
  158. %type <XNamedNumbers> EnumerationItem
  159. %type <XType> RealType
  160. %type <XType> BitStringType
  161. %type <XNamedNumbers> NamedBitList
  162. %type <XNamedNumbers> NamedBit
  163. %type <XType> OctetStringType
  164. %type <XType> UTF8StringType
  165. %type <XType> NullType
  166. %type <XType> SequenceType
  167. %type <XComponents> ExtensionAndException
  168. %type <XComponents> ExtendedComponentTypeList
  169. %type <XComponents> ComponentTypeListExtension
  170. %type <XComponents> AdditionalComponentTypeList
  171. %type <XComponents> ComponentTypeList
  172. %type <XComponents> ComponentType
  173. %type <XComponents> ComponentTypePostfix<XType>
  174. %type <XType> SequenceOfType
  175. %type <XType> SetType
  176. %type <XType> SetOfType
  177. %type <XType> ChoiceType
  178. %type <XType> AnyType
  179. %type <XComponents> ExtendedAlternativeTypeList
  180. %type <XComponents> AlternativeTypeListExtension
  181. %type <XComponents> AdditionalAlternativeTypeList
  182. %type <XComponents> AlternativeTypeList
  183. %type <XType> SelectionType
  184. %type <XType> TaggedType
  185. %type <XTagType> TagType
  186. %type <XTags> Tag
  187. %type <XValue> ClassNumber
  188. %type <XTagClass> Class
  189. %type <XType> ObjectIdentifierType
  190. %type <XType> EmbeddedPDVType
  191. %type <XType> ExternalType
  192. %type <XType> CharacterStringType
  193. %type <XType> RestrictedCharacterStringType
  194. %type <XType> UnrestrictedCharacterStringType
  195. %type <XType> UsefulType
  196. %type <XType> TypeWithConstraint
  197. #line 1 "value.ll"
  198. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  199. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  200. %type <XValue> DefinedValue
  201. %type <XValue> Value<XType>
  202. %type <XValue> BuiltinValue<XType>
  203. %type <XValue> ReferencedValue
  204. %type <XNamedValues> NamedValue<XComponents>
  205. %type <XValue> BooleanValue<XType>
  206. %type <XValue> SignedNumber<XType>
  207. %type <XValue> IntegerValue<XType>
  208. %type <XValue> EnumeratedValue<XType>
  209. %type <XValue> RealValue<XType>
  210. %type <XValue> NumericRealValue<XType>
  211. %type <XValue> SpecialRealValue<XType>
  212. %type <XValue> BitStringValue<XType>
  213. %type <XValue> IdentifierList<XType>
  214. %type <XValue> Identifier_EList<XType>
  215. %type <XValue> IdentifierList_Elem<XType>
  216. %type <XValue> OctetStringValue<XType>
  217. %type <XValue> NullValue<XType>
  218. %type <XValue> GeneralizedTimeValue<XType>
  219. %type <XValue> UTCTimeValue<XType>
  220. %type <XValue> ObjectDescriptorValue<XType>
  221. %type <XValue> SequenceValue<XType>
  222. %type <XNamedValues> ComponentValueList<XComponents>
  223. %type <XNamedValues> ComponentValueCList<XComponents>
  224. %type <XValue> SequenceOfValue<XType>
  225. %type <XValue> ValueList<XType>
  226. %type <XValue> ValueCList<XType>
  227. %type <XValue> SetValue<XType>
  228. %type <XValue> SetOfValue<XType>
  229. %type <XValue> ChoiceValue<XType>
  230. %type <XValue> ObjectIdentifierValue
  231. %type <XNamedObjIdValue> ObjIdComponentList
  232. %type <XNamedObjIdValue> ObjIdComponent_ESeq
  233. %type <XNamedObjIdValue> ObjIdComponent
  234. %type <XNamedObjIdValue> NameForm
  235. %type <XNamedObjIdValue> NumberForm
  236. %type <XNamedObjIdValue> NameAndNumberForm
  237. %type <XValue> EmbeddedPDVValue<XType>
  238. %type <XValue> ExternalValue<XType>
  239. %type <XValue> CharacterStringValue<XType>
  240. %type <XValue> RestrictedCharacterStringValue<XType>
  241. %type <XValue> UnrestrictedCharacterStringValue<XType>
  242. %type <XValue> CharacterStringList<XType>
  243. %type <XValue> CharSyms<XType>
  244. %type <XValue> CharDefn<XType>
  245. %type <XQuadruple> Quadruple
  246. %type <XTuple> Tuple
  247. %type <XValue> AnyValue<XType>
  248. #line 1 "constrai.ll"
  249. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  250. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  251. %token CON_XXX1
  252. %token CON_XXX2
  253. %type <XConstraints> Constraint<XType><XBoolean>
  254. %type <XConstraints> ConstraintSpec<XType><XBoolean>
  255. %type <XConstraints> SubtypeConstraint<XType><XBoolean>
  256. %type <XConstraints> ElementSetSpecs<XType><XBoolean>
  257. %type <XConstraints> ElementSetSpecExtension<XType><XBoolean>
  258. %type <XElementSetSpec> AdditionalElementSetSpec<XType><XBoolean>
  259. %type <XElementSetSpec> ElementSetSpec<XType><XObjectClass><XBoolean>
  260. %type <XElementSetSpec> Unions<XType><XObjectClass><XBoolean>
  261. %type <XElementSetSpec> UnionList<XType><XObjectClass><XBoolean>
  262. %type <XElementSetSpec> Intersections<XType><XObjectClass><XBoolean>
  263. %type <XElementSetSpec> IntersectionList<XType><XObjectClass><XBoolean>
  264. %type <XElementSetSpec> IntersectionElements<XType><XObjectClass><XBoolean>
  265. %type <XElementSetSpec> Exclusions_Opt<XType><XObjectClass><XBoolean>
  266. %type <XElementSetSpec> Exclusions<XType><XObjectClass><XBoolean>
  267. %type <XElementSetSpec> Elements<XType><XObjectClass><XBoolean>
  268. %type <XSubtypeElement> SubtypeElements<XType><XBoolean>
  269. %type <XSubtypeElement> SingleValue<XType>
  270. %type <XSubtypeElement> ContainedSubtype<XType>
  271. %type <XBoolean> Includes
  272. %type <XSubtypeElement> ValueRange<XType>
  273. %type <XEndPoint> LowerEndpoint<XType>
  274. %type <XEndPoint> UpperEndpoint<XType>
  275. %type <XEndPoint> LowerEndValue<XType>
  276. %type <XEndPoint> UpperEndValue<XType>
  277. %type <XSubtypeElement> SizeConstraint
  278. %type <XSubtypeElement> TypeConstraint
  279. %type <XSubtypeElement> PermittedAlphabet<XType>
  280. %type <XSubtypeElement> InnerTypeConstraints<XType>
  281. %type <XSubtypeElement> SingleTypeConstraint<XType>
  282. %type <XSubtypeElement> MultipleTypeConstraints<XComponents>
  283. %type <XSubtypeElement> FullSpecification<XComponents>
  284. %type <XSubtypeElement> PartialSpecification<XComponents>
  285. %type <XNamedConstraints> TypeConstraints<XComponents>
  286. %type <XNamedConstraints> NamedConstraint<XComponents>
  287. %type <XNamedConstraints> ComponentConstraint<XType>
  288. %type <XConstraints> ValueConstraint<XType>
  289. %type <XPresence> PresenceConstraint
  290. #line 1 "directiv.ll"
  291. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  292. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  293. %type <XDirectives> LocalTypeDirectiveSeq
  294. %type <XDirectives> LocalTypeDirectiveESeq
  295. %type <XDirectives> LocalTypeDirective
  296. %type <XDirectives> LocalSizeDirectiveSeq
  297. %type <XDirectives> LocalSizeDirectiveESeq
  298. %type <XDirectives> LocalSizeDirective
  299. %type <XString> PrivateDir_Field
  300. %type <XString> PrivateDir_Type
  301. %type <XString> PrivateDir_Value
  302. %type <int> PrivateDir_Public
  303. %type <int> PrivateDir_Intx
  304. %type <int> PrivateDir_LenPtr
  305. %type <int> PrivateDir_Pointer
  306. %type <int> PrivateDir_Array
  307. %type <int> PrivateDir_NoCode
  308. %type <int> PrivateDir_NoMemCopy
  309. %type <int> PrivateDir_OidPacked
  310. %type <int> PrivateDir_OidArray
  311. %type <int> PrivateDir_SLinked
  312. %type <int> PrivateDir_DLinked
  313. %type <XPrivateDirectives> PrivateDirectives
  314. #line 1 "object.ll"
  315. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  316. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  317. %token OBJ_XXX1
  318. %token OBJ_XXX2
  319. %token OBJ_XXX3
  320. %token OBJ_XXX4
  321. %token OBJ_XXX5
  322. %token OBJ_XXX6
  323. %token OBJ_XXX7
  324. %type <XObjectClass> DefinedObjectClass
  325. %type <XObject> DefinedObject
  326. %type <XObjectSet> DefinedObjectSet
  327. %type <XObjectClass> Usefulobjectclassreference
  328. %type <XObjectClass> ObjectClass<XObjectClass>
  329. %type <XObjectClass> ObjectClassDefn<XObjectClass>
  330. %type <XFieldSpecs> FieldSpec_List<XObjectClass>
  331. %type <XFieldSpecs> FieldSpec_EList<XObjectClass>
  332. %type <XSyntaxSpecs> WithSyntaxSpec_opt<XObjectClass>
  333. %type <XFieldSpecs> FieldSpec<XObjectClass>
  334. %type <XFieldSpecs> TypeFieldSpec<XObjectClass>
  335. %type <XOptionality> TypeOptionalitySpec_opt
  336. %type <XFieldSpecs> FixedTypeValueFieldSpec<XObjectClass>
  337. %type <XBoolean> UNIQUE_opt
  338. %type <XOptionality> ValueOptionalitySpec_opt<XType>
  339. %type <XFieldSpecs> VariableTypeValueFieldSpec<XObjectClass>
  340. %type <XFieldSpecs> FixedTypeValueSetFieldSpec<XObjectClass>
  341. %type <XOptionality> ValueSetOptionalitySpec_opt<XType>
  342. %type <XFieldSpecs> VariableTypeValueSetFieldSpec<XObjectClass>
  343. %type <XFieldSpecs> ObjectFieldSpec<XObjectClass>
  344. %type <XOptionality> ObjectOptionalitySpec_opt<XObjectClass>
  345. %type <XFieldSpecs> ObjectSetFieldSpec<XObjectClass>
  346. %type <XOptionality> ObjectSetOptionalitySpec_opt<XObjectClass>
  347. %type <XString> PrimitiveFieldName<XObjectClass>
  348. %type <XStrings> FieldName<XObjectClass>
  349. %type <XSyntaxSpecs> SyntaxList<XObjectClass>
  350. %type <XSyntaxSpecs> TokenOrGroupSpec_Seq<XObjectClass>
  351. %type <XSyntaxSpecs> TokenOrGroupSpec_ESeq<XObjectClass>
  352. %type <XSyntaxSpecs> TokenOrGroupSpec<XObjectClass>
  353. %type <XSyntaxSpecs> OptionalGroup<XObjectClass>
  354. %type <XSyntaxSpecs> RequiredToken<XObjectClass>
  355. %type <XString> Literal
  356. %type <XObject> Object<XObjectClass>
  357. %type <XObject> ObjectDefn<XObjectClass>
  358. %type <XObject> DefaultSyntax<XObjectClass>
  359. %type <XSettings> FieldSetting_EList<XObjectClass><XSettings>
  360. %type <XSettings> FieldSetting_EListC<XObjectClass><XSettings>
  361. %type <XSettings> FieldSetting<XObjectClass><XSettings>
  362. %type <XObject> DefinedSyntax<XObjectClass>
  363. %type <XSettings> DefinedSyntaxToken_ESeq<XObjectClass><XSettings><XSyntaxSpecs>
  364. %type <XSettings> DefinedSyntaxToken<XObjectClass><XSettings><XSyntaxSpecs>
  365. %type <XSettings> DefinedSyntaxToken_Elem<XObjectClass><XSettings><XSyntaxSpecs>
  366. %type <XSettings> Setting<XObjectClass><XSettings><XString>
  367. %type <XObjectSet> ObjectSet<XObjectClass>
  368. %type <XObjectSet> ObjectSetSpec<XObjectClass>
  369. %type <XObjectSetElement> ObjectSetElements<XObjectClass>
  370. %type <XType> ObjectClassFieldType
  371. %type <XValue> ObjectClassFieldValue<XType>
  372. %type <XValue> OpenTypeFieldVal
  373. %type <XValue> FixedTypeFieldVal<XType>
  374. %type <XValue> ValueFromObject
  375. %type <XValueSet> ValueSetFromObjects
  376. %type <XType> TypeFromObject
  377. %type <XObject> ObjectFromObject
  378. %type <XObjectSet> ObjectSetFromObjects
  379. %type <XObject> ReferencedObjects
  380. %type <XObjectSet> ReferencedObjectSets
  381. %type <XType> InstanceOfType
  382. %type <XValue> InstanceOfValue<XType>
  383. #line 1 "future.ll"
  384. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  385. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  386. %token DUM_XXX1
  387. %token DUM_XXX2
  388. %token DUM_XXX3
  389. %token DUM_XXX4
  390. %token DUM_XXX5
  391. %token DUM_XXX6
  392. %token DUM_XXX7
  393. %token DUM_XXX8
  394. %token DUM_XXX9
  395. %token DUM_XXX10
  396. %token DUM_XXX11
  397. %token DUM_XXX12
  398. %token DUM_XXX13
  399. %token DUM_XXX14
  400. %token DUM_XXX15
  401. %token DUM_XXX16
  402. %token DUM_XXX17
  403. %token DUM_XXX18
  404. %token DUM_XXX19
  405. %token DUM_XXX20
  406. %type <XType> MacroDefinedType
  407. %type <XValue> MacroDefinedValue<XType>
  408. %%
  409. #line 146 "main.ll"
  410. Main
  411. : ModuleDefinition ModuleDefinition_ESeq
  412. ;
  413. ModuleDefinition_ESeq
  414. : ModuleDefinition ModuleDefinition_ESeq
  415. | /* empty */
  416. ;
  417. ModuleDefinition
  418. : ModuleIdentifier "DEFINITIONS" TagDefault ExtensionDefault "::="
  419. { if (!AssignModuleIdentifier(&$<6.Assignments, $1))
  420. LLFAILED((&@1, "Module `%s' twice defined", $1->Identifier));
  421. $<6.MainModule = $1;
  422. $<6.Module = $1;
  423. $<6.TagDefault = $3;
  424. $<6.ExtensionDefault = $4;
  425. g_eDefTagType = $3;
  426. }
  427. "BEGIN" ModuleBody "END"
  428. { LLCUTALL;
  429. }
  430. ;
  431. ModuleIdentifier
  432. : modulereference DefinitiveIdentifier
  433. { if ($2) {
  434. $$ = NewModuleIdentifier();
  435. $$->Identifier = $1->Identifier;
  436. $$->ObjectIdentifier = $2;
  437. } else {
  438. $$ = $1;
  439. }
  440. }
  441. ;
  442. DefinitiveIdentifier
  443. : '{' DefinitiveObjIdComponentList '}'
  444. { switch (GetAssignedObjectIdentifier(
  445. &$>>.AssignedObjIds, NULL, $2, &$$)) {
  446. case -1:
  447. LLFAILED((&@2, "Different numbers for equally named object identifier components"));
  448. /*NOTREACHED*/
  449. case 0:
  450. $$ = NULL;
  451. break;
  452. case 1:
  453. break;
  454. }
  455. }
  456. | /* empty */
  457. { $$ = NULL;
  458. }
  459. ;
  460. DefinitiveObjIdComponentList
  461. : DefinitiveObjIdComponent DefinitiveObjIdComponentList
  462. { $$ = DupNamedObjIdValue($1);
  463. $$->Next = $2;
  464. }
  465. | DefinitiveObjIdComponent
  466. { $$ = $1;
  467. }
  468. ;
  469. DefinitiveObjIdComponent
  470. : NameForm
  471. { $$ = $1;
  472. }
  473. | DefinitiveNumberForm
  474. { $$ = $1;
  475. }
  476. | DefinitiveNameAndNumberForm
  477. { $$ = $1;
  478. }
  479. ;
  480. DefinitiveNumberForm
  481. : number
  482. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NumberForm);
  483. $$->Number = intx2uint32(&$1);
  484. }
  485. ;
  486. DefinitiveNameAndNumberForm
  487. : identifier '(' number ')'
  488. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NameAndNumberForm);
  489. $$->Name = $1;
  490. $$->Number = intx2uint32(&$3);
  491. }
  492. ;
  493. TagDefault
  494. : "EXPLICIT" "TAGS"
  495. { $$ = eTagType_Explicit;
  496. }
  497. | "IMPLICIT" "TAGS"
  498. { $$ = eTagType_Implicit;
  499. }
  500. | "AUTOMATIC" "TAGS"
  501. { $$ = eTagType_Automatic;
  502. }
  503. | /* empty */
  504. { $$ = eTagType_Explicit;
  505. }
  506. ;
  507. ExtensionDefault
  508. : "EXTENSIBILITY" "IMPLIED"
  509. { $$ = eExtensionType_Automatic;
  510. }
  511. | /* empty */
  512. { $$ = eExtensionType_None;
  513. }
  514. ;
  515. ModuleBody
  516. : Exports Imports
  517. { $<3.Imported = $2;
  518. }
  519. AssignmentList
  520. { String_t *s;
  521. StringModule_t *sm;
  522. Assignment_t *a, **aa, *oldass;
  523. UndefinedSymbol_t *u;
  524. if ($2 != IMPORT_ALL) {
  525. for (sm = $2; sm; sm = sm->Next) {
  526. if (!FindExportedAssignment($>>.Assignments,
  527. eAssignment_Undefined, sm->String, sm->Module)) {
  528. if (FindAssignment($>>.Assignments,
  529. eAssignment_Undefined, sm->String,
  530. sm->Module)) {
  531. u = NewUndefinedSymbol(
  532. eUndefinedSymbol_SymbolNotExported,
  533. eAssignment_Undefined);
  534. } else {
  535. u = NewUndefinedSymbol(
  536. eUndefinedSymbol_SymbolNotDefined,
  537. eAssignment_Undefined);
  538. }
  539. u->U.Symbol.Identifier = sm->String;
  540. u->U.Symbol.Module = sm->Module;
  541. u->Next = $>>.Undefined;
  542. $>>.Undefined = u;
  543. continue;
  544. }
  545. if (!FindAssignmentInCurrentPass($>>.Assignments,
  546. sm->String, $>>.Module)) {
  547. a = NewAssignment(eAssignment_Reference);
  548. a->Identifier = sm->String;
  549. a->Module = $>>.Module;
  550. a->U.Reference.Identifier = sm->String;
  551. a->U.Reference.Module = sm->Module;
  552. a->Next = $>>.Assignments;
  553. $>>.Assignments = a;
  554. }
  555. }
  556. }
  557. if ($1 != EXPORT_ALL) {
  558. for (s = $1; s; s = s->Next) {
  559. if (!FindAssignment($>>.Assignments, eAssignment_Undefined,
  560. s->String, $>>.Module))
  561. LLFAILED((&@1, "Exported symbol `%s' is undefined",
  562. s->String));
  563. }
  564. }
  565. oldass = $>>.Assignments;
  566. for (a = $>>.Assignments, aa = &$>>.Assignments; a;
  567. a = a->Next, aa = &(*aa)->Next) {
  568. if (a->Type == eAssignment_NextPass)
  569. break;
  570. *aa = DupAssignment(a);
  571. if (!FindAssignmentInCurrentPass(a->Next,
  572. a->Identifier, a->Module) &&
  573. FindAssignmentInCurrentPass(oldass,
  574. a->Identifier, a->Module) == a &&
  575. !CmpModuleIdentifier(oldass, a->Module, $>>.Module) &&
  576. ($1 == EXPORT_ALL || FindString($1, a->Identifier)))
  577. (*aa)->Flags |= eAssignmentFlags_Exported;
  578. }
  579. *aa = a;
  580. }
  581. | /* empty */
  582. ;
  583. Exports
  584. : "EXPORTS" SymbolsExported ';'
  585. { String_t *s, *t;
  586. for (s = $2; s && s->Next; s = s->Next) {
  587. for (t = s->Next; t; t = t->Next) {
  588. if (!strcmp(s->String, t->String))
  589. LLFAILED((&@2, "Symbol `%s' has been exported twice",
  590. s->String));
  591. }
  592. }
  593. $$ = $2;
  594. }
  595. | /* empty */
  596. { $$ = EXPORT_ALL;
  597. }
  598. ;
  599. SymbolsExported
  600. : SymbolList
  601. { $$ = $1;
  602. }
  603. | /* empty */
  604. { $$ = NULL;
  605. }
  606. ;
  607. Imports
  608. : "IMPORTS" SymbolsImported ';'
  609. { $$ = $2;
  610. }
  611. | /* empty */
  612. { $$ = IMPORT_ALL;
  613. }
  614. ;
  615. SymbolsImported
  616. : SymbolsFromModule_ESeq
  617. { $$ = $1;
  618. }
  619. ;
  620. SymbolsFromModule_ESeq
  621. : SymbolsFromModule SymbolsFromModule_ESeq
  622. { StringModule_t *s, **ss;
  623. for (s = $1, ss = &$$; s; s = s->Next) {
  624. *ss = DupStringModule(s);
  625. ss = &(*ss)->Next;
  626. }
  627. *ss = $2;
  628. }
  629. | /* empty */
  630. { $$ = NULL;
  631. }
  632. ;
  633. SymbolsFromModule
  634. : SymbolList "FROM" GlobalModuleReference
  635. { String_t *s, *t;
  636. StringModule_t **ss;
  637. for (s = $1; s && s->Next; s = s->Next) {
  638. for (t = s->Next; t; t = t->Next) {
  639. if (!strcmp(s->String, t->String))
  640. LLFAILED((&@2, "Symbol `%s' has been imported twice",
  641. s->String));
  642. }
  643. }
  644. for (s = $1, ss = &$$; s; s = s->Next) {
  645. *ss = NewStringModule();
  646. (*ss)->String = s->String;
  647. (*ss)->Module = $3;
  648. ss = &(*ss)->Next;
  649. }
  650. *ss = NULL;
  651. }
  652. ;
  653. GlobalModuleReference
  654. : modulereference AssignedIdentifier
  655. { $$ = NewModuleIdentifier();
  656. $$->Identifier = $1->Identifier;
  657. $$->ObjectIdentifier = $2;
  658. }
  659. ;
  660. AssignedIdentifier
  661. : ObjectIdentifierValue
  662. { $$ = $1;
  663. }
  664. | DefinedValue
  665. { $$ = $1;
  666. }
  667. | /* empty */
  668. { $$ = NULL;
  669. }
  670. ;
  671. SymbolList
  672. : Symbol ',' SymbolList
  673. { $$ = NewString();
  674. $$->String = $1;
  675. $$->Next = $3;
  676. }
  677. | Symbol
  678. { $$ = NewString();
  679. $$->String = $1;
  680. }
  681. ;
  682. Symbol
  683. : Reference
  684. { $$ = $1;
  685. }
  686. | ParameterizedReference
  687. { MyAbort();
  688. }
  689. ;
  690. Reference
  691. : ucsymbol
  692. /* => {type,objectclass,objectset,macro}reference */
  693. { $$ = $1;
  694. }
  695. | lcsymbol
  696. /* => {value,object}reference */
  697. { $$ = $1;
  698. }
  699. ;
  700. AssignmentList
  701. : Assignment Assignment_ESeq
  702. ;
  703. Assignment_ESeq
  704. : Assignment Assignment_ESeq
  705. | /* empty */
  706. ;
  707. Assignment
  708. : TypeAssignment
  709. { LLCUTALL;
  710. }
  711. | ValueAssignment
  712. { LLCUTALL;
  713. }
  714. | ValueSetTypeAssignment
  715. { LLCUTALL;
  716. }
  717. | ObjectClassAssignment
  718. { LLCUTALL;
  719. }
  720. | ObjectAssignment
  721. { LLCUTALL;
  722. }
  723. | ObjectSetAssignment
  724. { LLCUTALL;
  725. }
  726. | ParameterizedAssignment
  727. { LLCUTALL;
  728. }
  729. | MacroDefinition
  730. { LLCUTALL;
  731. }
  732. ;
  733. typereference
  734. : ucsymbol
  735. { Assignment_t *ref;
  736. UndefinedSymbol_t *u;
  737. ref = FindAssignment($>>.Assignments,
  738. eAssignment_Undefined, $1, $>>.Module);
  739. if (!ref) {
  740. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  741. eAssignment_Type);
  742. u->U.Symbol.Module = $>>.Module;
  743. u->U.Symbol.Identifier = $1;
  744. u->Next = $>>.Undefined;
  745. $>>.Undefined = u;
  746. } else if (GetAssignmentType($>>.Assignments, ref) !=
  747. eAssignment_Type)
  748. LLFAILED((&@1, "Symbol `%s' is not a typereference", $1));
  749. $$ = NewType(eType_Reference);
  750. if (ref && ref->U.Type.Type)
  751. {
  752. int fPublic = ref->U.Type.Type->PrivateDirectives.fPublic;
  753. ref->U.Type.Type->PrivateDirectives.fPublic = 0;
  754. PropagateReferenceTypePrivateDirectives($$, &(ref->U.Type.Type->PrivateDirectives));
  755. ref->U.Type.Type->PrivateDirectives.fPublic = fPublic;
  756. }
  757. $$->U.Reference.Identifier = $1;
  758. $$->U.Reference.Module = $>>.Module;
  759. }
  760. ;
  761. Externaltypereference
  762. : modulereference '.' ucsymbol
  763. { Assignment_t *ref;
  764. UndefinedSymbol_t *u;
  765. if ($>>.Imported != IMPORT_ALL &&
  766. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  767. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  768. $1->Identifier, $3));
  769. ref = FindExportedAssignment($>>.Assignments,
  770. eAssignment_Type, $3, $1);
  771. if (!ref) {
  772. if (FindAssignment($>>.Assignments,
  773. eAssignment_Type, $3, $1)) {
  774. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  775. eAssignment_Type);
  776. } else {
  777. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  778. eAssignment_Type);
  779. }
  780. u->U.Symbol.Module = $1;
  781. u->U.Symbol.Identifier = $3;
  782. u->Next = $>>.Undefined;
  783. $>>.Undefined = u;
  784. } else if (GetAssignmentType($>>.Assignments, ref) !=
  785. eAssignment_Type)
  786. LLFAILED((&@1, "Symbol `%s' is not a typereference", $1));
  787. $$ = NewType(eType_Reference);
  788. $$->U.Reference.Identifier = $3;
  789. $$->U.Reference.Module = $1;
  790. }
  791. ;
  792. valuereference
  793. : lcsymbol
  794. { Assignment_t *ref;
  795. UndefinedSymbol_t *u;
  796. ref = FindAssignment($>>.Assignments,
  797. eAssignment_Undefined, $1, $>>.Module);
  798. if (!ref) {
  799. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  800. eAssignment_Value);
  801. u->U.Symbol.Module = $>>.Module;
  802. u->U.Symbol.Identifier = $1;
  803. u->Next = $>>.Undefined;
  804. $>>.Undefined = u;
  805. } else if (GetAssignmentType($>>.Assignments, ref) !=
  806. eAssignment_Value)
  807. LLFAILED((&@1, "Symbol `%s' is not a valuereference", $1));
  808. $$ = NewValue(NULL, NULL);
  809. $$->U.Reference.Identifier = $1;
  810. $$->U.Reference.Module = $>>.Module;
  811. }
  812. ;
  813. Externalvaluereference
  814. : modulereference '.' lcsymbol
  815. { Assignment_t *ref;
  816. UndefinedSymbol_t *u;
  817. if ($>>.Imported != IMPORT_ALL &&
  818. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  819. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  820. $1->Identifier, $3));
  821. ref = FindExportedAssignment($>>.Assignments,
  822. eAssignment_Value, $3, $1);
  823. if (!ref) {
  824. if (FindAssignment($>>.Assignments,
  825. eAssignment_Value, $3, $1)) {
  826. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  827. eAssignment_Value);
  828. } else {
  829. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  830. eAssignment_Value);
  831. }
  832. u->U.Symbol.Module = $1;
  833. u->U.Symbol.Identifier = $3;
  834. u->Next = $>>.Undefined;
  835. $>>.Undefined = u;
  836. } else if (GetAssignmentType($>>.Assignments, ref) !=
  837. eAssignment_Value)
  838. LLFAILED((&@1, "Symbol `%s' is not a valuereference", $1));
  839. $$ = NewValue(NULL, NULL);
  840. $$->U.Reference.Identifier = $3;
  841. $$->U.Reference.Module = $1;
  842. }
  843. ;
  844. objectclassreference
  845. : ocsymbol
  846. { Assignment_t *ref;
  847. UndefinedSymbol_t *u;
  848. ref = FindAssignment($>>.Assignments,
  849. eAssignment_Undefined, $1, $>>.Module);
  850. if (!ref) {
  851. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  852. eAssignment_ObjectClass);
  853. u->U.Symbol.Module = $>>.Module;
  854. u->U.Symbol.Identifier = $1;
  855. u->Next = $>>.Undefined;
  856. $>>.Undefined = u;
  857. } else if (GetAssignmentType($>>.Assignments, ref) !=
  858. eAssignment_ObjectClass)
  859. LLFAILED((&@1, "Symbol `%s' is not an objectclassreference", $1));
  860. $$ = NewObjectClass(eObjectClass_Reference);
  861. $$->U.Reference.Identifier = $1;
  862. $$->U.Reference.Module = $>>.Module;
  863. }
  864. ;
  865. ExternalObjectClassReference
  866. : modulereference '.' ocsymbol
  867. { Assignment_t *ref;
  868. UndefinedSymbol_t *u;
  869. if ($>>.Imported != IMPORT_ALL &&
  870. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  871. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  872. $1->Identifier, $3));
  873. ref = FindExportedAssignment($>>.Assignments,
  874. eAssignment_ObjectClass, $3, $1);
  875. if (!ref) {
  876. if (FindAssignment($>>.Assignments,
  877. eAssignment_ObjectClass, $3, $1)) {
  878. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  879. eAssignment_ObjectClass);
  880. } else {
  881. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  882. eAssignment_ObjectClass);
  883. }
  884. u->U.Symbol.Module = $1;
  885. u->U.Symbol.Identifier = $3;
  886. u->Next = $>>.Undefined;
  887. $>>.Undefined = u;
  888. } else if (GetAssignmentType($>>.Assignments, ref) !=
  889. eAssignment_ObjectClass)
  890. LLFAILED((&@1, "Symbol `%s' is not an objectclassreference", $1));
  891. $$ = NewObjectClass(eObjectClass_Reference);
  892. $$->U.Reference.Identifier = $3;
  893. $$->U.Reference.Module = $1;
  894. }
  895. ;
  896. objectreference
  897. : lcsymbol
  898. { Assignment_t *ref;
  899. UndefinedSymbol_t *u;
  900. ref = FindAssignment($>>.Assignments,
  901. eAssignment_Undefined, $1, $>>.Module);
  902. if (!ref) {
  903. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  904. eAssignment_Object);
  905. u->U.Symbol.Module = $>>.Module;
  906. u->U.Symbol.Identifier = $1;
  907. u->Next = $>>.Undefined;
  908. $>>.Undefined = u;
  909. } else if (GetAssignmentType($>>.Assignments, ref) !=
  910. eAssignment_Object)
  911. LLFAILED((&@1, "Symbol `%s' is not an objectreference", $1));
  912. $$ = NewObject(eObject_Reference);
  913. $$->U.Reference.Identifier = $1;
  914. $$->U.Reference.Module = $>>.Module;
  915. }
  916. ;
  917. ExternalObjectReference
  918. : modulereference '.' lcsymbol
  919. { Assignment_t *ref;
  920. UndefinedSymbol_t *u;
  921. if ($>>.Imported != IMPORT_ALL &&
  922. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  923. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  924. $1->Identifier, $3));
  925. ref = FindExportedAssignment($>>.Assignments,
  926. eAssignment_Object, $3, $1);
  927. if (!ref) {
  928. if (FindAssignment($>>.Assignments,
  929. eAssignment_Object, $3, $1)) {
  930. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  931. eAssignment_Object);
  932. } else {
  933. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  934. eAssignment_Object);
  935. }
  936. u->U.Symbol.Module = $1;
  937. u->U.Symbol.Identifier = $3;
  938. u->Next = $>>.Undefined;
  939. $>>.Undefined = u;
  940. } else if (GetAssignmentType($>>.Assignments, ref) !=
  941. eAssignment_Object)
  942. LLFAILED((&@1, "Symbol `%s' is not an objectreference", $1));
  943. $$ = NewObject(eObject_Reference);
  944. $$->U.Reference.Identifier = $3;
  945. $$->U.Reference.Module = $1;
  946. }
  947. ;
  948. objectsetreference
  949. : ucsymbol
  950. { Assignment_t *ref;
  951. UndefinedSymbol_t *u;
  952. ref = FindAssignment($>>.Assignments,
  953. eAssignment_Undefined, $1, $>>.Module);
  954. if (!ref) {
  955. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  956. eAssignment_ObjectSet);
  957. u->U.Symbol.Module = $>>.Module;
  958. u->U.Symbol.Identifier = $1;
  959. u->Next = $>>.Undefined;
  960. $>>.Undefined = u;
  961. } else if (GetAssignmentType($>>.Assignments, ref) !=
  962. eAssignment_ObjectSet)
  963. LLFAILED((&@1, "Symbol `%s' is not an objectsetreference", $1));
  964. $$ = NewObjectSet(eObjectSet_Reference);
  965. $$->U.Reference.Identifier = $1;
  966. $$->U.Reference.Module = $>>.Module;
  967. }
  968. ;
  969. ExternalObjectSetReference
  970. : modulereference '.' ucsymbol
  971. { Assignment_t *ref;
  972. UndefinedSymbol_t *u;
  973. if ($>>.Imported != IMPORT_ALL &&
  974. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  975. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  976. $1->Identifier, $3));
  977. ref = FindExportedAssignment($>>.Assignments,
  978. eAssignment_ObjectSet, $3, $1);
  979. if (!ref) {
  980. if (FindAssignment($>>.Assignments,
  981. eAssignment_ObjectSet, $3, $1)) {
  982. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  983. eAssignment_ObjectSet);
  984. } else {
  985. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  986. eAssignment_ObjectSet);
  987. }
  988. u->U.Symbol.Module = $1;
  989. u->U.Symbol.Identifier = $3;
  990. u->Next = $>>.Undefined;
  991. $>>.Undefined = u;
  992. } else if (GetAssignmentType($>>.Assignments, ref) !=
  993. eAssignment_ObjectSet)
  994. LLFAILED((&@1, "Symbol `%s' is not an objectsetreference", $1));
  995. $$ = NewObjectSet(eObjectSet_Reference);
  996. $$->U.Reference.Identifier = $3;
  997. $$->U.Reference.Module = $1;
  998. }
  999. ;
  1000. macroreference
  1001. : ocsymbol
  1002. { Assignment_t *ref;
  1003. UndefinedSymbol_t *u;
  1004. ref = FindAssignment($>>.Assignments,
  1005. eAssignment_Undefined, $1, $>>.Module);
  1006. if (!ref) {
  1007. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  1008. eAssignment_Macro);
  1009. u->U.Symbol.Module = $>>.Module;
  1010. u->U.Symbol.Identifier = $1;
  1011. u->Next = $>>.Undefined;
  1012. $>>.Undefined = u;
  1013. } else if (GetAssignmentType($>>.Assignments, ref) !=
  1014. eAssignment_Macro)
  1015. LLFAILED((&@1, "Symbol `%s' is not an macroreference", $1));
  1016. $$ = NewMacro(eMacro_Reference);
  1017. $$->U.Reference.Identifier = $1;
  1018. $$->U.Reference.Module = $>>.Module;
  1019. }
  1020. ;
  1021. Externalmacroreference
  1022. : modulereference '.' ucsymbol
  1023. { Assignment_t *ref;
  1024. UndefinedSymbol_t *u;
  1025. if ($>>.Imported != IMPORT_ALL &&
  1026. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  1027. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  1028. $1->Identifier, $3));
  1029. ref = FindExportedAssignment($>>.Assignments,
  1030. eAssignment_Macro, $3, $1);
  1031. if (!ref) {
  1032. if (FindAssignment($>>.Assignments,
  1033. eAssignment_Macro, $3, $1)) {
  1034. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  1035. eAssignment_Macro);
  1036. } else {
  1037. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  1038. eAssignment_Macro);
  1039. }
  1040. u->U.Symbol.Module = $1;
  1041. u->U.Symbol.Identifier = $3;
  1042. u->Next = $>>.Undefined;
  1043. $>>.Undefined = u;
  1044. } else if (GetAssignmentType($>>.Assignments, ref) !=
  1045. eAssignment_Macro)
  1046. LLFAILED((&@1, "Symbol `%s' is not an macroreference", $1));
  1047. $$ = NewMacro(eMacro_Reference);
  1048. $$->U.Reference.Identifier = $3;
  1049. $$->U.Reference.Module = $1;
  1050. }
  1051. ;
  1052. localtypereference
  1053. : ucsymbol
  1054. { $$ = $1;
  1055. }
  1056. ;
  1057. localvaluereference
  1058. : ucsymbol
  1059. { $$ = $1;
  1060. }
  1061. ;
  1062. productionreference
  1063. : ucsymbol
  1064. { $$ = $1;
  1065. }
  1066. ;
  1067. modulereference
  1068. : ucsymbol
  1069. { $$ = NewModuleIdentifier();
  1070. $$->Identifier = $1;
  1071. }
  1072. ;
  1073. typefieldreference(oc)
  1074. : ampucsymbol
  1075. { FieldSpec_t *fs;
  1076. FieldSpecs_e fe;
  1077. ObjectClass_t *oc;
  1078. UndefinedSymbol_t *u;
  1079. oc = GetObjectClass($>>.Assignments, $oc);
  1080. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  1081. fe = GetFieldSpecType($>>.Assignments, fs);
  1082. if (fe == eFieldSpec_Undefined) {
  1083. if ($oc) {
  1084. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  1085. $oc, eSetting_Type);
  1086. u->U.Field.Module = $>>.Module;
  1087. u->U.Field.Identifier = $1;
  1088. u->Next = $>>.Undefined;
  1089. $>>.Undefined = u;
  1090. }
  1091. } else if (fe != eFieldSpec_Type)
  1092. LLFAILED((&@1, "%s is not a typefieldreference", $1));
  1093. $$ = $1;
  1094. }
  1095. ;
  1096. valuefieldreference(oc)
  1097. : amplcsymbol
  1098. { FieldSpec_t *fs;
  1099. FieldSpecs_e fe;
  1100. ObjectClass_t *oc;
  1101. UndefinedSymbol_t *u;
  1102. oc = GetObjectClass($>>.Assignments, $oc);
  1103. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  1104. fe = GetFieldSpecType($>>.Assignments, fs);
  1105. if (fe == eFieldSpec_Undefined) {
  1106. if ($oc) {
  1107. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  1108. $oc, eSetting_Value);
  1109. u->U.Field.Module = $>>.Module;
  1110. u->U.Field.Identifier = $1;
  1111. u->Next = $>>.Undefined;
  1112. $>>.Undefined = u;
  1113. }
  1114. } else if (fe != eFieldSpec_FixedTypeValue &&
  1115. fe != eFieldSpec_VariableTypeValue)
  1116. LLFAILED((&@1, "%s is not a valuefieldreference", $1));
  1117. $$ = $1;
  1118. }
  1119. ;
  1120. valuesetfieldreference(oc)
  1121. : ampucsymbol
  1122. { FieldSpec_t *fs;
  1123. FieldSpecs_e fe;
  1124. ObjectClass_t *oc;
  1125. UndefinedSymbol_t *u;
  1126. oc = GetObjectClass($>>.Assignments, $oc);
  1127. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  1128. fe = GetFieldSpecType($>>.Assignments, fs);
  1129. if (fe == eFieldSpec_Undefined) {
  1130. if ($oc) {
  1131. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  1132. $oc, eSetting_ValueSet);
  1133. u->U.Field.Module = $>>.Module;
  1134. u->U.Field.Identifier = $1;
  1135. u->Next = $>>.Undefined;
  1136. $>>.Undefined = u;
  1137. }
  1138. } else if (fe != eFieldSpec_FixedTypeValueSet &&
  1139. fe != eFieldSpec_VariableTypeValueSet)
  1140. LLFAILED((&@1, "%s is not a valuesetfieldreference", $1));
  1141. $$ = $1;
  1142. }
  1143. ;
  1144. objectfieldreference(oc)
  1145. : amplcsymbol
  1146. { FieldSpec_t *fs;
  1147. FieldSpecs_e fe;
  1148. ObjectClass_t *oc;
  1149. UndefinedSymbol_t *u;
  1150. oc = GetObjectClass($>>.Assignments, $oc);
  1151. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  1152. fe = GetFieldSpecType($>>.Assignments, fs);
  1153. if (fe == eFieldSpec_Undefined) {
  1154. if ($oc) {
  1155. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  1156. $oc, eSetting_Object);
  1157. u->U.Field.Module = $>>.Module;
  1158. u->U.Field.Identifier = $1;
  1159. u->Next = $>>.Undefined;
  1160. $>>.Undefined = u;
  1161. }
  1162. } else if (fe != eFieldSpec_Object)
  1163. LLFAILED((&@1, "%s is not a objectfieldreference", $1));
  1164. $$ = $1;
  1165. }
  1166. ;
  1167. objectsetfieldreference(oc)
  1168. : ampucsymbol
  1169. { FieldSpec_t *fs;
  1170. FieldSpecs_e fe;
  1171. ObjectClass_t *oc;
  1172. UndefinedSymbol_t *u;
  1173. oc = GetObjectClass($>>.Assignments, $oc);
  1174. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  1175. fe = GetFieldSpecType($>>.Assignments, fs);
  1176. if (fe == eFieldSpec_Undefined) {
  1177. if ($oc) {
  1178. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  1179. $oc, eSetting_ObjectSet);
  1180. u->U.Field.Module = $>>.Module;
  1181. u->U.Field.Identifier = $1;
  1182. u->Next = $>>.Undefined;
  1183. $>>.Undefined = u;
  1184. }
  1185. } else if (fe != eFieldSpec_ObjectSet)
  1186. LLFAILED((&@1, "%s is not a objectsetfieldreference", $1));
  1187. $$ = $1;
  1188. }
  1189. ;
  1190. word
  1191. : ucsymbol
  1192. { $$ = $1;
  1193. }
  1194. | "ABSENT"
  1195. { $$ = "ABSENT";
  1196. }
  1197. | "ABSTRACT-SYNTAX"
  1198. { $$ = "ABSTRACT-SYNTAX";
  1199. }
  1200. | "ALL"
  1201. { $$ = "ALL";
  1202. }
  1203. | "ANY"
  1204. { $$ = "ANY";
  1205. }
  1206. | "APPLICATION"
  1207. { $$ = "APPLICATION";
  1208. }
  1209. | "AUTOMATIC"
  1210. { $$ = "AUTOMATIC";
  1211. }
  1212. | "BEGIN"
  1213. { $$ = "BEGIN";
  1214. }
  1215. | "BMPString"
  1216. { $$ = "BMPString";
  1217. }
  1218. | "BY"
  1219. { $$ = "BY";
  1220. }
  1221. | "CLASS"
  1222. { $$ = "CLASS";
  1223. }
  1224. | "COMPONENT"
  1225. { $$ = "COMPONENT";
  1226. }
  1227. | "COMPONENTS"
  1228. { $$ = "COMPONENTS";
  1229. }
  1230. | "CONSTRAINED"
  1231. { $$ = "CONSTRAINED";
  1232. }
  1233. | "DEFAULT"
  1234. { $$ = "DEFAULT";
  1235. }
  1236. | "DEFINED"
  1237. { $$ = "DEFINED";
  1238. }
  1239. | "DEFINITIONS"
  1240. { $$ = "DEFINITIONS";
  1241. }
  1242. | "empty"
  1243. { $$ = "empty";
  1244. }
  1245. | "EXCEPT"
  1246. { $$ = "EXCEPT";
  1247. }
  1248. | "EXPLICIT"
  1249. { $$ = "EXPLICIT";
  1250. }
  1251. | "EXPORTS"
  1252. { $$ = "EXPORTS";
  1253. }
  1254. | "EXTENSIBILITY"
  1255. { $$ = "EXTENSIBILITY";
  1256. }
  1257. | "FROM"
  1258. { $$ = "FROM";
  1259. }
  1260. | "GeneralizedTime"
  1261. { $$ = "GeneralizedTime";
  1262. }
  1263. | "GeneralString"
  1264. { $$ = "GeneralString";
  1265. }
  1266. | "GraphicString"
  1267. { $$ = "GraphicString";
  1268. }
  1269. | "IA5String"
  1270. { $$ = "IA5String";
  1271. }
  1272. | "IDENTIFIER"
  1273. { $$ = "IDENTIFIER";
  1274. }
  1275. | "identifier"
  1276. { $$ = "identifier";
  1277. }
  1278. | "IMPLICIT"
  1279. { $$ = "IMPLICIT";
  1280. }
  1281. | "IMPLIED"
  1282. { $$ = "IMPLIED";
  1283. }
  1284. | "IMPORTS"
  1285. { $$ = "IMPORTS";
  1286. }
  1287. | "INCLUDES"
  1288. { $$ = "INCLUDES";
  1289. }
  1290. | "ISO646String"
  1291. { $$ = "ISO646String";
  1292. }
  1293. | "MACRO"
  1294. { $$ = "MACRO";
  1295. }
  1296. | "MAX"
  1297. { $$ = "MAX";
  1298. }
  1299. | "MIN"
  1300. { $$ = "MIN";
  1301. }
  1302. | "NOTATION"
  1303. { $$ = "NOTATION";
  1304. }
  1305. | "number"
  1306. { $$ = "number";
  1307. }
  1308. | "NumericString"
  1309. { $$ = "NumericString";
  1310. }
  1311. | "ObjectDescriptor"
  1312. { $$ = "ObjectDescriptor";
  1313. }
  1314. | "OF"
  1315. { $$ = "OF";
  1316. }
  1317. | "OPTIONAL"
  1318. { $$ = "OPTIONAL";
  1319. }
  1320. | "PDV"
  1321. { $$ = "PDV";
  1322. }
  1323. | "PRESENT"
  1324. { $$ = "PRESENT";
  1325. }
  1326. | "PrintableString"
  1327. { $$ = "PrintableString";
  1328. }
  1329. | "PRIVATE"
  1330. { $$ = "PRIVATE";
  1331. }
  1332. | "SIZE"
  1333. { $$ = "SIZE";
  1334. }
  1335. | "STRING"
  1336. { $$ = "STRING";
  1337. }
  1338. | "string"
  1339. { $$ = "string";
  1340. }
  1341. | "SYNTAX"
  1342. { $$ = "SYNTAX";
  1343. }
  1344. | "T61String"
  1345. { $$ = "T61String";
  1346. }
  1347. | "TAGS"
  1348. { $$ = "TAGS";
  1349. }
  1350. | "TeletexString"
  1351. { $$ = "TeletexString";
  1352. }
  1353. | "TYPE"
  1354. { $$ = "TYPE";
  1355. }
  1356. | "type"
  1357. { $$ = "type";
  1358. }
  1359. | "TYPE-IDENTIFIER"
  1360. { $$ = "TYPE-IDENTIFIER";
  1361. }
  1362. | "UNIQUE"
  1363. { $$ = "UNIQUE";
  1364. }
  1365. | "UNIVERSAL"
  1366. { $$ = "UNIVERSAL";
  1367. }
  1368. | "UniversalString"
  1369. { $$ = "UniversalString";
  1370. }
  1371. | "UTCTime"
  1372. { $$ = "UTCTime";
  1373. }
  1374. | "UTF8String"
  1375. { $$ = "UTF8String";
  1376. }
  1377. | "VALUE"
  1378. { $$ = "VALUE";
  1379. }
  1380. | "value"
  1381. { $$ = "value";
  1382. }
  1383. | "VideotexString"
  1384. { $$ = "VideotexString";
  1385. }
  1386. | "VisibleString"
  1387. { $$ = "VisibleString";
  1388. }
  1389. | "WITH"
  1390. { $$ = "WITH";
  1391. }
  1392. ;
  1393. identifier
  1394. : lcsymbol
  1395. { $$ = $1;
  1396. }
  1397. | "empty"
  1398. { $$ = "empty";
  1399. }
  1400. | "identifier"
  1401. { $$ = "identifier";
  1402. }
  1403. | "number"
  1404. { $$ = "number";
  1405. }
  1406. | "string"
  1407. { $$ = "string";
  1408. }
  1409. | "type"
  1410. { $$ = "type";
  1411. }
  1412. | "value"
  1413. { $$ = "value";
  1414. }
  1415. ;
  1416. ucsymbol
  1417. : ocsymbol
  1418. { $$ = $1;
  1419. }
  1420. | uppercase_symbol
  1421. { $$ = $1;
  1422. }
  1423. ;
  1424. ocsymbol
  1425. : only_uppercase_symbol
  1426. { $$ = $1;
  1427. }
  1428. | only_uppercase_digits_symbol
  1429. { $$ = $1;
  1430. }
  1431. | "MACRO"
  1432. { $$ = "MACRO";
  1433. }
  1434. | "NOTATION"
  1435. { $$ = "NOTATION";
  1436. }
  1437. | "TYPE"
  1438. { $$ = "TYPE";
  1439. }
  1440. | "VALUE"
  1441. { $$ = "VALUE";
  1442. }
  1443. ;
  1444. astring
  1445. : cstring
  1446. { uint32_t i, len;
  1447. len = str32len($1);
  1448. $$ = (char *)malloc(len + 1);
  1449. for (i = 0; i <= len; i++)
  1450. $$[i] = (char)($1[i]);
  1451. }
  1452. ;
  1453. #line 63 "type.ll"
  1454. DefinedType
  1455. : Externaltypereference
  1456. { $$ = $1;
  1457. }
  1458. | typereference
  1459. { $$ = $1;
  1460. }
  1461. | ParameterizedType
  1462. { MyAbort();
  1463. }
  1464. | ParameterizedValueSetType
  1465. { MyAbort();
  1466. }
  1467. ;
  1468. TypeAssignment
  1469. : typereference "::=" Type PrivateDirectives
  1470. {
  1471. PropagatePrivateDirectives($3, $4);
  1472. if (!AssignType(&$>>.Assignments, $1, $3))
  1473. LLFAILED((&@1, "Type `%s' twice defined",
  1474. $1->U.Reference.Identifier));
  1475. ($>>.Assignments)->eDefTagType = g_eDefTagType;
  1476. }
  1477. ;
  1478. ValueSetTypeAssignment
  1479. : typereference Type "::=" ValueSet($2)
  1480. { Type_t *type;
  1481. type = GetTypeOfValueSet($>>.Assignments, $4);
  1482. if (!AssignType(&$>>.Assignments, $1, type))
  1483. LLFAILED((&@1, "Type `%s' twice defined",
  1484. $1->U.Reference.Identifier));
  1485. }
  1486. ;
  1487. ValueSet(type)
  1488. : '{' ElementSetSpec($type, NULL, 0) '}'
  1489. { $$ = NewValueSet();
  1490. $$->Elements = $2;
  1491. $$->Type = $type;
  1492. }
  1493. ;
  1494. Type
  1495. : LocalTypeDirectiveESeq UndirectivedType LocalTypeDirectiveESeq
  1496. { Directive_t **dd, *d;
  1497. if ($1 || $3) {
  1498. $$ = DupType($2);
  1499. dd = &$$->Directives;
  1500. for (d = $1; d; d = d->Next) {
  1501. *dd = DupDirective(d);
  1502. dd = &(*dd)->Next;
  1503. }
  1504. for (d = $3; d; d = d->Next) {
  1505. *dd = DupDirective(d);
  1506. dd = &(*dd)->Next;
  1507. }
  1508. *dd = $2->Directives;
  1509. } else {
  1510. $$ = $2;
  1511. }
  1512. }
  1513. ;
  1514. UndirectivedType
  1515. : UntaggedType
  1516. { $$ = $1;
  1517. }
  1518. | TaggedType
  1519. { $$ = $1;
  1520. }
  1521. ;
  1522. UntaggedType
  1523. : ConstrainableType
  1524. { $$ = $1;
  1525. }
  1526. | SequenceOfType
  1527. { $$ = $1;
  1528. }
  1529. | SetOfType
  1530. { $$ = $1;
  1531. }
  1532. | TypeWithConstraint
  1533. { $$ = $1;
  1534. }
  1535. ;
  1536. ConstrainableType
  1537. : BuiltinType LocalTypeDirectiveESeq PrivateDirectives Constraint_ESeq($1)
  1538. LocalTypeDirectiveESeq PrivateDirectives
  1539. { Directive_t *d, **dd;
  1540. if ($2 || $4 || $5) {
  1541. $$ = DupType($1);
  1542. IntersectConstraints(&$$->Constraints,
  1543. $1->Constraints, $4);
  1544. dd = &$$->Directives;
  1545. for (d = $2; d; d = d->Next) {
  1546. *dd = DupDirective(d);
  1547. dd = &(*dd)->Next;
  1548. }
  1549. for (d = $5; d; d = d->Next) {
  1550. *dd = DupDirective(d);
  1551. dd = &(*dd)->Next;
  1552. }
  1553. *dd = NULL;
  1554. } else {
  1555. $$ = ($3 || $6) ? DupType($1) : $1;
  1556. }
  1557. PropagatePrivateDirectives($$, $3);
  1558. PropagatePrivateDirectives($$, $6);
  1559. }
  1560. | ReferencedType LocalTypeDirectiveESeq PrivateDirectives Constraint_ESeq($1)
  1561. LocalTypeDirectiveESeq PrivateDirectives
  1562. { Directive_t *d, **dd;
  1563. if ($2 || $4 || $5) {
  1564. $$ = DupType($1);
  1565. IntersectConstraints(&$$->Constraints,
  1566. $1->Constraints, $4);
  1567. dd = &$$->Directives;
  1568. for (d = $2; d; d = d->Next) {
  1569. *dd = DupDirective(d);
  1570. dd = &(*dd)->Next;
  1571. }
  1572. for (d = $5; d; d = d->Next) {
  1573. *dd = DupDirective(d);
  1574. dd = &(*dd)->Next;
  1575. }
  1576. *dd = NULL;
  1577. } else {
  1578. $$ = ($3 || $6) ? DupType($1) : $1;
  1579. }
  1580. PropagatePrivateDirectives($$, $3);
  1581. PropagatePrivateDirectives($$, $6);
  1582. }
  1583. ;
  1584. Constraint_ESeq(type)
  1585. : Constraint($type, 0) Constraint_ESeq($type)
  1586. { if ($2) {
  1587. IntersectConstraints(&$$, $1, $2);
  1588. } else {
  1589. $$ = $1;
  1590. }
  1591. }
  1592. | /* empty */
  1593. { $$ = NULL;
  1594. }
  1595. ;
  1596. BuiltinType
  1597. : BitStringType
  1598. { $$ = $1;
  1599. }
  1600. | BooleanType
  1601. { $$ = $1;
  1602. }
  1603. | CharacterStringType
  1604. { $$ = $1;
  1605. }
  1606. | ChoiceType
  1607. { $$ = $1;
  1608. }
  1609. | EmbeddedPDVType
  1610. { $$ = $1;
  1611. }
  1612. | EnumeratedType
  1613. { $$ = $1;
  1614. }
  1615. | ExternalType
  1616. { $$ = $1;
  1617. }
  1618. | InstanceOfType
  1619. { $$ = $1;
  1620. }
  1621. | IntegerType
  1622. { $$ = $1;
  1623. }
  1624. | NullType
  1625. { $$ = $1;
  1626. }
  1627. | ObjectClassFieldType
  1628. { $$ = $1;
  1629. }
  1630. | ObjectIdentifierType
  1631. { $$ = $1;
  1632. }
  1633. | OctetStringType
  1634. { $$ = $1;
  1635. }
  1636. | UTF8StringType
  1637. { $$ = $1;
  1638. }
  1639. | RealType
  1640. { $$ = $1;
  1641. }
  1642. | SequenceType
  1643. { $$ = $1;
  1644. }
  1645. | SetType
  1646. { $$ = $1;
  1647. }
  1648. | AnyType
  1649. { $$ = $1;
  1650. }
  1651. | MacroDefinedType
  1652. { $$ = $1;
  1653. }
  1654. ;
  1655. ReferencedType
  1656. : DefinedType
  1657. { $$ = $1;
  1658. }
  1659. | UsefulType
  1660. { $$ = $1;
  1661. }
  1662. | SelectionType
  1663. { $$ = $1;
  1664. }
  1665. | TypeFromObject
  1666. { $$ = $1;
  1667. }
  1668. | ValueSetFromObjects
  1669. { $$ = GetTypeOfValueSet($>>.Assignments, $1);
  1670. }
  1671. ;
  1672. NamedType
  1673. : identifier Type
  1674. {
  1675. $$ = NewNamedType($2->PrivateDirectives.pszFieldName ? $2->PrivateDirectives.pszFieldName : $1, $2);
  1676. $2->PrivateDirectives.pszFieldName = NULL;
  1677. }
  1678. | identifier '<' Type
  1679. { Type_t *type;
  1680. type = NewType(eType_Selection);
  1681. type->U.Selection.Type = $3;
  1682. type->U.Selection.Identifier = $1;
  1683. $$ = NewNamedType($3->PrivateDirectives.pszFieldName ? $3->PrivateDirectives.pszFieldName : $1, type);
  1684. $3->PrivateDirectives.pszFieldName = NULL;
  1685. }
  1686. ;
  1687. BooleanType
  1688. : "BOOLEAN"
  1689. { $$ = Builtin_Type_Boolean;
  1690. }
  1691. ;
  1692. IntegerType
  1693. : "INTEGER" '{' NamedNumberList '}'
  1694. { NamedNumber_t *n, *m;
  1695. for (n = $3; n && n->Next; n = n->Next) {
  1696. for (m = n->Next; m; m = m->Next) {
  1697. if (n->Type == eNamedNumber_Normal &&
  1698. m->Type == eNamedNumber_Normal) {
  1699. if (!strcmp(n->U.Normal.Identifier,
  1700. m->U.Normal.Identifier))
  1701. LLFAILED((&@3,
  1702. "identifier `%s' has been assigned twice",
  1703. n->U.Normal.Identifier));
  1704. if (GetValue($>>.Assignments, n->U.Normal.Value) &&
  1705. GetValue($>>.Assignments, m->U.Normal.Value) &&
  1706. GetTypeType($>>.Assignments,
  1707. GetValue($>>.Assignments, n->U.Normal.Value)->Type)
  1708. == eType_Integer &&
  1709. GetTypeType($>>.Assignments,
  1710. GetValue($>>.Assignments, m->U.Normal.Value)->Type)
  1711. == eType_Integer &&
  1712. !intx_cmp(&GetValue($>>.Assignments,
  1713. n->U.Normal.Value)->U.Integer.Value,
  1714. &GetValue($>>.Assignments,
  1715. m->U.Normal.Value)->U.Integer.Value))
  1716. LLFAILED((&@3,
  1717. "value `%d' has been assigned twice",
  1718. intx2int32(&GetValue($>>.Assignments,
  1719. n->U.Normal.Value)->U.Integer.Value)));
  1720. }
  1721. }
  1722. }
  1723. $$ = NewType(eType_Integer);
  1724. $$->ExtensionDefault = $>>.ExtensionDefault;
  1725. $$->U.Integer.NamedNumbers = $3;
  1726. }
  1727. | "INTEGER"
  1728. { $$ = NewType(eType_Integer);
  1729. $$->ExtensionDefault = $>>.ExtensionDefault;
  1730. }
  1731. ;
  1732. NamedNumberList
  1733. : NamedNumber ',' NamedNumberList
  1734. { $$ = DupNamedNumber($1);
  1735. $$->Next = $3;
  1736. }
  1737. | NamedNumber
  1738. { $$ = $1;
  1739. }
  1740. ;
  1741. NamedNumber
  1742. : identifier '(' SignedNumber(Builtin_Type_Integer) ')'
  1743. { $$ = NewNamedNumber(eNamedNumber_Normal);
  1744. $$->U.Normal.Identifier = $1;
  1745. $$->U.Normal.Value = $3;
  1746. }
  1747. | identifier '(' DefinedValue ')'
  1748. { Value_t *v;
  1749. v = GetValue($>>.Assignments, $3);
  1750. if (v) {
  1751. if (GetTypeType($>>.Assignments, v->Type) != eType_Undefined &&
  1752. GetTypeType($>>.Assignments, v->Type) != eType_Integer)
  1753. LLFAILED((&@3, "Bad type of value"));
  1754. if (GetTypeType($>>.Assignments, v->Type) != eType_Integer &&
  1755. intx_cmp(&v->U.Integer.Value, &intx_0) < 0)
  1756. LLFAILED((&@3, "Bad value"));
  1757. }
  1758. $$ = NewNamedNumber(eNamedNumber_Normal);
  1759. $$->U.Normal.Identifier = $1;
  1760. $$->U.Normal.Value = $3;
  1761. }
  1762. ;
  1763. EnumeratedType
  1764. : "ENUMERATED" '{' Enumerations '}'
  1765. { NamedNumber_t **nn, *n, *m;
  1766. intx_t *ix;
  1767. uint32_t num = 0;
  1768. $$ = NewType(eType_Enumerated);
  1769. $$->ExtensionDefault = $>>.ExtensionDefault;
  1770. for (n = $3; n; n = n->Next)
  1771. if (n->Type == eNamedNumber_Normal)
  1772. KeepEnumNames(n->U.Normal.Identifier); // global conflict check
  1773. for (n = $3; n && n->Next; n = n->Next) {
  1774. if (n->Type != eNamedNumber_Normal)
  1775. continue;
  1776. for (m = n->Next; m; m = m->Next) {
  1777. if (m->Type != eNamedNumber_Normal)
  1778. continue;
  1779. if (!strcmp(n->U.Normal.Identifier,
  1780. m->U.Normal.Identifier))
  1781. LLFAILED((&@3,
  1782. "identifier `%s' has been assigned twice",
  1783. n->U.Normal.Identifier));
  1784. if (GetValue($>>.Assignments, n->U.Normal.Value) &&
  1785. GetValue($>>.Assignments, m->U.Normal.Value) &&
  1786. GetTypeType($>>.Assignments,
  1787. GetValue($>>.Assignments, n->U.Normal.Value)->Type)
  1788. == eType_Integer &&
  1789. GetTypeType($>>.Assignments,
  1790. GetValue($>>.Assignments, m->U.Normal.Value)->Type)
  1791. == eType_Integer &&
  1792. !intx_cmp(&GetValue($>>.Assignments,
  1793. n->U.Normal.Value)->U.Integer.Value,
  1794. &GetValue($>>.Assignments,
  1795. m->U.Normal.Value)->U.Integer.Value))
  1796. LLFAILED((&@3,
  1797. "value `%d' has been assigned twice",
  1798. intx2int32(&GetValue($>>.Assignments,
  1799. n->U.Normal.Value)->U.Integer.Value)));
  1800. }
  1801. }
  1802. nn = &$$->U.Enumerated.NamedNumbers;
  1803. for (n = $3; n; n = n->Next) {
  1804. *nn = DupNamedNumber(n);
  1805. switch (n->Type) {
  1806. case eNamedNumber_Normal:
  1807. if (n->U.Normal.Value)
  1808. break;
  1809. for (;; num++) {
  1810. for (m = $3; m; m = m->Next) {
  1811. switch (m->Type) {
  1812. case eNamedNumber_Normal:
  1813. if (!m->U.Normal.Value)
  1814. continue;
  1815. ix = &GetValue($>>.Assignments,
  1816. m->U.Normal.Value)->U.Integer.Value;
  1817. if (!intxisuint32(ix) ||
  1818. intx2uint32(ix) != num)
  1819. continue;
  1820. break;
  1821. default:
  1822. continue;
  1823. }
  1824. break;
  1825. }
  1826. if (!m)
  1827. break;
  1828. }
  1829. (*nn)->U.Normal.Value = NewValue(NULL,
  1830. Builtin_Type_Integer);
  1831. intx_setuint32(
  1832. &(*nn)->U.Normal.Value->U.Integer.Value,
  1833. num++);
  1834. break;
  1835. case eNamedNumber_ExtensionMarker:
  1836. break;
  1837. }
  1838. nn = &(*nn)->Next;
  1839. }
  1840. *nn = NULL;
  1841. }
  1842. ;
  1843. Enumerations
  1844. : Enumeration EnumerationExtension
  1845. { NamedNumber_t **nn, *n;
  1846. nn = &$$;
  1847. for (n = $1; n; n = n->Next) {
  1848. *nn = DupNamedNumber(n);
  1849. nn = &(*nn)->Next;
  1850. }
  1851. *nn = $2;
  1852. }
  1853. ;
  1854. EnumerationExtension
  1855. : ',' "..." ',' Enumeration
  1856. { $$ = NewNamedNumber(eNamedNumber_ExtensionMarker);
  1857. $$->Next = $4;
  1858. }
  1859. | ',' "..."
  1860. { $$ = NewNamedNumber(eNamedNumber_ExtensionMarker);
  1861. }
  1862. | /* empty */
  1863. { $$ = NULL;
  1864. }
  1865. ;
  1866. Enumeration
  1867. : EnumerationItem ',' Enumeration
  1868. { $$ = DupNamedNumber($1);
  1869. $$->Next = $3;
  1870. }
  1871. | EnumerationItem
  1872. { $$ = $1;
  1873. }
  1874. ;
  1875. EnumerationItem
  1876. : identifier
  1877. { $$ = NewNamedNumber(eNamedNumber_Normal);
  1878. $$->U.Normal.Identifier = $1;
  1879. }
  1880. | NamedNumber
  1881. { $$ = $1;
  1882. }
  1883. ;
  1884. RealType
  1885. : "REAL"
  1886. { $$ = Builtin_Type_Real;
  1887. }
  1888. ;
  1889. BitStringType
  1890. : "BIT" "STRING" '{' NamedBitList '}'
  1891. { NamedNumber_t *n, *m;
  1892. $$ = NewType(eType_BitString);
  1893. $$->ExtensionDefault = $>>.ExtensionDefault;
  1894. $$->U.BitString.NamedNumbers = $4;
  1895. for (n = $4; n; n = n->Next)
  1896. KeepEnumNames(n->U.Normal.Identifier); // global conflict check
  1897. for (n = $4; n && n->Next; n = n->Next) {
  1898. for (m = n->Next; m; m = m->Next) {
  1899. if (!strcmp(n->U.Normal.Identifier,
  1900. m->U.Normal.Identifier))
  1901. LLFAILED((&@4,
  1902. "identifier `%s' has been assigned twice",
  1903. n->U.Normal.Identifier));
  1904. if (GetValue($>>.Assignments, n->U.Normal.Value) &&
  1905. GetValue($>>.Assignments, m->U.Normal.Value) &&
  1906. GetTypeType($>>.Assignments,
  1907. GetValue($>>.Assignments, n->U.Normal.Value)->Type)
  1908. == eType_Integer &&
  1909. GetTypeType($>>.Assignments,
  1910. GetValue($>>.Assignments, m->U.Normal.Value)->Type)
  1911. == eType_Integer &&
  1912. !intx_cmp(&GetValue($>>.Assignments,
  1913. n->U.Normal.Value)->U.Integer.Value,
  1914. &GetValue($>>.Assignments,
  1915. m->U.Normal.Value)->U.Integer.Value))
  1916. LLFAILED((&@4,
  1917. "value `%u' has been assigned twice",
  1918. intx2uint32(&GetValue($>>.Assignments,
  1919. n->U.Normal.Value)->U.Integer.Value)));
  1920. }
  1921. }
  1922. }
  1923. | "BIT" "STRING"
  1924. { $$ = NewType(eType_BitString);
  1925. $$->ExtensionDefault = $>>.ExtensionDefault;
  1926. }
  1927. ;
  1928. NamedBitList
  1929. : NamedBit ',' NamedBitList
  1930. { $$ = DupNamedNumber($1);
  1931. $$->Next = $3;
  1932. }
  1933. | NamedBit
  1934. { $$ = $1;
  1935. }
  1936. ;
  1937. NamedBit
  1938. : identifier '(' number ')'
  1939. { $$ = NewNamedNumber(eNamedNumber_Normal);
  1940. $$->U.Normal.Identifier = $1;
  1941. $$->U.Normal.Value = NewValue(NULL, Builtin_Type_Integer);
  1942. $$->U.Normal.Value->U.Integer.Value = $3;
  1943. }
  1944. | identifier '(' DefinedValue ')'
  1945. { Value_t *v;
  1946. v = GetValue($>>.Assignments, $3);
  1947. if (v) {
  1948. if (GetTypeType($>>.Assignments, v->Type) != eType_Undefined &&
  1949. GetTypeType($>>.Assignments, v->Type) != eType_Integer)
  1950. LLFAILED((&@3, "Bad type of value"));
  1951. if (GetTypeType($>>.Assignments, v->Type) == eType_Integer &&
  1952. intx_cmp(&v->U.Integer.Value, &intx_0) < 0)
  1953. LLFAILED((&@3, "Bad value"));
  1954. }
  1955. $$ = NewNamedNumber(eNamedNumber_Normal);
  1956. $$->U.Normal.Identifier = $1;
  1957. $$->U.Normal.Value = $3;
  1958. }
  1959. ;
  1960. OctetStringType
  1961. : "OCTET" "STRING"
  1962. { $$ = Builtin_Type_OctetString;
  1963. }
  1964. ;
  1965. UTF8StringType
  1966. : "UTF8String"
  1967. { $$ = Builtin_Type_UTF8String;
  1968. }
  1969. ;
  1970. NullType
  1971. : "NULL"
  1972. { $$ = Builtin_Type_Null;
  1973. }
  1974. ;
  1975. SequenceType
  1976. : "SEQUENCE" '{' ExtendedComponentTypeList '}'
  1977. { Component_t *c, *d; int fExtended = 0;
  1978. for (c = $3; c; c = c->Next)
  1979. if (c->Type == eComponent_Optional || c->Type == eComponent_Default || fExtended)
  1980. KeepOptNames(c->U.NOD.NamedType->Identifier); // global conflict check
  1981. else
  1982. if (c->Type == eComponent_ExtensionMarker)
  1983. fExtended = 1;
  1984. for (c = $3; c && c->Next; c = c->Next) {
  1985. if (c->Type != eComponent_Normal &&
  1986. c->Type != eComponent_Optional &&
  1987. c->Type != eComponent_Default)
  1988. continue;
  1989. for (d = c->Next; d; d = d->Next) {
  1990. if (d->Type != eComponent_Normal &&
  1991. d->Type != eComponent_Optional &&
  1992. d->Type != eComponent_Default)
  1993. continue;
  1994. if (!strcmp(c->U.NOD.NamedType->Identifier,
  1995. d->U.NOD.NamedType->Identifier))
  1996. LLFAILED((&@3, "Component `%s' has been used twice",
  1997. c->U.NOD.NamedType->Identifier));
  1998. }
  1999. }
  2000. $$ = NewType(eType_Sequence);
  2001. $$->TagDefault = $>>.TagDefault;
  2002. $$->ExtensionDefault = $>>.ExtensionDefault;
  2003. $$->U.Sequence.Components = $3;
  2004. }
  2005. | "SEQUENCE" '{' '}'
  2006. { $$ = NewType(eType_Sequence);
  2007. $$->ExtensionDefault = $>>.ExtensionDefault;
  2008. }
  2009. ;
  2010. ExtensionAndException
  2011. : "..." ExceptionSpec
  2012. { $$ = NewComponent(eComponent_ExtensionMarker);
  2013. /*$$->U.ExtensionMarker.ExceptionSpec = $2;*/
  2014. }
  2015. | "..."
  2016. { $$ = NewComponent(eComponent_ExtensionMarker);
  2017. }
  2018. ;
  2019. ExtendedComponentTypeList
  2020. : ComponentTypeList ComponentTypeListExtension
  2021. { Component_t **cc, *c;
  2022. if ($2) {
  2023. cc = &$$;
  2024. for (c = $1; c; c = c->Next) {
  2025. *cc = DupComponent(c);
  2026. cc = &(*cc)->Next;
  2027. }
  2028. *cc = $2;
  2029. } else {
  2030. $$ = $1;
  2031. }
  2032. }
  2033. | ExtensionAndException
  2034. AdditionalComponentTypeList
  2035. { Component_t **cc, *c;
  2036. if ($2) {
  2037. cc = &$$;
  2038. for (c = $1; c; c = c->Next) {
  2039. *cc = DupComponent(c);
  2040. cc = &(*cc)->Next;
  2041. }
  2042. *cc = $2;
  2043. } else {
  2044. $$ = $1;
  2045. }
  2046. }
  2047. ;
  2048. ComponentTypeListExtension
  2049. : ',' ExtensionAndException AdditionalComponentTypeList
  2050. { Component_t **cc, *c;
  2051. if ($3) {
  2052. cc = &$$;
  2053. for (c = $2; c; c = c->Next) {
  2054. *cc = DupComponent(c);
  2055. cc = &(*cc)->Next;
  2056. }
  2057. *cc = $3;
  2058. } else {
  2059. $$ = $2;
  2060. }
  2061. }
  2062. | /* empty */
  2063. { $$ = NULL;
  2064. }
  2065. ;
  2066. AdditionalComponentTypeList
  2067. : ',' ComponentTypeList
  2068. { $$ = $2;
  2069. }
  2070. | /* empty */
  2071. { $$ = NULL;
  2072. }
  2073. ;
  2074. ComponentTypeList
  2075. : ComponentType AdditionalComponentTypeList
  2076. { if ($2) {
  2077. $$ = DupComponent($1);
  2078. $$->Next = $2;
  2079. } else {
  2080. $$ = $1;
  2081. }
  2082. }
  2083. ;
  2084. ComponentType
  2085. : NamedType ComponentTypePostfix($1->Type)
  2086. { $$ = DupComponent($2);
  2087. $$->U.NOD.NamedType = $1;
  2088. }
  2089. | "COMPONENTS" "OF" Type
  2090. { $$ = NewComponent(eComponent_ComponentsOf);
  2091. $$->U.ComponentsOf.Type = $3;
  2092. }
  2093. ;
  2094. ComponentTypePostfix(type)
  2095. : "OPTIONAL"
  2096. { $$ = NewComponent(eComponent_Optional);
  2097. }
  2098. | "DEFAULT" Value($type)
  2099. { $$ = NewComponent(eComponent_Default);
  2100. $$->U.Default.Value = $2;
  2101. }
  2102. | /* empty */
  2103. { $$ = NewComponent(eComponent_Normal);
  2104. }
  2105. ;
  2106. SequenceOfType
  2107. : "SEQUENCE" LocalSizeDirectiveESeq PrivateDirectives "OF" Type
  2108. { $$ = NewType(eType_SequenceOf);
  2109. $$->ExtensionDefault = $>>.ExtensionDefault;
  2110. $$->U.SequenceOf.Type = $5;
  2111. $$->U.SequenceOf.Directives = $2;
  2112. if ($3)
  2113. {
  2114. PropagatePrivateDirectives($$, $3);
  2115. }
  2116. if ($$->PrivateDirectives.pszTypeName &&
  2117. strncmp("PSetOf", $$->PrivateDirectives.pszTypeName, 6) == 0)
  2118. {
  2119. $$->PrivateDirectives.pszTypeName++;
  2120. }
  2121. }
  2122. ;
  2123. SetType
  2124. : "SET" '{' ExtendedComponentTypeList '}'
  2125. { Component_t *c, *d;
  2126. for (c = $3; c && c->Next; c = c->Next) {
  2127. if (c->Type != eComponent_Normal &&
  2128. c->Type != eComponent_Optional &&
  2129. c->Type != eComponent_Default)
  2130. continue;
  2131. for (d = c->Next; d; d = d->Next) {
  2132. if (d->Type != eComponent_Normal &&
  2133. d->Type != eComponent_Optional &&
  2134. d->Type != eComponent_Default)
  2135. continue;
  2136. if (!strcmp(c->U.NOD.NamedType->Identifier,
  2137. d->U.NOD.NamedType->Identifier))
  2138. LLFAILED((&@3, "Component `%s' has been used twice",
  2139. c->U.NOD.NamedType->Identifier));
  2140. }
  2141. }
  2142. $$ = NewType(eType_Set);
  2143. $$->TagDefault = $>>.TagDefault;
  2144. $$->ExtensionDefault = $>>.ExtensionDefault;
  2145. $$->U.Set.Components = $3;
  2146. }
  2147. | "SET" '{' '}'
  2148. { $$ = NewType(eType_Set);
  2149. $$->ExtensionDefault = $>>.ExtensionDefault;
  2150. }
  2151. ;
  2152. SetOfType
  2153. : "SET" LocalSizeDirectiveESeq PrivateDirectives "OF" Type
  2154. { $$ = NewType(eType_SetOf);
  2155. $$->ExtensionDefault = $>>.ExtensionDefault;
  2156. $$->U.SetOf.Type = $5;
  2157. $$->U.SetOf.Directives = $2;
  2158. if ($3)
  2159. {
  2160. PropagatePrivateDirectives($$, $3);
  2161. }
  2162. if ($$->PrivateDirectives.pszTypeName &&
  2163. strncmp("PSetOf", $$->PrivateDirectives.pszTypeName, 6) == 0)
  2164. {
  2165. $$->PrivateDirectives.pszTypeName++;
  2166. }
  2167. }
  2168. ;
  2169. ChoiceType
  2170. : "CHOICE" '{' ExtendedAlternativeTypeList '}'
  2171. { Component_t *c, *d;
  2172. for (c = $3; c; c = c->Next)
  2173. if (c->Type == eComponent_Normal ||
  2174. c->Type == eComponent_Optional ||
  2175. c->Type == eComponent_Default)
  2176. KeepChoiceNames(c->U.NOD.NamedType->Identifier); // global conflict check
  2177. for (c = $3; c && c->Next; c = c->Next) {
  2178. if (c->Type != eComponent_Normal &&
  2179. c->Type != eComponent_Optional &&
  2180. c->Type != eComponent_Default)
  2181. continue;
  2182. for (d = c->Next; d; d = d->Next) {
  2183. if (d->Type != eComponent_Normal &&
  2184. d->Type != eComponent_Optional &&
  2185. d->Type != eComponent_Default)
  2186. continue;
  2187. if (!strcmp(c->U.NOD.NamedType->Identifier,
  2188. d->U.NOD.NamedType->Identifier))
  2189. LLFAILED((&@3, "Component `%s' has been used twice",
  2190. c->U.NOD.NamedType->Identifier));
  2191. }
  2192. }
  2193. $$ = NewType(eType_Choice);
  2194. $$->TagDefault = $>>.TagDefault;
  2195. $$->ExtensionDefault = $>>.ExtensionDefault;
  2196. $$->U.Choice.Components = $3;
  2197. }
  2198. ;
  2199. ExtendedAlternativeTypeList
  2200. : AlternativeTypeList AlternativeTypeListExtension
  2201. { Component_t **cc, *c;
  2202. if ($2) {
  2203. cc = &$$;
  2204. for (c = $1; c; c = c->Next) {
  2205. *cc = DupComponent(c);
  2206. cc = &(*cc)->Next;
  2207. }
  2208. *cc = $2;
  2209. } else {
  2210. $$ = $1;
  2211. }
  2212. }
  2213. ;
  2214. AlternativeTypeListExtension
  2215. : ',' ExtensionAndException AdditionalAlternativeTypeList
  2216. { Component_t **cc, *c;
  2217. if ($3) {
  2218. cc = &$$;
  2219. for (c = $2; c; c = c->Next) {
  2220. *cc = DupComponent(c);
  2221. cc = &(*cc)->Next;
  2222. }
  2223. *cc = $3;
  2224. } else {
  2225. $$ = $2;
  2226. }
  2227. }
  2228. | /* empty */
  2229. { $$ = NULL;
  2230. }
  2231. ;
  2232. AdditionalAlternativeTypeList
  2233. : ',' AlternativeTypeList
  2234. { $$ = $2;
  2235. }
  2236. | /* empty */
  2237. { $$ = NULL;
  2238. }
  2239. ;
  2240. AlternativeTypeList
  2241. : NamedType AdditionalAlternativeTypeList
  2242. { $$ = NewComponent(eComponent_Normal);
  2243. $$->U.Normal.NamedType = $1;
  2244. $$->Next = $2;
  2245. }
  2246. ;
  2247. AnyType
  2248. : "ANY"
  2249. { $$ = Builtin_Type_Open;
  2250. }
  2251. | "ANY" "DEFINED" "BY" identifier
  2252. { $$ = Builtin_Type_Open;
  2253. }
  2254. ;
  2255. SelectionType
  2256. : identifier '<' Type
  2257. { $$ = NewType(eType_Selection);
  2258. $$->U.Selection.Identifier = $1;
  2259. $$->U.Selection.Type = $3;
  2260. }
  2261. ;
  2262. TaggedType
  2263. : Tag TagType Type
  2264. { Tag_t *t;
  2265. Type_e eType = GetTypeType($>>.Assignments, $3);
  2266. if (eType == eType_Choice || eType == eType_Open)
  2267. {
  2268. if ($2 == eTagType_Unknown &&
  2269. ($>>.TagDefault == eTagType_Implicit || $>>.TagDefault == eTagType_Automatic))
  2270. {
  2271. $2 = eTagType_Explicit;
  2272. }
  2273. else
  2274. if ($2 == eTagType_Implicit)
  2275. {
  2276. for (t = $3->Tags; t; t = t->Next) {
  2277. if (t->Type == eTagType_Explicit)
  2278. break;
  2279. }
  2280. if (!t)
  2281. LLFAILED((&@3, "Bad tag type for choice/open type"));
  2282. }
  2283. }
  2284. $$ = DupType($3);
  2285. $$->Tags = DupTag($1);
  2286. $$->Tags->Type = $2;
  2287. $$->Tags->Next = $3->Tags;
  2288. }
  2289. ;
  2290. TagType
  2291. : /* empty */
  2292. { $$ = eTagType_Unknown;
  2293. }
  2294. | "IMPLICIT"
  2295. { $$ = eTagType_Implicit;
  2296. }
  2297. | "EXPLICIT"
  2298. { $$ = eTagType_Explicit;
  2299. }
  2300. ;
  2301. Tag
  2302. : '[' Class ClassNumber ']'
  2303. { $$ = NewTag(eTagType_Unknown);
  2304. $$->Class = $2;
  2305. $$->Tag = $3;
  2306. }
  2307. ;
  2308. ClassNumber
  2309. : number
  2310. { if (intx_cmp(&$1, &intx_1G) >= 0)
  2311. LLFAILED((&@1, "Bad tag value"));
  2312. $$ = NewValue(NULL, Builtin_Type_Integer);
  2313. $$->U.Integer.Value = $1;
  2314. }
  2315. | DefinedValue
  2316. { Value_t *v;
  2317. v = GetValue($>>.Assignments, $1);
  2318. if (v &&
  2319. GetTypeType($>>.Assignments, v->Type) != eType_Integer &&
  2320. GetTypeType($>>.Assignments, v->Type) != eType_Undefined)
  2321. LLFAILED((&@1, "Bad type of tag value"));
  2322. if (v &&
  2323. GetTypeType($>>.Assignments, v->Type) == eType_Integer &&
  2324. (intx_cmp(&v->U.Integer.Value, &intx_0) < 0 ||
  2325. intx_cmp(&v->U.Integer.Value, &intx_1G) >= 0))
  2326. LLFAILED((&@1, "Bad tag value"));
  2327. $$ = $1;
  2328. }
  2329. ;
  2330. Class
  2331. : "UNIVERSAL"
  2332. { $$ = eTagClass_Universal;
  2333. }
  2334. | "APPLICATION"
  2335. { $$ = eTagClass_Application;
  2336. }
  2337. | "PRIVATE"
  2338. { $$ = eTagClass_Private;
  2339. }
  2340. | /* empty */
  2341. { $$ = eTagClass_Unknown;
  2342. }
  2343. ;
  2344. ObjectIdentifierType
  2345. : "OBJECT" "IDENTIFIER"
  2346. { $$ = Builtin_Type_ObjectIdentifier;
  2347. }
  2348. ;
  2349. EmbeddedPDVType
  2350. : "EMBEDDED" "PDV"
  2351. { $$ = Builtin_Type_EmbeddedPdv;
  2352. }
  2353. ;
  2354. ExternalType
  2355. : "EXTERNAL"
  2356. { $$ = Builtin_Type_External;
  2357. }
  2358. ;
  2359. CharacterStringType
  2360. : RestrictedCharacterStringType
  2361. { $$ = $1;
  2362. }
  2363. | UnrestrictedCharacterStringType
  2364. { $$ = $1;
  2365. }
  2366. ;
  2367. RestrictedCharacterStringType
  2368. : "BMPString"
  2369. { $$ = Builtin_Type_BMPString;
  2370. }
  2371. | "GeneralString"
  2372. { $$ = Builtin_Type_GeneralString;
  2373. }
  2374. | "GraphicString"
  2375. { $$ = Builtin_Type_GraphicString;
  2376. }
  2377. | "IA5String"
  2378. { $$ = Builtin_Type_IA5String;
  2379. }
  2380. | "ISO646String"
  2381. { $$ = Builtin_Type_ISO646String;
  2382. }
  2383. | "NumericString"
  2384. { $$ = Builtin_Type_NumericString;
  2385. }
  2386. | "PrintableString"
  2387. { $$ = Builtin_Type_PrintableString;
  2388. }
  2389. | "TeletexString"
  2390. { $$ = Builtin_Type_TeletexString;
  2391. }
  2392. | "T61String"
  2393. { $$ = Builtin_Type_T61String;
  2394. }
  2395. | "UniversalString"
  2396. { $$ = Builtin_Type_UniversalString;
  2397. }
  2398. | "VideotexString"
  2399. { $$ = Builtin_Type_VideotexString;
  2400. }
  2401. | "VisibleString"
  2402. { $$ = Builtin_Type_VisibleString;
  2403. }
  2404. ;
  2405. UnrestrictedCharacterStringType
  2406. : "CHARACTER" "STRING"
  2407. { $$ = Builtin_Type_CharacterString;
  2408. }
  2409. ;
  2410. UsefulType
  2411. : "GeneralizedTime"
  2412. { $$ = Builtin_Type_GeneralizedTime;
  2413. }
  2414. | "UTCTime"
  2415. { $$ = Builtin_Type_UTCTime;
  2416. }
  2417. | "ObjectDescriptor"
  2418. { $$ = Builtin_Type_ObjectDescriptor;
  2419. }
  2420. ;
  2421. TypeWithConstraint
  2422. : "SET" LocalSizeDirectiveESeq PrivateDirectives Constraint(NULL, 0)
  2423. LocalSizeDirectiveESeq "OF" Type /*XXX*/
  2424. { Directive_t **dd, *d;
  2425. $$ = NewType(eType_SetOf);
  2426. $$->ExtensionDefault = $>>.ExtensionDefault;
  2427. $$->Constraints = $4;
  2428. $$->U.SetOf.Type = $7;
  2429. if ($3)
  2430. {
  2431. PropagatePrivateDirectives($$, $3);
  2432. }
  2433. dd = &$$->U.SetOf.Directives;
  2434. for (d = $2; d; d = d->Next) {
  2435. *dd = DupDirective(d);
  2436. dd = &(*dd)->Next;
  2437. }
  2438. for (d = $5; d; d = d->Next) {
  2439. *dd = DupDirective(d);
  2440. dd = &(*dd)->Next;
  2441. }
  2442. *dd = NULL;
  2443. if ($$->PrivateDirectives.pszTypeName &&
  2444. strncmp("PSetOf", $$->PrivateDirectives.pszTypeName, 6) == 0)
  2445. {
  2446. $$->PrivateDirectives.pszTypeName++;
  2447. }
  2448. }
  2449. | "SET" LocalSizeDirectiveESeq PrivateDirectives SizeConstraint
  2450. LocalSizeDirectiveESeq PrivateDirectives "OF" Type
  2451. { Directive_t **dd, *d;
  2452. $$ = NewType(eType_SetOf);
  2453. $$->ExtensionDefault = $>>.ExtensionDefault;
  2454. $$->Constraints = NewConstraint();
  2455. $$->Constraints->Type = eExtension_Unextended;
  2456. $$->Constraints->Root = NewElementSetSpec(
  2457. eElementSetSpec_SubtypeElement);
  2458. $$->Constraints->Root->U.SubtypeElement.SubtypeElement = $4;
  2459. $$->U.SetOf.Type = $8;
  2460. if ($3)
  2461. {
  2462. PropagatePrivateDirectives($$, $3);
  2463. }
  2464. if ($6)
  2465. {
  2466. PropagatePrivateDirectives($$, $6);
  2467. }
  2468. dd = &$$->U.SetOf.Directives;
  2469. for (d = $2; d; d = d->Next) {
  2470. *dd = DupDirective(d);
  2471. dd = &(*dd)->Next;
  2472. }
  2473. for (d = $5; d; d = d->Next) {
  2474. *dd = DupDirective(d);
  2475. dd = &(*dd)->Next;
  2476. }
  2477. *dd = NULL;
  2478. if ($$->PrivateDirectives.pszTypeName &&
  2479. strncmp("PSetOf", $$->PrivateDirectives.pszTypeName, 6) == 0)
  2480. {
  2481. $$->PrivateDirectives.pszTypeName++;
  2482. }
  2483. }
  2484. | "SEQUENCE" LocalSizeDirectiveESeq PrivateDirectives Constraint(NULL, 0)
  2485. LocalSizeDirectiveESeq "OF" Type /*XXX*/
  2486. { Directive_t **dd, *d;
  2487. $$ = NewType(eType_SequenceOf);
  2488. $$->ExtensionDefault = $>>.ExtensionDefault;
  2489. $$->Constraints = $4;
  2490. $$->U.SequenceOf.Type = $7;
  2491. if ($3)
  2492. {
  2493. PropagatePrivateDirectives($$, $3);
  2494. }
  2495. dd = &$$->U.SequenceOf.Directives;
  2496. for (d = $2; d; d = d->Next) {
  2497. *dd = DupDirective(d);
  2498. dd = &(*dd)->Next;
  2499. }
  2500. for (d = $5; d; d = d->Next) {
  2501. *dd = DupDirective(d);
  2502. dd = &(*dd)->Next;
  2503. }
  2504. *dd = NULL;
  2505. if ($$->PrivateDirectives.pszTypeName &&
  2506. strncmp("PSetOf", $$->PrivateDirectives.pszTypeName, 6) == 0)
  2507. {
  2508. $$->PrivateDirectives.pszTypeName++;
  2509. }
  2510. }
  2511. | "SEQUENCE" LocalSizeDirectiveESeq PrivateDirectives SizeConstraint
  2512. LocalSizeDirectiveESeq PrivateDirectives "OF" Type
  2513. { Directive_t **dd, *d;
  2514. $$ = NewType(eType_SequenceOf);
  2515. $$->ExtensionDefault = $>>.ExtensionDefault;
  2516. $$->Constraints = NewConstraint();
  2517. $$->Constraints->Type = eExtension_Unextended;
  2518. $$->Constraints->Root = NewElementSetSpec(
  2519. eElementSetSpec_SubtypeElement);
  2520. $$->Constraints->Root->U.SubtypeElement.SubtypeElement = $4;
  2521. $$->U.SequenceOf.Type = $8;
  2522. if ($3)
  2523. {
  2524. PropagatePrivateDirectives($$, $3);
  2525. }
  2526. if ($6)
  2527. {
  2528. PropagatePrivateDirectives($$, $6);
  2529. }
  2530. dd = &$$->U.SequenceOf.Directives;
  2531. for (d = $2; d; d = d->Next) {
  2532. *dd = DupDirective(d);
  2533. dd = &(*dd)->Next;
  2534. }
  2535. for (d = $5; d; d = d->Next) {
  2536. *dd = DupDirective(d);
  2537. dd = &(*dd)->Next;
  2538. }
  2539. *dd = NULL;
  2540. if ($$->PrivateDirectives.pszTypeName &&
  2541. strncmp("PSetOf", $$->PrivateDirectives.pszTypeName, 6) == 0)
  2542. {
  2543. $$->PrivateDirectives.pszTypeName++;
  2544. }
  2545. }
  2546. ;
  2547. #line 54 "value.ll"
  2548. DefinedValue
  2549. : Externalvaluereference
  2550. { $$ = $1;
  2551. }
  2552. | valuereference
  2553. { $$ = $1;
  2554. }
  2555. | ParameterizedValue
  2556. { MyAbort();
  2557. }
  2558. ;
  2559. ValueAssignment
  2560. : valuereference Type "::=" Value($2)
  2561. { if (!AssignValue(&$>>.Assignments, $1, $4))
  2562. LLFAILED((&@1, "Value `%s' twice defined",
  2563. $1->U.Reference.Identifier));
  2564. }
  2565. ;
  2566. Value(type)
  2567. : BuiltinValue($type)
  2568. { $$ = $1;
  2569. }
  2570. | ReferencedValue
  2571. { $$ = $1;
  2572. }
  2573. | ObjectClassFieldValue($type)
  2574. { $$ = $1;
  2575. }
  2576. ;
  2577. BuiltinValue(type)
  2578. :
  2579. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2580. GetTypeType($<<.Assignments, $type) != eType_BitString)
  2581. LLFAILED((&@@, "Bad type of value"));
  2582. }
  2583. BitStringValue($type)
  2584. { $$ = $1;
  2585. }
  2586. |
  2587. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2588. GetTypeType($<<.Assignments, $type) != eType_Boolean)
  2589. LLFAILED((&@@, "Bad type of value"));
  2590. }
  2591. BooleanValue($type)
  2592. { $$ = $1;
  2593. }
  2594. | CharacterStringValue($type)
  2595. { $$ = $1;
  2596. }
  2597. |
  2598. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2599. GetTypeType($<<.Assignments, $type) != eType_Choice)
  2600. LLFAILED((&@@, "Bad type of value"));
  2601. }
  2602. ChoiceValue($type)
  2603. { $$ = $1;
  2604. }
  2605. |
  2606. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2607. GetTypeType($<<.Assignments, $type) != eType_EmbeddedPdv)
  2608. LLFAILED((&@@, "Bad type of value"));
  2609. }
  2610. EmbeddedPDVValue($type)
  2611. { $$ = $1;
  2612. }
  2613. |
  2614. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2615. GetTypeType($<<.Assignments, $type) != eType_Enumerated)
  2616. LLFAILED((&@@, "Bad type of value"));
  2617. }
  2618. EnumeratedValue($type)
  2619. { $$ = $1;
  2620. }
  2621. |
  2622. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2623. GetTypeType($<<.Assignments, $type) != eType_External)
  2624. LLFAILED((&@@, "Bad type of value"));
  2625. }
  2626. ExternalValue($type)
  2627. { $$ = $1;
  2628. }
  2629. |
  2630. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2631. GetTypeType($<<.Assignments, $type) != eType_InstanceOf)
  2632. LLFAILED((&@@, "Bad type of value"));
  2633. }
  2634. InstanceOfValue($type)
  2635. { $$ = $1;
  2636. }
  2637. |
  2638. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2639. GetTypeType($<<.Assignments, $type) != eType_Integer)
  2640. LLFAILED((&@@, "Bad type of value"));
  2641. }
  2642. IntegerValue($type)
  2643. { $$ = $1;
  2644. }
  2645. |
  2646. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2647. GetTypeType($<<.Assignments, $type) != eType_Null)
  2648. LLFAILED((&@@, "Bad type of value"));
  2649. }
  2650. NullValue($type)
  2651. { $$ = $1;
  2652. }
  2653. |
  2654. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2655. GetTypeType($<<.Assignments, $type) != eType_ObjectIdentifier)
  2656. LLFAILED((&@@, "Bad type of value"));
  2657. }
  2658. ObjectIdentifierValue
  2659. { $$ = $1;
  2660. if ($1->Type != NULL)
  2661. {
  2662. PropagatePrivateDirectives($1->Type, &($type->PrivateDirectives));
  2663. }
  2664. }
  2665. |
  2666. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2667. GetTypeType($<<.Assignments, $type) != eType_OctetString)
  2668. LLFAILED((&@@, "Bad type of value"));
  2669. }
  2670. OctetStringValue($type)
  2671. { $$ = $1;
  2672. }
  2673. |
  2674. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2675. GetTypeType($<<.Assignments, $type) != eType_Real)
  2676. LLFAILED((&@@, "Bad type of value"));
  2677. }
  2678. RealValue($type)
  2679. { $$ = $1;
  2680. }
  2681. |
  2682. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2683. GetTypeType($<<.Assignments, $type) !=
  2684. eType_GeneralizedTime)
  2685. LLFAILED((&@@, "Bad type of value"));
  2686. }
  2687. GeneralizedTimeValue($type)
  2688. { $$ = $1;
  2689. }
  2690. |
  2691. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2692. GetTypeType($<<.Assignments, $type) != eType_UTCTime)
  2693. LLFAILED((&@@, "Bad type of value"));
  2694. }
  2695. UTCTimeValue($type)
  2696. { $$ = $1;
  2697. }
  2698. |
  2699. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2700. GetTypeType($<<.Assignments, $type) != eType_ObjectDescriptor)
  2701. LLFAILED((&@@, "Bad type of value"));
  2702. }
  2703. ObjectDescriptorValue($type)
  2704. { $$ = $1;
  2705. }
  2706. |
  2707. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2708. GetTypeType($<<.Assignments, $type) != eType_Sequence)
  2709. LLFAILED((&@@, "Bad type of value"));
  2710. }
  2711. SequenceValue($type)
  2712. { $$ = $1;
  2713. }
  2714. |
  2715. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2716. GetTypeType($<<.Assignments, $type) != eType_SequenceOf)
  2717. LLFAILED((&@@, "Bad type of value"));
  2718. }
  2719. SequenceOfValue($type)
  2720. { $$ = $1;
  2721. }
  2722. |
  2723. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2724. GetTypeType($<<.Assignments, $type) != eType_Set)
  2725. LLFAILED((&@@, "Bad type of value"));
  2726. }
  2727. SetValue($type)
  2728. { $$ = $1;
  2729. }
  2730. |
  2731. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2732. GetTypeType($<<.Assignments, $type) != eType_SetOf)
  2733. LLFAILED((&@@, "Bad type of value"));
  2734. }
  2735. SetOfValue($type)
  2736. { $$ = $1;
  2737. }
  2738. |
  2739. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2740. GetTypeType($<<.Assignments, $type) != eType_Open)
  2741. LLFAILED((&@@, "Bad type of value"));
  2742. }
  2743. AnyValue($type)
  2744. { $$ = $1;
  2745. }
  2746. |
  2747. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  2748. GetTypeType($<<.Assignments, $type) != eType_Macro)
  2749. LLFAILED((&@@, "Bad type of value"));
  2750. }
  2751. MacroDefinedValue($type)
  2752. { $$ = $1;
  2753. }
  2754. ;
  2755. ReferencedValue
  2756. : DefinedValue
  2757. { $$ = $1;
  2758. }
  2759. | ValueFromObject
  2760. { $$ = $1;
  2761. }
  2762. ;
  2763. NamedValue(components)
  2764. : identifier
  2765. { Component_t *component;
  2766. Type_t *type;
  2767. component = FindComponent($<<.Assignments, $components, $1);
  2768. if (component)
  2769. type = component->U.NOD.NamedType->Type;
  2770. else
  2771. type = NULL;
  2772. }
  2773. Value(type)
  2774. { $$ = NewNamedValue($1, $2);
  2775. }
  2776. ;
  2777. BooleanValue(type)
  2778. : "TRUE"
  2779. { $$ = NewValue($>>.Assignments, $type);
  2780. $$->U.Boolean.Value = 1;
  2781. }
  2782. | "FALSE"
  2783. { $$ = NewValue($>>.Assignments, $type);
  2784. $$->U.Boolean.Value = 0;
  2785. }
  2786. ;
  2787. SignedNumber(type)
  2788. : number
  2789. { $$ = NewValue($>>.Assignments, $type);
  2790. $$->U.Integer.Value = $1;
  2791. }
  2792. | '-' number
  2793. { if (!intx_cmp(&$2, &intx_0))
  2794. LLFAILED((&@2, "Bad negative value"));
  2795. $$ = NewValue($>>.Assignments, $type);
  2796. intx_neg(&$$->U.Integer.Value, &$2);
  2797. }
  2798. ;
  2799. IntegerValue(type)
  2800. : SignedNumber($type)
  2801. { $$ = $1;
  2802. }
  2803. | identifier
  2804. { NamedNumber_t *n;
  2805. Type_t *type;
  2806. type = GetType($>>.Assignments, $type);
  2807. if (type) {
  2808. n = FindNamedNumber(type->U.Integer.NamedNumbers, $1);
  2809. if (!n)
  2810. LLFAILED((&@1, "Undefined integer value"));
  2811. $$ = NewValue($>>.Assignments, $type);
  2812. intx_dup(&$$->U.Integer.Value,
  2813. &n->U.Normal.Value->U.Integer.Value);
  2814. } else {
  2815. $$ = NULL;
  2816. }
  2817. }
  2818. ;
  2819. EnumeratedValue(type)
  2820. : identifier
  2821. { NamedNumber_t *n;
  2822. Type_t *type;
  2823. type = GetType($>>.Assignments, $type);
  2824. if (type) {
  2825. n = FindNamedNumber(type->U.Enumerated.NamedNumbers, $1);
  2826. if (!n)
  2827. LLFAILED((&@1, "Undefined enumeration value"));
  2828. $$ = NewValue($>>.Assignments, $type);
  2829. $$->U.Enumerated.Value =
  2830. intx2uint32(&n->U.Normal.Value->U.Integer.Value);
  2831. } else {
  2832. $$ = NULL;
  2833. }
  2834. }
  2835. ;
  2836. RealValue(type)
  2837. : NumericRealValue($type)
  2838. { $$ = $1;
  2839. }
  2840. | SpecialRealValue($type)
  2841. { $$ = $1;
  2842. }
  2843. ;
  2844. NumericRealValue(type)
  2845. : number /* only 0 allowed! */
  2846. { if (intx_cmp(&$1, &intx_0))
  2847. LLFAILED((&@1, "Bad real value"));
  2848. $$ = NewValue($>>.Assignments, $type);
  2849. }
  2850. | SequenceValue($type)
  2851. { NamedValue_t *mant, *expo, *base;
  2852. mant = FindNamedValue($1->U.Sequence.NamedValues, "mantissa");
  2853. expo = FindNamedValue($1->U.Sequence.NamedValues, "exponent");
  2854. base = FindNamedValue($1->U.Sequence.NamedValues, "base");
  2855. if (!mant || !expo || !base) {
  2856. $$ = NULL;
  2857. } else {
  2858. $$ = NewValue($>>.Assignments, $type);
  2859. intx_dup(&$$->U.Real.Value.mantissa,
  2860. &mant->Value->U.Integer.Value);
  2861. intx_dup(&$$->U.Real.Value.exponent,
  2862. &expo->Value->U.Integer.Value);
  2863. $$->U.Real.Value.base =
  2864. intx2uint32(&base->Value->U.Integer.Value);
  2865. }
  2866. }
  2867. ;
  2868. SpecialRealValue(type)
  2869. : "PLUS_INFINITY"
  2870. { $$ = NewValue($>>.Assignments, $type);
  2871. $$->U.Real.Value.type = eReal_PlusInfinity;
  2872. }
  2873. | "MINUS_INFINITY"
  2874. { $$ = NewValue($>>.Assignments, $type);
  2875. $$->U.Real.Value.type = eReal_MinusInfinity;
  2876. }
  2877. ;
  2878. BitStringValue(type)
  2879. : bstring
  2880. { int i, len;
  2881. if (GetTypeType($>>.Assignments, $type) == eType_BitString) {
  2882. len = strlen($1);
  2883. $$ = NewValue($>>.Assignments, $type);
  2884. $$->U.BitString.Value.length = len;
  2885. $$->U.BitString.Value.value =
  2886. (octet_t *)malloc((len + 7) / 8);
  2887. memset($$->U.BitString.Value.value, 0, (len + 7) / 8);
  2888. for (i = 0; i < len; i++) {
  2889. if ($1[i] == '1')
  2890. ASN1BITSET($$->U.BitString.Value.value, i);
  2891. }
  2892. } else {
  2893. $$ = NULL;
  2894. }
  2895. }
  2896. | hstring
  2897. { int i, len, c;
  2898. if (GetTypeType($>>.Assignments, $type) == eType_BitString) {
  2899. len = strlen($1);
  2900. $$ = NewValue($>>.Assignments, $type);
  2901. $$->U.BitString.Value.length = len * 4;
  2902. $$->U.BitString.Value.value =
  2903. (octet_t *)malloc((len + 1) / 2);
  2904. memset($$->U.BitString.Value.value, 0, (len + 1) / 2);
  2905. for (i = 0; i < len; i++) {
  2906. c = isdigit($1[i]) ? $1[i] - '0' : $1[i] - 'A' + 10;
  2907. $$->U.BitString.Value.value[i / 2] |=
  2908. (i & 1) ? c : (c << 4);
  2909. }
  2910. } else {
  2911. $$ = NULL;
  2912. }
  2913. }
  2914. | '{' IdentifierList($type) '}'
  2915. { $$ = $2;
  2916. }
  2917. | '{' '}'
  2918. { $$ = NewValue($>>.Assignments, $type);
  2919. }
  2920. ;
  2921. IdentifierList(type)
  2922. : IdentifierList_Elem($type)
  2923. Identifier_EList($type)
  2924. { uint32_t bit, len;
  2925. bitstring_t *src, *dst;
  2926. if ($1 && $2) {
  2927. bit = intx2uint32(&$1->U.Integer.Value);
  2928. src = &$2->U.BitString.Value;
  2929. len = bit + 1;
  2930. if (len < src->length)
  2931. len = src->length;
  2932. $$ = DupValue($2);
  2933. dst = &$$->U.BitString.Value;
  2934. dst->length = len;
  2935. dst->value = (octet_t *)malloc((len + 7) / 8);
  2936. memcpy(dst->value, src->value, (src->length + 7) / 8);
  2937. memset(dst->value + (src->length + 7) / 8, 0,
  2938. (len + 7) / 8 - (src->length + 7) / 8);
  2939. ASN1BITSET(dst->value, bit);
  2940. } else if ($1) {
  2941. bit = intx2uint32(&$1->U.Integer.Value);
  2942. len = bit + 1;
  2943. $$ = NewValue($>>.Assignments, $type);
  2944. dst = &$$->U.BitString.Value;
  2945. dst->length = len;
  2946. dst->value = (octet_t *)malloc((len + 7) / 8);
  2947. memset(dst->value, 0, (len + 7) / 8);
  2948. ASN1BITSET(dst->value, bit);
  2949. } else {
  2950. $$ = NULL;
  2951. }
  2952. }
  2953. ;
  2954. Identifier_EList(type)
  2955. : IdentifierList_Elem($type)
  2956. Identifier_EList($type)
  2957. { uint32_t bit, len;
  2958. bitstring_t *src, *dst;
  2959. if ($1 && $2) {
  2960. bit = intx2uint32(&$1->U.Integer.Value);
  2961. src = &$2->U.BitString.Value;
  2962. len = bit + 1;
  2963. if (len < src->length)
  2964. len = src->length;
  2965. $$ = DupValue($2);
  2966. dst = &$$->U.BitString.Value;
  2967. dst->length = len;
  2968. dst->value = (octet_t *)malloc((len + 7) / 8);
  2969. memcpy(dst->value, src->value, (src->length + 7) / 8);
  2970. memset(dst->value + (src->length + 7) / 8, 0,
  2971. (len + 7) / 8 - (src->length + 7) / 8);
  2972. ASN1BITSET(dst->value, bit);
  2973. } else if ($1) {
  2974. bit = intx2uint32(&$1->U.Integer.Value);
  2975. len = bit + 1;
  2976. $$ = NewValue($>>.Assignments, $type);
  2977. dst = &$$->U.BitString.Value;
  2978. dst->length = len;
  2979. dst->value = (octet_t *)malloc((len + 7) / 8);
  2980. memset(dst->value, 0, (len + 7) / 8);
  2981. ASN1BITSET(dst->value, bit);
  2982. } else {
  2983. $$ = NULL;
  2984. }
  2985. }
  2986. | /* empty */
  2987. { if ($type) {
  2988. $$ = NewValue($>>.Assignments, $type);
  2989. } else {
  2990. $$ = NULL;
  2991. }
  2992. }
  2993. ;
  2994. IdentifierList_Elem(type)
  2995. : identifier
  2996. { Value_t *v;
  2997. NamedNumber_t *n;
  2998. Type_t *type;
  2999. type = GetType($>>.Assignments, $type);
  3000. if (type) {
  3001. n = FindNamedNumber(type->U.BitString.NamedNumbers, $1);
  3002. if (!n)
  3003. LLFAILED((&@1, "Bad bit string value"));
  3004. v = GetValue($>>.Assignments, n->U.Normal.Value);
  3005. if (v) {
  3006. if (GetTypeType($>>.Assignments, v->Type) != eType_Integer)
  3007. MyAbort();
  3008. $$ = v;
  3009. } else {
  3010. $$ = NULL;
  3011. }
  3012. } else {
  3013. $$ = NULL;
  3014. }
  3015. }
  3016. ;
  3017. OctetStringValue(type)
  3018. : bstring
  3019. { int len, i;
  3020. if (GetTypeType($>>.Assignments, $type) == eType_OctetString) {
  3021. len = strlen($1);
  3022. $$ = NewValue($>>.Assignments, $type);
  3023. $$->U.OctetString.Value.length = (len + 7) / 8;
  3024. $$->U.OctetString.Value.value =
  3025. (octet_t *)malloc((len + 7) / 8);
  3026. memset($$->U.OctetString.Value.value, 0, (len + 7) / 8);
  3027. for (i = 0; i < len; i++) {
  3028. if ($1[i] == '1')
  3029. ASN1BITSET($$->U.OctetString.Value.value, i);
  3030. }
  3031. } else {
  3032. $$ = NULL;
  3033. }
  3034. }
  3035. | hstring
  3036. { int i, len, c;
  3037. if (GetTypeType($>>.Assignments, $type) == eType_OctetString) {
  3038. len = strlen($1);
  3039. $$ = NewValue($>>.Assignments, $type);
  3040. $$->U.OctetString.Value.length = (len + 1) / 2;
  3041. $$->U.OctetString.Value.value =
  3042. (octet_t *)malloc((len + 1) / 2);
  3043. memset($$->U.OctetString.Value.value, 0, (len + 1) / 2);
  3044. for (i = 0; i < len; i++) {
  3045. c = isdigit($1[i]) ? $1[i] - '0' : $1[i] - 'A' + 10;
  3046. $$->U.OctetString.Value.value[i / 2] |=
  3047. (i & 1) ? c : (c << 4);
  3048. }
  3049. } else {
  3050. $$ = NULL;
  3051. }
  3052. }
  3053. ;
  3054. NullValue(type)
  3055. : "NULL"
  3056. { $$ = NewValue($>>.Assignments, $type);
  3057. }
  3058. ;
  3059. GeneralizedTimeValue(type)
  3060. : RestrictedCharacterStringValue($type)
  3061. { $$ = NewValue($>>.Assignments, $type);
  3062. if (!String2GeneralizedTime(&$$->U.GeneralizedTime.Value,
  3063. &$1->U.RestrictedString.Value))
  3064. LLFAILED((&@1, "Bad time value"));
  3065. }
  3066. ;
  3067. UTCTimeValue(type)
  3068. : RestrictedCharacterStringValue($type)
  3069. { $$ = NewValue($>>.Assignments, $type);
  3070. if (!String2UTCTime(&$$->U.UTCTime.Value,
  3071. &$1->U.RestrictedString.Value))
  3072. LLFAILED((&@1, "Bad time value"));
  3073. }
  3074. ;
  3075. ObjectDescriptorValue(type)
  3076. : RestrictedCharacterStringValue($type)
  3077. { $$ = $1;
  3078. }
  3079. ;
  3080. SequenceValue(type)
  3081. : '{'
  3082. { Component_t *components;
  3083. Type_t *type;
  3084. type = GetType($>1.Assignments, $type);
  3085. components = type ? type->U.SSC.Components : NULL;
  3086. }
  3087. ComponentValueList(components) '}'
  3088. { Component_t *c;
  3089. NamedValue_t *v;
  3090. if (type) {
  3091. for (c = components, v = $2; c; c = c->Next) {
  3092. switch (c->Type) {
  3093. case eComponent_Normal:
  3094. if (!v)
  3095. LLFAILED((&@2,
  3096. "Value for component `%s' is missing",
  3097. c->U.NOD.NamedType->Identifier));
  3098. if (strcmp(v->Identifier,
  3099. c->U.NOD.NamedType->Identifier))
  3100. LLFAILED((&@2, "Value for component `%s' expected",
  3101. c->U.NOD.NamedType->Identifier));
  3102. v = v->Next;
  3103. break;
  3104. case eComponent_Optional:
  3105. case eComponent_Default:
  3106. if (v && !strcmp(v->Identifier,
  3107. c->U.NOD.NamedType->Identifier))
  3108. v = v->Next;
  3109. break;
  3110. }
  3111. }
  3112. if (v)
  3113. LLFAILED((&@2, "Component `%s' is unexpected",
  3114. v->Identifier));
  3115. }
  3116. $$ = NewValue($>>.Assignments, $type);
  3117. $$->U.SSC.NamedValues = $2;
  3118. }
  3119. | '{' '}'
  3120. { $$ = NewValue($>>.Assignments, $type);
  3121. }
  3122. ;
  3123. ComponentValueList(components)
  3124. : NamedValue($components) ComponentValueCList($components)
  3125. { if ($2) {
  3126. $$ = DupNamedValue($1);
  3127. $$->Next = $2;
  3128. } else {
  3129. $$ = $1;
  3130. }
  3131. }
  3132. ;
  3133. ComponentValueCList(components)
  3134. : ',' ComponentValueList($components)
  3135. { $$ = $2;
  3136. }
  3137. | /* empty */
  3138. { $$ = NULL;
  3139. }
  3140. ;
  3141. SequenceOfValue(type)
  3142. : '{'
  3143. { Type_t *type, *subtype;
  3144. type = GetType($>1.Assignments, $type);
  3145. subtype = (type ? type->U.SS.Type : NULL);
  3146. }
  3147. ValueList(subtype) '}'
  3148. { $$ = NewValue($>>.Assignments, $type);
  3149. $$->U.SequenceOf.Values = $2;
  3150. }
  3151. | '{' '}'
  3152. { $$ = NewValue($>>.Assignments, $type);
  3153. }
  3154. ;
  3155. ValueList(type)
  3156. : Value($type) ValueCList($type)
  3157. { $$ = DupValue($1);
  3158. $$->Next = $2;
  3159. }
  3160. ;
  3161. ValueCList(type)
  3162. : ',' ValueList($type)
  3163. { $$ = $2;
  3164. }
  3165. | /* empty */
  3166. { $$ = NULL;
  3167. }
  3168. ;
  3169. SetValue(type)
  3170. : '{'
  3171. { Component_t *components;
  3172. Type_t *type;
  3173. type = GetType($>1.Assignments, $type);
  3174. components = type ? type->U.SSC.Components : NULL;
  3175. }
  3176. ComponentValueList(components) '}'
  3177. { Component_t *c;
  3178. NamedValue_t *v;
  3179. if (type) {
  3180. for (c = components; c; c = c->Next) {
  3181. switch (c->Type) {
  3182. case eComponent_Normal:
  3183. v = FindNamedValue($2, c->U.NOD.NamedType->Identifier);
  3184. if (!v)
  3185. LLFAILED((&@2,
  3186. "Value for component `%s' is missing",
  3187. c->U.NOD.NamedType->Identifier));
  3188. break;
  3189. }
  3190. }
  3191. for (v = $2; v; v = v->Next) {
  3192. if (!FindComponent($>>.Assignments, components,
  3193. v->Identifier) ||
  3194. FindNamedValue(v->Next, v->Identifier))
  3195. LLFAILED((&@2, "Component `%s' is unexpected",
  3196. v->Identifier));
  3197. }
  3198. }
  3199. $$ = NewValue($>>.Assignments, $type);
  3200. $$->U.Set.NamedValues = $2;
  3201. }
  3202. | '{' '}'
  3203. { $$ = NewValue($>>.Assignments, $type);
  3204. }
  3205. ;
  3206. SetOfValue(type)
  3207. : '{'
  3208. { Type_t *type, *subtype;
  3209. type = GetType($>1.Assignments, $type);
  3210. subtype = (type ? type->U.SS.Type : NULL);
  3211. }
  3212. ValueList(subtype) '}'
  3213. { $$ = NewValue($>>.Assignments, $type);
  3214. $$->U.SetOf.Values = $2;
  3215. }
  3216. | '{' '}'
  3217. { $$ = NewValue($>>.Assignments, $type);
  3218. }
  3219. ;
  3220. ChoiceValue(type)
  3221. : identifier ':'
  3222. { Component_t *component;
  3223. Type_t *type, *subtype;
  3224. type = GetType($>2.Assignments, $type);
  3225. if (type) {
  3226. component = FindComponent($>2.Assignments,
  3227. type->U.Choice.Components, $1);
  3228. if (!component)
  3229. LLFAILED((&@1, "Bad alternative `%s'", $1));
  3230. subtype = component->U.NOD.NamedType->Type;
  3231. } else {
  3232. subtype = NULL;
  3233. }
  3234. }
  3235. Value(subtype)
  3236. { $$ = NewValue($>>.Assignments, $type);
  3237. $$->U.SSC.NamedValues = NewNamedValue($1, $3);
  3238. }
  3239. ;
  3240. ObjectIdentifierValue
  3241. : '{' ObjIdComponentList '}'
  3242. { switch (GetAssignedObjectIdentifier(
  3243. &$>>.AssignedObjIds, NULL, $2, &$$)) {
  3244. case -1:
  3245. LLFAILED((&@2, "Different numbers for equally named object identifier components"));
  3246. /*NOTREACHED*/
  3247. case 0:
  3248. if (pass <= 2)
  3249. $$ = NULL;
  3250. else
  3251. LLFAILED((&@2, "Unknown object identifier component"));
  3252. break;
  3253. case 1:
  3254. break;
  3255. }
  3256. }
  3257. | '{' DefinedValue ObjIdComponentList '}'
  3258. { Value_t *v;
  3259. v = GetValue($>>.Assignments, $2);
  3260. if (v) {
  3261. if (GetTypeType($>>.Assignments, v->Type) !=
  3262. eType_ObjectIdentifier &&
  3263. GetTypeType($>>.Assignments, v->Type) !=
  3264. eType_Undefined)
  3265. LLFAILED((&@2, "Bad type of value in object identifier"));
  3266. if (GetTypeType($>>.Assignments, v->Type) ==
  3267. eType_ObjectIdentifier) {
  3268. switch (GetAssignedObjectIdentifier(
  3269. &$>>.AssignedObjIds, v, $3, &$$)) {
  3270. case -1:
  3271. LLFAILED((&@3, "Different numbers for equally named object identifier components"));
  3272. /*NOTREACHED*/
  3273. case 0:
  3274. if (pass <= 2)
  3275. $$ = NULL;
  3276. else
  3277. LLFAILED((&@2, "Unknown object identifier component"));
  3278. break;
  3279. case 1:
  3280. break;
  3281. }
  3282. }
  3283. } else {
  3284. $$ = NULL;
  3285. }
  3286. }
  3287. ;
  3288. ObjIdComponentList
  3289. : ObjIdComponent ObjIdComponent_ESeq
  3290. { if ($1) {
  3291. $$ = DupNamedObjIdValue($1);
  3292. $$->Next = $2;
  3293. } else {
  3294. $$ = NULL;
  3295. }
  3296. }
  3297. ;
  3298. ObjIdComponent_ESeq
  3299. : ObjIdComponent ObjIdComponent_ESeq
  3300. { if ($1) {
  3301. $$ = DupNamedObjIdValue($1);
  3302. $$->Next = $2;
  3303. } else {
  3304. $$ = NULL;
  3305. }
  3306. }
  3307. | /* empty */
  3308. { $$ = NULL;
  3309. }
  3310. ;
  3311. ObjIdComponent
  3312. : NameForm
  3313. { $$ = $1;
  3314. }
  3315. | NumberForm
  3316. { $$ = $1;
  3317. }
  3318. | NameAndNumberForm
  3319. { $$ = $1;
  3320. }
  3321. ;
  3322. NameForm
  3323. : identifier
  3324. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NameForm);
  3325. $$->Name = $1;
  3326. }
  3327. ;
  3328. NumberForm
  3329. : number
  3330. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NumberForm);
  3331. $$->Number = intx2uint32(&$1);
  3332. }
  3333. | DefinedValue
  3334. { Value_t *v;
  3335. v = GetValue($>>.Assignments, $1);
  3336. if (v &&
  3337. GetTypeType($>>.Assignments, v->Type) != eType_Integer &&
  3338. GetTypeType($>>.Assignments, v->Type) != eType_Undefined)
  3339. LLFAILED((&@1, "Bad type in object identifier"));
  3340. if (v &&
  3341. GetTypeType($>>.Assignments, v->Type) == eType_Integer &&
  3342. intx_cmp(&v->U.Integer.Value, &intx_0) < 0)
  3343. LLFAILED((&@1, "Bad value in object identifier"));
  3344. if (v &&
  3345. GetTypeType($>>.Assignments, v->Type) == eType_Integer) {
  3346. $$ = NewNamedObjIdValue(eNamedObjIdValue_NumberForm);
  3347. $$->Number = intx2uint32(&v->U.Integer.Value);
  3348. } else {
  3349. $$ = NULL;
  3350. }
  3351. }
  3352. ;
  3353. NameAndNumberForm
  3354. : identifier '(' NumberForm ')'
  3355. { if ($3) {
  3356. $$ = NewNamedObjIdValue(eNamedObjIdValue_NameAndNumberForm);
  3357. $$->Name = $1;
  3358. $$->Number = $3->Number;
  3359. } else {
  3360. $$ = NULL;
  3361. }
  3362. }
  3363. ;
  3364. EmbeddedPDVValue(type)
  3365. : SequenceValue($type)
  3366. { $$ = $1;
  3367. }
  3368. ;
  3369. ExternalValue(type)
  3370. : SequenceValue($type)
  3371. { $$ = $1;
  3372. }
  3373. ;
  3374. CharacterStringValue(type)
  3375. :
  3376. { Type_e type;
  3377. type = GetTypeType($<<.Assignments, $type);
  3378. if (type != eType_Undefined && !IsRestrictedString(type))
  3379. LLFAILED((&@@, "Bad type of value"));
  3380. }
  3381. RestrictedCharacterStringValue($type)
  3382. { $$ = $1;
  3383. }
  3384. |
  3385. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  3386. GetTypeType($<<.Assignments, $type) != eType_CharacterString)
  3387. LLFAILED((&@@, "Bad type of value"));
  3388. }
  3389. UnrestrictedCharacterStringValue($type)
  3390. { $$ = $1;
  3391. }
  3392. ;
  3393. RestrictedCharacterStringValue(type): cstring
  3394. { $$ = NewValue($>>.Assignments, $type);
  3395. $$->U.RestrictedString.Value.length = str32len($1);
  3396. $$->U.RestrictedString.Value.value = $1;
  3397. }
  3398. | CharacterStringList($type)
  3399. { $$ = $1;
  3400. }
  3401. | Quadruple
  3402. { $$ = NewValue($>>.Assignments, $type);
  3403. $$->U.RestrictedString.Value.length = 1;
  3404. $$->U.RestrictedString.Value.value =
  3405. (char32_t *)malloc(sizeof(char32_t));
  3406. $$->U.RestrictedString.Value.value[0] =
  3407. 256 * (256 * (256 * $1.Group + $1.Plane) + $1.Row) + $1.Cell;
  3408. }
  3409. | Tuple
  3410. { $$ = NewValue($>>.Assignments, $type);
  3411. $$->U.RestrictedString.Value.length = 1;
  3412. $$->U.RestrictedString.Value.value =
  3413. (char32_t *)malloc(sizeof(char32_t));
  3414. *$$->U.RestrictedString.Value.value =
  3415. $1.Column * 16 + $1.Row;
  3416. }
  3417. ;
  3418. UnrestrictedCharacterStringValue(type)
  3419. : SequenceValue($type)
  3420. { $$ = $1;
  3421. }
  3422. ;
  3423. CharacterStringList(type)
  3424. : '{' CharSyms($type) '}'
  3425. { $$ = $2;
  3426. }
  3427. ;
  3428. CharSyms(type)
  3429. : CharDefn($type)
  3430. { $$ = $1;
  3431. }
  3432. | CharDefn($type) ',' CharSyms($type)
  3433. { if (!$1 || !$3) {
  3434. $$ = NULL;
  3435. } else {
  3436. $$ = NewValue($>>.Assignments, $type);
  3437. $$->U.RestrictedString.Value.length =
  3438. $1->U.RestrictedString.Value.length +
  3439. $3->U.RestrictedString.Value.length;
  3440. $$->U.RestrictedString.Value.value =
  3441. (char32_t *)malloc(
  3442. $$->U.RestrictedString.Value.length *
  3443. sizeof(char32_t));
  3444. memcpy($$->U.RestrictedString.Value.value,
  3445. $1->U.RestrictedString.Value.value,
  3446. $1->U.RestrictedString.Value.length *
  3447. sizeof(char32_t));
  3448. memcpy($$->U.RestrictedString.Value.value +
  3449. $1->U.RestrictedString.Value.length,
  3450. $3->U.RestrictedString.Value.value,
  3451. $3->U.RestrictedString.Value.length *
  3452. sizeof(char32_t));
  3453. }
  3454. }
  3455. ;
  3456. CharDefn(type)
  3457. : cstring
  3458. { $$ = NewValue($>>.Assignments, $type);
  3459. $$->U.RestrictedString.Value.length = str32len($1);
  3460. $$->U.RestrictedString.Value.value = $1;
  3461. }
  3462. | DefinedValue
  3463. { $$ = $1;
  3464. }
  3465. ;
  3466. Quadruple
  3467. : '{' number ',' number ',' number ',' number '}'
  3468. { $$.Group = intx2uint32(&$2);
  3469. $$.Plane = intx2uint32(&$4);
  3470. $$.Row = intx2uint32(&$6);
  3471. $$.Cell = intx2uint32(&$8);
  3472. }
  3473. ;
  3474. Tuple
  3475. : '{' number ',' number '}'
  3476. { $$.Column = intx2uint32(&$2);
  3477. $$.Row = intx2uint32(&$4);
  3478. }
  3479. ;
  3480. AnyValue(type)
  3481. : Type ':' Value($1)
  3482. { $$ = $3;
  3483. }
  3484. ;
  3485. #line 46 "constrai.ll"
  3486. Constraint(type, permalpha)
  3487. : '(' ConstraintSpec($type, $permalpha) ExceptionSpec ')'
  3488. { $$ = $2; /*XXX ExceptionSpec */
  3489. }
  3490. ;
  3491. ConstraintSpec(type, permalpha)
  3492. : SubtypeConstraint($type, $permalpha)
  3493. { $$ = $1;
  3494. }
  3495. | GeneralConstraint
  3496. { $$ = NULL; /*XXX*/
  3497. }
  3498. ;
  3499. SubtypeConstraint(type, permalpha)
  3500. : ElementSetSpecs($type, $permalpha)
  3501. { $$ = $1;
  3502. }
  3503. ;
  3504. ExceptionSpec
  3505. : '!' ExceptionIdentification
  3506. | /* empty */
  3507. ;
  3508. ExceptionIdentification
  3509. : SignedNumber(Builtin_Type_Integer)
  3510. | DefinedValue
  3511. | Type ':' Value($1)
  3512. ;
  3513. ElementSetSpecs(type, permalpha)
  3514. : ElementSetSpec($type, NULL, $permalpha)
  3515. ElementSetSpecExtension($type, $permalpha)
  3516. { if ($2) {
  3517. $$ = DupConstraint($2);
  3518. } else {
  3519. $$ = NewConstraint();
  3520. }
  3521. $$->Root = $1;
  3522. }
  3523. | "..." AdditionalElementSetSpec($type, $permalpha)
  3524. { $$ = NewConstraint();
  3525. $$->Type = $2 ? eExtension_Extended : eExtension_Extendable;
  3526. $$->Additional = $2;
  3527. }
  3528. ;
  3529. ElementSetSpecExtension(type, permalpha)
  3530. : ',' "..." AdditionalElementSetSpec($type, $permalpha)
  3531. { $$ = NewConstraint();
  3532. $$->Type = $3 ? eExtension_Extended : eExtension_Extendable;
  3533. $$->Additional = $3;
  3534. }
  3535. | /* empty */
  3536. { $$ = NULL;
  3537. }
  3538. ;
  3539. AdditionalElementSetSpec(type, permalpha)
  3540. : ',' ElementSetSpec($type, NULL, $permalpha)
  3541. { $$ = $2;
  3542. }
  3543. | /* empty */
  3544. { $$ = NULL;
  3545. }
  3546. ;
  3547. ElementSetSpec(type, objectclass, permalpha)
  3548. : Unions($type, $objectclass, $permalpha)
  3549. { $$ = $1;
  3550. }
  3551. | "ALL" Exclusions($type, $objectclass, $permalpha)
  3552. { $$ = NewElementSetSpec(eElementSetSpec_AllExcept);
  3553. $$->U.AllExcept.Elements = $2;
  3554. }
  3555. ;
  3556. Unions(type, objectclass, permalpha)
  3557. : Intersections($type, $objectclass, $permalpha)
  3558. UnionList($type, $objectclass, $permalpha)
  3559. { if ($2) {
  3560. $$ = NewElementSetSpec(eElementSetSpec_Union);
  3561. $$->U.Union.Elements1 = $1;
  3562. $$->U.Union.Elements2 = $2;
  3563. } else {
  3564. $$ = $1;
  3565. }
  3566. }
  3567. ;
  3568. UnionList(type, objectclass, permalpha)
  3569. : UnionMark Unions($type, $objectclass, $permalpha)
  3570. { $$ = $2;
  3571. }
  3572. | /* empty */
  3573. { $$ = NULL;
  3574. }
  3575. ;
  3576. Intersections(type, objectclass, permalpha)
  3577. : IntersectionElements($type, $objectclass, $permalpha)
  3578. IntersectionList($type, $objectclass, $permalpha)
  3579. { if ($2) {
  3580. $$ = NewElementSetSpec(eElementSetSpec_Intersection);
  3581. $$->U.Intersection.Elements1 = $1;
  3582. $$->U.Intersection.Elements2 = $2;
  3583. } else {
  3584. $$ = $1;
  3585. }
  3586. }
  3587. ;
  3588. IntersectionList(type, objectclass, permalpha)
  3589. : IntersectionMark Intersections($type, $objectclass, $permalpha)
  3590. { $$ = $2;
  3591. }
  3592. | /* empty */
  3593. { $$ = NULL;
  3594. }
  3595. ;
  3596. IntersectionElements(type, objectclass, permalpha)
  3597. : Elements($type, $objectclass, $permalpha)
  3598. Exclusions_Opt($type, $objectclass, $permalpha)
  3599. { if ($2) {
  3600. $$ = NewElementSetSpec(eElementSetSpec_Exclusion);
  3601. $$->U.Exclusion.Elements1 = $1;
  3602. $$->U.Exclusion.Elements2 = $2;
  3603. } else {
  3604. $$ = $1;
  3605. }
  3606. }
  3607. ;
  3608. Exclusions_Opt(type, objectclass, permalpha)
  3609. : Exclusions($type, $objectclass, $permalpha)
  3610. { $$ = $1;
  3611. }
  3612. | /* empty */
  3613. { $$ = NULL;
  3614. }
  3615. ;
  3616. Exclusions(type, objectclass, permalpha)
  3617. : "EXCEPT" Elements($type, $objectclass, $permalpha)
  3618. { $$ = $2;
  3619. }
  3620. ;
  3621. UnionMark
  3622. : '|'
  3623. | "UNION"
  3624. ;
  3625. IntersectionMark
  3626. : '^'
  3627. | "INTERSECTION"
  3628. ;
  3629. Elements(type, objectclass, permalpha)
  3630. :
  3631. { if ($objectclass)
  3632. LLFAILED((&@@, "Bad object set"));
  3633. }
  3634. SubtypeElements($type, $permalpha)
  3635. { $$ = NewElementSetSpec(eElementSetSpec_SubtypeElement);
  3636. $$->U.SubtypeElement.SubtypeElement = $1;
  3637. }
  3638. |
  3639. { if ($type)
  3640. LLFAILED((&@@, "Bad constraint"));
  3641. }
  3642. ObjectSetElements($objectclass)
  3643. { $$ = NewElementSetSpec(eElementSetSpec_ObjectSetElement);
  3644. $$->U.ObjectSetElement.ObjectSetElement = $1;
  3645. }
  3646. | '(' ElementSetSpec($type, $objectclass, $permalpha) ')'
  3647. { $$ = $2;
  3648. }
  3649. ;
  3650. SubtypeElements(type, permalpha)
  3651. :
  3652. { Type_e type;
  3653. type = GetTypeType($<<.Assignments, $type);
  3654. if (type == eType_Open)
  3655. LLFAILED((&@@, "Bad constraint"));
  3656. }
  3657. SingleValue($type)
  3658. { $$ = $1;
  3659. }
  3660. |
  3661. { Type_e type;
  3662. type = GetTypeType($<<.Assignments, $type);
  3663. if (type == eType_EmbeddedPdv ||
  3664. type == eType_External ||
  3665. type == eType_Open ||
  3666. type == eType_CharacterString)
  3667. LLFAILED((&@@, "Bad constraint"));
  3668. }
  3669. ContainedSubtype($type)
  3670. { $$ = $1;
  3671. }
  3672. |
  3673. { Type_e type;
  3674. type = GetTypeType($<<.Assignments, $type);
  3675. if ($permalpha ?
  3676. (type != eType_Undefined &&
  3677. type != eType_BMPString &&
  3678. type != eType_IA5String &&
  3679. type != eType_NumericString &&
  3680. type != eType_PrintableString &&
  3681. type != eType_VisibleString &&
  3682. type != eType_UniversalString) :
  3683. (type != eType_Undefined &&
  3684. type != eType_Integer &&
  3685. type != eType_Real))
  3686. LLFAILED((&@@, "Bad constraint"));
  3687. }
  3688. ValueRange($type)
  3689. { $$ = $1;
  3690. }
  3691. |
  3692. { Type_e type;
  3693. type = GetTypeType($<<.Assignments, $type);
  3694. if (type != eType_Undefined &&
  3695. !IsRestrictedString(type) ||
  3696. $permalpha)
  3697. LLFAILED((&@@, "Bad constraint"));
  3698. }
  3699. PermittedAlphabet($type)
  3700. { $$ = $1;
  3701. }
  3702. |
  3703. { Type_e type;
  3704. type = GetTypeType($<<.Assignments, $type);
  3705. if (type != eType_Undefined &&
  3706. type != eType_BitString &&
  3707. type != eType_OctetString &&
  3708. type != eType_UTF8String &&
  3709. type != eType_SequenceOf &&
  3710. type != eType_SetOf &&
  3711. type != eType_CharacterString &&
  3712. !IsRestrictedString(type) ||
  3713. $permalpha)
  3714. LLFAILED((&@@, "Bad constraint"));
  3715. }
  3716. SizeConstraint
  3717. { $$ = $1;
  3718. }
  3719. |
  3720. { Type_e type;
  3721. type = GetTypeType($<<.Assignments, $type);
  3722. if (type != eType_Undefined &&
  3723. type != eType_Open ||
  3724. $permalpha)
  3725. LLFAILED((&@@, "Bad constraint"));
  3726. }
  3727. TypeConstraint
  3728. { $$ = $1;
  3729. }
  3730. |
  3731. { Type_e type;
  3732. type = GetTypeType($<<.Assignments, $type);
  3733. if (type != eType_Undefined &&
  3734. type != eType_Choice &&
  3735. type != eType_EmbeddedPdv &&
  3736. type != eType_External &&
  3737. type != eType_InstanceOf &&
  3738. type != eType_Real &&
  3739. type != eType_Sequence &&
  3740. type != eType_SequenceOf &&
  3741. type != eType_Set &&
  3742. type != eType_SetOf &&
  3743. type != eType_CharacterString ||
  3744. $permalpha)
  3745. LLFAILED((&@@, "Bad constraint"));
  3746. }
  3747. InnerTypeConstraints($type)
  3748. { $$ = $1;
  3749. }
  3750. ;
  3751. SingleValue(type)
  3752. : Value($type)
  3753. { $$ = NewSubtypeElement(eSubtypeElement_SingleValue);
  3754. $$->U.SingleValue.Value = $1;
  3755. }
  3756. ;
  3757. ContainedSubtype(type)
  3758. : Includes Type
  3759. { if (GetTypeType($>>.Assignments, $2) == eType_Null && !$1)
  3760. LLFAILED((&@1, "Bad constraint"));
  3761. if (GetTypeType($>>.Assignments, $type) != eType_Undefined &&
  3762. GetTypeType($>>.Assignments, $2) != eType_Undefined &&
  3763. GetTypeType($>>.Assignments, $type) !=
  3764. GetTypeType($>>.Assignments, $2) &&
  3765. GetTypeType($>>.Assignments, $type) != eType_Open &&
  3766. GetTypeType($>>.Assignments, $2) != eType_Open &&
  3767. (!IsRestrictedString(GetTypeType($>>.Assignments, $type)) ||
  3768. !IsRestrictedString(GetTypeType($>>.Assignments, $2))))
  3769. LLFAILED((&@2, "Bad type of contained-subtype-constraint"));
  3770. $$ = NewSubtypeElement(eSubtypeElement_ContainedSubtype);
  3771. $$->U.ContainedSubtype.Type = $2;
  3772. }
  3773. ;
  3774. Includes
  3775. : "INCLUDES"
  3776. { $$ = 1;
  3777. }
  3778. | /* empty */
  3779. { $$ = 0;
  3780. }
  3781. ;
  3782. ValueRange(type)
  3783. : LowerEndpoint($type) ".." UpperEndpoint($type)
  3784. { if (!$type) {
  3785. $$ = NULL;
  3786. } else {
  3787. $$ = NewSubtypeElement(eSubtypeElement_ValueRange);
  3788. $$->U.ValueRange.Lower = $1;
  3789. $$->U.ValueRange.Upper = $3;
  3790. }
  3791. }
  3792. ;
  3793. LowerEndpoint(type)
  3794. : LowerEndValue($type) '<'
  3795. { $$ = $1;
  3796. $$.Flags |= eEndPoint_Open;
  3797. }
  3798. | LowerEndValue($type)
  3799. { $$ = $1;
  3800. }
  3801. ;
  3802. UpperEndpoint(type)
  3803. : '<' UpperEndValue($type)
  3804. { $$ = $2;
  3805. $$.Flags |= eEndPoint_Open;
  3806. }
  3807. | UpperEndValue($type)
  3808. { $$ = $1;
  3809. }
  3810. ;
  3811. LowerEndValue(type)
  3812. : Value($type)
  3813. { $$.Value = $1;
  3814. $$.Flags = 0;
  3815. }
  3816. | "MIN"
  3817. { $$.Value = NULL;
  3818. $$.Flags = eEndPoint_Min;
  3819. }
  3820. ;
  3821. UpperEndValue(type)
  3822. : Value($type)
  3823. { $$.Value = $1;
  3824. $$.Flags = 0;
  3825. }
  3826. | "MAX"
  3827. { $$.Value = NULL;
  3828. $$.Flags = eEndPoint_Max;
  3829. }
  3830. ;
  3831. SizeConstraint
  3832. : "SIZE" Constraint(Builtin_Type_PositiveInteger, 0)
  3833. { $$ = NewSubtypeElement(eSubtypeElement_Size);
  3834. $$->U.Size.Constraints = $2;
  3835. }
  3836. ;
  3837. TypeConstraint
  3838. : Type
  3839. { $$ = NewSubtypeElement(eSubtypeElement_Type);
  3840. $$->U.Type.Type = $1;
  3841. }
  3842. ;
  3843. PermittedAlphabet(type)
  3844. : "FROM" Constraint($type, 1)
  3845. { $$ = NewSubtypeElement(eSubtypeElement_PermittedAlphabet);
  3846. $$->U.PermittedAlphabet.Constraints = $2;
  3847. }
  3848. ;
  3849. InnerTypeConstraints(type)
  3850. :
  3851. { Type_t *subtype;
  3852. if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  3853. GetTypeType($<<.Assignments, $type) != eType_SequenceOf &&
  3854. GetTypeType($<<.Assignments, $type) != eType_SetOf)
  3855. LLFAILED((&@@, "Bad constraint"));
  3856. if (GetTypeType($<<.Assignments, $type) == eType_Undefined)
  3857. subtype = NULL;
  3858. else
  3859. subtype = GetType($<<.Assignments, $type)->U.SS.Type;
  3860. }
  3861. "WITH" "COMPONENT" SingleTypeConstraint(subtype)
  3862. { $$ = $3;
  3863. }
  3864. |
  3865. { Component_t *components;
  3866. if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  3867. GetTypeType($<<.Assignments, $type) != eType_Sequence &&
  3868. GetTypeType($<<.Assignments, $type) != eType_Set &&
  3869. GetTypeType($<<.Assignments, $type) != eType_Choice &&
  3870. GetTypeType($<<.Assignments, $type) != eType_Real &&
  3871. GetTypeType($<<.Assignments, $type) != eType_External &&
  3872. GetTypeType($<<.Assignments, $type) != eType_EmbeddedPdv &&
  3873. GetTypeType($<<.Assignments, $type) != eType_CharacterString)
  3874. LLFAILED((&@@, "Bad constraint"));
  3875. if (GetTypeType($<<.Assignments, $type) == eType_Undefined)
  3876. components = NULL;
  3877. else
  3878. components = GetType($<<.Assignments, $type)->U.SSC.Components;
  3879. }
  3880. "WITH" "COMPONENTS" MultipleTypeConstraints(components)
  3881. { $$ = $3;
  3882. }
  3883. ;
  3884. SingleTypeConstraint(type)
  3885. : Constraint($type, 0)
  3886. { $$ = NewSubtypeElement(eSubtypeElement_SingleType);
  3887. $$->U.SingleType.Constraints = $1;
  3888. }
  3889. ;
  3890. MultipleTypeConstraints(components)
  3891. : FullSpecification($components)
  3892. { $$ = $1;
  3893. }
  3894. | PartialSpecification($components)
  3895. { $$ = $1;
  3896. }
  3897. ;
  3898. FullSpecification(components)
  3899. : '{' TypeConstraints($components) '}'
  3900. { $$ = NewSubtypeElement(eSubtypeElement_FullSpecification);
  3901. $$->U.FullSpecification.NamedConstraints = $2;
  3902. }
  3903. ;
  3904. PartialSpecification(components)
  3905. : '{' "..." ',' TypeConstraints($components) '}'
  3906. { $$ = NewSubtypeElement(eSubtypeElement_PartialSpecification);
  3907. $$->U.PartialSpecification.NamedConstraints = $4;
  3908. }
  3909. ;
  3910. TypeConstraints(components)
  3911. : NamedConstraint($components)
  3912. { $$ = $1;
  3913. }
  3914. | NamedConstraint($components) ',' TypeConstraints($components)
  3915. { $$ = $1;
  3916. $$->Next = $3;
  3917. }
  3918. ;
  3919. NamedConstraint(components)
  3920. : identifier
  3921. { Component_t *component;
  3922. Type_t *type;
  3923. component = FindComponent($>1.Assignments, $components, $1);
  3924. type = component ? component->U.NOD.NamedType->Type : NULL;
  3925. }
  3926. ComponentConstraint(type)
  3927. { $$ = $2;
  3928. $$->Identifier = $1;
  3929. }
  3930. ;
  3931. ComponentConstraint(type)
  3932. : ValueConstraint($type) PresenceConstraint
  3933. { $$ = NewNamedConstraint();
  3934. $$->Constraint = $1;
  3935. $$->Presence = $2;
  3936. }
  3937. ;
  3938. ValueConstraint(type)
  3939. : Constraint($type, 0)
  3940. { $$ = $1;
  3941. }
  3942. | /* empty */
  3943. { $$ = NULL;
  3944. }
  3945. ;
  3946. PresenceConstraint
  3947. : "PRESENT"
  3948. { $$ = ePresence_Present;
  3949. }
  3950. | "ABSENT"
  3951. { $$ = ePresence_Absent;
  3952. }
  3953. | "OPTIONAL"
  3954. { $$ = ePresence_Optional;
  3955. }
  3956. | /* empty */
  3957. { $$ = ePresence_Normal;
  3958. }
  3959. ;
  3960. GeneralConstraint
  3961. : CON_XXX1 { MyAbort(); } ;
  3962. #line 28 "directiv.ll"
  3963. LocalTypeDirectiveSeq
  3964. : LocalTypeDirective LocalTypeDirectiveESeq
  3965. { if ($2) {
  3966. $$ = DupDirective($1);
  3967. $$->Next = $2;
  3968. } else {
  3969. $$ = $1;
  3970. }
  3971. }
  3972. ;
  3973. LocalTypeDirectiveESeq
  3974. : LocalTypeDirective LocalTypeDirectiveESeq
  3975. { if ($2) {
  3976. $$ = DupDirective($1);
  3977. $$->Next = $2;
  3978. } else {
  3979. $$ = $1;
  3980. }
  3981. }
  3982. | /* empty */
  3983. { $$ = NULL;
  3984. }
  3985. ;
  3986. LocalTypeDirective
  3987. : "--$zero-terminated--"
  3988. { $$ = NewDirective(eDirective_ZeroTerminated);
  3989. }
  3990. | "--$pointer--"
  3991. { $$ = NewDirective(eDirective_Pointer);
  3992. }
  3993. | "--$no-pointer--"
  3994. { $$ = NewDirective(eDirective_NoPointer);
  3995. }
  3996. ;
  3997. LocalSizeDirectiveSeq
  3998. : LocalSizeDirective LocalSizeDirectiveESeq
  3999. { if ($2) {
  4000. $$ = DupDirective($1);
  4001. $$->Next = $2;
  4002. } else {
  4003. $$ = $1;
  4004. }
  4005. }
  4006. ;
  4007. LocalSizeDirectiveESeq
  4008. : LocalSizeDirective LocalSizeDirectiveESeq
  4009. { if ($2) {
  4010. $$ = DupDirective($1);
  4011. $$->Next = $2;
  4012. } else {
  4013. $$ = $1;
  4014. }
  4015. }
  4016. | /* empty */
  4017. { $$ = NULL;
  4018. }
  4019. ;
  4020. LocalSizeDirective
  4021. : "--$fixed-array--"
  4022. { $$ = NewDirective(eDirective_FixedArray);
  4023. }
  4024. | "--$doubly-linked-list--"
  4025. { $$ = NewDirective(eDirective_DoublyLinkedList);
  4026. }
  4027. | "--$singly-linked-list--"
  4028. { $$ = NewDirective(eDirective_SinglyLinkedList);
  4029. }
  4030. | "--$length-pointer--"
  4031. { $$ = NewDirective(eDirective_LengthPointer);
  4032. }
  4033. ;
  4034. PrivateDir_Type
  4035. : "PrivateDir_TypeName" lcsymbol
  4036. {
  4037. $$ = $2;
  4038. }
  4039. | /* empty */
  4040. {
  4041. $$ = NULL;
  4042. };
  4043. PrivateDir_Field
  4044. : "PrivateDir_FieldName" lcsymbol
  4045. {
  4046. $$ = $2;
  4047. }
  4048. | /* empty */
  4049. {
  4050. $$ = NULL;
  4051. };
  4052. PrivateDir_Value
  4053. : "PrivateDir_ValueName" lcsymbol
  4054. {
  4055. $$ = $2;
  4056. }
  4057. | /* empty */
  4058. {
  4059. $$ = NULL;
  4060. };
  4061. PrivateDir_Public
  4062. : "PrivateDir_Public"
  4063. {
  4064. $$ = 1;
  4065. }
  4066. | /* empty */
  4067. {
  4068. $$ = 0;
  4069. };
  4070. PrivateDir_Intx
  4071. : "PrivateDir_Intx"
  4072. {
  4073. $$ = 1;
  4074. }
  4075. | /* empty */
  4076. {
  4077. $$ = 0;
  4078. };
  4079. PrivateDir_LenPtr
  4080. : "PrivateDir_LenPtr"
  4081. {
  4082. $$ = 1;
  4083. }
  4084. | /* empty */
  4085. {
  4086. $$ = 0;
  4087. };
  4088. PrivateDir_Pointer
  4089. : "PrivateDir_Pointer"
  4090. {
  4091. $$ = 1;
  4092. }
  4093. | /* empty */
  4094. {
  4095. $$ = 0;
  4096. };
  4097. PrivateDir_Array
  4098. : "PrivateDir_Array"
  4099. {
  4100. $$ = 1;
  4101. }
  4102. | /* empty */
  4103. {
  4104. $$ = 0;
  4105. };
  4106. PrivateDir_NoCode
  4107. : "PrivateDir_NoCode"
  4108. {
  4109. $$ = 1;
  4110. }
  4111. | /* empty */
  4112. {
  4113. $$ = 0;
  4114. };
  4115. PrivateDir_NoMemCopy
  4116. : "PrivateDir_NoMemCopy"
  4117. {
  4118. $$ = 1;
  4119. }
  4120. | /* empty */
  4121. {
  4122. $$ = 0;
  4123. };
  4124. PrivateDir_OidPacked
  4125. : "PrivateDir_OidPacked"
  4126. {
  4127. $$ = 1;
  4128. }
  4129. | /* empty */
  4130. {
  4131. $$ = 0;
  4132. };
  4133. PrivateDir_OidArray
  4134. : "PrivateDir_OidArray"
  4135. {
  4136. $$ = 1;
  4137. }
  4138. | /* empty */
  4139. {
  4140. $$ = 0;
  4141. };
  4142. PrivateDir_SLinked
  4143. : "PrivateDir_SLinked"
  4144. {
  4145. $$ = 1;
  4146. }
  4147. | /* empty */
  4148. {
  4149. $$ = 0;
  4150. };
  4151. PrivateDir_DLinked
  4152. : "PrivateDir_DLinked"
  4153. {
  4154. $$ = 1;
  4155. }
  4156. | /* empty */
  4157. {
  4158. $$ = 0;
  4159. };
  4160. PrivateDirectives
  4161. : PrivateDir_Intx PrivateDir_LenPtr PrivateDir_Pointer
  4162. PrivateDir_Array PrivateDir_NoCode PrivateDir_NoMemCopy PrivateDir_Public
  4163. PrivateDir_OidPacked PrivateDir_OidArray
  4164. PrivateDir_Type PrivateDir_Field PrivateDir_Value
  4165. PrivateDir_SLinked PrivateDir_DLinked
  4166. {
  4167. $$ = (PrivateDirectives_t *) malloc(sizeof(PrivateDirectives_t));
  4168. if ($$)
  4169. {
  4170. memset($$, 0, sizeof(PrivateDirectives_t));
  4171. $$->fIntx = $1;
  4172. $$->fLenPtr = $2;
  4173. $$->fPointer = $3;
  4174. $$->fArray = $4;
  4175. $$->fNoCode = $5;
  4176. $$->fNoMemCopy = $6;
  4177. $$->fPublic = $7;
  4178. $$->fOidPacked = $8;
  4179. $$->fOidArray = $9 | g_fOidArray;
  4180. $$->pszTypeName = $10;
  4181. $$->pszFieldName = $11;
  4182. $$->pszValueName = $12;
  4183. $$->fSLinked = $13;
  4184. $$->fDLinked = $14;
  4185. }
  4186. }
  4187. | /* empty */
  4188. {
  4189. $$ = NULL;
  4190. };
  4191. #line 73 "object.ll"
  4192. DefinedObjectClass
  4193. : ExternalObjectClassReference
  4194. { $$ = $1;
  4195. }
  4196. | objectclassreference
  4197. { $$ = $1;
  4198. }
  4199. | Usefulobjectclassreference
  4200. { $$ = $1;
  4201. }
  4202. ;
  4203. DefinedObject
  4204. : ExternalObjectReference
  4205. { $$ = $1;
  4206. }
  4207. | objectreference
  4208. { $$ = $1;
  4209. }
  4210. ;
  4211. DefinedObjectSet
  4212. : ExternalObjectSetReference
  4213. { $$ = $1;
  4214. }
  4215. | objectsetreference
  4216. { $$ = $1;
  4217. }
  4218. ;
  4219. Usefulobjectclassreference
  4220. : "TYPE-IDENTIFIER"
  4221. { $$ = Builtin_ObjectClass_TypeIdentifier;
  4222. }
  4223. | "ABSTRACT-SYNTAX"
  4224. { $$ = Builtin_ObjectClass_AbstractSyntax;
  4225. }
  4226. ;
  4227. ObjectClassAssignment
  4228. : objectclassreference "::=" ObjectClass($1)
  4229. { if (!AssignObjectClass(&$>>.Assignments, $1, $3))
  4230. LLFAILED((&@1, "Type `%s' twice defined",
  4231. $1->U.Reference.Identifier));
  4232. }
  4233. ;
  4234. ObjectClass(oc)
  4235. : DefinedObjectClass
  4236. { $$ = $1;
  4237. }
  4238. | ObjectClassDefn($oc)
  4239. { $$ = $1;
  4240. }
  4241. | ParameterizedObjectClass
  4242. { MyAbort();
  4243. }
  4244. ;
  4245. ObjectClassDefn(oc)
  4246. : "CLASS" '{' FieldSpec_List($oc) '}' WithSyntaxSpec_opt($oc)
  4247. { ObjectClass_t *oc;
  4248. oc = NewObjectClass(eObjectClass_ObjectClass);
  4249. oc->U.ObjectClass.FieldSpec = $3;
  4250. oc->U.ObjectClass.SyntaxSpec = $5;
  4251. $$ = oc;
  4252. }
  4253. ;
  4254. FieldSpec_List(oc)
  4255. : FieldSpec($oc) FieldSpec_EList($oc)
  4256. { if ($1) {
  4257. if ($2) {
  4258. $$ = DupFieldSpec($1);
  4259. $$->Next = $2;
  4260. } else {
  4261. $$ = $1;
  4262. }
  4263. } else {
  4264. $$ = $2;
  4265. }
  4266. }
  4267. ;
  4268. FieldSpec_EList(oc)
  4269. : ',' FieldSpec($oc) FieldSpec_EList($oc)
  4270. { if ($2) {
  4271. if ($3) {
  4272. $$ = DupFieldSpec($2);
  4273. $$->Next = $3;
  4274. } else {
  4275. $$ = $2;
  4276. }
  4277. } else {
  4278. $$ = $3;
  4279. }
  4280. }
  4281. | /* empty */
  4282. { $$ = NULL;
  4283. }
  4284. ;
  4285. WithSyntaxSpec_opt(oc)
  4286. : "WITH" "SYNTAX" SyntaxList($oc)
  4287. { $$ = $3;
  4288. }
  4289. | /* empty */
  4290. { $$ = NULL;
  4291. }
  4292. ;
  4293. FieldSpec(oc)
  4294. : TypeFieldSpec($oc)
  4295. { $$ = $1;
  4296. }
  4297. | FixedTypeValueFieldSpec($oc)
  4298. { $$ = $1;
  4299. }
  4300. | VariableTypeValueFieldSpec($oc)
  4301. { $$ = $1;
  4302. }
  4303. | FixedTypeValueSetFieldSpec($oc)
  4304. { $$ = $1;
  4305. }
  4306. | VariableTypeValueSetFieldSpec($oc)
  4307. { $$ = $1;
  4308. }
  4309. | ObjectFieldSpec($oc)
  4310. { $$ = $1;
  4311. }
  4312. | ObjectSetFieldSpec($oc)
  4313. { $$ = $1;
  4314. }
  4315. ;
  4316. TypeFieldSpec(oc)
  4317. : typefieldreference($oc) TypeOptionalitySpec_opt
  4318. { $$ = NewFieldSpec(eFieldSpec_Type);
  4319. $$->Identifier = $1;
  4320. $$->U.Type.Optionality = $2;
  4321. }
  4322. ;
  4323. TypeOptionalitySpec_opt
  4324. : "OPTIONAL"
  4325. { $$ = NewOptionality(eOptionality_Optional);
  4326. }
  4327. | "DEFAULT" Type
  4328. { $$ = NewOptionality(eOptionality_Default_Type);
  4329. $$->U.Type = $2;
  4330. }
  4331. | /* empty */
  4332. { $$ = NewOptionality(eOptionality_Normal);
  4333. }
  4334. ;
  4335. FixedTypeValueFieldSpec(oc)
  4336. : valuefieldreference($oc) Type UNIQUE_opt ValueOptionalitySpec_opt($2)
  4337. { if (GetType($>>.Assignments, $2)) {
  4338. $$ = NewFieldSpec(eFieldSpec_FixedTypeValue);
  4339. $$->Identifier = $1;
  4340. $$->U.FixedTypeValue.Type = $2;
  4341. $$->U.FixedTypeValue.Unique = $3;
  4342. $$->U.FixedTypeValue.Optionality = $4;
  4343. } else {
  4344. $$ = NULL;
  4345. }
  4346. }
  4347. ;
  4348. UNIQUE_opt
  4349. : "UNIQUE"
  4350. { $$ = 1;
  4351. }
  4352. | /* empty */
  4353. { $$ = 0;
  4354. }
  4355. ;
  4356. ValueOptionalitySpec_opt(type)
  4357. : "OPTIONAL"
  4358. { $$ = NewOptionality(eOptionality_Optional);
  4359. }
  4360. | "DEFAULT" Value($type)
  4361. { $$ = NewOptionality(eOptionality_Default_Value);
  4362. $$->U.Value = $2;
  4363. }
  4364. | /* empty */
  4365. { $$ = NewOptionality(eOptionality_Normal);
  4366. }
  4367. ;
  4368. VariableTypeValueFieldSpec(oc)
  4369. : valuefieldreference($oc) FieldName($oc)
  4370. { Type_t *deftype;
  4371. FieldSpec_t *fs, *deffs;
  4372. fs = GetFieldSpecFromObjectClass($>2.Assignments, $oc, $2);
  4373. deffs = GetFieldSpec($>2.Assignments, fs);
  4374. if (deffs &&
  4375. deffs->Type == eFieldSpec_Type &&
  4376. deffs->U.Type.Optionality->Type == eOptionality_Default_Type)
  4377. deftype = deffs->U.Type.Optionality->U.Type;
  4378. else
  4379. deftype = NULL;
  4380. }
  4381. ValueOptionalitySpec_opt(deftype)
  4382. { $$ = NewFieldSpec(eFieldSpec_VariableTypeValue);
  4383. $$->Identifier = $1;
  4384. $$->U.VariableTypeValue.Fields = $2;
  4385. $$->U.VariableTypeValue.Optionality = $3;
  4386. }
  4387. ;
  4388. FixedTypeValueSetFieldSpec(oc)
  4389. : valuesetfieldreference($oc) Type ValueSetOptionalitySpec_opt($2)
  4390. { if (GetType($>>.Assignments, $2)) {
  4391. $$ = NewFieldSpec(eFieldSpec_FixedTypeValueSet);
  4392. $$->Identifier = $1;
  4393. $$->U.FixedTypeValueSet.Type = $2;
  4394. $$->U.FixedTypeValueSet.Optionality = $3;
  4395. } else {
  4396. $$ = NULL;
  4397. }
  4398. }
  4399. ;
  4400. ValueSetOptionalitySpec_opt(type)
  4401. : "OPTIONAL"
  4402. { $$ = NewOptionality(eOptionality_Optional);
  4403. }
  4404. | "DEFAULT" ValueSet($type)
  4405. { $$ = NewOptionality(eOptionality_Default_ValueSet);
  4406. $$->U.ValueSet = $2;
  4407. }
  4408. | /* empty */
  4409. { $$ = NewOptionality(eOptionality_Normal);
  4410. }
  4411. ;
  4412. VariableTypeValueSetFieldSpec(oc)
  4413. : valuesetfieldreference($oc) FieldName($oc)
  4414. { Type_t *deftype;
  4415. FieldSpec_t *fs, *deffs;
  4416. fs = GetFieldSpecFromObjectClass($>2.Assignments, $oc, $2);
  4417. deffs = GetFieldSpec($>2.Assignments, fs);
  4418. if (deffs &&
  4419. deffs->Type == eFieldSpec_Type &&
  4420. deffs->U.Type.Optionality->Type == eOptionality_Default_Type)
  4421. deftype = deffs->U.Type.Optionality->U.Type;
  4422. else
  4423. deftype = NULL;
  4424. }
  4425. ValueSetOptionalitySpec_opt(deftype)
  4426. { $$ = NewFieldSpec(eFieldSpec_VariableTypeValueSet);
  4427. $$->Identifier = $1;
  4428. $$->U.VariableTypeValueSet.Fields = $2;
  4429. $$->U.VariableTypeValueSet.Optionality = $3;
  4430. }
  4431. ;
  4432. ObjectFieldSpec(oc)
  4433. : objectfieldreference($oc) DefinedObjectClass
  4434. ObjectOptionalitySpec_opt($2)
  4435. { if (GetObjectClass($>>.Assignments, $2)) {
  4436. $$ = NewFieldSpec(eFieldSpec_Object);
  4437. $$->Identifier = $1;
  4438. $$->U.Object.ObjectClass = $2;
  4439. $$->U.Object.Optionality = $3;
  4440. } else {
  4441. $$ = NULL;
  4442. }
  4443. }
  4444. ;
  4445. ObjectOptionalitySpec_opt(oc)
  4446. : "OPTIONAL"
  4447. { $$ = NewOptionality(eOptionality_Optional);
  4448. }
  4449. | "DEFAULT" Object($oc)
  4450. { $$ = NewOptionality(eOptionality_Default_Object);
  4451. $$->U.Object = $2;
  4452. }
  4453. | /* empty */
  4454. { $$ = NewOptionality(eOptionality_Normal);
  4455. }
  4456. ;
  4457. ObjectSetFieldSpec(oc)
  4458. : objectsetfieldreference($oc) DefinedObjectClass
  4459. ObjectSetOptionalitySpec_opt($2)
  4460. { if (GetObjectClass($>>.Assignments, $2)) {
  4461. $$ = NewFieldSpec(eFieldSpec_ObjectSet);
  4462. $$->Identifier = $1;
  4463. $$->U.ObjectSet.ObjectClass = $2;
  4464. $$->U.ObjectSet.Optionality = $3;
  4465. } else {
  4466. $$ = NULL;
  4467. }
  4468. }
  4469. ;
  4470. ObjectSetOptionalitySpec_opt(oc)
  4471. : "OPTIONAL"
  4472. { $$ = NewOptionality(eOptionality_Optional);
  4473. }
  4474. | "DEFAULT" ObjectSet($oc)
  4475. { $$ = NewOptionality(eOptionality_Default_ObjectSet);
  4476. $$->U.ObjectSet = $2;
  4477. }
  4478. | /* empty */
  4479. { $$ = NewOptionality(eOptionality_Normal);
  4480. }
  4481. ;
  4482. PrimitiveFieldName(oc)
  4483. : typefieldreference($oc)
  4484. { $$ = $1;
  4485. }
  4486. | valuefieldreference($oc)
  4487. { $$ = $1;
  4488. }
  4489. | valuesetfieldreference($oc)
  4490. { $$ = $1;
  4491. }
  4492. | objectfieldreference($oc)
  4493. { $$ = $1;
  4494. }
  4495. | objectsetfieldreference($oc)
  4496. { $$ = $1;
  4497. }
  4498. ;
  4499. FieldName(oc)
  4500. : objectfieldreference($oc) '.'
  4501. { FieldSpec_t *fs;
  4502. ObjectClass_t *oc;
  4503. fs = GetObjectClassField($>2.Assignments, $oc, $1);
  4504. if (fs)
  4505. oc = fs->U.Object.ObjectClass;
  4506. else
  4507. oc = NULL;
  4508. }
  4509. FieldName(oc)
  4510. { $$ = NewString();
  4511. $$->String = $1;
  4512. $$->Next = $3;
  4513. }
  4514. | objectsetfieldreference($oc) '.'
  4515. { FieldSpec_t *fs;
  4516. ObjectClass_t *oc;
  4517. fs = GetObjectClassField($>2.Assignments, $oc, $1);
  4518. if (fs)
  4519. oc = fs->U.ObjectSet.ObjectClass;
  4520. else
  4521. oc = NULL;
  4522. }
  4523. FieldName(oc)
  4524. { $$ = NewString();
  4525. $$->String = $1;
  4526. $$->Next = $3;
  4527. }
  4528. | PrimitiveFieldName($oc)
  4529. { $$ = NewString();
  4530. $$->String = $1;
  4531. }
  4532. ;
  4533. SyntaxList(oc)
  4534. : '{' TokenOrGroupSpec_Seq($oc) '}'
  4535. { $$ = $2;
  4536. }
  4537. ;
  4538. TokenOrGroupSpec_Seq(oc)
  4539. : TokenOrGroupSpec($oc) TokenOrGroupSpec_ESeq($oc)
  4540. { $$ = DupSyntaxSpec($1);
  4541. $$->Next = $2;
  4542. }
  4543. ;
  4544. TokenOrGroupSpec_ESeq(oc)
  4545. : TokenOrGroupSpec($oc) TokenOrGroupSpec_ESeq($oc)
  4546. { $$ = DupSyntaxSpec($1);
  4547. $$->Next = $2;
  4548. }
  4549. | /* empty */
  4550. { $$ = NULL;
  4551. }
  4552. ;
  4553. TokenOrGroupSpec(oc)
  4554. : RequiredToken($oc)
  4555. { $$ = $1;
  4556. }
  4557. | OptionalGroup($oc)
  4558. { $$ = $1;
  4559. }
  4560. ;
  4561. OptionalGroup(oc)
  4562. : '[' TokenOrGroupSpec_Seq($oc) ']'
  4563. { $$ = NewSyntaxSpec(eSyntaxSpec_Optional);
  4564. $$->U.Optional.SyntaxSpec = $2;
  4565. }
  4566. ;
  4567. RequiredToken(oc)
  4568. : Literal
  4569. { $$ = NewSyntaxSpec(eSyntaxSpec_Literal);
  4570. $$->U.Literal.Literal = $1;
  4571. }
  4572. | PrimitiveFieldName($oc)
  4573. { $$ = NewSyntaxSpec(eSyntaxSpec_Field);
  4574. $$->U.Field.Field = $1;
  4575. }
  4576. ;
  4577. Literal
  4578. : word
  4579. { $$ = $1;
  4580. }
  4581. | ','
  4582. { $$ = ",";
  4583. }
  4584. ;
  4585. ObjectAssignment
  4586. : objectreference DefinedObjectClass "::=" Object($2)
  4587. { AssignObject(&$>>.Assignments, $1, $4);
  4588. }
  4589. ;
  4590. Object(oc)
  4591. : ObjectDefn($oc)
  4592. { $$ = $1;
  4593. }
  4594. | ObjectFromObject
  4595. { $$ = $1;
  4596. }
  4597. | DefinedObject
  4598. { $$ = $1;
  4599. }
  4600. | ParameterizedObject
  4601. { MyAbort();
  4602. }
  4603. ;
  4604. ObjectDefn(oc)
  4605. : DefaultSyntax($oc)
  4606. { $$ = $1;
  4607. }
  4608. | DefinedSyntax($oc)
  4609. { $$ = $1;
  4610. }
  4611. ;
  4612. DefaultSyntax(oc)
  4613. : '{' FieldSetting_EList($oc, NULL) '}'
  4614. { $$ = NewObject(eObject_Object);
  4615. $$->U.Object.ObjectClass = $oc;
  4616. $$->U.Object.Settings = $2;
  4617. }
  4618. ;
  4619. FieldSetting_EList(oc, se)
  4620. : FieldSetting($oc, $se)
  4621. { Setting_t *s, **ss, *se;
  4622. for (s = $1, ss = &se; s; s = s->Next, ss = &(*ss)->Next)
  4623. *ss = DupSetting(s);
  4624. *ss = $se;
  4625. }
  4626. FieldSetting_EListC($oc, se)
  4627. { for (s = $1, ss = &$$; s; s = s->Next, ss = &(*ss)->Next)
  4628. *ss = DupSetting(s);
  4629. *ss = $2;
  4630. }
  4631. | /* empty */
  4632. { $$ = NULL;
  4633. }
  4634. ;
  4635. FieldSetting_EListC(oc, se)
  4636. : ',' FieldSetting($oc, $se)
  4637. { Setting_t *s, **ss, *se;
  4638. for (s = $2, ss = &se; s; s = s->Next, ss = &(*ss)->Next)
  4639. *ss = DupSetting(s);
  4640. *ss = $se;
  4641. }
  4642. FieldSetting_EListC($oc, se)
  4643. { for (s = $2, ss = &$$; s; s = s->Next, ss = &(*ss)->Next)
  4644. *ss = DupSetting(s);
  4645. *ss = $3;
  4646. }
  4647. | /* empty */
  4648. { $$ = NULL;
  4649. }
  4650. ;
  4651. FieldSetting(oc, se)
  4652. : PrimitiveFieldName($oc) Setting($oc, $se, $1)
  4653. { $$ = $2;
  4654. }
  4655. ;
  4656. DefinedSyntax(oc)
  4657. :
  4658. { ObjectClass_t *oc;
  4659. SyntaxSpec_t *sy;
  4660. oc = GetObjectClass($<<.Assignments, $oc);
  4661. if (oc && !oc->U.ObjectClass.SyntaxSpec)
  4662. LLFAILED((&@@, "Bad settings"));
  4663. sy = oc ? oc->U.ObjectClass.SyntaxSpec : UndefSyntaxSpecs;
  4664. }
  4665. '{' DefinedSyntaxToken_ESeq($oc, NULL, sy) '}'
  4666. { $$ = NewObject(eObject_Object);
  4667. $$->U.Object.ObjectClass = $oc;
  4668. $$->U.Object.Settings = $2;
  4669. }
  4670. ;
  4671. DefinedSyntaxToken_ESeq(oc, se, sy)
  4672. :
  4673. { if (!$sy)
  4674. LLFAILED((&@@, "Bad settings"));
  4675. }
  4676. DefinedSyntaxToken($oc, $se, $sy)
  4677. { Setting_t *s, **ss, *se;
  4678. for (s = $1, ss = &se; s; s = s->Next, ss = &(*ss)->Next)
  4679. *ss = DupSetting(s);
  4680. *ss = $se;
  4681. }
  4682. DefinedSyntaxToken_ESeq($oc, se, DEFINED($sy) ? $sy->Next : $sy)
  4683. { for (s = $1, ss = &$$; s; s = s->Next, ss = &(*ss)->Next)
  4684. *ss = DupSetting(s);
  4685. *ss = $2;
  4686. }
  4687. | /* empty */
  4688. { if (DEFINED($sy))
  4689. LLFAILED((&@@, "Bad settings"));
  4690. $$ = NULL;
  4691. }
  4692. ;
  4693. DefinedSyntaxToken(oc, se, sy)
  4694. :
  4695. { if (!DEFINED($sy) || $sy->Type != eSyntaxSpec_Optional)
  4696. LLFAILED((&@@, "Bad settings"));
  4697. }
  4698. DefinedSyntaxToken_ESeq($oc, $se, $sy->U.Optional.SyntaxSpec)
  4699. { $$ = $1;
  4700. }
  4701. |
  4702. { if (!DEFINED($sy) || $sy->Type != eSyntaxSpec_Optional)
  4703. LLFAILED((&@@, "Bad settings"));
  4704. }
  4705. /* empty */
  4706. { $$ = NULL;
  4707. }
  4708. |
  4709. { if (DEFINED($sy) && $sy->Type == eSyntaxSpec_Optional)
  4710. LLFAILED((&@@, "Bad settings"));
  4711. }
  4712. DefinedSyntaxToken_Elem($oc, $se, $sy)
  4713. { $$ = $1;
  4714. }
  4715. ;
  4716. DefinedSyntaxToken_Elem(oc, se, sy)
  4717. :
  4718. { if (!$sy || (DEFINED($sy) && $sy->Type != eSyntaxSpec_Literal))
  4719. LLFAILED((&@@, "Bad settings"));
  4720. }
  4721. Literal
  4722. { if (DEFINED($sy) && strcmp($sy->U.Literal.Literal, $1))
  4723. LLFAILED((&@@, "Bad settings"));
  4724. $$ = NULL;
  4725. }
  4726. |
  4727. { if (!$sy || (DEFINED($sy) && $sy->Type != eSyntaxSpec_Field))
  4728. LLFAILED((&@@, "Bad settings"));
  4729. }
  4730. Setting($oc, $se, DEFINED($sy) ? $sy->U.Field.Field : NULL)
  4731. { $$ = $1;
  4732. }
  4733. ;
  4734. Setting(oc, se, f)
  4735. :
  4736. { FieldSpec_t *fs;
  4737. FieldSpecs_e fe;
  4738. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  4739. fe = GetFieldSpecType($<<.Assignments, fs);
  4740. if (fe != eFieldSpec_Undefined &&
  4741. fe != eFieldSpec_Type)
  4742. LLFAILED((&@@, "Bad setting"));
  4743. }
  4744. Type
  4745. { $$ = NewSetting(eSetting_Type);
  4746. $$->Identifier = $f;
  4747. $$->U.Type.Type = $1;
  4748. }
  4749. |
  4750. { Type_t *type;
  4751. FieldSpec_t *fs;
  4752. FieldSpecs_e fe;
  4753. Setting_t *se;
  4754. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  4755. fe = GetFieldSpecType($<<.Assignments, fs);
  4756. if (fe != eFieldSpec_Undefined &&
  4757. fe != eFieldSpec_FixedTypeValue &&
  4758. fe != eFieldSpec_VariableTypeValue)
  4759. LLFAILED((&@@, "Bad setting"));
  4760. if (fe == eFieldSpec_FixedTypeValue) {
  4761. type = fs->U.FixedTypeValue.Type;
  4762. } else if (fe == eFieldSpec_VariableTypeValue) {
  4763. se = GetSettingFromSettings($<<.Assignments, $se,
  4764. fs->U.VariableTypeValue.Fields);
  4765. if (GetSettingType(se) != eSetting_Type &&
  4766. GetSettingType(se) != eSetting_Undefined)
  4767. MyAbort();
  4768. if (GetSettingType(se) == eSetting_Type)
  4769. type = se->U.Type.Type;
  4770. else
  4771. type = NULL;
  4772. } else {
  4773. type = NULL;
  4774. }
  4775. }
  4776. Value(type)
  4777. { if (type) {
  4778. $$ = NewSetting(eSetting_Value);
  4779. $$->Identifier = $f;
  4780. $$->U.Value.Value = $1;
  4781. } else {
  4782. $$ = NULL;
  4783. }
  4784. }
  4785. |
  4786. { Type_t *type;
  4787. FieldSpec_t *fs;
  4788. FieldSpecs_e fe;
  4789. Setting_t *se;
  4790. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  4791. fe = GetFieldSpecType($<<.Assignments, fs);
  4792. if (fe != eFieldSpec_Undefined &&
  4793. fe != eFieldSpec_FixedTypeValueSet &&
  4794. fe != eFieldSpec_VariableTypeValueSet)
  4795. LLFAILED((&@@, "Bad setting"));
  4796. if (fe == eFieldSpec_FixedTypeValueSet) {
  4797. type = fs->U.FixedTypeValueSet.Type;
  4798. } else if (fe == eFieldSpec_VariableTypeValueSet) {
  4799. se = GetSettingFromSettings($<<.Assignments, $se,
  4800. fs->U.VariableTypeValueSet.Fields);
  4801. if (GetSettingType(se) != eSetting_Type &&
  4802. GetSettingType(se) != eSetting_Undefined)
  4803. MyAbort();
  4804. if (GetSettingType(se) == eSetting_Type)
  4805. type = se->U.Type.Type;
  4806. else
  4807. type = NULL;
  4808. } else {
  4809. type = NULL;
  4810. }
  4811. }
  4812. ValueSet(type)
  4813. { if (type) {
  4814. $$ = NewSetting(eSetting_ValueSet);
  4815. $$->Identifier = $f;
  4816. $$->U.ValueSet.ValueSet = $1;
  4817. } else {
  4818. $$ = NULL;
  4819. }
  4820. }
  4821. |
  4822. { ObjectClass_t *oc;
  4823. FieldSpec_t *fs;
  4824. FieldSpecs_e fe;
  4825. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  4826. fe = GetFieldSpecType($<<.Assignments, fs);
  4827. if (fe != eFieldSpec_Undefined &&
  4828. fe != eFieldSpec_Object)
  4829. LLFAILED((&@@, "Bad setting"));
  4830. if (fe == eFieldSpec_Object)
  4831. oc = fs->U.Object.ObjectClass;
  4832. else
  4833. oc = NULL;
  4834. }
  4835. Object(oc)
  4836. { $$ = NewSetting(eSetting_Object);
  4837. $$->Identifier = $f;
  4838. $$->U.Object.Object = $1;
  4839. }
  4840. |
  4841. { ObjectClass_t *oc;
  4842. FieldSpec_t *fs;
  4843. FieldSpecs_e fe;
  4844. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  4845. fe = GetFieldSpecType($<<.Assignments, fs);
  4846. if (fe != eFieldSpec_Undefined &&
  4847. fe != eFieldSpec_ObjectSet)
  4848. LLFAILED((&@@, "Bad setting"));
  4849. if (fe == eFieldSpec_ObjectSet)
  4850. oc = fs->U.ObjectSet.ObjectClass;
  4851. else
  4852. oc = NULL;
  4853. }
  4854. ObjectSet(oc)
  4855. { $$ = NewSetting(eSetting_ObjectSet);
  4856. $$->Identifier = $f;
  4857. $$->U.ObjectSet.ObjectSet = $1;
  4858. }
  4859. ;
  4860. ObjectSetAssignment
  4861. : objectsetreference DefinedObjectClass "::=" ObjectSet($2)
  4862. { AssignObjectSet(&$>>.Assignments, $1, $4);
  4863. }
  4864. ;
  4865. ObjectSet(oc)
  4866. : '{' ObjectSetSpec($oc) '}'
  4867. { $$ = $2;
  4868. }
  4869. ;
  4870. ObjectSetSpec(oc)
  4871. : ElementSetSpec(NULL, $oc, 0)
  4872. { $$ = NewObjectSet(eObjectSet_ObjectSet);
  4873. $$->U.ObjectSet.ObjectClass = $oc;
  4874. $$->U.ObjectSet.Elements = $1;
  4875. }
  4876. | "..."
  4877. { $$ = NewObjectSet(eObjectSet_ExtensionMarker);
  4878. $$->U.ExtensionMarker.ObjectClass = $oc;
  4879. }
  4880. ;
  4881. ObjectSetElements(oc)
  4882. : ObjectSetFromObjects
  4883. { $$ = NewObjectSetElement(eObjectSetElement_ObjectSet);
  4884. $$->U.ObjectSet.ObjectSet = $1;
  4885. }
  4886. | Object($oc)
  4887. { $$ = NewObjectSetElement(eObjectSetElement_Object);
  4888. $$->U.Object.Object = $1;
  4889. }
  4890. | DefinedObjectSet
  4891. { $$ = NewObjectSetElement(eObjectSetElement_ObjectSet);
  4892. $$->U.ObjectSet.ObjectSet = $1;
  4893. }
  4894. | ParameterizedObjectSet
  4895. { MyAbort();
  4896. }
  4897. ;
  4898. ObjectClassFieldType
  4899. : DefinedObjectClass '.' FieldName($1)
  4900. { FieldSpec_t *fs;
  4901. fs = GetFieldSpecFromObjectClass($>>.Assignments, $1, $3);
  4902. if (!fs) {
  4903. $$ = NewType(eType_Undefined);
  4904. } else {
  4905. switch (fs->Type) {
  4906. case eFieldSpec_Type:
  4907. case eFieldSpec_VariableTypeValue:
  4908. case eFieldSpec_VariableTypeValueSet:
  4909. $$ = NewType(eType_Open);
  4910. break;
  4911. case eFieldSpec_FixedTypeValue:
  4912. $$ = fs->U.FixedTypeValue.Type;
  4913. break;
  4914. case eFieldSpec_FixedTypeValueSet:
  4915. $$ = fs->U.FixedTypeValueSet.Type;
  4916. break;
  4917. case eFieldSpec_Object:
  4918. LLFAILED((&@1, "Object field not permitted"));
  4919. /*NOTREACHED*/
  4920. case eFieldSpec_ObjectSet:
  4921. LLFAILED((&@1, "ObjectSet field not permitted"));
  4922. /*NOTREACHED*/
  4923. default:
  4924. MyAbort();
  4925. }
  4926. }
  4927. }
  4928. ;
  4929. ObjectClassFieldValue(type)
  4930. : OpenTypeFieldVal
  4931. { $$ = $1;
  4932. }
  4933. | FixedTypeFieldVal($type)
  4934. { $$ = $1;
  4935. }
  4936. ;
  4937. OpenTypeFieldVal
  4938. : Type ':' Value($1)
  4939. { $$ = $3;
  4940. }
  4941. ;
  4942. FixedTypeFieldVal(type)
  4943. : BuiltinValue($type)
  4944. { $$ = $1;
  4945. }
  4946. | ReferencedValue
  4947. { $$ = $1;
  4948. }
  4949. ;
  4950. %comment
  4951. InformationFromObjects
  4952. : ValueFromObject
  4953. | ValueSetFromObjects
  4954. | TypeFromObject
  4955. | ObjectFromObject
  4956. | ObjectSetFromObjects
  4957. ;
  4958. %endcomment
  4959. %comment
  4960. ValueFromObject
  4961. : OBJ_XXX1
  4962. ;
  4963. ValueSetFromObjects
  4964. : OBJ_XXX1
  4965. ;
  4966. TypeFromObject
  4967. : OBJ_XXX1
  4968. ;
  4969. ObjectFromObject
  4970. : OBJ_XXX1
  4971. ;
  4972. ObjectSetFromObjects
  4973. : OBJ_XXX1
  4974. ;
  4975. %endcomment
  4976. ValueFromObject
  4977. : ReferencedObjects '.'
  4978. { Object_t *o;
  4979. ObjectClass_t *oc;
  4980. o = GetObject($>2.Assignments, $1);
  4981. oc = o ? o->U.Object.ObjectClass : NULL;
  4982. }
  4983. FieldName(oc)
  4984. { FieldSpec_t *fs;
  4985. FieldSpecs_e fe;
  4986. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  4987. fe = GetFieldSpecType($>>.Assignments, fs);
  4988. if (fe != eFieldSpec_Undefined &&
  4989. fe != eFieldSpec_FixedTypeValue &&
  4990. fe != eFieldSpec_VariableTypeValue)
  4991. LLFAILED((&@2, "Bad field type"));
  4992. if (fe != eFieldSpec_Undefined) {
  4993. $$ = GetValueFromObject($>>.Assignments, $1, $3);
  4994. } else {
  4995. $$ = NULL;
  4996. }
  4997. }
  4998. ;
  4999. ValueSetFromObjects
  5000. : ReferencedObjects '.'
  5001. { Object_t *o;
  5002. ObjectClass_t *oc;
  5003. o = GetObject($>2.Assignments, $1);
  5004. oc = o ? o->U.Object.ObjectClass : NULL;
  5005. }
  5006. FieldName(oc)
  5007. { FieldSpec_t *fs;
  5008. FieldSpecs_e fe;
  5009. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  5010. fe = GetFieldSpecType($>>.Assignments, fs);
  5011. if (fe != eFieldSpec_Undefined &&
  5012. fe != eFieldSpec_FixedTypeValueSet &&
  5013. fe != eFieldSpec_VariableTypeValueSet)
  5014. LLFAILED((&@2, "Bad field type"));
  5015. if (fe != eFieldSpec_Undefined) {
  5016. $$ = GetValueSetFromObject($>>.Assignments, $1, $3);
  5017. } else {
  5018. $$ = NULL;
  5019. }
  5020. }
  5021. | ReferencedObjectSets '.'
  5022. { ObjectSet_t *os;
  5023. ObjectClass_t *oc;
  5024. os = GetObjectSet($>2.Assignments, $1);
  5025. oc = os && os->Type == eObjectSet_ObjectSet ?
  5026. os->U.ObjectSet.ObjectClass : NULL;
  5027. }
  5028. FieldName(oc)
  5029. { FieldSpec_t *fs;
  5030. FieldSpecs_e fe;
  5031. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  5032. fe = GetFieldSpecType($>>.Assignments, fs);
  5033. if (fe != eFieldSpec_Undefined &&
  5034. fe != eFieldSpec_FixedTypeValue &&
  5035. fe != eFieldSpec_FixedTypeValueSet)
  5036. LLFAILED((&@2, "Bad field type"));
  5037. if (fe != eFieldSpec_Undefined) {
  5038. $$ = GetValueSetFromObjectSet($>>.Assignments, $1, $3);
  5039. } else {
  5040. $$ = NULL;
  5041. }
  5042. }
  5043. ;
  5044. TypeFromObject
  5045. : ReferencedObjects '.'
  5046. { Object_t *o;
  5047. ObjectClass_t *oc;
  5048. o = GetObject($>2.Assignments, $1);
  5049. oc = o ? o->U.Object.ObjectClass : NULL;
  5050. }
  5051. FieldName(oc)
  5052. { FieldSpec_t *fs;
  5053. FieldSpecs_e fe;
  5054. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  5055. fe = GetFieldSpecType($>>.Assignments, fs);
  5056. if (fe != eFieldSpec_Undefined &&
  5057. fe != eFieldSpec_Type)
  5058. LLFAILED((&@2, "Bad field type"));
  5059. if (fe != eFieldSpec_Undefined)
  5060. $$ = GetTypeFromObject($>>.Assignments, $1, $3);
  5061. else
  5062. $$ = NULL;
  5063. }
  5064. ;
  5065. ObjectFromObject
  5066. : ReferencedObjects '.'
  5067. { Object_t *o;
  5068. ObjectClass_t *oc;
  5069. o = GetObject($>2.Assignments, $1);
  5070. oc = o ? o->U.Object.ObjectClass : NULL;
  5071. }
  5072. FieldName(oc)
  5073. { FieldSpec_t *fs;
  5074. FieldSpecs_e fe;
  5075. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  5076. fe = GetFieldSpecType($>>.Assignments, fs);
  5077. if (fe != eFieldSpec_Undefined &&
  5078. fe != eFieldSpec_Object)
  5079. LLFAILED((&@2, "Bad field type"));
  5080. if (fe != eFieldSpec_Undefined)
  5081. $$ = GetObjectFromObject($>>.Assignments, $1, $3);
  5082. else
  5083. $$ = NULL;
  5084. }
  5085. ;
  5086. ObjectSetFromObjects
  5087. : ReferencedObjects '.'
  5088. { Object_t *o;
  5089. ObjectClass_t *oc;
  5090. o = GetObject($>2.Assignments, $1);
  5091. oc = o ? o->U.Object.ObjectClass : NULL;
  5092. }
  5093. FieldName(oc)
  5094. { FieldSpec_t *fs;
  5095. FieldSpecs_e fe;
  5096. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  5097. fe = GetFieldSpecType($>>.Assignments, fs);
  5098. if (fe != eFieldSpec_Undefined &&
  5099. fe != eFieldSpec_ObjectSet)
  5100. LLFAILED((&@2, "Bad field type"));
  5101. if (fe != eFieldSpec_Undefined)
  5102. $$ = GetObjectSetFromObject($>>.Assignments, $1, $3);
  5103. else
  5104. $$ = NULL;
  5105. }
  5106. | ReferencedObjectSets '.'
  5107. { ObjectSet_t *os;
  5108. ObjectClass_t *oc;
  5109. os = GetObjectSet($>2.Assignments, $1);
  5110. oc = os ? os->U.OE.ObjectClass : NULL;
  5111. }
  5112. FieldName(oc)
  5113. { FieldSpec_t *fs;
  5114. FieldSpecs_e fe;
  5115. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  5116. fe = GetFieldSpecType($>>.Assignments, fs);
  5117. if (fe != eFieldSpec_Undefined &&
  5118. fe != eFieldSpec_Object &&
  5119. fe != eFieldSpec_ObjectSet)
  5120. LLFAILED((&@2, "Bad field type"));
  5121. if (fe != eFieldSpec_Undefined)
  5122. $$ = GetObjectSetFromObjectSet($>>.Assignments, $1, $3);
  5123. else
  5124. $$ = NULL;
  5125. }
  5126. ;
  5127. ReferencedObjects
  5128. : DefinedObject
  5129. { $$ = $1;
  5130. }
  5131. | ParameterizedObject
  5132. { MyAbort();
  5133. }
  5134. ;
  5135. ReferencedObjectSets
  5136. : DefinedObjectSet
  5137. { $$ = $1;
  5138. }
  5139. | ParameterizedObjectSet
  5140. { MyAbort();
  5141. }
  5142. ;
  5143. InstanceOfType
  5144. : "INSTANCE" "OF" DefinedObjectClass
  5145. { Component_t *co1, *co2;
  5146. Type_t *ty;
  5147. $$ = NewType(eType_InstanceOf);
  5148. $$->U.Sequence.Components = co1 = NewComponent(eComponent_Normal);
  5149. co1->Next = co2 = NewComponent(eComponent_Normal);
  5150. ty = NewType(eType_FieldReference);
  5151. ty->U.FieldReference.Identifier = "&id";
  5152. ty->U.FieldReference.ObjectClass = $3;
  5153. co1->U.Normal.NamedType = NewNamedType("type-id", ty);
  5154. ty = NewType(eType_FieldReference);
  5155. ty->Tags = NewTag(eTagType_Explicit);
  5156. ty->Tags->Tag = Builtin_Value_Integer_0;
  5157. ty->U.FieldReference.Identifier = "&Type";
  5158. ty->U.FieldReference.ObjectClass = $3;
  5159. co2->U.Normal.NamedType = NewNamedType("value", ty);
  5160. }
  5161. ;
  5162. InstanceOfValue(type)
  5163. : SequenceValue($type)
  5164. { $$ = $1;
  5165. }
  5166. ;
  5167. #line 29 "future.ll"
  5168. MacroDefinition : DUM_XXX1 { MyAbort(); } ;
  5169. MacroDefinedType : DUM_XXX2 { MyAbort(); } ;
  5170. MacroDefinedValue(type) : DUM_XXX3 { MyAbort(); } ;
  5171. ParameterizedValueSetType : DUM_XXX4 { MyAbort(); } ;
  5172. ParameterizedReference : DUM_XXX5 { MyAbort(); } ;
  5173. ParameterizedType : DUM_XXX7 { MyAbort(); } ;
  5174. ParameterizedValue : DUM_XXX9 { MyAbort(); } ;
  5175. ParameterizedAssignment : DUM_XXX16 { MyAbort(); } ;
  5176. ParameterizedObjectClass : DUM_XXX17 { MyAbort(); } ;
  5177. ParameterizedObject : DUM_XXX2 { MyAbort(); } ;
  5178. ParameterizedObjectSet : DUM_XXX12 { MyAbort(); } ;
  5179. %%
  5180. #line 1242 "main.ll"
  5181. #line 280 "directiv.ll"