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.

1039 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. %type <XValue> DefinedValue
  4. %type <XValue> Value<XType>
  5. %type <XValue> BuiltinValue<XType>
  6. %type <XValue> ReferencedValue
  7. %type <XNamedValues> NamedValue<XComponents>
  8. %type <XValue> BooleanValue<XType>
  9. %type <XValue> SignedNumber<XType>
  10. %type <XValue> IntegerValue<XType>
  11. %type <XValue> EnumeratedValue<XType>
  12. %type <XValue> RealValue<XType>
  13. %type <XValue> NumericRealValue<XType>
  14. %type <XValue> SpecialRealValue<XType>
  15. %type <XValue> BitStringValue<XType>
  16. %type <XValue> IdentifierList<XType>
  17. %type <XValue> Identifier_EList<XType>
  18. %type <XValue> IdentifierList_Elem<XType>
  19. %type <XValue> OctetStringValue<XType>
  20. %type <XValue> NullValue<XType>
  21. %type <XValue> GeneralizedTimeValue<XType>
  22. %type <XValue> UTCTimeValue<XType>
  23. %type <XValue> ObjectDescriptorValue<XType>
  24. %type <XValue> SequenceValue<XType>
  25. %type <XNamedValues> ComponentValueList<XComponents>
  26. %type <XNamedValues> ComponentValueCList<XComponents>
  27. %type <XValue> SequenceOfValue<XType>
  28. %type <XValue> ValueList<XType>
  29. %type <XValue> ValueCList<XType>
  30. %type <XValue> SetValue<XType>
  31. %type <XValue> SetOfValue<XType>
  32. %type <XValue> ChoiceValue<XType>
  33. %type <XValue> ObjectIdentifierValue
  34. %type <XNamedObjIdValue> ObjIdComponentList
  35. %type <XNamedObjIdValue> ObjIdComponent_ESeq
  36. %type <XNamedObjIdValue> ObjIdComponent
  37. %type <XNamedObjIdValue> NameForm
  38. %type <XNamedObjIdValue> NumberForm
  39. %type <XNamedObjIdValue> NameAndNumberForm
  40. %type <XValue> EmbeddedPDVValue<XType>
  41. %type <XValue> ExternalValue<XType>
  42. %type <XValue> CharacterStringValue<XType>
  43. %type <XValue> RestrictedCharacterStringValue<XType>
  44. %type <XValue> UnrestrictedCharacterStringValue<XType>
  45. %type <XValue> CharacterStringList<XType>
  46. %type <XValue> CharSyms<XType>
  47. %type <XValue> CharDefn<XType>
  48. %type <XQuadruple> Quadruple
  49. %type <XTuple> Tuple
  50. %type <XValue> AnyValue<XType>
  51. %%
  52. DefinedValue
  53. : Externalvaluereference
  54. { $$ = $1;
  55. }
  56. | valuereference
  57. { $$ = $1;
  58. }
  59. | ParameterizedValue
  60. { MyAbort();
  61. }
  62. ;
  63. ValueAssignment
  64. : valuereference Type "::=" Value($2)
  65. { if (!AssignValue(&$>>.Assignments, $1, $4))
  66. LLFAILED((&@1, "Value `%s' twice defined",
  67. $1->U.Reference.Identifier));
  68. }
  69. ;
  70. Value(type)
  71. : BuiltinValue($type)
  72. { $$ = $1;
  73. }
  74. | ReferencedValue
  75. { $$ = $1;
  76. }
  77. | ObjectClassFieldValue($type)
  78. { $$ = $1;
  79. }
  80. ;
  81. BuiltinValue(type)
  82. :
  83. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  84. GetTypeType($<<.Assignments, $type) != eType_BitString)
  85. LLFAILED((&@@, "Bad type of value"));
  86. }
  87. BitStringValue($type)
  88. { $$ = $1;
  89. }
  90. |
  91. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  92. GetTypeType($<<.Assignments, $type) != eType_Boolean)
  93. LLFAILED((&@@, "Bad type of value"));
  94. }
  95. BooleanValue($type)
  96. { $$ = $1;
  97. }
  98. | CharacterStringValue($type)
  99. { $$ = $1;
  100. }
  101. |
  102. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  103. GetTypeType($<<.Assignments, $type) != eType_Choice)
  104. LLFAILED((&@@, "Bad type of value"));
  105. }
  106. ChoiceValue($type)
  107. { $$ = $1;
  108. }
  109. |
  110. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  111. GetTypeType($<<.Assignments, $type) != eType_EmbeddedPdv)
  112. LLFAILED((&@@, "Bad type of value"));
  113. }
  114. EmbeddedPDVValue($type)
  115. { $$ = $1;
  116. }
  117. |
  118. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  119. GetTypeType($<<.Assignments, $type) != eType_Enumerated)
  120. LLFAILED((&@@, "Bad type of value"));
  121. }
  122. EnumeratedValue($type)
  123. { $$ = $1;
  124. }
  125. |
  126. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  127. GetTypeType($<<.Assignments, $type) != eType_External)
  128. LLFAILED((&@@, "Bad type of value"));
  129. }
  130. ExternalValue($type)
  131. { $$ = $1;
  132. }
  133. |
  134. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  135. GetTypeType($<<.Assignments, $type) != eType_InstanceOf)
  136. LLFAILED((&@@, "Bad type of value"));
  137. }
  138. InstanceOfValue($type)
  139. { $$ = $1;
  140. }
  141. |
  142. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  143. GetTypeType($<<.Assignments, $type) != eType_Integer)
  144. LLFAILED((&@@, "Bad type of value"));
  145. }
  146. IntegerValue($type)
  147. { $$ = $1;
  148. }
  149. |
  150. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  151. GetTypeType($<<.Assignments, $type) != eType_Null)
  152. LLFAILED((&@@, "Bad type of value"));
  153. }
  154. NullValue($type)
  155. { $$ = $1;
  156. }
  157. |
  158. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  159. GetTypeType($<<.Assignments, $type) != eType_ObjectIdentifier)
  160. LLFAILED((&@@, "Bad type of value"));
  161. }
  162. ObjectIdentifierValue
  163. { $$ = $1;
  164. if ($1->Type != NULL)
  165. {
  166. PropagatePrivateDirectives($1->Type, &($type->PrivateDirectives));
  167. }
  168. }
  169. |
  170. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  171. GetTypeType($<<.Assignments, $type) != eType_OctetString)
  172. LLFAILED((&@@, "Bad type of value"));
  173. }
  174. OctetStringValue($type)
  175. { $$ = $1;
  176. }
  177. |
  178. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  179. GetTypeType($<<.Assignments, $type) != eType_Real)
  180. LLFAILED((&@@, "Bad type of value"));
  181. }
  182. RealValue($type)
  183. { $$ = $1;
  184. }
  185. |
  186. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  187. GetTypeType($<<.Assignments, $type) !=
  188. eType_GeneralizedTime)
  189. LLFAILED((&@@, "Bad type of value"));
  190. }
  191. GeneralizedTimeValue($type)
  192. { $$ = $1;
  193. }
  194. |
  195. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  196. GetTypeType($<<.Assignments, $type) != eType_UTCTime)
  197. LLFAILED((&@@, "Bad type of value"));
  198. }
  199. UTCTimeValue($type)
  200. { $$ = $1;
  201. }
  202. |
  203. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  204. GetTypeType($<<.Assignments, $type) != eType_ObjectDescriptor)
  205. LLFAILED((&@@, "Bad type of value"));
  206. }
  207. ObjectDescriptorValue($type)
  208. { $$ = $1;
  209. }
  210. |
  211. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  212. GetTypeType($<<.Assignments, $type) != eType_Sequence)
  213. LLFAILED((&@@, "Bad type of value"));
  214. }
  215. SequenceValue($type)
  216. { $$ = $1;
  217. }
  218. |
  219. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  220. GetTypeType($<<.Assignments, $type) != eType_SequenceOf)
  221. LLFAILED((&@@, "Bad type of value"));
  222. }
  223. SequenceOfValue($type)
  224. { $$ = $1;
  225. }
  226. |
  227. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  228. GetTypeType($<<.Assignments, $type) != eType_Set)
  229. LLFAILED((&@@, "Bad type of value"));
  230. }
  231. SetValue($type)
  232. { $$ = $1;
  233. }
  234. |
  235. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  236. GetTypeType($<<.Assignments, $type) != eType_SetOf)
  237. LLFAILED((&@@, "Bad type of value"));
  238. }
  239. SetOfValue($type)
  240. { $$ = $1;
  241. }
  242. |
  243. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  244. GetTypeType($<<.Assignments, $type) != eType_Open)
  245. LLFAILED((&@@, "Bad type of value"));
  246. }
  247. AnyValue($type)
  248. { $$ = $1;
  249. }
  250. |
  251. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  252. GetTypeType($<<.Assignments, $type) != eType_Macro)
  253. LLFAILED((&@@, "Bad type of value"));
  254. }
  255. MacroDefinedValue($type)
  256. { $$ = $1;
  257. }
  258. ;
  259. ReferencedValue
  260. : DefinedValue
  261. { $$ = $1;
  262. }
  263. | ValueFromObject
  264. { $$ = $1;
  265. }
  266. ;
  267. NamedValue(components)
  268. : identifier
  269. { Component_t *component;
  270. Type_t *type;
  271. component = FindComponent($<<.Assignments, $components, $1);
  272. if (component)
  273. type = component->U.NOD.NamedType->Type;
  274. else
  275. type = NULL;
  276. }
  277. Value(type)
  278. { $$ = NewNamedValue($1, $2);
  279. }
  280. ;
  281. BooleanValue(type)
  282. : "TRUE"
  283. { $$ = NewValue($>>.Assignments, $type);
  284. $$->U.Boolean.Value = 1;
  285. }
  286. | "FALSE"
  287. { $$ = NewValue($>>.Assignments, $type);
  288. $$->U.Boolean.Value = 0;
  289. }
  290. ;
  291. SignedNumber(type)
  292. : number
  293. { $$ = NewValue($>>.Assignments, $type);
  294. $$->U.Integer.Value = $1;
  295. }
  296. | '-' number
  297. { if (!intx_cmp(&$2, &intx_0))
  298. LLFAILED((&@2, "Bad negative value"));
  299. $$ = NewValue($>>.Assignments, $type);
  300. intx_neg(&$$->U.Integer.Value, &$2);
  301. }
  302. ;
  303. IntegerValue(type)
  304. : SignedNumber($type)
  305. { $$ = $1;
  306. }
  307. | identifier
  308. { NamedNumber_t *n;
  309. Type_t *type;
  310. type = GetType($>>.Assignments, $type);
  311. if (type) {
  312. n = FindNamedNumber(type->U.Integer.NamedNumbers, $1);
  313. if (!n)
  314. LLFAILED((&@1, "Undefined integer value"));
  315. $$ = NewValue($>>.Assignments, $type);
  316. intx_dup(&$$->U.Integer.Value,
  317. &n->U.Normal.Value->U.Integer.Value);
  318. } else {
  319. $$ = NULL;
  320. }
  321. }
  322. ;
  323. EnumeratedValue(type)
  324. : identifier
  325. { NamedNumber_t *n;
  326. Type_t *type;
  327. type = GetType($>>.Assignments, $type);
  328. if (type) {
  329. n = FindNamedNumber(type->U.Enumerated.NamedNumbers, $1);
  330. if (!n)
  331. LLFAILED((&@1, "Undefined enumeration value"));
  332. $$ = NewValue($>>.Assignments, $type);
  333. $$->U.Enumerated.Value =
  334. intx2uint32(&n->U.Normal.Value->U.Integer.Value);
  335. } else {
  336. $$ = NULL;
  337. }
  338. }
  339. ;
  340. RealValue(type)
  341. : NumericRealValue($type)
  342. { $$ = $1;
  343. }
  344. | SpecialRealValue($type)
  345. { $$ = $1;
  346. }
  347. ;
  348. NumericRealValue(type)
  349. : number /* only 0 allowed! */
  350. { if (intx_cmp(&$1, &intx_0))
  351. LLFAILED((&@1, "Bad real value"));
  352. $$ = NewValue($>>.Assignments, $type);
  353. }
  354. | SequenceValue($type)
  355. { NamedValue_t *mant, *expo, *base;
  356. mant = FindNamedValue($1->U.Sequence.NamedValues, "mantissa");
  357. expo = FindNamedValue($1->U.Sequence.NamedValues, "exponent");
  358. base = FindNamedValue($1->U.Sequence.NamedValues, "base");
  359. if (!mant || !expo || !base) {
  360. $$ = NULL;
  361. } else {
  362. $$ = NewValue($>>.Assignments, $type);
  363. intx_dup(&$$->U.Real.Value.mantissa,
  364. &mant->Value->U.Integer.Value);
  365. intx_dup(&$$->U.Real.Value.exponent,
  366. &expo->Value->U.Integer.Value);
  367. $$->U.Real.Value.base =
  368. intx2uint32(&base->Value->U.Integer.Value);
  369. }
  370. }
  371. ;
  372. SpecialRealValue(type)
  373. : "PLUS_INFINITY"
  374. { $$ = NewValue($>>.Assignments, $type);
  375. $$->U.Real.Value.type = eReal_PlusInfinity;
  376. }
  377. | "MINUS_INFINITY"
  378. { $$ = NewValue($>>.Assignments, $type);
  379. $$->U.Real.Value.type = eReal_MinusInfinity;
  380. }
  381. ;
  382. BitStringValue(type)
  383. : bstring
  384. { int i, len;
  385. if (GetTypeType($>>.Assignments, $type) == eType_BitString) {
  386. len = strlen($1);
  387. $$ = NewValue($>>.Assignments, $type);
  388. $$->U.BitString.Value.length = len;
  389. $$->U.BitString.Value.value =
  390. (octet_t *)malloc((len + 7) / 8);
  391. memset($$->U.BitString.Value.value, 0, (len + 7) / 8);
  392. for (i = 0; i < len; i++) {
  393. if ($1[i] == '1')
  394. ASN1BITSET($$->U.BitString.Value.value, i);
  395. }
  396. } else {
  397. $$ = NULL;
  398. }
  399. }
  400. | hstring
  401. { int i, len, c;
  402. if (GetTypeType($>>.Assignments, $type) == eType_BitString) {
  403. len = strlen($1);
  404. $$ = NewValue($>>.Assignments, $type);
  405. $$->U.BitString.Value.length = len * 4;
  406. $$->U.BitString.Value.value =
  407. (octet_t *)malloc((len + 1) / 2);
  408. memset($$->U.BitString.Value.value, 0, (len + 1) / 2);
  409. for (i = 0; i < len; i++) {
  410. c = isdigit($1[i]) ? $1[i] - '0' : $1[i] - 'A' + 10;
  411. $$->U.BitString.Value.value[i / 2] |=
  412. (i & 1) ? c : (c << 4);
  413. }
  414. } else {
  415. $$ = NULL;
  416. }
  417. }
  418. | '{' IdentifierList($type) '}'
  419. { $$ = $2;
  420. }
  421. | '{' '}'
  422. { $$ = NewValue($>>.Assignments, $type);
  423. }
  424. ;
  425. IdentifierList(type)
  426. : IdentifierList_Elem($type)
  427. Identifier_EList($type)
  428. { uint32_t bit, len;
  429. bitstring_t *src, *dst;
  430. if ($1 && $2) {
  431. bit = intx2uint32(&$1->U.Integer.Value);
  432. src = &$2->U.BitString.Value;
  433. len = bit + 1;
  434. if (len < src->length)
  435. len = src->length;
  436. $$ = DupValue($2);
  437. dst = &$$->U.BitString.Value;
  438. dst->length = len;
  439. dst->value = (octet_t *)malloc((len + 7) / 8);
  440. memcpy(dst->value, src->value, (src->length + 7) / 8);
  441. memset(dst->value + (src->length + 7) / 8, 0,
  442. (len + 7) / 8 - (src->length + 7) / 8);
  443. ASN1BITSET(dst->value, bit);
  444. } else if ($1) {
  445. bit = intx2uint32(&$1->U.Integer.Value);
  446. len = bit + 1;
  447. $$ = NewValue($>>.Assignments, $type);
  448. dst = &$$->U.BitString.Value;
  449. dst->length = len;
  450. dst->value = (octet_t *)malloc((len + 7) / 8);
  451. memset(dst->value, 0, (len + 7) / 8);
  452. ASN1BITSET(dst->value, bit);
  453. } else {
  454. $$ = NULL;
  455. }
  456. }
  457. ;
  458. Identifier_EList(type)
  459. : IdentifierList_Elem($type)
  460. Identifier_EList($type)
  461. { uint32_t bit, len;
  462. bitstring_t *src, *dst;
  463. if ($1 && $2) {
  464. bit = intx2uint32(&$1->U.Integer.Value);
  465. src = &$2->U.BitString.Value;
  466. len = bit + 1;
  467. if (len < src->length)
  468. len = src->length;
  469. $$ = DupValue($2);
  470. dst = &$$->U.BitString.Value;
  471. dst->length = len;
  472. dst->value = (octet_t *)malloc((len + 7) / 8);
  473. memcpy(dst->value, src->value, (src->length + 7) / 8);
  474. memset(dst->value + (src->length + 7) / 8, 0,
  475. (len + 7) / 8 - (src->length + 7) / 8);
  476. ASN1BITSET(dst->value, bit);
  477. } else if ($1) {
  478. bit = intx2uint32(&$1->U.Integer.Value);
  479. len = bit + 1;
  480. $$ = NewValue($>>.Assignments, $type);
  481. dst = &$$->U.BitString.Value;
  482. dst->length = len;
  483. dst->value = (octet_t *)malloc((len + 7) / 8);
  484. memset(dst->value, 0, (len + 7) / 8);
  485. ASN1BITSET(dst->value, bit);
  486. } else {
  487. $$ = NULL;
  488. }
  489. }
  490. | /* empty */
  491. { if ($type) {
  492. $$ = NewValue($>>.Assignments, $type);
  493. } else {
  494. $$ = NULL;
  495. }
  496. }
  497. ;
  498. IdentifierList_Elem(type)
  499. : identifier
  500. { Value_t *v;
  501. NamedNumber_t *n;
  502. Type_t *type;
  503. type = GetType($>>.Assignments, $type);
  504. if (type) {
  505. n = FindNamedNumber(type->U.BitString.NamedNumbers, $1);
  506. if (!n)
  507. LLFAILED((&@1, "Bad bit string value"));
  508. v = GetValue($>>.Assignments, n->U.Normal.Value);
  509. if (v) {
  510. if (GetTypeType($>>.Assignments, v->Type) != eType_Integer)
  511. MyAbort();
  512. $$ = v;
  513. } else {
  514. $$ = NULL;
  515. }
  516. } else {
  517. $$ = NULL;
  518. }
  519. }
  520. ;
  521. OctetStringValue(type)
  522. : bstring
  523. { int len, i;
  524. if (GetTypeType($>>.Assignments, $type) == eType_OctetString) {
  525. len = strlen($1);
  526. $$ = NewValue($>>.Assignments, $type);
  527. $$->U.OctetString.Value.length = (len + 7) / 8;
  528. $$->U.OctetString.Value.value =
  529. (octet_t *)malloc((len + 7) / 8);
  530. memset($$->U.OctetString.Value.value, 0, (len + 7) / 8);
  531. for (i = 0; i < len; i++) {
  532. if ($1[i] == '1')
  533. ASN1BITSET($$->U.OctetString.Value.value, i);
  534. }
  535. } else {
  536. $$ = NULL;
  537. }
  538. }
  539. | hstring
  540. { int i, len, c;
  541. if (GetTypeType($>>.Assignments, $type) == eType_OctetString) {
  542. len = strlen($1);
  543. $$ = NewValue($>>.Assignments, $type);
  544. $$->U.OctetString.Value.length = (len + 1) / 2;
  545. $$->U.OctetString.Value.value =
  546. (octet_t *)malloc((len + 1) / 2);
  547. memset($$->U.OctetString.Value.value, 0, (len + 1) / 2);
  548. for (i = 0; i < len; i++) {
  549. c = isdigit($1[i]) ? $1[i] - '0' : $1[i] - 'A' + 10;
  550. $$->U.OctetString.Value.value[i / 2] |=
  551. (i & 1) ? c : (c << 4);
  552. }
  553. } else {
  554. $$ = NULL;
  555. }
  556. }
  557. ;
  558. NullValue(type)
  559. : "NULL"
  560. { $$ = NewValue($>>.Assignments, $type);
  561. }
  562. ;
  563. GeneralizedTimeValue(type)
  564. : RestrictedCharacterStringValue($type)
  565. { $$ = NewValue($>>.Assignments, $type);
  566. if (!String2GeneralizedTime(&$$->U.GeneralizedTime.Value,
  567. &$1->U.RestrictedString.Value))
  568. LLFAILED((&@1, "Bad time value"));
  569. }
  570. ;
  571. UTCTimeValue(type)
  572. : RestrictedCharacterStringValue($type)
  573. { $$ = NewValue($>>.Assignments, $type);
  574. if (!String2UTCTime(&$$->U.UTCTime.Value,
  575. &$1->U.RestrictedString.Value))
  576. LLFAILED((&@1, "Bad time value"));
  577. }
  578. ;
  579. ObjectDescriptorValue(type)
  580. : RestrictedCharacterStringValue($type)
  581. { $$ = $1;
  582. }
  583. ;
  584. SequenceValue(type)
  585. : '{'
  586. { Component_t *components;
  587. Type_t *type;
  588. type = GetType($>1.Assignments, $type);
  589. components = type ? type->U.SSC.Components : NULL;
  590. }
  591. ComponentValueList(components) '}'
  592. { Component_t *c;
  593. NamedValue_t *v;
  594. if (type) {
  595. for (c = components, v = $2; c; c = c->Next) {
  596. switch (c->Type) {
  597. case eComponent_Normal:
  598. if (!v)
  599. LLFAILED((&@2,
  600. "Value for component `%s' is missing",
  601. c->U.NOD.NamedType->Identifier));
  602. if (strcmp(v->Identifier,
  603. c->U.NOD.NamedType->Identifier))
  604. LLFAILED((&@2, "Value for component `%s' expected",
  605. c->U.NOD.NamedType->Identifier));
  606. v = v->Next;
  607. break;
  608. case eComponent_Optional:
  609. case eComponent_Default:
  610. if (v && !strcmp(v->Identifier,
  611. c->U.NOD.NamedType->Identifier))
  612. v = v->Next;
  613. break;
  614. }
  615. }
  616. if (v)
  617. LLFAILED((&@2, "Component `%s' is unexpected",
  618. v->Identifier));
  619. }
  620. $$ = NewValue($>>.Assignments, $type);
  621. $$->U.SSC.NamedValues = $2;
  622. }
  623. | '{' '}'
  624. { $$ = NewValue($>>.Assignments, $type);
  625. }
  626. ;
  627. ComponentValueList(components)
  628. : NamedValue($components) ComponentValueCList($components)
  629. { if ($2) {
  630. $$ = DupNamedValue($1);
  631. $$->Next = $2;
  632. } else {
  633. $$ = $1;
  634. }
  635. }
  636. ;
  637. ComponentValueCList(components)
  638. : ',' ComponentValueList($components)
  639. { $$ = $2;
  640. }
  641. | /* empty */
  642. { $$ = NULL;
  643. }
  644. ;
  645. SequenceOfValue(type)
  646. : '{'
  647. { Type_t *type, *subtype;
  648. type = GetType($>1.Assignments, $type);
  649. subtype = (type ? type->U.SS.Type : NULL);
  650. }
  651. ValueList(subtype) '}'
  652. { $$ = NewValue($>>.Assignments, $type);
  653. $$->U.SequenceOf.Values = $2;
  654. }
  655. | '{' '}'
  656. { $$ = NewValue($>>.Assignments, $type);
  657. }
  658. ;
  659. ValueList(type)
  660. : Value($type) ValueCList($type)
  661. { $$ = DupValue($1);
  662. $$->Next = $2;
  663. }
  664. ;
  665. ValueCList(type)
  666. : ',' ValueList($type)
  667. { $$ = $2;
  668. }
  669. | /* empty */
  670. { $$ = NULL;
  671. }
  672. ;
  673. SetValue(type)
  674. : '{'
  675. { Component_t *components;
  676. Type_t *type;
  677. type = GetType($>1.Assignments, $type);
  678. components = type ? type->U.SSC.Components : NULL;
  679. }
  680. ComponentValueList(components) '}'
  681. { Component_t *c;
  682. NamedValue_t *v;
  683. if (type) {
  684. for (c = components; c; c = c->Next) {
  685. switch (c->Type) {
  686. case eComponent_Normal:
  687. v = FindNamedValue($2, c->U.NOD.NamedType->Identifier);
  688. if (!v)
  689. LLFAILED((&@2,
  690. "Value for component `%s' is missing",
  691. c->U.NOD.NamedType->Identifier));
  692. break;
  693. }
  694. }
  695. for (v = $2; v; v = v->Next) {
  696. if (!FindComponent($>>.Assignments, components,
  697. v->Identifier) ||
  698. FindNamedValue(v->Next, v->Identifier))
  699. LLFAILED((&@2, "Component `%s' is unexpected",
  700. v->Identifier));
  701. }
  702. }
  703. $$ = NewValue($>>.Assignments, $type);
  704. $$->U.Set.NamedValues = $2;
  705. }
  706. | '{' '}'
  707. { $$ = NewValue($>>.Assignments, $type);
  708. }
  709. ;
  710. SetOfValue(type)
  711. : '{'
  712. { Type_t *type, *subtype;
  713. type = GetType($>1.Assignments, $type);
  714. subtype = (type ? type->U.SS.Type : NULL);
  715. }
  716. ValueList(subtype) '}'
  717. { $$ = NewValue($>>.Assignments, $type);
  718. $$->U.SetOf.Values = $2;
  719. }
  720. | '{' '}'
  721. { $$ = NewValue($>>.Assignments, $type);
  722. }
  723. ;
  724. ChoiceValue(type)
  725. : identifier ':'
  726. { Component_t *component;
  727. Type_t *type, *subtype;
  728. type = GetType($>2.Assignments, $type);
  729. if (type) {
  730. component = FindComponent($>2.Assignments,
  731. type->U.Choice.Components, $1);
  732. if (!component)
  733. LLFAILED((&@1, "Bad alternative `%s'", $1));
  734. subtype = component->U.NOD.NamedType->Type;
  735. } else {
  736. subtype = NULL;
  737. }
  738. }
  739. Value(subtype)
  740. { $$ = NewValue($>>.Assignments, $type);
  741. $$->U.SSC.NamedValues = NewNamedValue($1, $3);
  742. }
  743. ;
  744. ObjectIdentifierValue
  745. : '{' ObjIdComponentList '}'
  746. { switch (GetAssignedObjectIdentifier(
  747. &$>>.AssignedObjIds, NULL, $2, &$$)) {
  748. case -1:
  749. LLFAILED((&@2, "Different numbers for equally named object identifier components"));
  750. /*NOTREACHED*/
  751. case 0:
  752. if (pass <= 2)
  753. $$ = NULL;
  754. else
  755. LLFAILED((&@2, "Unknown object identifier component"));
  756. break;
  757. case 1:
  758. break;
  759. }
  760. }
  761. | '{' DefinedValue ObjIdComponentList '}'
  762. { Value_t *v;
  763. v = GetValue($>>.Assignments, $2);
  764. if (v) {
  765. if (GetTypeType($>>.Assignments, v->Type) !=
  766. eType_ObjectIdentifier &&
  767. GetTypeType($>>.Assignments, v->Type) !=
  768. eType_Undefined)
  769. LLFAILED((&@2, "Bad type of value in object identifier"));
  770. if (GetTypeType($>>.Assignments, v->Type) ==
  771. eType_ObjectIdentifier) {
  772. switch (GetAssignedObjectIdentifier(
  773. &$>>.AssignedObjIds, v, $3, &$$)) {
  774. case -1:
  775. LLFAILED((&@3, "Different numbers for equally named object identifier components"));
  776. /*NOTREACHED*/
  777. case 0:
  778. if (pass <= 2)
  779. $$ = NULL;
  780. else
  781. LLFAILED((&@2, "Unknown object identifier component"));
  782. break;
  783. case 1:
  784. break;
  785. }
  786. }
  787. } else {
  788. $$ = NULL;
  789. }
  790. }
  791. ;
  792. ObjIdComponentList
  793. : ObjIdComponent ObjIdComponent_ESeq
  794. { if ($1) {
  795. $$ = DupNamedObjIdValue($1);
  796. $$->Next = $2;
  797. } else {
  798. $$ = NULL;
  799. }
  800. }
  801. ;
  802. ObjIdComponent_ESeq
  803. : ObjIdComponent ObjIdComponent_ESeq
  804. { if ($1) {
  805. $$ = DupNamedObjIdValue($1);
  806. $$->Next = $2;
  807. } else {
  808. $$ = NULL;
  809. }
  810. }
  811. | /* empty */
  812. { $$ = NULL;
  813. }
  814. ;
  815. ObjIdComponent
  816. : NameForm
  817. { $$ = $1;
  818. }
  819. | NumberForm
  820. { $$ = $1;
  821. }
  822. | NameAndNumberForm
  823. { $$ = $1;
  824. }
  825. ;
  826. NameForm
  827. : identifier
  828. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NameForm);
  829. $$->Name = $1;
  830. }
  831. ;
  832. NumberForm
  833. : number
  834. { $$ = NewNamedObjIdValue(eNamedObjIdValue_NumberForm);
  835. $$->Number = intx2uint32(&$1);
  836. }
  837. | DefinedValue
  838. { Value_t *v;
  839. v = GetValue($>>.Assignments, $1);
  840. if (v &&
  841. GetTypeType($>>.Assignments, v->Type) != eType_Integer &&
  842. GetTypeType($>>.Assignments, v->Type) != eType_Undefined)
  843. LLFAILED((&@1, "Bad type in object identifier"));
  844. if (v &&
  845. GetTypeType($>>.Assignments, v->Type) == eType_Integer &&
  846. intx_cmp(&v->U.Integer.Value, &intx_0) < 0)
  847. LLFAILED((&@1, "Bad value in object identifier"));
  848. if (v &&
  849. GetTypeType($>>.Assignments, v->Type) == eType_Integer) {
  850. $$ = NewNamedObjIdValue(eNamedObjIdValue_NumberForm);
  851. $$->Number = intx2uint32(&v->U.Integer.Value);
  852. } else {
  853. $$ = NULL;
  854. }
  855. }
  856. ;
  857. NameAndNumberForm
  858. : identifier '(' NumberForm ')'
  859. { if ($3) {
  860. $$ = NewNamedObjIdValue(eNamedObjIdValue_NameAndNumberForm);
  861. $$->Name = $1;
  862. $$->Number = $3->Number;
  863. } else {
  864. $$ = NULL;
  865. }
  866. }
  867. ;
  868. EmbeddedPDVValue(type)
  869. : SequenceValue($type)
  870. { $$ = $1;
  871. }
  872. ;
  873. ExternalValue(type)
  874. : SequenceValue($type)
  875. { $$ = $1;
  876. }
  877. ;
  878. CharacterStringValue(type)
  879. :
  880. { Type_e type;
  881. type = GetTypeType($<<.Assignments, $type);
  882. if (type != eType_Undefined && !IsRestrictedString(type))
  883. LLFAILED((&@@, "Bad type of value"));
  884. }
  885. RestrictedCharacterStringValue($type)
  886. { $$ = $1;
  887. }
  888. |
  889. { if (GetTypeType($<<.Assignments, $type) != eType_Undefined &&
  890. GetTypeType($<<.Assignments, $type) != eType_CharacterString)
  891. LLFAILED((&@@, "Bad type of value"));
  892. }
  893. UnrestrictedCharacterStringValue($type)
  894. { $$ = $1;
  895. }
  896. ;
  897. RestrictedCharacterStringValue(type): cstring
  898. { $$ = NewValue($>>.Assignments, $type);
  899. $$->U.RestrictedString.Value.length = str32len($1);
  900. $$->U.RestrictedString.Value.value = $1;
  901. }
  902. | CharacterStringList($type)
  903. { $$ = $1;
  904. }
  905. | Quadruple
  906. { $$ = NewValue($>>.Assignments, $type);
  907. $$->U.RestrictedString.Value.length = 1;
  908. $$->U.RestrictedString.Value.value =
  909. (char32_t *)malloc(sizeof(char32_t));
  910. $$->U.RestrictedString.Value.value[0] =
  911. 256 * (256 * (256 * $1.Group + $1.Plane) + $1.Row) + $1.Cell;
  912. }
  913. | Tuple
  914. { $$ = NewValue($>>.Assignments, $type);
  915. $$->U.RestrictedString.Value.length = 1;
  916. $$->U.RestrictedString.Value.value =
  917. (char32_t *)malloc(sizeof(char32_t));
  918. *$$->U.RestrictedString.Value.value =
  919. $1.Column * 16 + $1.Row;
  920. }
  921. ;
  922. UnrestrictedCharacterStringValue(type)
  923. : SequenceValue($type)
  924. { $$ = $1;
  925. }
  926. ;
  927. CharacterStringList(type)
  928. : '{' CharSyms($type) '}'
  929. { $$ = $2;
  930. }
  931. ;
  932. CharSyms(type)
  933. : CharDefn($type)
  934. { $$ = $1;
  935. }
  936. | CharDefn($type) ',' CharSyms($type)
  937. { if (!$1 || !$3) {
  938. $$ = NULL;
  939. } else {
  940. $$ = NewValue($>>.Assignments, $type);
  941. $$->U.RestrictedString.Value.length =
  942. $1->U.RestrictedString.Value.length +
  943. $3->U.RestrictedString.Value.length;
  944. $$->U.RestrictedString.Value.value =
  945. (char32_t *)malloc(
  946. $$->U.RestrictedString.Value.length *
  947. sizeof(char32_t));
  948. memcpy($$->U.RestrictedString.Value.value,
  949. $1->U.RestrictedString.Value.value,
  950. $1->U.RestrictedString.Value.length *
  951. sizeof(char32_t));
  952. memcpy($$->U.RestrictedString.Value.value +
  953. $1->U.RestrictedString.Value.length,
  954. $3->U.RestrictedString.Value.value,
  955. $3->U.RestrictedString.Value.length *
  956. sizeof(char32_t));
  957. }
  958. }
  959. ;
  960. CharDefn(type)
  961. : cstring
  962. { $$ = NewValue($>>.Assignments, $type);
  963. $$->U.RestrictedString.Value.length = str32len($1);
  964. $$->U.RestrictedString.Value.value = $1;
  965. }
  966. | DefinedValue
  967. { $$ = $1;
  968. }
  969. ;
  970. Quadruple
  971. : '{' number ',' number ',' number ',' number '}'
  972. { $$.Group = intx2uint32(&$2);
  973. $$.Plane = intx2uint32(&$4);
  974. $$.Row = intx2uint32(&$6);
  975. $$.Cell = intx2uint32(&$8);
  976. }
  977. ;
  978. Tuple
  979. : '{' number ',' number '}'
  980. { $$.Column = intx2uint32(&$2);
  981. $$.Row = intx2uint32(&$4);
  982. }
  983. ;
  984. AnyValue(type)
  985. : Type ':' Value($1)
  986. { $$ = $3;
  987. }
  988. ;