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.

563 lines
13 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  3. %token CON_XXX1
  4. %token CON_XXX2
  5. %type <XConstraints> Constraint<XType><XBoolean>
  6. %type <XConstraints> ConstraintSpec<XType><XBoolean>
  7. %type <XConstraints> SubtypeConstraint<XType><XBoolean>
  8. %type <XConstraints> ElementSetSpecs<XType><XBoolean>
  9. %type <XConstraints> ElementSetSpecExtension<XType><XBoolean>
  10. %type <XElementSetSpec> AdditionalElementSetSpec<XType><XBoolean>
  11. %type <XElementSetSpec> ElementSetSpec<XType><XObjectClass><XBoolean>
  12. %type <XElementSetSpec> Unions<XType><XObjectClass><XBoolean>
  13. %type <XElementSetSpec> UnionList<XType><XObjectClass><XBoolean>
  14. %type <XElementSetSpec> Intersections<XType><XObjectClass><XBoolean>
  15. %type <XElementSetSpec> IntersectionList<XType><XObjectClass><XBoolean>
  16. %type <XElementSetSpec> IntersectionElements<XType><XObjectClass><XBoolean>
  17. %type <XElementSetSpec> Exclusions_Opt<XType><XObjectClass><XBoolean>
  18. %type <XElementSetSpec> Exclusions<XType><XObjectClass><XBoolean>
  19. %type <XElementSetSpec> Elements<XType><XObjectClass><XBoolean>
  20. %type <XSubtypeElement> SubtypeElements<XType><XBoolean>
  21. %type <XSubtypeElement> SingleValue<XType>
  22. %type <XSubtypeElement> ContainedSubtype<XType>
  23. %type <XBoolean> Includes
  24. %type <XSubtypeElement> ValueRange<XType>
  25. %type <XEndPoint> LowerEndpoint<XType>
  26. %type <XEndPoint> UpperEndpoint<XType>
  27. %type <XEndPoint> LowerEndValue<XType>
  28. %type <XEndPoint> UpperEndValue<XType>
  29. %type <XSubtypeElement> SizeConstraint
  30. %type <XSubtypeElement> TypeConstraint
  31. %type <XSubtypeElement> PermittedAlphabet<XType>
  32. %type <XSubtypeElement> InnerTypeConstraints<XType>
  33. %type <XSubtypeElement> SingleTypeConstraint<XType>
  34. %type <XSubtypeElement> MultipleTypeConstraints<XComponents>
  35. %type <XSubtypeElement> FullSpecification<XComponents>
  36. %type <XSubtypeElement> PartialSpecification<XComponents>
  37. %type <XNamedConstraints> TypeConstraints<XComponents>
  38. %type <XNamedConstraints> NamedConstraint<XComponents>
  39. %type <XNamedConstraints> ComponentConstraint<XType>
  40. %type <XConstraints> ValueConstraint<XType>
  41. %type <XPresence> PresenceConstraint
  42. %%
  43. Constraint(type, permalpha)
  44. : '(' ConstraintSpec($type, $permalpha) ExceptionSpec ')'
  45. { $$ = $2; /*XXX ExceptionSpec */
  46. }
  47. ;
  48. ConstraintSpec(type, permalpha)
  49. : SubtypeConstraint($type, $permalpha)
  50. { $$ = $1;
  51. }
  52. | GeneralConstraint
  53. { $$ = NULL; /*XXX*/
  54. }
  55. ;
  56. SubtypeConstraint(type, permalpha)
  57. : ElementSetSpecs($type, $permalpha)
  58. { $$ = $1;
  59. }
  60. ;
  61. ExceptionSpec
  62. : '!' ExceptionIdentification
  63. | /* empty */
  64. ;
  65. ExceptionIdentification
  66. : SignedNumber(Builtin_Type_Integer)
  67. | DefinedValue
  68. | Type ':' Value($1)
  69. ;
  70. ElementSetSpecs(type, permalpha)
  71. : ElementSetSpec($type, NULL, $permalpha)
  72. ElementSetSpecExtension($type, $permalpha)
  73. { if ($2) {
  74. $$ = DupConstraint($2);
  75. } else {
  76. $$ = NewConstraint();
  77. }
  78. $$->Root = $1;
  79. }
  80. | "..." AdditionalElementSetSpec($type, $permalpha)
  81. { $$ = NewConstraint();
  82. $$->Type = $2 ? eExtension_Extended : eExtension_Extendable;
  83. $$->Additional = $2;
  84. }
  85. ;
  86. ElementSetSpecExtension(type, permalpha)
  87. : ',' "..." AdditionalElementSetSpec($type, $permalpha)
  88. { $$ = NewConstraint();
  89. $$->Type = $3 ? eExtension_Extended : eExtension_Extendable;
  90. $$->Additional = $3;
  91. }
  92. | /* empty */
  93. { $$ = NULL;
  94. }
  95. ;
  96. AdditionalElementSetSpec(type, permalpha)
  97. : ',' ElementSetSpec($type, NULL, $permalpha)
  98. { $$ = $2;
  99. }
  100. | /* empty */
  101. { $$ = NULL;
  102. }
  103. ;
  104. ElementSetSpec(type, objectclass, permalpha)
  105. : Unions($type, $objectclass, $permalpha)
  106. { $$ = $1;
  107. }
  108. | "ALL" Exclusions($type, $objectclass, $permalpha)
  109. { $$ = NewElementSetSpec(eElementSetSpec_AllExcept);
  110. $$->U.AllExcept.Elements = $2;
  111. }
  112. ;
  113. Unions(type, objectclass, permalpha)
  114. : Intersections($type, $objectclass, $permalpha)
  115. UnionList($type, $objectclass, $permalpha)
  116. { if ($2) {
  117. $$ = NewElementSetSpec(eElementSetSpec_Union);
  118. $$->U.Union.Elements1 = $1;
  119. $$->U.Union.Elements2 = $2;
  120. } else {
  121. $$ = $1;
  122. }
  123. }
  124. ;
  125. UnionList(type, objectclass, permalpha)
  126. : UnionMark Unions($type, $objectclass, $permalpha)
  127. { $$ = $2;
  128. }
  129. | /* empty */
  130. { $$ = NULL;
  131. }
  132. ;
  133. Intersections(type, objectclass, permalpha)
  134. : IntersectionElements($type, $objectclass, $permalpha)
  135. IntersectionList($type, $objectclass, $permalpha)
  136. { if ($2) {
  137. $$ = NewElementSetSpec(eElementSetSpec_Intersection);
  138. $$->U.Intersection.Elements1 = $1;
  139. $$->U.Intersection.Elements2 = $2;
  140. } else {
  141. $$ = $1;
  142. }
  143. }
  144. ;
  145. IntersectionList(type, objectclass, permalpha)
  146. : IntersectionMark Intersections($type, $objectclass, $permalpha)
  147. { $$ = $2;
  148. }
  149. | /* empty */
  150. { $$ = NULL;
  151. }
  152. ;
  153. IntersectionElements(type, objectclass, permalpha)
  154. : Elements($type, $objectclass, $permalpha)
  155. Exclusions_Opt($type, $objectclass, $permalpha)
  156. { if ($2) {
  157. $$ = NewElementSetSpec(eElementSetSpec_Exclusion);
  158. $$->U.Exclusion.Elements1 = $1;
  159. $$->U.Exclusion.Elements2 = $2;
  160. } else {
  161. $$ = $1;
  162. }
  163. }
  164. ;
  165. Exclusions_Opt(type, objectclass, permalpha)
  166. : Exclusions($type, $objectclass, $permalpha)
  167. { $$ = $1;
  168. }
  169. | /* empty */
  170. { $$ = NULL;
  171. }
  172. ;
  173. Exclusions(type, objectclass, permalpha)
  174. : "EXCEPT" Elements($type, $objectclass, $permalpha)
  175. { $$ = $2;
  176. }
  177. ;
  178. UnionMark
  179. : '|'
  180. | "UNION"
  181. ;
  182. IntersectionMark
  183. : '^'
  184. | "INTERSECTION"
  185. ;
  186. Elements(type, objectclass, permalpha)
  187. :
  188. { if ($objectclass)
  189. LLFAILED((&@@, "Bad object set"));
  190. }
  191. SubtypeElements($type, $permalpha)
  192. { $$ = NewElementSetSpec(eElementSetSpec_SubtypeElement);
  193. $$->U.SubtypeElement.SubtypeElement = $1;
  194. }
  195. |
  196. { if ($type)
  197. LLFAILED((&@@, "Bad constraint"));
  198. }
  199. ObjectSetElements($objectclass)
  200. { $$ = NewElementSetSpec(eElementSetSpec_ObjectSetElement);
  201. $$->U.ObjectSetElement.ObjectSetElement = $1;
  202. }
  203. | '(' ElementSetSpec($type, $objectclass, $permalpha) ')'
  204. { $$ = $2;
  205. }
  206. ;
  207. SubtypeElements(type, permalpha)
  208. :
  209. { Type_e type;
  210. type = GetTypeType($<<.Assignments, $type);
  211. if (type == eType_Open)
  212. LLFAILED((&@@, "Bad constraint"));
  213. }
  214. SingleValue($type)
  215. { $$ = $1;
  216. }
  217. |
  218. { Type_e type;
  219. type = GetTypeType($<<.Assignments, $type);
  220. if (type == eType_EmbeddedPdv ||
  221. type == eType_External ||
  222. type == eType_Open ||
  223. type == eType_CharacterString)
  224. LLFAILED((&@@, "Bad constraint"));
  225. }
  226. ContainedSubtype($type)
  227. { $$ = $1;
  228. }
  229. |
  230. { Type_e type;
  231. type = GetTypeType($<<.Assignments, $type);
  232. if ($permalpha ?
  233. (type != eType_Undefined &&
  234. type != eType_BMPString &&
  235. type != eType_IA5String &&
  236. type != eType_NumericString &&
  237. type != eType_PrintableString &&
  238. type != eType_VisibleString &&
  239. type != eType_UniversalString) :
  240. (type != eType_Undefined &&
  241. type != eType_Integer &&
  242. type != eType_Real))
  243. LLFAILED((&@@, "Bad constraint"));
  244. }
  245. ValueRange($type)
  246. { $$ = $1;
  247. }
  248. |
  249. { Type_e type;
  250. type = GetTypeType($<<.Assignments, $type);
  251. if (type != eType_Undefined &&
  252. !IsRestrictedString(type) ||
  253. $permalpha)
  254. LLFAILED((&@@, "Bad constraint"));
  255. }
  256. PermittedAlphabet($type)
  257. { $$ = $1;
  258. }
  259. |
  260. { Type_e type;
  261. type = GetTypeType($<<.Assignments, $type);
  262. if (type != eType_Undefined &&
  263. type != eType_BitString &&
  264. type != eType_OctetString &&
  265. type != eType_UTF8String &&
  266. type != eType_SequenceOf &&
  267. type != eType_SetOf &&
  268. type != eType_CharacterString &&
  269. !IsRestrictedString(type) ||
  270. $permalpha)
  271. LLFAILED((&@@, "Bad constraint"));
  272. }
  273. SizeConstraint
  274. { $$ = $1;
  275. }
  276. |
  277. { Type_e type;
  278. type = GetTypeType($<<.Assignments, $type);
  279. if (type != eType_Undefined &&
  280. type != eType_Open ||
  281. $permalpha)
  282. LLFAILED((&@@, "Bad constraint"));
  283. }
  284. TypeConstraint
  285. { $$ = $1;
  286. }
  287. |
  288. { Type_e type;
  289. type = GetTypeType($<<.Assignments, $type);
  290. if (type != eType_Undefined &&
  291. type != eType_Choice &&
  292. type != eType_EmbeddedPdv &&
  293. type != eType_External &&
  294. type != eType_InstanceOf &&
  295. type != eType_Real &&
  296. type != eType_Sequence &&
  297. type != eType_SequenceOf &&
  298. type != eType_Set &&
  299. type != eType_SetOf &&
  300. type != eType_CharacterString ||
  301. $permalpha)
  302. LLFAILED((&@@, "Bad constraint"));
  303. }
  304. InnerTypeConstraints($type)
  305. { $$ = $1;
  306. }
  307. ;
  308. SingleValue(type)
  309. : Value($type)
  310. { $$ = NewSubtypeElement(eSubtypeElement_SingleValue);
  311. $$->U.SingleValue.Value = $1;
  312. }
  313. ;
  314. ContainedSubtype(type)
  315. : Includes Type
  316. { if (GetTypeType($>>.Assignments, $2) == eType_Null && !$1)
  317. LLFAILED((&@1, "Bad constraint"));
  318. if (GetTypeType($>>.Assignments, $type) != eType_Undefined &&
  319. GetTypeType($>>.Assignments, $2) != eType_Undefined &&
  320. GetTypeType($>>.Assignments, $type) !=
  321. GetTypeType($>>.Assignments, $2) &&
  322. GetTypeType($>>.Assignments, $type) != eType_Open &&
  323. GetTypeType($>>.Assignments, $2) != eType_Open &&
  324. (!IsRestrictedString(GetTypeType($>>.Assignments, $type)) ||
  325. !IsRestrictedString(GetTypeType($>>.Assignments, $2))))
  326. LLFAILED((&@2, "Bad type of contained-subtype-constraint"));
  327. $$ = NewSubtypeElement(eSubtypeElement_ContainedSubtype);
  328. $$->U.ContainedSubtype.Type = $2;
  329. }
  330. ;
  331. Includes
  332. : "INCLUDES"
  333. { $$ = 1;
  334. }
  335. | /* empty */
  336. { $$ = 0;
  337. }
  338. ;
  339. ValueRange(type)
  340. : LowerEndpoint($type) ".." UpperEndpoint($type)
  341. { if (!$type) {
  342. $$ = NULL;
  343. } else {
  344. $$ = NewSubtypeElement(eSubtypeElement_ValueRange);
  345. $$->U.ValueRange.Lower = $1;
  346. $$->U.ValueRange.Upper = $3;
  347. }
  348. }
  349. ;
  350. LowerEndpoint(type)
  351. : LowerEndValue($type) '<'
  352. { $$ = $1;
  353. $$.Flags |= eEndPoint_Open;
  354. }
  355. | LowerEndValue($type)
  356. { $$ = $1;
  357. }
  358. ;
  359. UpperEndpoint(type)
  360. : '<' UpperEndValue($type)
  361. { $$ = $2;
  362. $$.Flags |= eEndPoint_Open;
  363. }
  364. | UpperEndValue($type)
  365. { $$ = $1;
  366. }
  367. ;
  368. LowerEndValue(type)
  369. : Value($type)
  370. { $$.Value = $1;
  371. $$.Flags = 0;
  372. }
  373. | "MIN"
  374. { $$.Value = NULL;
  375. $$.Flags = eEndPoint_Min;
  376. }
  377. ;
  378. UpperEndValue(type)
  379. : Value($type)
  380. { $$.Value = $1;
  381. $$.Flags = 0;
  382. }
  383. | "MAX"
  384. { $$.Value = NULL;
  385. $$.Flags = eEndPoint_Max;
  386. }
  387. ;
  388. SizeConstraint
  389. : "SIZE" Constraint(Builtin_Type_PositiveInteger, 0)
  390. { $$ = NewSubtypeElement(eSubtypeElement_Size);
  391. $$->U.Size.Constraints = $2;
  392. }
  393. ;
  394. TypeConstraint
  395. : Type
  396. { $$ = NewSubtypeElement(eSubtypeElement_Type);
  397. $$->U.Type.Type = $1;
  398. }
  399. ;
  400. PermittedAlphabet(type)
  401. : "FROM" Constraint($type, 1)
  402. { $$ = NewSubtypeElement(eSubtypeElement_PermittedAlphabet);
  403. $$->U.PermittedAlphabet.Constraints = $2;
  404. }
  405. ;
  406. InnerTypeConstraints(type)
  407. :
  408. { Type_t *subtype;
  409. if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  410. GetTypeType($<<.Assignments, $type) != eType_SequenceOf &&
  411. GetTypeType($<<.Assignments, $type) != eType_SetOf)
  412. LLFAILED((&@@, "Bad constraint"));
  413. if (GetTypeType($<<.Assignments, $type) == eType_Undefined)
  414. subtype = NULL;
  415. else
  416. subtype = GetType($<<.Assignments, $type)->U.SS.Type;
  417. }
  418. "WITH" "COMPONENT" SingleTypeConstraint(subtype)
  419. { $$ = $3;
  420. }
  421. |
  422. { Component_t *components;
  423. if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  424. GetTypeType($<<.Assignments, $type) != eType_Sequence &&
  425. GetTypeType($<<.Assignments, $type) != eType_Set &&
  426. GetTypeType($<<.Assignments, $type) != eType_Choice &&
  427. GetTypeType($<<.Assignments, $type) != eType_Real &&
  428. GetTypeType($<<.Assignments, $type) != eType_External &&
  429. GetTypeType($<<.Assignments, $type) != eType_EmbeddedPdv &&
  430. GetTypeType($<<.Assignments, $type) != eType_CharacterString)
  431. LLFAILED((&@@, "Bad constraint"));
  432. if (GetTypeType($<<.Assignments, $type) == eType_Undefined)
  433. components = NULL;
  434. else
  435. components = GetType($<<.Assignments, $type)->U.SSC.Components;
  436. }
  437. "WITH" "COMPONENTS" MultipleTypeConstraints(components)
  438. { $$ = $3;
  439. }
  440. ;
  441. SingleTypeConstraint(type)
  442. : Constraint($type, 0)
  443. { $$ = NewSubtypeElement(eSubtypeElement_SingleType);
  444. $$->U.SingleType.Constraints = $1;
  445. }
  446. ;
  447. MultipleTypeConstraints(components)
  448. : FullSpecification($components)
  449. { $$ = $1;
  450. }
  451. | PartialSpecification($components)
  452. { $$ = $1;
  453. }
  454. ;
  455. FullSpecification(components)
  456. : '{' TypeConstraints($components) '}'
  457. { $$ = NewSubtypeElement(eSubtypeElement_FullSpecification);
  458. $$->U.FullSpecification.NamedConstraints = $2;
  459. }
  460. ;
  461. PartialSpecification(components)
  462. : '{' "..." ',' TypeConstraints($components) '}'
  463. { $$ = NewSubtypeElement(eSubtypeElement_PartialSpecification);
  464. $$->U.PartialSpecification.NamedConstraints = $4;
  465. }
  466. ;
  467. TypeConstraints(components)
  468. : NamedConstraint($components)
  469. { $$ = $1;
  470. }
  471. | NamedConstraint($components) ',' TypeConstraints($components)
  472. { $$ = $1;
  473. $$->Next = $3;
  474. }
  475. ;
  476. NamedConstraint(components)
  477. : identifier
  478. { Component_t *component;
  479. Type_t *type;
  480. component = FindComponent($>1.Assignments, $components, $1);
  481. type = component ? component->U.NOD.NamedType->Type : NULL;
  482. }
  483. ComponentConstraint(type)
  484. { $$ = $2;
  485. $$->Identifier = $1;
  486. }
  487. ;
  488. ComponentConstraint(type)
  489. : ValueConstraint($type) PresenceConstraint
  490. { $$ = NewNamedConstraint();
  491. $$->Constraint = $1;
  492. $$->Presence = $2;
  493. }
  494. ;
  495. ValueConstraint(type)
  496. : Constraint($type, 0)
  497. { $$ = $1;
  498. }
  499. | /* empty */
  500. { $$ = NULL;
  501. }
  502. ;
  503. PresenceConstraint
  504. : "PRESENT"
  505. { $$ = ePresence_Present;
  506. }
  507. | "ABSENT"
  508. { $$ = ePresence_Absent;
  509. }
  510. | "OPTIONAL"
  511. { $$ = ePresence_Optional;
  512. }
  513. | /* empty */
  514. { $$ = ePresence_Normal;
  515. }
  516. ;
  517. GeneralConstraint
  518. : CON_XXX1 { MyAbort(); } ;