Source code of Windows XP (NT5)
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.

1116 lines
25 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  3. %token OBJ_XXX1
  4. %token OBJ_XXX2
  5. %token OBJ_XXX3
  6. %token OBJ_XXX4
  7. %token OBJ_XXX5
  8. %token OBJ_XXX6
  9. %token OBJ_XXX7
  10. %type <XObjectClass> DefinedObjectClass
  11. %type <XObject> DefinedObject
  12. %type <XObjectSet> DefinedObjectSet
  13. %type <XObjectClass> Usefulobjectclassreference
  14. %type <XObjectClass> ObjectClass<XObjectClass>
  15. %type <XObjectClass> ObjectClassDefn<XObjectClass>
  16. %type <XFieldSpecs> FieldSpec_List<XObjectClass>
  17. %type <XFieldSpecs> FieldSpec_EList<XObjectClass>
  18. %type <XSyntaxSpecs> WithSyntaxSpec_opt<XObjectClass>
  19. %type <XFieldSpecs> FieldSpec<XObjectClass>
  20. %type <XFieldSpecs> TypeFieldSpec<XObjectClass>
  21. %type <XOptionality> TypeOptionalitySpec_opt
  22. %type <XFieldSpecs> FixedTypeValueFieldSpec<XObjectClass>
  23. %type <XBoolean> UNIQUE_opt
  24. %type <XOptionality> ValueOptionalitySpec_opt<XType>
  25. %type <XFieldSpecs> VariableTypeValueFieldSpec<XObjectClass>
  26. %type <XFieldSpecs> FixedTypeValueSetFieldSpec<XObjectClass>
  27. %type <XOptionality> ValueSetOptionalitySpec_opt<XType>
  28. %type <XFieldSpecs> VariableTypeValueSetFieldSpec<XObjectClass>
  29. %type <XFieldSpecs> ObjectFieldSpec<XObjectClass>
  30. %type <XOptionality> ObjectOptionalitySpec_opt<XObjectClass>
  31. %type <XFieldSpecs> ObjectSetFieldSpec<XObjectClass>
  32. %type <XOptionality> ObjectSetOptionalitySpec_opt<XObjectClass>
  33. %type <XString> PrimitiveFieldName<XObjectClass>
  34. %type <XStrings> FieldName<XObjectClass>
  35. %type <XSyntaxSpecs> SyntaxList<XObjectClass>
  36. %type <XSyntaxSpecs> TokenOrGroupSpec_Seq<XObjectClass>
  37. %type <XSyntaxSpecs> TokenOrGroupSpec_ESeq<XObjectClass>
  38. %type <XSyntaxSpecs> TokenOrGroupSpec<XObjectClass>
  39. %type <XSyntaxSpecs> OptionalGroup<XObjectClass>
  40. %type <XSyntaxSpecs> RequiredToken<XObjectClass>
  41. %type <XString> Literal
  42. %type <XObject> Object<XObjectClass>
  43. %type <XObject> ObjectDefn<XObjectClass>
  44. %type <XObject> DefaultSyntax<XObjectClass>
  45. %type <XSettings> FieldSetting_EList<XObjectClass><XSettings>
  46. %type <XSettings> FieldSetting_EListC<XObjectClass><XSettings>
  47. %type <XSettings> FieldSetting<XObjectClass><XSettings>
  48. %type <XObject> DefinedSyntax<XObjectClass>
  49. %type <XSettings> DefinedSyntaxToken_ESeq<XObjectClass><XSettings><XSyntaxSpecs>
  50. %type <XSettings> DefinedSyntaxToken<XObjectClass><XSettings><XSyntaxSpecs>
  51. %type <XSettings> DefinedSyntaxToken_Elem<XObjectClass><XSettings><XSyntaxSpecs>
  52. %type <XSettings> Setting<XObjectClass><XSettings><XString>
  53. %type <XObjectSet> ObjectSet<XObjectClass>
  54. %type <XObjectSet> ObjectSetSpec<XObjectClass>
  55. %type <XObjectSetElement> ObjectSetElements<XObjectClass>
  56. %type <XType> ObjectClassFieldType
  57. %type <XValue> ObjectClassFieldValue<XType>
  58. %type <XValue> OpenTypeFieldVal
  59. %type <XValue> FixedTypeFieldVal<XType>
  60. %type <XValue> ValueFromObject
  61. %type <XValueSet> ValueSetFromObjects
  62. %type <XType> TypeFromObject
  63. %type <XObject> ObjectFromObject
  64. %type <XObjectSet> ObjectSetFromObjects
  65. %type <XObject> ReferencedObjects
  66. %type <XObjectSet> ReferencedObjectSets
  67. %type <XType> InstanceOfType
  68. %type <XValue> InstanceOfValue<XType>
  69. %%
  70. DefinedObjectClass
  71. : ExternalObjectClassReference
  72. { $$ = $1;
  73. }
  74. | objectclassreference
  75. { $$ = $1;
  76. }
  77. | Usefulobjectclassreference
  78. { $$ = $1;
  79. }
  80. ;
  81. DefinedObject
  82. : ExternalObjectReference
  83. { $$ = $1;
  84. }
  85. | objectreference
  86. { $$ = $1;
  87. }
  88. ;
  89. DefinedObjectSet
  90. : ExternalObjectSetReference
  91. { $$ = $1;
  92. }
  93. | objectsetreference
  94. { $$ = $1;
  95. }
  96. ;
  97. Usefulobjectclassreference
  98. : "TYPE-IDENTIFIER"
  99. { $$ = Builtin_ObjectClass_TypeIdentifier;
  100. }
  101. | "ABSTRACT-SYNTAX"
  102. { $$ = Builtin_ObjectClass_AbstractSyntax;
  103. }
  104. ;
  105. ObjectClassAssignment
  106. : objectclassreference "::=" ObjectClass($1)
  107. { if (!AssignObjectClass(&$>>.Assignments, $1, $3))
  108. LLFAILED((&@1, "Type `%s' twice defined",
  109. $1->U.Reference.Identifier));
  110. }
  111. ;
  112. ObjectClass(oc)
  113. : DefinedObjectClass
  114. { $$ = $1;
  115. }
  116. | ObjectClassDefn($oc)
  117. { $$ = $1;
  118. }
  119. | ParameterizedObjectClass
  120. { MyAbort();
  121. }
  122. ;
  123. ObjectClassDefn(oc)
  124. : "CLASS" '{' FieldSpec_List($oc) '}' WithSyntaxSpec_opt($oc)
  125. { ObjectClass_t *oc;
  126. oc = NewObjectClass(eObjectClass_ObjectClass);
  127. oc->U.ObjectClass.FieldSpec = $3;
  128. oc->U.ObjectClass.SyntaxSpec = $5;
  129. $$ = oc;
  130. }
  131. ;
  132. FieldSpec_List(oc)
  133. : FieldSpec($oc) FieldSpec_EList($oc)
  134. { if ($1) {
  135. if ($2) {
  136. $$ = DupFieldSpec($1);
  137. $$->Next = $2;
  138. } else {
  139. $$ = $1;
  140. }
  141. } else {
  142. $$ = $2;
  143. }
  144. }
  145. ;
  146. FieldSpec_EList(oc)
  147. : ',' FieldSpec($oc) FieldSpec_EList($oc)
  148. { if ($2) {
  149. if ($3) {
  150. $$ = DupFieldSpec($2);
  151. $$->Next = $3;
  152. } else {
  153. $$ = $2;
  154. }
  155. } else {
  156. $$ = $3;
  157. }
  158. }
  159. | /* empty */
  160. { $$ = NULL;
  161. }
  162. ;
  163. WithSyntaxSpec_opt(oc)
  164. : "WITH" "SYNTAX" SyntaxList($oc)
  165. { $$ = $3;
  166. }
  167. | /* empty */
  168. { $$ = NULL;
  169. }
  170. ;
  171. FieldSpec(oc)
  172. : TypeFieldSpec($oc)
  173. { $$ = $1;
  174. }
  175. | FixedTypeValueFieldSpec($oc)
  176. { $$ = $1;
  177. }
  178. | VariableTypeValueFieldSpec($oc)
  179. { $$ = $1;
  180. }
  181. | FixedTypeValueSetFieldSpec($oc)
  182. { $$ = $1;
  183. }
  184. | VariableTypeValueSetFieldSpec($oc)
  185. { $$ = $1;
  186. }
  187. | ObjectFieldSpec($oc)
  188. { $$ = $1;
  189. }
  190. | ObjectSetFieldSpec($oc)
  191. { $$ = $1;
  192. }
  193. ;
  194. TypeFieldSpec(oc)
  195. : typefieldreference($oc) TypeOptionalitySpec_opt
  196. { $$ = NewFieldSpec(eFieldSpec_Type);
  197. $$->Identifier = $1;
  198. $$->U.Type.Optionality = $2;
  199. }
  200. ;
  201. TypeOptionalitySpec_opt
  202. : "OPTIONAL"
  203. { $$ = NewOptionality(eOptionality_Optional);
  204. }
  205. | "DEFAULT" Type
  206. { $$ = NewOptionality(eOptionality_Default_Type);
  207. $$->U.Type = $2;
  208. }
  209. | /* empty */
  210. { $$ = NewOptionality(eOptionality_Normal);
  211. }
  212. ;
  213. FixedTypeValueFieldSpec(oc)
  214. : valuefieldreference($oc) Type UNIQUE_opt ValueOptionalitySpec_opt($2)
  215. { if (GetType($>>.Assignments, $2)) {
  216. $$ = NewFieldSpec(eFieldSpec_FixedTypeValue);
  217. $$->Identifier = $1;
  218. $$->U.FixedTypeValue.Type = $2;
  219. $$->U.FixedTypeValue.Unique = $3;
  220. $$->U.FixedTypeValue.Optionality = $4;
  221. } else {
  222. $$ = NULL;
  223. }
  224. }
  225. ;
  226. UNIQUE_opt
  227. : "UNIQUE"
  228. { $$ = 1;
  229. }
  230. | /* empty */
  231. { $$ = 0;
  232. }
  233. ;
  234. ValueOptionalitySpec_opt(type)
  235. : "OPTIONAL"
  236. { $$ = NewOptionality(eOptionality_Optional);
  237. }
  238. | "DEFAULT" Value($type)
  239. { $$ = NewOptionality(eOptionality_Default_Value);
  240. $$->U.Value = $2;
  241. }
  242. | /* empty */
  243. { $$ = NewOptionality(eOptionality_Normal);
  244. }
  245. ;
  246. VariableTypeValueFieldSpec(oc)
  247. : valuefieldreference($oc) FieldName($oc)
  248. { Type_t *deftype;
  249. FieldSpec_t *fs, *deffs;
  250. fs = GetFieldSpecFromObjectClass($>2.Assignments, $oc, $2);
  251. deffs = GetFieldSpec($>2.Assignments, fs);
  252. if (deffs &&
  253. deffs->Type == eFieldSpec_Type &&
  254. deffs->U.Type.Optionality->Type == eOptionality_Default_Type)
  255. deftype = deffs->U.Type.Optionality->U.Type;
  256. else
  257. deftype = NULL;
  258. }
  259. ValueOptionalitySpec_opt(deftype)
  260. { $$ = NewFieldSpec(eFieldSpec_VariableTypeValue);
  261. $$->Identifier = $1;
  262. $$->U.VariableTypeValue.Fields = $2;
  263. $$->U.VariableTypeValue.Optionality = $3;
  264. }
  265. ;
  266. FixedTypeValueSetFieldSpec(oc)
  267. : valuesetfieldreference($oc) Type ValueSetOptionalitySpec_opt($2)
  268. { if (GetType($>>.Assignments, $2)) {
  269. $$ = NewFieldSpec(eFieldSpec_FixedTypeValueSet);
  270. $$->Identifier = $1;
  271. $$->U.FixedTypeValueSet.Type = $2;
  272. $$->U.FixedTypeValueSet.Optionality = $3;
  273. } else {
  274. $$ = NULL;
  275. }
  276. }
  277. ;
  278. ValueSetOptionalitySpec_opt(type)
  279. : "OPTIONAL"
  280. { $$ = NewOptionality(eOptionality_Optional);
  281. }
  282. | "DEFAULT" ValueSet($type)
  283. { $$ = NewOptionality(eOptionality_Default_ValueSet);
  284. $$->U.ValueSet = $2;
  285. }
  286. | /* empty */
  287. { $$ = NewOptionality(eOptionality_Normal);
  288. }
  289. ;
  290. VariableTypeValueSetFieldSpec(oc)
  291. : valuesetfieldreference($oc) FieldName($oc)
  292. { Type_t *deftype;
  293. FieldSpec_t *fs, *deffs;
  294. fs = GetFieldSpecFromObjectClass($>2.Assignments, $oc, $2);
  295. deffs = GetFieldSpec($>2.Assignments, fs);
  296. if (deffs &&
  297. deffs->Type == eFieldSpec_Type &&
  298. deffs->U.Type.Optionality->Type == eOptionality_Default_Type)
  299. deftype = deffs->U.Type.Optionality->U.Type;
  300. else
  301. deftype = NULL;
  302. }
  303. ValueSetOptionalitySpec_opt(deftype)
  304. { $$ = NewFieldSpec(eFieldSpec_VariableTypeValueSet);
  305. $$->Identifier = $1;
  306. $$->U.VariableTypeValueSet.Fields = $2;
  307. $$->U.VariableTypeValueSet.Optionality = $3;
  308. }
  309. ;
  310. ObjectFieldSpec(oc)
  311. : objectfieldreference($oc) DefinedObjectClass
  312. ObjectOptionalitySpec_opt($2)
  313. { if (GetObjectClass($>>.Assignments, $2)) {
  314. $$ = NewFieldSpec(eFieldSpec_Object);
  315. $$->Identifier = $1;
  316. $$->U.Object.ObjectClass = $2;
  317. $$->U.Object.Optionality = $3;
  318. } else {
  319. $$ = NULL;
  320. }
  321. }
  322. ;
  323. ObjectOptionalitySpec_opt(oc)
  324. : "OPTIONAL"
  325. { $$ = NewOptionality(eOptionality_Optional);
  326. }
  327. | "DEFAULT" Object($oc)
  328. { $$ = NewOptionality(eOptionality_Default_Object);
  329. $$->U.Object = $2;
  330. }
  331. | /* empty */
  332. { $$ = NewOptionality(eOptionality_Normal);
  333. }
  334. ;
  335. ObjectSetFieldSpec(oc)
  336. : objectsetfieldreference($oc) DefinedObjectClass
  337. ObjectSetOptionalitySpec_opt($2)
  338. { if (GetObjectClass($>>.Assignments, $2)) {
  339. $$ = NewFieldSpec(eFieldSpec_ObjectSet);
  340. $$->Identifier = $1;
  341. $$->U.ObjectSet.ObjectClass = $2;
  342. $$->U.ObjectSet.Optionality = $3;
  343. } else {
  344. $$ = NULL;
  345. }
  346. }
  347. ;
  348. ObjectSetOptionalitySpec_opt(oc)
  349. : "OPTIONAL"
  350. { $$ = NewOptionality(eOptionality_Optional);
  351. }
  352. | "DEFAULT" ObjectSet($oc)
  353. { $$ = NewOptionality(eOptionality_Default_ObjectSet);
  354. $$->U.ObjectSet = $2;
  355. }
  356. | /* empty */
  357. { $$ = NewOptionality(eOptionality_Normal);
  358. }
  359. ;
  360. PrimitiveFieldName(oc)
  361. : typefieldreference($oc)
  362. { $$ = $1;
  363. }
  364. | valuefieldreference($oc)
  365. { $$ = $1;
  366. }
  367. | valuesetfieldreference($oc)
  368. { $$ = $1;
  369. }
  370. | objectfieldreference($oc)
  371. { $$ = $1;
  372. }
  373. | objectsetfieldreference($oc)
  374. { $$ = $1;
  375. }
  376. ;
  377. FieldName(oc)
  378. : objectfieldreference($oc) '.'
  379. { FieldSpec_t *fs;
  380. ObjectClass_t *oc;
  381. fs = GetObjectClassField($>2.Assignments, $oc, $1);
  382. if (fs)
  383. oc = fs->U.Object.ObjectClass;
  384. else
  385. oc = NULL;
  386. }
  387. FieldName(oc)
  388. { $$ = NewString();
  389. $$->String = $1;
  390. $$->Next = $3;
  391. }
  392. | objectsetfieldreference($oc) '.'
  393. { FieldSpec_t *fs;
  394. ObjectClass_t *oc;
  395. fs = GetObjectClassField($>2.Assignments, $oc, $1);
  396. if (fs)
  397. oc = fs->U.ObjectSet.ObjectClass;
  398. else
  399. oc = NULL;
  400. }
  401. FieldName(oc)
  402. { $$ = NewString();
  403. $$->String = $1;
  404. $$->Next = $3;
  405. }
  406. | PrimitiveFieldName($oc)
  407. { $$ = NewString();
  408. $$->String = $1;
  409. }
  410. ;
  411. SyntaxList(oc)
  412. : '{' TokenOrGroupSpec_Seq($oc) '}'
  413. { $$ = $2;
  414. }
  415. ;
  416. TokenOrGroupSpec_Seq(oc)
  417. : TokenOrGroupSpec($oc) TokenOrGroupSpec_ESeq($oc)
  418. { $$ = DupSyntaxSpec($1);
  419. $$->Next = $2;
  420. }
  421. ;
  422. TokenOrGroupSpec_ESeq(oc)
  423. : TokenOrGroupSpec($oc) TokenOrGroupSpec_ESeq($oc)
  424. { $$ = DupSyntaxSpec($1);
  425. $$->Next = $2;
  426. }
  427. | /* empty */
  428. { $$ = NULL;
  429. }
  430. ;
  431. TokenOrGroupSpec(oc)
  432. : RequiredToken($oc)
  433. { $$ = $1;
  434. }
  435. | OptionalGroup($oc)
  436. { $$ = $1;
  437. }
  438. ;
  439. OptionalGroup(oc)
  440. : '[' TokenOrGroupSpec_Seq($oc) ']'
  441. { $$ = NewSyntaxSpec(eSyntaxSpec_Optional);
  442. $$->U.Optional.SyntaxSpec = $2;
  443. }
  444. ;
  445. RequiredToken(oc)
  446. : Literal
  447. { $$ = NewSyntaxSpec(eSyntaxSpec_Literal);
  448. $$->U.Literal.Literal = $1;
  449. }
  450. | PrimitiveFieldName($oc)
  451. { $$ = NewSyntaxSpec(eSyntaxSpec_Field);
  452. $$->U.Field.Field = $1;
  453. }
  454. ;
  455. Literal
  456. : word
  457. { $$ = $1;
  458. }
  459. | ','
  460. { $$ = ",";
  461. }
  462. ;
  463. ObjectAssignment
  464. : objectreference DefinedObjectClass "::=" Object($2)
  465. { AssignObject(&$>>.Assignments, $1, $4);
  466. }
  467. ;
  468. Object(oc)
  469. : ObjectDefn($oc)
  470. { $$ = $1;
  471. }
  472. | ObjectFromObject
  473. { $$ = $1;
  474. }
  475. | DefinedObject
  476. { $$ = $1;
  477. }
  478. | ParameterizedObject
  479. { MyAbort();
  480. }
  481. ;
  482. ObjectDefn(oc)
  483. : DefaultSyntax($oc)
  484. { $$ = $1;
  485. }
  486. | DefinedSyntax($oc)
  487. { $$ = $1;
  488. }
  489. ;
  490. DefaultSyntax(oc)
  491. : '{' FieldSetting_EList($oc, NULL) '}'
  492. { $$ = NewObject(eObject_Object);
  493. $$->U.Object.ObjectClass = $oc;
  494. $$->U.Object.Settings = $2;
  495. }
  496. ;
  497. FieldSetting_EList(oc, se)
  498. : FieldSetting($oc, $se)
  499. { Setting_t *s, **ss, *se;
  500. for (s = $1, ss = &se; s; s = s->Next, ss = &(*ss)->Next)
  501. *ss = DupSetting(s);
  502. *ss = $se;
  503. }
  504. FieldSetting_EListC($oc, se)
  505. { for (s = $1, ss = &$$; s; s = s->Next, ss = &(*ss)->Next)
  506. *ss = DupSetting(s);
  507. *ss = $2;
  508. }
  509. | /* empty */
  510. { $$ = NULL;
  511. }
  512. ;
  513. FieldSetting_EListC(oc, se)
  514. : ',' FieldSetting($oc, $se)
  515. { Setting_t *s, **ss, *se;
  516. for (s = $2, ss = &se; s; s = s->Next, ss = &(*ss)->Next)
  517. *ss = DupSetting(s);
  518. *ss = $se;
  519. }
  520. FieldSetting_EListC($oc, se)
  521. { for (s = $2, ss = &$$; s; s = s->Next, ss = &(*ss)->Next)
  522. *ss = DupSetting(s);
  523. *ss = $3;
  524. }
  525. | /* empty */
  526. { $$ = NULL;
  527. }
  528. ;
  529. FieldSetting(oc, se)
  530. : PrimitiveFieldName($oc) Setting($oc, $se, $1)
  531. { $$ = $2;
  532. }
  533. ;
  534. DefinedSyntax(oc)
  535. :
  536. { ObjectClass_t *oc;
  537. SyntaxSpec_t *sy;
  538. oc = GetObjectClass($<<.Assignments, $oc);
  539. if (oc && !oc->U.ObjectClass.SyntaxSpec)
  540. LLFAILED((&@@, "Bad settings"));
  541. sy = oc ? oc->U.ObjectClass.SyntaxSpec : UndefSyntaxSpecs;
  542. }
  543. '{' DefinedSyntaxToken_ESeq($oc, NULL, sy) '}'
  544. { $$ = NewObject(eObject_Object);
  545. $$->U.Object.ObjectClass = $oc;
  546. $$->U.Object.Settings = $2;
  547. }
  548. ;
  549. DefinedSyntaxToken_ESeq(oc, se, sy)
  550. :
  551. { if (!$sy)
  552. LLFAILED((&@@, "Bad settings"));
  553. }
  554. DefinedSyntaxToken($oc, $se, $sy)
  555. { Setting_t *s, **ss, *se;
  556. for (s = $1, ss = &se; s; s = s->Next, ss = &(*ss)->Next)
  557. *ss = DupSetting(s);
  558. *ss = $se;
  559. }
  560. DefinedSyntaxToken_ESeq($oc, se, DEFINED($sy) ? $sy->Next : $sy)
  561. { for (s = $1, ss = &$$; s; s = s->Next, ss = &(*ss)->Next)
  562. *ss = DupSetting(s);
  563. *ss = $2;
  564. }
  565. | /* empty */
  566. { if (DEFINED($sy))
  567. LLFAILED((&@@, "Bad settings"));
  568. $$ = NULL;
  569. }
  570. ;
  571. DefinedSyntaxToken(oc, se, sy)
  572. :
  573. { if (!DEFINED($sy) || $sy->Type != eSyntaxSpec_Optional)
  574. LLFAILED((&@@, "Bad settings"));
  575. }
  576. DefinedSyntaxToken_ESeq($oc, $se, $sy->U.Optional.SyntaxSpec)
  577. { $$ = $1;
  578. }
  579. |
  580. { if (!DEFINED($sy) || $sy->Type != eSyntaxSpec_Optional)
  581. LLFAILED((&@@, "Bad settings"));
  582. }
  583. /* empty */
  584. { $$ = NULL;
  585. }
  586. |
  587. { if (DEFINED($sy) && $sy->Type == eSyntaxSpec_Optional)
  588. LLFAILED((&@@, "Bad settings"));
  589. }
  590. DefinedSyntaxToken_Elem($oc, $se, $sy)
  591. { $$ = $1;
  592. }
  593. ;
  594. DefinedSyntaxToken_Elem(oc, se, sy)
  595. :
  596. { if (!$sy || (DEFINED($sy) && $sy->Type != eSyntaxSpec_Literal))
  597. LLFAILED((&@@, "Bad settings"));
  598. }
  599. Literal
  600. { if (DEFINED($sy) && strcmp($sy->U.Literal.Literal, $1))
  601. LLFAILED((&@@, "Bad settings"));
  602. $$ = NULL;
  603. }
  604. |
  605. { if (!$sy || (DEFINED($sy) && $sy->Type != eSyntaxSpec_Field))
  606. LLFAILED((&@@, "Bad settings"));
  607. }
  608. Setting($oc, $se, DEFINED($sy) ? $sy->U.Field.Field : NULL)
  609. { $$ = $1;
  610. }
  611. ;
  612. Setting(oc, se, f)
  613. :
  614. { FieldSpec_t *fs;
  615. FieldSpecs_e fe;
  616. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  617. fe = GetFieldSpecType($<<.Assignments, fs);
  618. if (fe != eFieldSpec_Undefined &&
  619. fe != eFieldSpec_Type)
  620. LLFAILED((&@@, "Bad setting"));
  621. }
  622. Type
  623. { $$ = NewSetting(eSetting_Type);
  624. $$->Identifier = $f;
  625. $$->U.Type.Type = $1;
  626. }
  627. |
  628. { Type_t *type;
  629. FieldSpec_t *fs;
  630. FieldSpecs_e fe;
  631. Setting_t *se;
  632. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  633. fe = GetFieldSpecType($<<.Assignments, fs);
  634. if (fe != eFieldSpec_Undefined &&
  635. fe != eFieldSpec_FixedTypeValue &&
  636. fe != eFieldSpec_VariableTypeValue)
  637. LLFAILED((&@@, "Bad setting"));
  638. if (fe == eFieldSpec_FixedTypeValue) {
  639. type = fs->U.FixedTypeValue.Type;
  640. } else if (fe == eFieldSpec_VariableTypeValue) {
  641. se = GetSettingFromSettings($<<.Assignments, $se,
  642. fs->U.VariableTypeValue.Fields);
  643. if (GetSettingType(se) != eSetting_Type &&
  644. GetSettingType(se) != eSetting_Undefined)
  645. MyAbort();
  646. if (GetSettingType(se) == eSetting_Type)
  647. type = se->U.Type.Type;
  648. else
  649. type = NULL;
  650. } else {
  651. type = NULL;
  652. }
  653. }
  654. Value(type)
  655. { if (type) {
  656. $$ = NewSetting(eSetting_Value);
  657. $$->Identifier = $f;
  658. $$->U.Value.Value = $1;
  659. } else {
  660. $$ = NULL;
  661. }
  662. }
  663. |
  664. { Type_t *type;
  665. FieldSpec_t *fs;
  666. FieldSpecs_e fe;
  667. Setting_t *se;
  668. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  669. fe = GetFieldSpecType($<<.Assignments, fs);
  670. if (fe != eFieldSpec_Undefined &&
  671. fe != eFieldSpec_FixedTypeValueSet &&
  672. fe != eFieldSpec_VariableTypeValueSet)
  673. LLFAILED((&@@, "Bad setting"));
  674. if (fe == eFieldSpec_FixedTypeValueSet) {
  675. type = fs->U.FixedTypeValueSet.Type;
  676. } else if (fe == eFieldSpec_VariableTypeValueSet) {
  677. se = GetSettingFromSettings($<<.Assignments, $se,
  678. fs->U.VariableTypeValueSet.Fields);
  679. if (GetSettingType(se) != eSetting_Type &&
  680. GetSettingType(se) != eSetting_Undefined)
  681. MyAbort();
  682. if (GetSettingType(se) == eSetting_Type)
  683. type = se->U.Type.Type;
  684. else
  685. type = NULL;
  686. } else {
  687. type = NULL;
  688. }
  689. }
  690. ValueSet(type)
  691. { if (type) {
  692. $$ = NewSetting(eSetting_ValueSet);
  693. $$->Identifier = $f;
  694. $$->U.ValueSet.ValueSet = $1;
  695. } else {
  696. $$ = NULL;
  697. }
  698. }
  699. |
  700. { ObjectClass_t *oc;
  701. FieldSpec_t *fs;
  702. FieldSpecs_e fe;
  703. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  704. fe = GetFieldSpecType($<<.Assignments, fs);
  705. if (fe != eFieldSpec_Undefined &&
  706. fe != eFieldSpec_Object)
  707. LLFAILED((&@@, "Bad setting"));
  708. if (fe == eFieldSpec_Object)
  709. oc = fs->U.Object.ObjectClass;
  710. else
  711. oc = NULL;
  712. }
  713. Object(oc)
  714. { $$ = NewSetting(eSetting_Object);
  715. $$->Identifier = $f;
  716. $$->U.Object.Object = $1;
  717. }
  718. |
  719. { ObjectClass_t *oc;
  720. FieldSpec_t *fs;
  721. FieldSpecs_e fe;
  722. fs = GetObjectClassField($<<.Assignments, $oc, $f);
  723. fe = GetFieldSpecType($<<.Assignments, fs);
  724. if (fe != eFieldSpec_Undefined &&
  725. fe != eFieldSpec_ObjectSet)
  726. LLFAILED((&@@, "Bad setting"));
  727. if (fe == eFieldSpec_ObjectSet)
  728. oc = fs->U.ObjectSet.ObjectClass;
  729. else
  730. oc = NULL;
  731. }
  732. ObjectSet(oc)
  733. { $$ = NewSetting(eSetting_ObjectSet);
  734. $$->Identifier = $f;
  735. $$->U.ObjectSet.ObjectSet = $1;
  736. }
  737. ;
  738. ObjectSetAssignment
  739. : objectsetreference DefinedObjectClass "::=" ObjectSet($2)
  740. { AssignObjectSet(&$>>.Assignments, $1, $4);
  741. }
  742. ;
  743. ObjectSet(oc)
  744. : '{' ObjectSetSpec($oc) '}'
  745. { $$ = $2;
  746. }
  747. ;
  748. ObjectSetSpec(oc)
  749. : ElementSetSpec(NULL, $oc, 0)
  750. { $$ = NewObjectSet(eObjectSet_ObjectSet);
  751. $$->U.ObjectSet.ObjectClass = $oc;
  752. $$->U.ObjectSet.Elements = $1;
  753. }
  754. | "..."
  755. { $$ = NewObjectSet(eObjectSet_ExtensionMarker);
  756. $$->U.ExtensionMarker.ObjectClass = $oc;
  757. }
  758. ;
  759. ObjectSetElements(oc)
  760. : ObjectSetFromObjects
  761. { $$ = NewObjectSetElement(eObjectSetElement_ObjectSet);
  762. $$->U.ObjectSet.ObjectSet = $1;
  763. }
  764. | Object($oc)
  765. { $$ = NewObjectSetElement(eObjectSetElement_Object);
  766. $$->U.Object.Object = $1;
  767. }
  768. | DefinedObjectSet
  769. { $$ = NewObjectSetElement(eObjectSetElement_ObjectSet);
  770. $$->U.ObjectSet.ObjectSet = $1;
  771. }
  772. | ParameterizedObjectSet
  773. { MyAbort();
  774. }
  775. ;
  776. ObjectClassFieldType
  777. : DefinedObjectClass '.' FieldName($1)
  778. { FieldSpec_t *fs;
  779. fs = GetFieldSpecFromObjectClass($>>.Assignments, $1, $3);
  780. if (!fs) {
  781. $$ = NewType(eType_Undefined);
  782. } else {
  783. switch (fs->Type) {
  784. case eFieldSpec_Type:
  785. case eFieldSpec_VariableTypeValue:
  786. case eFieldSpec_VariableTypeValueSet:
  787. $$ = NewType(eType_Open);
  788. break;
  789. case eFieldSpec_FixedTypeValue:
  790. $$ = fs->U.FixedTypeValue.Type;
  791. break;
  792. case eFieldSpec_FixedTypeValueSet:
  793. $$ = fs->U.FixedTypeValueSet.Type;
  794. break;
  795. case eFieldSpec_Object:
  796. LLFAILED((&@1, "Object field not permitted"));
  797. /*NOTREACHED*/
  798. case eFieldSpec_ObjectSet:
  799. LLFAILED((&@1, "ObjectSet field not permitted"));
  800. /*NOTREACHED*/
  801. default:
  802. MyAbort();
  803. }
  804. }
  805. }
  806. ;
  807. ObjectClassFieldValue(type)
  808. : OpenTypeFieldVal
  809. { $$ = $1;
  810. }
  811. | FixedTypeFieldVal($type)
  812. { $$ = $1;
  813. }
  814. ;
  815. OpenTypeFieldVal
  816. : Type ':' Value($1)
  817. { $$ = $3;
  818. }
  819. ;
  820. FixedTypeFieldVal(type)
  821. : BuiltinValue($type)
  822. { $$ = $1;
  823. }
  824. | ReferencedValue
  825. { $$ = $1;
  826. }
  827. ;
  828. %comment
  829. InformationFromObjects
  830. : ValueFromObject
  831. | ValueSetFromObjects
  832. | TypeFromObject
  833. | ObjectFromObject
  834. | ObjectSetFromObjects
  835. ;
  836. %endcomment
  837. %comment
  838. ValueFromObject
  839. : OBJ_XXX1
  840. ;
  841. ValueSetFromObjects
  842. : OBJ_XXX1
  843. ;
  844. TypeFromObject
  845. : OBJ_XXX1
  846. ;
  847. ObjectFromObject
  848. : OBJ_XXX1
  849. ;
  850. ObjectSetFromObjects
  851. : OBJ_XXX1
  852. ;
  853. %endcomment
  854. ValueFromObject
  855. : ReferencedObjects '.'
  856. { Object_t *o;
  857. ObjectClass_t *oc;
  858. o = GetObject($>2.Assignments, $1);
  859. oc = o ? o->U.Object.ObjectClass : NULL;
  860. }
  861. FieldName(oc)
  862. { FieldSpec_t *fs;
  863. FieldSpecs_e fe;
  864. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  865. fe = GetFieldSpecType($>>.Assignments, fs);
  866. if (fe != eFieldSpec_Undefined &&
  867. fe != eFieldSpec_FixedTypeValue &&
  868. fe != eFieldSpec_VariableTypeValue)
  869. LLFAILED((&@2, "Bad field type"));
  870. if (fe != eFieldSpec_Undefined) {
  871. $$ = GetValueFromObject($>>.Assignments, $1, $3);
  872. } else {
  873. $$ = NULL;
  874. }
  875. }
  876. ;
  877. ValueSetFromObjects
  878. : ReferencedObjects '.'
  879. { Object_t *o;
  880. ObjectClass_t *oc;
  881. o = GetObject($>2.Assignments, $1);
  882. oc = o ? o->U.Object.ObjectClass : NULL;
  883. }
  884. FieldName(oc)
  885. { FieldSpec_t *fs;
  886. FieldSpecs_e fe;
  887. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  888. fe = GetFieldSpecType($>>.Assignments, fs);
  889. if (fe != eFieldSpec_Undefined &&
  890. fe != eFieldSpec_FixedTypeValueSet &&
  891. fe != eFieldSpec_VariableTypeValueSet)
  892. LLFAILED((&@2, "Bad field type"));
  893. if (fe != eFieldSpec_Undefined) {
  894. $$ = GetValueSetFromObject($>>.Assignments, $1, $3);
  895. } else {
  896. $$ = NULL;
  897. }
  898. }
  899. | ReferencedObjectSets '.'
  900. { ObjectSet_t *os;
  901. ObjectClass_t *oc;
  902. os = GetObjectSet($>2.Assignments, $1);
  903. oc = os && os->Type == eObjectSet_ObjectSet ?
  904. os->U.ObjectSet.ObjectClass : NULL;
  905. }
  906. FieldName(oc)
  907. { FieldSpec_t *fs;
  908. FieldSpecs_e fe;
  909. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  910. fe = GetFieldSpecType($>>.Assignments, fs);
  911. if (fe != eFieldSpec_Undefined &&
  912. fe != eFieldSpec_FixedTypeValue &&
  913. fe != eFieldSpec_FixedTypeValueSet)
  914. LLFAILED((&@2, "Bad field type"));
  915. if (fe != eFieldSpec_Undefined) {
  916. $$ = GetValueSetFromObjectSet($>>.Assignments, $1, $3);
  917. } else {
  918. $$ = NULL;
  919. }
  920. }
  921. ;
  922. TypeFromObject
  923. : ReferencedObjects '.'
  924. { Object_t *o;
  925. ObjectClass_t *oc;
  926. o = GetObject($>2.Assignments, $1);
  927. oc = o ? o->U.Object.ObjectClass : NULL;
  928. }
  929. FieldName(oc)
  930. { FieldSpec_t *fs;
  931. FieldSpecs_e fe;
  932. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  933. fe = GetFieldSpecType($>>.Assignments, fs);
  934. if (fe != eFieldSpec_Undefined &&
  935. fe != eFieldSpec_Type)
  936. LLFAILED((&@2, "Bad field type"));
  937. if (fe != eFieldSpec_Undefined)
  938. $$ = GetTypeFromObject($>>.Assignments, $1, $3);
  939. else
  940. $$ = NULL;
  941. }
  942. ;
  943. ObjectFromObject
  944. : ReferencedObjects '.'
  945. { Object_t *o;
  946. ObjectClass_t *oc;
  947. o = GetObject($>2.Assignments, $1);
  948. oc = o ? o->U.Object.ObjectClass : NULL;
  949. }
  950. FieldName(oc)
  951. { FieldSpec_t *fs;
  952. FieldSpecs_e fe;
  953. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  954. fe = GetFieldSpecType($>>.Assignments, fs);
  955. if (fe != eFieldSpec_Undefined &&
  956. fe != eFieldSpec_Object)
  957. LLFAILED((&@2, "Bad field type"));
  958. if (fe != eFieldSpec_Undefined)
  959. $$ = GetObjectFromObject($>>.Assignments, $1, $3);
  960. else
  961. $$ = NULL;
  962. }
  963. ;
  964. ObjectSetFromObjects
  965. : ReferencedObjects '.'
  966. { Object_t *o;
  967. ObjectClass_t *oc;
  968. o = GetObject($>2.Assignments, $1);
  969. oc = o ? o->U.Object.ObjectClass : NULL;
  970. }
  971. FieldName(oc)
  972. { FieldSpec_t *fs;
  973. FieldSpecs_e fe;
  974. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  975. fe = GetFieldSpecType($>>.Assignments, fs);
  976. if (fe != eFieldSpec_Undefined &&
  977. fe != eFieldSpec_ObjectSet)
  978. LLFAILED((&@2, "Bad field type"));
  979. if (fe != eFieldSpec_Undefined)
  980. $$ = GetObjectSetFromObject($>>.Assignments, $1, $3);
  981. else
  982. $$ = NULL;
  983. }
  984. | ReferencedObjectSets '.'
  985. { ObjectSet_t *os;
  986. ObjectClass_t *oc;
  987. os = GetObjectSet($>2.Assignments, $1);
  988. oc = os ? os->U.OE.ObjectClass : NULL;
  989. }
  990. FieldName(oc)
  991. { FieldSpec_t *fs;
  992. FieldSpecs_e fe;
  993. fs = GetFieldSpecFromObjectClass($>>.Assignments, oc, $3);
  994. fe = GetFieldSpecType($>>.Assignments, fs);
  995. if (fe != eFieldSpec_Undefined &&
  996. fe != eFieldSpec_Object &&
  997. fe != eFieldSpec_ObjectSet)
  998. LLFAILED((&@2, "Bad field type"));
  999. if (fe != eFieldSpec_Undefined)
  1000. $$ = GetObjectSetFromObjectSet($>>.Assignments, $1, $3);
  1001. else
  1002. $$ = NULL;
  1003. }
  1004. ;
  1005. ReferencedObjects
  1006. : DefinedObject
  1007. { $$ = $1;
  1008. }
  1009. | ParameterizedObject
  1010. { MyAbort();
  1011. }
  1012. ;
  1013. ReferencedObjectSets
  1014. : DefinedObjectSet
  1015. { $$ = $1;
  1016. }
  1017. | ParameterizedObjectSet
  1018. { MyAbort();
  1019. }
  1020. ;
  1021. InstanceOfType
  1022. : "INSTANCE" "OF" DefinedObjectClass
  1023. { Component_t *co1, *co2;
  1024. Type_t *ty;
  1025. $$ = NewType(eType_InstanceOf);
  1026. $$->U.Sequence.Components = co1 = NewComponent(eComponent_Normal);
  1027. co1->Next = co2 = NewComponent(eComponent_Normal);
  1028. ty = NewType(eType_FieldReference);
  1029. ty->U.FieldReference.Identifier = "&id";
  1030. ty->U.FieldReference.ObjectClass = $3;
  1031. co1->U.Normal.NamedType = NewNamedType("type-id", ty);
  1032. ty = NewType(eType_FieldReference);
  1033. ty->Tags = NewTag(eTagType_Explicit);
  1034. ty->Tags->Tag = Builtin_Value_Integer_0;
  1035. ty->U.FieldReference.Identifier = "&Type";
  1036. ty->U.FieldReference.ObjectClass = $3;
  1037. co2->U.Normal.NamedType = NewNamedType("value", ty);
  1038. }
  1039. ;
  1040. InstanceOfValue(type)
  1041. : SequenceValue($type)
  1042. { $$ = $1;
  1043. }
  1044. ;