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.

1241 lines
29 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  3. %{
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include "defs.h"
  8. #include "builtin.h"
  9. #include "hackdir.h"
  10. extern int pass;
  11. %}
  12. %union{
  13. char *XString;
  14. char32_t *XString32;
  15. intx_t XNumber;
  16. ASN1bool_t XBoolean;
  17. Type_t *XType;
  18. TagType_e XTagType;
  19. TagClass_e XTagClass;
  20. Tag_t *XTags;
  21. ExtensionType_e XExtensionType;
  22. NamedType_t *XNamedType;
  23. ComponentList_t XComponents;
  24. Constraint_t *XConstraints;
  25. ElementSetSpec_t *XElementSetSpec;
  26. SubtypeElement_t *XSubtypeElement;
  27. ObjectSetElement_t *XObjectSetElement;
  28. DirectiveList_t XDirectives;
  29. NamedConstraintList_t XNamedConstraints;
  30. Presence_e XPresence;
  31. NamedNumberList_t XNamedNumbers;
  32. Value_t *XValue;
  33. ValueSet_t *XValueSet;
  34. EndPoint_t XEndPoint;
  35. Tuple_t XTuple;
  36. Quadruple_t XQuadruple;
  37. NamedValueList_t XNamedValues;
  38. ModuleIdentifier_t *XModuleIdentifier;
  39. NamedObjIdValueList_t XNamedObjIdValue;
  40. ObjectClass_t *XObjectClass;
  41. ObjectSet_t *XObjectSet;
  42. Object_t *XObject;
  43. SyntaxSpecList_t XSyntaxSpecs;
  44. FieldSpecList_t XFieldSpecs;
  45. Optionality_t *XOptionality;
  46. SettingList_t XSettings;
  47. StringList_t XStrings;
  48. StringModuleList_t XStringModules;
  49. Macro_t *XMacro;
  50. MacroProduction_t *XMacroProduction;
  51. NamedMacroProductionList_t XMacroProductions;
  52. MacroLocalAssignmentList_t XMacroLocalAssignments;
  53. PrivateDirectives_t *XPrivateDirectives;
  54. }
  55. %state {
  56. AssignmentList_t Assignments;
  57. AssignedObjIdList_t AssignedObjIds;
  58. UndefinedSymbolList_t Undefined;
  59. UndefinedSymbolList_t BadlyDefined;
  60. ModuleIdentifier_t *Module;
  61. ModuleIdentifier_t *MainModule;
  62. StringModuleList_t Imported;
  63. TagType_e TagDefault;
  64. ExtensionType_e ExtensionDefault;
  65. }
  66. %token "::=" = DEF
  67. %token ".." = DDOT
  68. %token "..." = TDOT
  69. %token "TYPE-IDENTIFIER" = TYPE_IDENTIFIER
  70. %token "ABSTRACT-SYNTAX" = ABSTRACT_SYNTAX
  71. %token "--$zero-terminated--" = ZERO_TERMINATED
  72. %token "--$pointer--" = POINTER
  73. %token "--$no-pointer--" = NO_POINTER
  74. %token "--$fixed-array--" = FIXED_ARRAY
  75. %token "--$singly-linked-list--" = SINGLY_LINKED_LIST
  76. %token "--$doubly-linked-list--" = DOUBLY_LINKED_LIST
  77. %token "--$length-pointer--" = LENGTH_POINTER
  78. %token "number" = Number
  79. %token <XNumber> number
  80. %token <XString> bstring
  81. %token <XString> hstring
  82. %token <XString32> cstring
  83. %token <XString> only_uppercase_symbol
  84. %token <XString> only_uppercase_digits_symbol
  85. %token <XString> uppercase_symbol
  86. %token <XString> lcsymbol
  87. %token <XString> ampucsymbol
  88. %token <XString> amplcsymbol
  89. %prefix T_
  90. %type <XModuleIdentifier> ModuleIdentifier
  91. %type <XValue> DefinitiveIdentifier
  92. %type <XNamedObjIdValue> DefinitiveObjIdComponentList
  93. %type <XNamedObjIdValue> DefinitiveObjIdComponent
  94. %type <XNamedObjIdValue> DefinitiveNumberForm
  95. %type <XNamedObjIdValue> DefinitiveNameAndNumberForm
  96. %type <XTagType> TagDefault
  97. %type <XExtensionType> ExtensionDefault
  98. %type <XModuleIdentifier> GlobalModuleReference
  99. %type <XValue> AssignedIdentifier
  100. %type <XStrings> Exports
  101. %type <XStrings> SymbolsExported
  102. %type <XStringModules> Imports
  103. %type <XStringModules> SymbolsImported
  104. %type <XStringModules> SymbolsFromModule_ESeq
  105. %type <XStringModules> SymbolsFromModule
  106. %type <XStrings> SymbolList
  107. %type <XString> Symbol
  108. %type <XString> Reference
  109. %type <XType> typereference
  110. %type <XType> Externaltypereference
  111. %type <XValue> valuereference
  112. %type <XValue> Externalvaluereference
  113. %type <XObjectClass> objectclassreference
  114. %type <XObjectClass> ExternalObjectClassReference
  115. %type <XObject> objectreference
  116. %type <XObject> ExternalObjectReference
  117. %type <XObjectSet> objectsetreference
  118. %type <XObjectSet> ExternalObjectSetReference
  119. %type <XModuleIdentifier> modulereference
  120. %type <XMacro> macroreference
  121. %type <XMacro> Externalmacroreference
  122. %type <XString> localtypereference
  123. %type <XString> localvaluereference
  124. %type <XString> productionreference
  125. %type <XString> typefieldreference<XObjectClass>
  126. %type <XString> valuefieldreference<XObjectClass>
  127. %type <XString> valuesetfieldreference<XObjectClass>
  128. %type <XString> objectfieldreference<XObjectClass>
  129. %type <XString> objectsetfieldreference<XObjectClass>
  130. %type <XString> word
  131. %type <XString> identifier
  132. %type <XString> ucsymbol
  133. %type <XString> ocsymbol
  134. %type <XString> astring
  135. %start Main
  136. %%
  137. Main
  138. : ModuleDefinition ModuleDefinition_ESeq
  139. ;
  140. ModuleDefinition_ESeq
  141. : ModuleDefinition ModuleDefinition_ESeq
  142. | /* empty */
  143. ;
  144. ModuleDefinition
  145. : ModuleIdentifier "DEFINITIONS" TagDefault ExtensionDefault "::="
  146. { if (!AssignModuleIdentifier(&$<6.Assignments, $1))
  147. LLFAILED((&@1, "Module `%s' twice defined", $1->Identifier));
  148. $<6.MainModule = $1;
  149. $<6.Module = $1;
  150. $<6.TagDefault = $3;
  151. $<6.ExtensionDefault = $4;
  152. g_eDefTagType = $3;
  153. }
  154. "BEGIN" ModuleBody "END"
  155. { LLCUTALL;
  156. }
  157. ;
  158. ModuleIdentifier
  159. : modulereference DefinitiveIdentifier
  160. { if ($2) {
  161. $$ = NewModuleIdentifier();
  162. $$->Identifier = $1->Identifier;
  163. $$->ObjectIdentifier = $2;
  164. } else {
  165. $$ = $1;
  166. }
  167. }
  168. ;
  169. DefinitiveIdentifier
  170. : '{' DefinitiveObjIdComponentList '}'
  171. { switch (GetAssignedObjectIdentifier(
  172. &$>>.AssignedObjIds, NULL, $2, &$$)) {
  173. case -1:
  174. LLFAILED((&@2, "Different numbers for equally named object identifier components"));
  175. /*NOTREACHED*/
  176. case 0:
  177. $$ = NULL;
  178. break;
  179. case 1:
  180. break;
  181. }
  182. }
  183. | /* empty */
  184. { $$ = NULL;
  185. }
  186. ;
  187. DefinitiveObjIdComponentList
  188. : DefinitiveObjIdComponent DefinitiveObjIdComponentList
  189. { $$ = DupNamedObjIdValue($1);
  190. $$->Next = $2;
  191. }
  192. | DefinitiveObjIdComponent
  193. { $$ = $1;
  194. }
  195. ;
  196. DefinitiveObjIdComponent
  197. : NameForm
  198. { $$ = $1;
  199. }
  200. | DefinitiveNumberForm
  201. { $$ = $1;
  202. }
  203. | DefinitiveNameAndNumberForm
  204. { $$ = $1;
  205. }
  206. ;
  207. DefinitiveNumberForm
  208. : number
  209. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NumberForm);
  210. $$->Number = intx2uint32(&$1);
  211. }
  212. ;
  213. DefinitiveNameAndNumberForm
  214. : identifier '(' number ')'
  215. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NameAndNumberForm);
  216. $$->Name = $1;
  217. $$->Number = intx2uint32(&$3);
  218. }
  219. ;
  220. TagDefault
  221. : "EXPLICIT" "TAGS"
  222. { $$ = eTagType_Explicit;
  223. }
  224. | "IMPLICIT" "TAGS"
  225. { $$ = eTagType_Implicit;
  226. }
  227. | "AUTOMATIC" "TAGS"
  228. { $$ = eTagType_Automatic;
  229. }
  230. | /* empty */
  231. { $$ = eTagType_Explicit;
  232. }
  233. ;
  234. ExtensionDefault
  235. : "EXTENSIBILITY" "IMPLIED"
  236. { $$ = eExtensionType_Automatic;
  237. }
  238. | /* empty */
  239. { $$ = eExtensionType_None;
  240. }
  241. ;
  242. ModuleBody
  243. : Exports Imports
  244. { $<3.Imported = $2;
  245. }
  246. AssignmentList
  247. { String_t *s;
  248. StringModule_t *sm;
  249. Assignment_t *a, **aa, *oldass;
  250. UndefinedSymbol_t *u;
  251. if ($2 != IMPORT_ALL) {
  252. for (sm = $2; sm; sm = sm->Next) {
  253. if (!FindExportedAssignment($>>.Assignments,
  254. eAssignment_Undefined, sm->String, sm->Module)) {
  255. if (FindAssignment($>>.Assignments,
  256. eAssignment_Undefined, sm->String,
  257. sm->Module)) {
  258. u = NewUndefinedSymbol(
  259. eUndefinedSymbol_SymbolNotExported,
  260. eAssignment_Undefined);
  261. } else {
  262. u = NewUndefinedSymbol(
  263. eUndefinedSymbol_SymbolNotDefined,
  264. eAssignment_Undefined);
  265. }
  266. u->U.Symbol.Identifier = sm->String;
  267. u->U.Symbol.Module = sm->Module;
  268. u->Next = $>>.Undefined;
  269. $>>.Undefined = u;
  270. continue;
  271. }
  272. if (!FindAssignmentInCurrentPass($>>.Assignments,
  273. sm->String, $>>.Module)) {
  274. a = NewAssignment(eAssignment_Reference);
  275. a->Identifier = sm->String;
  276. a->Module = $>>.Module;
  277. a->U.Reference.Identifier = sm->String;
  278. a->U.Reference.Module = sm->Module;
  279. a->Next = $>>.Assignments;
  280. $>>.Assignments = a;
  281. }
  282. }
  283. }
  284. if ($1 != EXPORT_ALL) {
  285. for (s = $1; s; s = s->Next) {
  286. if (!FindAssignment($>>.Assignments, eAssignment_Undefined,
  287. s->String, $>>.Module))
  288. LLFAILED((&@1, "Exported symbol `%s' is undefined",
  289. s->String));
  290. }
  291. }
  292. oldass = $>>.Assignments;
  293. for (a = $>>.Assignments, aa = &$>>.Assignments; a;
  294. a = a->Next, aa = &(*aa)->Next) {
  295. if (a->Type == eAssignment_NextPass)
  296. break;
  297. *aa = DupAssignment(a);
  298. if (!FindAssignmentInCurrentPass(a->Next,
  299. a->Identifier, a->Module) &&
  300. FindAssignmentInCurrentPass(oldass,
  301. a->Identifier, a->Module) == a &&
  302. !CmpModuleIdentifier(oldass, a->Module, $>>.Module) &&
  303. ($1 == EXPORT_ALL || FindString($1, a->Identifier)))
  304. (*aa)->Flags |= eAssignmentFlags_Exported;
  305. }
  306. *aa = a;
  307. }
  308. | /* empty */
  309. ;
  310. Exports
  311. : "EXPORTS" SymbolsExported ';'
  312. { String_t *s, *t;
  313. for (s = $2; s && s->Next; s = s->Next) {
  314. for (t = s->Next; t; t = t->Next) {
  315. if (!strcmp(s->String, t->String))
  316. LLFAILED((&@2, "Symbol `%s' has been exported twice",
  317. s->String));
  318. }
  319. }
  320. $$ = $2;
  321. }
  322. | /* empty */
  323. { $$ = EXPORT_ALL;
  324. }
  325. ;
  326. SymbolsExported
  327. : SymbolList
  328. { $$ = $1;
  329. }
  330. | /* empty */
  331. { $$ = NULL;
  332. }
  333. ;
  334. Imports
  335. : "IMPORTS" SymbolsImported ';'
  336. { $$ = $2;
  337. }
  338. | /* empty */
  339. { $$ = IMPORT_ALL;
  340. }
  341. ;
  342. SymbolsImported
  343. : SymbolsFromModule_ESeq
  344. { $$ = $1;
  345. }
  346. ;
  347. SymbolsFromModule_ESeq
  348. : SymbolsFromModule SymbolsFromModule_ESeq
  349. { StringModule_t *s, **ss;
  350. for (s = $1, ss = &$$; s; s = s->Next) {
  351. *ss = DupStringModule(s);
  352. ss = &(*ss)->Next;
  353. }
  354. *ss = $2;
  355. }
  356. | /* empty */
  357. { $$ = NULL;
  358. }
  359. ;
  360. SymbolsFromModule
  361. : SymbolList "FROM" GlobalModuleReference
  362. { String_t *s, *t;
  363. StringModule_t **ss;
  364. for (s = $1; s && s->Next; s = s->Next) {
  365. for (t = s->Next; t; t = t->Next) {
  366. if (!strcmp(s->String, t->String))
  367. LLFAILED((&@2, "Symbol `%s' has been imported twice",
  368. s->String));
  369. }
  370. }
  371. for (s = $1, ss = &$$; s; s = s->Next) {
  372. *ss = NewStringModule();
  373. (*ss)->String = s->String;
  374. (*ss)->Module = $3;
  375. ss = &(*ss)->Next;
  376. }
  377. *ss = NULL;
  378. }
  379. ;
  380. GlobalModuleReference
  381. : modulereference AssignedIdentifier
  382. { $$ = NewModuleIdentifier();
  383. $$->Identifier = $1->Identifier;
  384. $$->ObjectIdentifier = $2;
  385. }
  386. ;
  387. AssignedIdentifier
  388. : ObjectIdentifierValue
  389. { $$ = $1;
  390. }
  391. | DefinedValue
  392. { $$ = $1;
  393. }
  394. | /* empty */
  395. { $$ = NULL;
  396. }
  397. ;
  398. SymbolList
  399. : Symbol ',' SymbolList
  400. { $$ = NewString();
  401. $$->String = $1;
  402. $$->Next = $3;
  403. }
  404. | Symbol
  405. { $$ = NewString();
  406. $$->String = $1;
  407. }
  408. ;
  409. Symbol
  410. : Reference
  411. { $$ = $1;
  412. }
  413. | ParameterizedReference
  414. { MyAbort();
  415. }
  416. ;
  417. Reference
  418. : ucsymbol
  419. /* => {type,objectclass,objectset,macro}reference */
  420. { $$ = $1;
  421. }
  422. | lcsymbol
  423. /* => {value,object}reference */
  424. { $$ = $1;
  425. }
  426. ;
  427. AssignmentList
  428. : Assignment Assignment_ESeq
  429. ;
  430. Assignment_ESeq
  431. : Assignment Assignment_ESeq
  432. | /* empty */
  433. ;
  434. Assignment
  435. : TypeAssignment
  436. { LLCUTALL;
  437. }
  438. | ValueAssignment
  439. { LLCUTALL;
  440. }
  441. | ValueSetTypeAssignment
  442. { LLCUTALL;
  443. }
  444. | ObjectClassAssignment
  445. { LLCUTALL;
  446. }
  447. | ObjectAssignment
  448. { LLCUTALL;
  449. }
  450. | ObjectSetAssignment
  451. { LLCUTALL;
  452. }
  453. | ParameterizedAssignment
  454. { LLCUTALL;
  455. }
  456. | MacroDefinition
  457. { LLCUTALL;
  458. }
  459. ;
  460. typereference
  461. : ucsymbol
  462. { Assignment_t *ref;
  463. UndefinedSymbol_t *u;
  464. ref = FindAssignment($>>.Assignments,
  465. eAssignment_Undefined, $1, $>>.Module);
  466. if (!ref) {
  467. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  468. eAssignment_Type);
  469. u->U.Symbol.Module = $>>.Module;
  470. u->U.Symbol.Identifier = $1;
  471. u->Next = $>>.Undefined;
  472. $>>.Undefined = u;
  473. } else if (GetAssignmentType($>>.Assignments, ref) !=
  474. eAssignment_Type)
  475. LLFAILED((&@1, "Symbol `%s' is not a typereference", $1));
  476. $$ = NewType(eType_Reference);
  477. if (ref && ref->U.Type.Type)
  478. {
  479. int fPublic = ref->U.Type.Type->PrivateDirectives.fPublic;
  480. ref->U.Type.Type->PrivateDirectives.fPublic = 0;
  481. PropagateReferenceTypePrivateDirectives($$, &(ref->U.Type.Type->PrivateDirectives));
  482. ref->U.Type.Type->PrivateDirectives.fPublic = fPublic;
  483. }
  484. $$->U.Reference.Identifier = $1;
  485. $$->U.Reference.Module = $>>.Module;
  486. }
  487. ;
  488. Externaltypereference
  489. : modulereference '.' ucsymbol
  490. { Assignment_t *ref;
  491. UndefinedSymbol_t *u;
  492. if ($>>.Imported != IMPORT_ALL &&
  493. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  494. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  495. $1->Identifier, $3));
  496. ref = FindExportedAssignment($>>.Assignments,
  497. eAssignment_Type, $3, $1);
  498. if (!ref) {
  499. if (FindAssignment($>>.Assignments,
  500. eAssignment_Type, $3, $1)) {
  501. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  502. eAssignment_Type);
  503. } else {
  504. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  505. eAssignment_Type);
  506. }
  507. u->U.Symbol.Module = $1;
  508. u->U.Symbol.Identifier = $3;
  509. u->Next = $>>.Undefined;
  510. $>>.Undefined = u;
  511. } else if (GetAssignmentType($>>.Assignments, ref) !=
  512. eAssignment_Type)
  513. LLFAILED((&@1, "Symbol `%s' is not a typereference", $1));
  514. $$ = NewType(eType_Reference);
  515. $$->U.Reference.Identifier = $3;
  516. $$->U.Reference.Module = $1;
  517. }
  518. ;
  519. valuereference
  520. : lcsymbol
  521. { Assignment_t *ref;
  522. UndefinedSymbol_t *u;
  523. ref = FindAssignment($>>.Assignments,
  524. eAssignment_Undefined, $1, $>>.Module);
  525. if (!ref) {
  526. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  527. eAssignment_Value);
  528. u->U.Symbol.Module = $>>.Module;
  529. u->U.Symbol.Identifier = $1;
  530. u->Next = $>>.Undefined;
  531. $>>.Undefined = u;
  532. } else if (GetAssignmentType($>>.Assignments, ref) !=
  533. eAssignment_Value)
  534. LLFAILED((&@1, "Symbol `%s' is not a valuereference", $1));
  535. $$ = NewValue(NULL, NULL);
  536. $$->U.Reference.Identifier = $1;
  537. $$->U.Reference.Module = $>>.Module;
  538. }
  539. ;
  540. Externalvaluereference
  541. : modulereference '.' lcsymbol
  542. { Assignment_t *ref;
  543. UndefinedSymbol_t *u;
  544. if ($>>.Imported != IMPORT_ALL &&
  545. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  546. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  547. $1->Identifier, $3));
  548. ref = FindExportedAssignment($>>.Assignments,
  549. eAssignment_Value, $3, $1);
  550. if (!ref) {
  551. if (FindAssignment($>>.Assignments,
  552. eAssignment_Value, $3, $1)) {
  553. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  554. eAssignment_Value);
  555. } else {
  556. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  557. eAssignment_Value);
  558. }
  559. u->U.Symbol.Module = $1;
  560. u->U.Symbol.Identifier = $3;
  561. u->Next = $>>.Undefined;
  562. $>>.Undefined = u;
  563. } else if (GetAssignmentType($>>.Assignments, ref) !=
  564. eAssignment_Value)
  565. LLFAILED((&@1, "Symbol `%s' is not a valuereference", $1));
  566. $$ = NewValue(NULL, NULL);
  567. $$->U.Reference.Identifier = $3;
  568. $$->U.Reference.Module = $1;
  569. }
  570. ;
  571. objectclassreference
  572. : ocsymbol
  573. { Assignment_t *ref;
  574. UndefinedSymbol_t *u;
  575. ref = FindAssignment($>>.Assignments,
  576. eAssignment_Undefined, $1, $>>.Module);
  577. if (!ref) {
  578. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  579. eAssignment_ObjectClass);
  580. u->U.Symbol.Module = $>>.Module;
  581. u->U.Symbol.Identifier = $1;
  582. u->Next = $>>.Undefined;
  583. $>>.Undefined = u;
  584. } else if (GetAssignmentType($>>.Assignments, ref) !=
  585. eAssignment_ObjectClass)
  586. LLFAILED((&@1, "Symbol `%s' is not an objectclassreference", $1));
  587. $$ = NewObjectClass(eObjectClass_Reference);
  588. $$->U.Reference.Identifier = $1;
  589. $$->U.Reference.Module = $>>.Module;
  590. }
  591. ;
  592. ExternalObjectClassReference
  593. : modulereference '.' ocsymbol
  594. { Assignment_t *ref;
  595. UndefinedSymbol_t *u;
  596. if ($>>.Imported != IMPORT_ALL &&
  597. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  598. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  599. $1->Identifier, $3));
  600. ref = FindExportedAssignment($>>.Assignments,
  601. eAssignment_ObjectClass, $3, $1);
  602. if (!ref) {
  603. if (FindAssignment($>>.Assignments,
  604. eAssignment_ObjectClass, $3, $1)) {
  605. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  606. eAssignment_ObjectClass);
  607. } else {
  608. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  609. eAssignment_ObjectClass);
  610. }
  611. u->U.Symbol.Module = $1;
  612. u->U.Symbol.Identifier = $3;
  613. u->Next = $>>.Undefined;
  614. $>>.Undefined = u;
  615. } else if (GetAssignmentType($>>.Assignments, ref) !=
  616. eAssignment_ObjectClass)
  617. LLFAILED((&@1, "Symbol `%s' is not an objectclassreference", $1));
  618. $$ = NewObjectClass(eObjectClass_Reference);
  619. $$->U.Reference.Identifier = $3;
  620. $$->U.Reference.Module = $1;
  621. }
  622. ;
  623. objectreference
  624. : lcsymbol
  625. { Assignment_t *ref;
  626. UndefinedSymbol_t *u;
  627. ref = FindAssignment($>>.Assignments,
  628. eAssignment_Undefined, $1, $>>.Module);
  629. if (!ref) {
  630. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  631. eAssignment_Object);
  632. u->U.Symbol.Module = $>>.Module;
  633. u->U.Symbol.Identifier = $1;
  634. u->Next = $>>.Undefined;
  635. $>>.Undefined = u;
  636. } else if (GetAssignmentType($>>.Assignments, ref) !=
  637. eAssignment_Object)
  638. LLFAILED((&@1, "Symbol `%s' is not an objectreference", $1));
  639. $$ = NewObject(eObject_Reference);
  640. $$->U.Reference.Identifier = $1;
  641. $$->U.Reference.Module = $>>.Module;
  642. }
  643. ;
  644. ExternalObjectReference
  645. : modulereference '.' lcsymbol
  646. { Assignment_t *ref;
  647. UndefinedSymbol_t *u;
  648. if ($>>.Imported != IMPORT_ALL &&
  649. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  650. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  651. $1->Identifier, $3));
  652. ref = FindExportedAssignment($>>.Assignments,
  653. eAssignment_Object, $3, $1);
  654. if (!ref) {
  655. if (FindAssignment($>>.Assignments,
  656. eAssignment_Object, $3, $1)) {
  657. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  658. eAssignment_Object);
  659. } else {
  660. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  661. eAssignment_Object);
  662. }
  663. u->U.Symbol.Module = $1;
  664. u->U.Symbol.Identifier = $3;
  665. u->Next = $>>.Undefined;
  666. $>>.Undefined = u;
  667. } else if (GetAssignmentType($>>.Assignments, ref) !=
  668. eAssignment_Object)
  669. LLFAILED((&@1, "Symbol `%s' is not an objectreference", $1));
  670. $$ = NewObject(eObject_Reference);
  671. $$->U.Reference.Identifier = $3;
  672. $$->U.Reference.Module = $1;
  673. }
  674. ;
  675. objectsetreference
  676. : ucsymbol
  677. { Assignment_t *ref;
  678. UndefinedSymbol_t *u;
  679. ref = FindAssignment($>>.Assignments,
  680. eAssignment_Undefined, $1, $>>.Module);
  681. if (!ref) {
  682. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  683. eAssignment_ObjectSet);
  684. u->U.Symbol.Module = $>>.Module;
  685. u->U.Symbol.Identifier = $1;
  686. u->Next = $>>.Undefined;
  687. $>>.Undefined = u;
  688. } else if (GetAssignmentType($>>.Assignments, ref) !=
  689. eAssignment_ObjectSet)
  690. LLFAILED((&@1, "Symbol `%s' is not an objectsetreference", $1));
  691. $$ = NewObjectSet(eObjectSet_Reference);
  692. $$->U.Reference.Identifier = $1;
  693. $$->U.Reference.Module = $>>.Module;
  694. }
  695. ;
  696. ExternalObjectSetReference
  697. : modulereference '.' ucsymbol
  698. { Assignment_t *ref;
  699. UndefinedSymbol_t *u;
  700. if ($>>.Imported != IMPORT_ALL &&
  701. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  702. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  703. $1->Identifier, $3));
  704. ref = FindExportedAssignment($>>.Assignments,
  705. eAssignment_ObjectSet, $3, $1);
  706. if (!ref) {
  707. if (FindAssignment($>>.Assignments,
  708. eAssignment_ObjectSet, $3, $1)) {
  709. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  710. eAssignment_ObjectSet);
  711. } else {
  712. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  713. eAssignment_ObjectSet);
  714. }
  715. u->U.Symbol.Module = $1;
  716. u->U.Symbol.Identifier = $3;
  717. u->Next = $>>.Undefined;
  718. $>>.Undefined = u;
  719. } else if (GetAssignmentType($>>.Assignments, ref) !=
  720. eAssignment_ObjectSet)
  721. LLFAILED((&@1, "Symbol `%s' is not an objectsetreference", $1));
  722. $$ = NewObjectSet(eObjectSet_Reference);
  723. $$->U.Reference.Identifier = $3;
  724. $$->U.Reference.Module = $1;
  725. }
  726. ;
  727. macroreference
  728. : ocsymbol
  729. { Assignment_t *ref;
  730. UndefinedSymbol_t *u;
  731. ref = FindAssignment($>>.Assignments,
  732. eAssignment_Undefined, $1, $>>.Module);
  733. if (!ref) {
  734. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  735. eAssignment_Macro);
  736. u->U.Symbol.Module = $>>.Module;
  737. u->U.Symbol.Identifier = $1;
  738. u->Next = $>>.Undefined;
  739. $>>.Undefined = u;
  740. } else if (GetAssignmentType($>>.Assignments, ref) !=
  741. eAssignment_Macro)
  742. LLFAILED((&@1, "Symbol `%s' is not an macroreference", $1));
  743. $$ = NewMacro(eMacro_Reference);
  744. $$->U.Reference.Identifier = $1;
  745. $$->U.Reference.Module = $>>.Module;
  746. }
  747. ;
  748. Externalmacroreference
  749. : modulereference '.' ucsymbol
  750. { Assignment_t *ref;
  751. UndefinedSymbol_t *u;
  752. if ($>>.Imported != IMPORT_ALL &&
  753. !FindStringModule($>>.Assignments, $>>.Imported, $3, $1))
  754. LLFAILED((&@1, "Symbol `%s.%s' has not been imported",
  755. $1->Identifier, $3));
  756. ref = FindExportedAssignment($>>.Assignments,
  757. eAssignment_Macro, $3, $1);
  758. if (!ref) {
  759. if (FindAssignment($>>.Assignments,
  760. eAssignment_Macro, $3, $1)) {
  761. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotExported,
  762. eAssignment_Macro);
  763. } else {
  764. u = NewUndefinedSymbol(eUndefinedSymbol_SymbolNotDefined,
  765. eAssignment_Macro);
  766. }
  767. u->U.Symbol.Module = $1;
  768. u->U.Symbol.Identifier = $3;
  769. u->Next = $>>.Undefined;
  770. $>>.Undefined = u;
  771. } else if (GetAssignmentType($>>.Assignments, ref) !=
  772. eAssignment_Macro)
  773. LLFAILED((&@1, "Symbol `%s' is not an macroreference", $1));
  774. $$ = NewMacro(eMacro_Reference);
  775. $$->U.Reference.Identifier = $3;
  776. $$->U.Reference.Module = $1;
  777. }
  778. ;
  779. localtypereference
  780. : ucsymbol
  781. { $$ = $1;
  782. }
  783. ;
  784. localvaluereference
  785. : ucsymbol
  786. { $$ = $1;
  787. }
  788. ;
  789. productionreference
  790. : ucsymbol
  791. { $$ = $1;
  792. }
  793. ;
  794. modulereference
  795. : ucsymbol
  796. { $$ = NewModuleIdentifier();
  797. $$->Identifier = $1;
  798. }
  799. ;
  800. typefieldreference(oc)
  801. : ampucsymbol
  802. { FieldSpec_t *fs;
  803. FieldSpecs_e fe;
  804. ObjectClass_t *oc;
  805. UndefinedSymbol_t *u;
  806. oc = GetObjectClass($>>.Assignments, $oc);
  807. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  808. fe = GetFieldSpecType($>>.Assignments, fs);
  809. if (fe == eFieldSpec_Undefined) {
  810. if ($oc) {
  811. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  812. $oc, eSetting_Type);
  813. u->U.Field.Module = $>>.Module;
  814. u->U.Field.Identifier = $1;
  815. u->Next = $>>.Undefined;
  816. $>>.Undefined = u;
  817. }
  818. } else if (fe != eFieldSpec_Type)
  819. LLFAILED((&@1, "%s is not a typefieldreference", $1));
  820. $$ = $1;
  821. }
  822. ;
  823. valuefieldreference(oc)
  824. : amplcsymbol
  825. { FieldSpec_t *fs;
  826. FieldSpecs_e fe;
  827. ObjectClass_t *oc;
  828. UndefinedSymbol_t *u;
  829. oc = GetObjectClass($>>.Assignments, $oc);
  830. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  831. fe = GetFieldSpecType($>>.Assignments, fs);
  832. if (fe == eFieldSpec_Undefined) {
  833. if ($oc) {
  834. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  835. $oc, eSetting_Value);
  836. u->U.Field.Module = $>>.Module;
  837. u->U.Field.Identifier = $1;
  838. u->Next = $>>.Undefined;
  839. $>>.Undefined = u;
  840. }
  841. } else if (fe != eFieldSpec_FixedTypeValue &&
  842. fe != eFieldSpec_VariableTypeValue)
  843. LLFAILED((&@1, "%s is not a valuefieldreference", $1));
  844. $$ = $1;
  845. }
  846. ;
  847. valuesetfieldreference(oc)
  848. : ampucsymbol
  849. { FieldSpec_t *fs;
  850. FieldSpecs_e fe;
  851. ObjectClass_t *oc;
  852. UndefinedSymbol_t *u;
  853. oc = GetObjectClass($>>.Assignments, $oc);
  854. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  855. fe = GetFieldSpecType($>>.Assignments, fs);
  856. if (fe == eFieldSpec_Undefined) {
  857. if ($oc) {
  858. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  859. $oc, eSetting_ValueSet);
  860. u->U.Field.Module = $>>.Module;
  861. u->U.Field.Identifier = $1;
  862. u->Next = $>>.Undefined;
  863. $>>.Undefined = u;
  864. }
  865. } else if (fe != eFieldSpec_FixedTypeValueSet &&
  866. fe != eFieldSpec_VariableTypeValueSet)
  867. LLFAILED((&@1, "%s is not a valuesetfieldreference", $1));
  868. $$ = $1;
  869. }
  870. ;
  871. objectfieldreference(oc)
  872. : amplcsymbol
  873. { FieldSpec_t *fs;
  874. FieldSpecs_e fe;
  875. ObjectClass_t *oc;
  876. UndefinedSymbol_t *u;
  877. oc = GetObjectClass($>>.Assignments, $oc);
  878. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  879. fe = GetFieldSpecType($>>.Assignments, fs);
  880. if (fe == eFieldSpec_Undefined) {
  881. if ($oc) {
  882. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  883. $oc, eSetting_Object);
  884. u->U.Field.Module = $>>.Module;
  885. u->U.Field.Identifier = $1;
  886. u->Next = $>>.Undefined;
  887. $>>.Undefined = u;
  888. }
  889. } else if (fe != eFieldSpec_Object)
  890. LLFAILED((&@1, "%s is not a objectfieldreference", $1));
  891. $$ = $1;
  892. }
  893. ;
  894. objectsetfieldreference(oc)
  895. : ampucsymbol
  896. { FieldSpec_t *fs;
  897. FieldSpecs_e fe;
  898. ObjectClass_t *oc;
  899. UndefinedSymbol_t *u;
  900. oc = GetObjectClass($>>.Assignments, $oc);
  901. fs = oc ? FindFieldSpec(oc->U.ObjectClass.FieldSpec, $1) : NULL;
  902. fe = GetFieldSpecType($>>.Assignments, fs);
  903. if (fe == eFieldSpec_Undefined) {
  904. if ($oc) {
  905. u = NewUndefinedField(eUndefinedSymbol_FieldNotDefined,
  906. $oc, eSetting_ObjectSet);
  907. u->U.Field.Module = $>>.Module;
  908. u->U.Field.Identifier = $1;
  909. u->Next = $>>.Undefined;
  910. $>>.Undefined = u;
  911. }
  912. } else if (fe != eFieldSpec_ObjectSet)
  913. LLFAILED((&@1, "%s is not a objectsetfieldreference", $1));
  914. $$ = $1;
  915. }
  916. ;
  917. word
  918. : ucsymbol
  919. { $$ = $1;
  920. }
  921. | "ABSENT"
  922. { $$ = "ABSENT";
  923. }
  924. | "ABSTRACT-SYNTAX"
  925. { $$ = "ABSTRACT-SYNTAX";
  926. }
  927. | "ALL"
  928. { $$ = "ALL";
  929. }
  930. | "ANY"
  931. { $$ = "ANY";
  932. }
  933. | "APPLICATION"
  934. { $$ = "APPLICATION";
  935. }
  936. | "AUTOMATIC"
  937. { $$ = "AUTOMATIC";
  938. }
  939. | "BEGIN"
  940. { $$ = "BEGIN";
  941. }
  942. | "BMPString"
  943. { $$ = "BMPString";
  944. }
  945. | "BY"
  946. { $$ = "BY";
  947. }
  948. | "CLASS"
  949. { $$ = "CLASS";
  950. }
  951. | "COMPONENT"
  952. { $$ = "COMPONENT";
  953. }
  954. | "COMPONENTS"
  955. { $$ = "COMPONENTS";
  956. }
  957. | "CONSTRAINED"
  958. { $$ = "CONSTRAINED";
  959. }
  960. | "DEFAULT"
  961. { $$ = "DEFAULT";
  962. }
  963. | "DEFINED"
  964. { $$ = "DEFINED";
  965. }
  966. | "DEFINITIONS"
  967. { $$ = "DEFINITIONS";
  968. }
  969. | "empty"
  970. { $$ = "empty";
  971. }
  972. | "EXCEPT"
  973. { $$ = "EXCEPT";
  974. }
  975. | "EXPLICIT"
  976. { $$ = "EXPLICIT";
  977. }
  978. | "EXPORTS"
  979. { $$ = "EXPORTS";
  980. }
  981. | "EXTENSIBILITY"
  982. { $$ = "EXTENSIBILITY";
  983. }
  984. | "FROM"
  985. { $$ = "FROM";
  986. }
  987. | "GeneralizedTime"
  988. { $$ = "GeneralizedTime";
  989. }
  990. | "GeneralString"
  991. { $$ = "GeneralString";
  992. }
  993. | "GraphicString"
  994. { $$ = "GraphicString";
  995. }
  996. | "IA5String"
  997. { $$ = "IA5String";
  998. }
  999. | "IDENTIFIER"
  1000. { $$ = "IDENTIFIER";
  1001. }
  1002. | "identifier"
  1003. { $$ = "identifier";
  1004. }
  1005. | "IMPLICIT"
  1006. { $$ = "IMPLICIT";
  1007. }
  1008. | "IMPLIED"
  1009. { $$ = "IMPLIED";
  1010. }
  1011. | "IMPORTS"
  1012. { $$ = "IMPORTS";
  1013. }
  1014. | "INCLUDES"
  1015. { $$ = "INCLUDES";
  1016. }
  1017. | "ISO646String"
  1018. { $$ = "ISO646String";
  1019. }
  1020. | "MACRO"
  1021. { $$ = "MACRO";
  1022. }
  1023. | "MAX"
  1024. { $$ = "MAX";
  1025. }
  1026. | "MIN"
  1027. { $$ = "MIN";
  1028. }
  1029. | "NOTATION"
  1030. { $$ = "NOTATION";
  1031. }
  1032. | "number"
  1033. { $$ = "number";
  1034. }
  1035. | "NumericString"
  1036. { $$ = "NumericString";
  1037. }
  1038. | "ObjectDescriptor"
  1039. { $$ = "ObjectDescriptor";
  1040. }
  1041. | "OF"
  1042. { $$ = "OF";
  1043. }
  1044. | "OPTIONAL"
  1045. { $$ = "OPTIONAL";
  1046. }
  1047. | "PDV"
  1048. { $$ = "PDV";
  1049. }
  1050. | "PRESENT"
  1051. { $$ = "PRESENT";
  1052. }
  1053. | "PrintableString"
  1054. { $$ = "PrintableString";
  1055. }
  1056. | "PRIVATE"
  1057. { $$ = "PRIVATE";
  1058. }
  1059. | "SIZE"
  1060. { $$ = "SIZE";
  1061. }
  1062. | "STRING"
  1063. { $$ = "STRING";
  1064. }
  1065. | "string"
  1066. { $$ = "string";
  1067. }
  1068. | "SYNTAX"
  1069. { $$ = "SYNTAX";
  1070. }
  1071. | "T61String"
  1072. { $$ = "T61String";
  1073. }
  1074. | "TAGS"
  1075. { $$ = "TAGS";
  1076. }
  1077. | "TeletexString"
  1078. { $$ = "TeletexString";
  1079. }
  1080. | "TYPE"
  1081. { $$ = "TYPE";
  1082. }
  1083. | "type"
  1084. { $$ = "type";
  1085. }
  1086. | "TYPE-IDENTIFIER"
  1087. { $$ = "TYPE-IDENTIFIER";
  1088. }
  1089. | "UNIQUE"
  1090. { $$ = "UNIQUE";
  1091. }
  1092. | "UNIVERSAL"
  1093. { $$ = "UNIVERSAL";
  1094. }
  1095. | "UniversalString"
  1096. { $$ = "UniversalString";
  1097. }
  1098. | "UTCTime"
  1099. { $$ = "UTCTime";
  1100. }
  1101. | "UTF8String"
  1102. { $$ = "UTF8String";
  1103. }
  1104. | "VALUE"
  1105. { $$ = "VALUE";
  1106. }
  1107. | "value"
  1108. { $$ = "value";
  1109. }
  1110. | "VideotexString"
  1111. { $$ = "VideotexString";
  1112. }
  1113. | "VisibleString"
  1114. { $$ = "VisibleString";
  1115. }
  1116. | "WITH"
  1117. { $$ = "WITH";
  1118. }
  1119. ;
  1120. identifier
  1121. : lcsymbol
  1122. { $$ = $1;
  1123. }
  1124. | "empty"
  1125. { $$ = "empty";
  1126. }
  1127. | "identifier"
  1128. { $$ = "identifier";
  1129. }
  1130. | "number"
  1131. { $$ = "number";
  1132. }
  1133. | "string"
  1134. { $$ = "string";
  1135. }
  1136. | "type"
  1137. { $$ = "type";
  1138. }
  1139. | "value"
  1140. { $$ = "value";
  1141. }
  1142. ;
  1143. ucsymbol
  1144. : ocsymbol
  1145. { $$ = $1;
  1146. }
  1147. | uppercase_symbol
  1148. { $$ = $1;
  1149. }
  1150. ;
  1151. ocsymbol
  1152. : only_uppercase_symbol
  1153. { $$ = $1;
  1154. }
  1155. | only_uppercase_digits_symbol
  1156. { $$ = $1;
  1157. }
  1158. | "MACRO"
  1159. { $$ = "MACRO";
  1160. }
  1161. | "NOTATION"
  1162. { $$ = "NOTATION";
  1163. }
  1164. | "TYPE"
  1165. { $$ = "TYPE";
  1166. }
  1167. | "VALUE"
  1168. { $$ = "VALUE";
  1169. }
  1170. ;
  1171. astring
  1172. : cstring
  1173. { uint32_t i, len;
  1174. len = str32len($1);
  1175. $$ = (char *)malloc(len + 1);
  1176. for (i = 0; i <= len; i++)
  1177. $$[i] = (char)($1[i]);
  1178. }
  1179. ;
  1180. %%