]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/CCode/Source/GenDepex/DepexParser.c
More moves for Tool Packages
[mirror_edk2.git] / Tools / CCode / Source / GenDepex / DepexParser.c
1 /*++
2
3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 DepexParser.c
15
16 Abstract:
17
18 Validate Dependency Expression syntax
19 recursive descent Algorithm
20
21 The original BNF grammar(taken from "Pre EFI Initialization Core Interface Specification
22 draft review 0.9") is thus:
23 <depex> ::= BEFORE <guid> END
24 | AFTER <guid> END
25 | SOR <bool> END
26 | <bool> END
27 <bool> ::= <bool> AND <term>
28 | <bool> OR <term>
29 | <term>
30 <term> ::= NOT <factor>
31 | <factor>
32 <factor> ::= <bool>
33 | TRUE
34 | FALSE
35 | GUID
36
37 <guid> ::= '{' <hex32> ',' <hex16> ',' <hex16> ','
38 <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ','
39 <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'
40 <hex32> ::= <hexprefix> <hexvalue>
41 <hex16> ::= <hexprefix> <hexvalue>
42 <hex8> ::= <hexprefix> <hexvalue>
43 <hexprefix>::= '0' 'x'
44 | '0' 'X'
45 <hexvalue> ::= <hexdigit> <hexvalue>
46 | <hexdigit>
47 <hexdigit> ::= [0-9]
48 | [a-f]
49 | [A-F]
50
51 After cleaning left recursive and parentheses supported, the BNF grammar used in this module is thus:
52 <depex> ::= BEFORE <guid>
53 | AFTER <guid>
54 | SOR <bool>
55 | <bool>
56 <bool> ::= <term><rightbool>
57 <rightbool>::= AND <term><rightbool>
58 | OR <term><rightbool>
59 | ''
60 <term> ::= NOT <factor>
61 | <factor>
62 <factor> ::= '('<bool>')'<rightfactor>
63 | NOT <factor> <rightbool> <rightfactor>
64 | TRUE <rightfactor>
65 | FALSE <rightfactor>
66 | END <rightfactor>
67 | <guid> <rightfactor>
68 <rightfactor> ::=AND <term><rightbool> <rightfactor>
69 | OR <term><rightbool> <rightfactor>
70 | ''
71 <guid> ::= '{' <hex32> ',' <hex16> ',' <hex16> ','
72 <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ','
73 <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'
74 <hex32> ::= <hexprefix> <hexvalue>
75 <hex16> ::= <hexprefix> <hexvalue>
76 <hex8> ::= <hexprefix> <hexvalue>
77 <hexprefix>::= '0' 'x'
78 | '0' 'X'
79 <hexvalue> ::= <hexdigit> <hexvalue>
80 | <hexdigit>
81 <hexdigit> ::= [0-9]
82 | [a-f]
83 | [A-F]
84
85 Note: 1. There's no precedence in operators except parentheses;
86 2. For hex32, less and equal than 8 bits is valid, more than 8 bits is invalid.
87 Same constraint for hex16 is 4, hex8 is 2. All hex should contains at least 1 bit.
88 3. "<factor> ::= '('<bool>')'<rightfactor>" is added to support parentheses;
89 4. "<factor> ::= GUID" is changed to "<factor> ::= <guid>";
90 5. "DEPENDENCY_END" is the terminal of the expression. But it has been filtered by caller.
91 During parsing, "DEPENDENCY_END" will be treated as illegal factor;
92
93 This code should build in any environment that supports a standard C-library w/ string
94 operations and File I/O services.
95
96 As an example of usage, consider the following:
97
98 The input string could be something like:
99
100 NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,
101 0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,
102 0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,
103 0x3f, 0xc1, 0x4d } AND
104
105 It's invalid for an extra "AND" in the end.
106
107 Complies with Tiano C Coding Standards Document, version 0.33, 16 Aug 2001.
108
109 --*/
110
111 #include "DepexParser.h"
112
113 BOOLEAN
114 ParseBool (
115 IN INT8 *Pbegin,
116 IN UINT32 length,
117 IN OUT INT8 **Pindex
118 );
119
120 BOOLEAN
121 ParseTerm (
122 IN INT8 *Pbegin,
123 IN UINT32 length,
124 IN OUT INT8 **Pindex
125 );
126
127 BOOLEAN
128 ParseRightBool (
129 IN INT8 *Pbegin,
130 IN UINT32 length,
131 IN OUT INT8 **Pindex
132 );
133
134 BOOLEAN
135 ParseFactor (
136 IN INT8 *Pbegin,
137 IN UINT32 length,
138 IN OUT INT8 **Pindex
139 );
140
141 VOID
142 LeftTrim (
143 IN INT8 *Pbegin,
144 IN UINT32 length,
145 IN OUT INT8 **Pindex
146 )
147 /*++
148
149 Routine Description:
150
151 Left trim the space, '\n' and '\r' character in string.
152 The space at the end does not need trim.
153
154
155 Arguments:
156
157 Pbegin The pointer to the string
158 length length of the string
159 Pindex The pointer of pointer to the next parse character in the string
160
161 Returns:
162
163 None
164
165
166 --*/
167 {
168 while
169 (
170 ((*Pindex) < (Pbegin + length)) &&
171 ((strncmp (*Pindex, " ", 1) == 0) || (strncmp (*Pindex, "\n", 1) == 0) || (strncmp (*Pindex, "\r", 1) == 0))
172 ) {
173 (*Pindex)++;
174 }
175 }
176
177 BOOLEAN
178 ParseHexdigit (
179 IN INT8 *Pbegin,
180 IN UINT32 length,
181 IN OUT INT8 **Pindex
182 )
183 /*++
184
185 Routine Description:
186
187 Parse Hex bit in dependency expression.
188
189 Arguments:
190
191 Pbegin The pointer to the string
192 length Length of the string
193 Pindex The pointer of pointer to the next parse character in the string
194
195 Returns:
196
197 BOOLEAN If parses a valid hex bit, return TRUE, otherwise FALSE
198
199
200 --*/
201 {
202 //
203 // <hexdigit> ::= [0-9] | [a-f] | [A-F]
204 //
205 if (((**Pindex) >= '0' && (**Pindex) <= '9') ||
206 ((**Pindex) >= 'a' && (**Pindex) <= 'f') ||
207 ((**Pindex) >= 'A' && (**Pindex) <= 'F')
208 ) {
209 (*Pindex)++;
210 return TRUE;
211 } else {
212 return FALSE;
213 }
214 }
215
216 BOOLEAN
217 ParseHex32 (
218 IN INT8 *Pbegin,
219 IN UINT32 length,
220 IN OUT INT8 **Pindex
221 )
222 /*++
223
224 Routine Description:
225
226 Parse Hex32 in dependency expression.
227
228 Arguments:
229
230 Pbegin The pointer to the string
231 length Length of the string
232 Pindex The pointer of point to the next parse character in the string
233
234 Returns:
235
236 BOOLEAN If parses a valid hex32, return TRUE, otherwise FALSE
237
238
239 --*/
240 {
241 INT32 Index;
242 INT8 *Pin;
243
244 Index = 0;
245 Pin = *Pindex;
246 LeftTrim (Pbegin, length, Pindex);
247
248 if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {
249 return FALSE;
250 }
251 (*Pindex) += 2;
252
253 while (ParseHexdigit (Pbegin, length, Pindex)) {
254 Index++;
255 }
256
257 if (Index > 0 && Index <= 8) {
258 return TRUE;
259 } else {
260 *Pindex = Pin;
261 return FALSE;
262 }
263 }
264
265 BOOLEAN
266 ParseHex16 (
267 IN INT8 *Pbegin,
268 IN UINT32 length,
269 IN OUT INT8 **Pindex
270 )
271 /*++
272
273 Routine Description:
274
275 Parse Hex16 in dependency expression.
276
277 Arguments:
278
279 Pbegin The pointer to the string
280 length Length of the string
281 Pindex The pointer of pointer to the next parse character in the string
282
283 Returns:
284
285 BOOLEAN If parses a valid hex16, return TRUE, otherwise FALSE
286
287
288 --*/
289 {
290 int Index;
291 INT8 *Pin;
292
293 Index = 0;
294 Pin = *Pindex;
295 LeftTrim (Pbegin, length, Pindex);
296
297 if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {
298 return FALSE;
299 }
300 (*Pindex) += 2;
301
302 while (ParseHexdigit (Pbegin, length, Pindex)) {
303 Index++;
304 }
305
306 if (Index > 0 && Index <= 4) {
307 return TRUE;
308 } else {
309 *Pindex = Pin;
310 return FALSE;
311 }
312 }
313
314 BOOLEAN
315 ParseHex8 (
316 IN INT8 *Pbegin,
317 IN UINT32 length,
318 IN OUT INT8 **Pindex
319 )
320 /*++
321
322 Routine Description:
323
324 Parse Hex8 in dependency expression.
325
326 Arguments:
327
328 Pbegin The pointer to the string
329 length Length of the string
330 Pindex The pointer of pointer to the next parse character in the string
331
332 Returns:
333
334 BOOLEAN If parses a valid hex8, return TRUE, otherwise FALSE
335
336
337 --*/
338 {
339 int Index;
340 INT8 *Pin;
341
342 Index = 0;
343 Pin = *Pindex;
344 LeftTrim (Pbegin, length, Pindex);
345
346 if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {
347 return FALSE;
348 }
349 (*Pindex) += 2;
350
351 while (ParseHexdigit (Pbegin, length, Pindex)) {
352 Index++;
353 }
354
355 if (Index > 0 && Index <= 2) {
356 return TRUE;
357 } else {
358 *Pindex = Pin;
359 return FALSE;
360 }
361 }
362
363 BOOLEAN
364 ParseGuid (
365 IN INT8 *Pbegin,
366 IN UINT32 length,
367 IN OUT INT8 **Pindex
368 )
369 /*++
370
371 Routine Description:
372
373 Parse guid in dependency expression.
374 There can be any number of spaces between '{' and hexword, ',' and hexword,
375 hexword and ',', hexword and '}'. The hexword include hex32, hex16 and hex8.
376
377 Arguments:
378
379 Pbegin The pointer to the string
380 length length of the string
381 Pindex The pointer of pointer to the next parse character in the string
382
383 Returns:
384
385 BOOLEAN If parses a valid guid, return TRUE, otherwise FALSE
386
387
388 --*/
389 {
390 INT32 Index;
391 INT8 *Pin;
392 Pin = *Pindex;
393 LeftTrim (Pbegin, length, Pindex);
394 if (strncmp (*Pindex, "{", 1) != 0) {
395 return FALSE;
396 }
397 (*Pindex)++;
398
399 LeftTrim (Pbegin, length, Pindex);
400 if (!ParseHex32 (Pbegin, length, Pindex)) {
401 *Pindex = Pin;
402 return FALSE;
403 }
404
405 LeftTrim (Pbegin, length, Pindex);
406 if (strncmp (*Pindex, ",", 1) != 0) {
407 return FALSE;
408 } else {
409 (*Pindex)++;
410 }
411
412 for (Index = 0; Index < 2; Index++) {
413 LeftTrim (Pbegin, length, Pindex);
414 if (!ParseHex16 (Pbegin, length, Pindex)) {
415 *Pindex = Pin;
416 return FALSE;
417 }
418
419 LeftTrim (Pbegin, length, Pindex);
420 if (strncmp (*Pindex, ",", 1) != 0) {
421 return FALSE;
422 } else {
423 (*Pindex)++;
424 }
425 }
426
427 LeftTrim (Pbegin, length, Pindex);
428 if (strncmp (*Pindex, "{", 1) != 0) {
429 return FALSE;
430 }
431 (*Pindex)++;
432
433 for (Index = 0; Index < 7; Index++) {
434 LeftTrim (Pbegin, length, Pindex);
435 if (!ParseHex8 (Pbegin, length, Pindex)) {
436 *Pindex = Pin;
437 return FALSE;
438 }
439
440 LeftTrim (Pbegin, length, Pindex);
441 if (strncmp (*Pindex, ",", 1) != 0) {
442 return FALSE;
443 } else {
444 (*Pindex)++;
445 }
446 }
447
448 LeftTrim (Pbegin, length, Pindex);
449 if (!ParseHex8 (Pbegin, length, Pindex)) {
450 *Pindex = Pin;
451 return FALSE;
452 }
453
454 LeftTrim (Pbegin, length, Pindex);
455 if (strncmp (*Pindex, "}", 1) != 0) {
456 return FALSE;
457 } else {
458 (*Pindex)++;
459 }
460
461 LeftTrim (Pbegin, length, Pindex);
462 if (strncmp (*Pindex, "}", 1) != 0) {
463 return FALSE;
464 } else {
465 (*Pindex)++;
466 }
467
468 return TRUE;
469 }
470
471 BOOLEAN
472 ParseRightFactor (
473 IN INT8 *Pbegin,
474 IN UINT32 length,
475 IN OUT INT8 **Pindex
476 )
477 /*++
478
479 Routine Description:
480
481 Parse rightfactor in bool expression.
482
483 Arguments:
484
485 Pbegin The pointer to the string
486 length length of the string
487 Pindex The pointer of pointer to the next parse character in the string
488
489 Returns:
490
491 BOOLEAN If string is a valid rightfactor expression, return TRUE, otherwise FALSE
492
493
494 --*/
495 {
496 INT8 *Pin;
497
498 Pin = *Pindex;
499 LeftTrim (Pbegin, length, Pindex);
500
501 //
502 // <rightfactor> ::=AND <term> <rightbool> <rightfactor>
503 //
504 if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {
505 *Pindex += strlen (OPERATOR_AND);
506 LeftTrim (Pbegin, length, Pindex);
507
508 if (ParseTerm (Pbegin, length, Pindex)) {
509 LeftTrim (Pbegin, length, Pindex);
510
511 if (ParseRightBool (Pbegin, length, Pindex)) {
512 LeftTrim (Pbegin, length, Pindex);
513 if (ParseRightFactor (Pbegin, length, Pindex)) {
514 return TRUE;
515 } else {
516 *Pindex = Pin;
517 }
518 } else {
519 *Pindex = Pin;
520 }
521 } else {
522 *Pindex = Pin;
523 }
524 }
525 //
526 // <rightfactor> ::=OR <term> <rightbool> <rightfactor>
527 //
528 if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {
529 *Pindex += strlen (OPERATOR_OR);
530 LeftTrim (Pbegin, length, Pindex);
531
532 if (ParseTerm (Pbegin, length, Pindex)) {
533 LeftTrim (Pbegin, length, Pindex);
534
535 if (ParseRightBool (Pbegin, length, Pindex)) {
536 LeftTrim (Pbegin, length, Pindex);
537 if (ParseRightFactor (Pbegin, length, Pindex)) {
538 return TRUE;
539 } else {
540 *Pindex = Pin;
541 }
542 } else {
543 *Pindex = Pin;
544 }
545 } else {
546 *Pindex = Pin;
547 }
548 }
549 //
550 // <rightfactor> ::= ''
551 //
552 *Pindex = Pin;
553 return TRUE;
554 }
555
556 BOOLEAN
557 ParseRightBool (
558 IN INT8 *Pbegin,
559 IN UINT32 length,
560 IN OUT INT8 **Pindex
561 )
562 /*++
563
564 Routine Description:
565
566 Parse rightbool in bool expression.
567
568 Arguments:
569
570 Pbegin The pointer to the string
571 length length of the string
572 Pindex The pointer of pointer to the next parse character in the string
573
574 Returns:
575
576 BOOLEAN If string is a valid rightbool expression, return TRUE, otherwise FALSE
577
578
579 --*/
580 {
581 INT8 *Pin;
582
583 Pin = *Pindex;
584 LeftTrim (Pbegin, length, Pindex);
585
586 //
587 // <rightbool>::= AND <term><rightbool>
588 //
589 if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {
590 *Pindex += strlen (OPERATOR_AND);
591 LeftTrim (Pbegin, length, Pindex);
592
593 if (ParseTerm (Pbegin, length, Pindex)) {
594 LeftTrim (Pbegin, length, Pindex);
595
596 if (ParseRightBool (Pbegin, length, Pindex)) {
597 return TRUE;
598 } else {
599 *Pindex = Pin;
600 }
601 } else {
602 *Pindex = Pin;
603 }
604 }
605 //
606 // <rightbool>::= OR <term><rightbool>
607 //
608 if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {
609 *Pindex += strlen (OPERATOR_OR);
610 LeftTrim (Pbegin, length, Pindex);
611
612 if (ParseTerm (Pbegin, length, Pindex)) {
613 LeftTrim (Pbegin, length, Pindex);
614
615 if (ParseRightBool (Pbegin, length, Pindex)) {
616 return TRUE;
617 } else {
618 *Pindex = Pin;
619 }
620 } else {
621 *Pindex = Pin;
622 }
623 }
624 //
625 // <rightbool>::= ''
626 //
627 *Pindex = Pin;
628 return TRUE;
629 }
630
631 BOOLEAN
632 ParseFactor (
633 IN INT8 *Pbegin,
634 IN UINT32 length,
635 IN OUT INT8 **Pindex
636 )
637 /*++
638
639 Routine Description:
640
641 Parse factor in bool expression.
642
643 Arguments:
644
645 Pbegin The pointer to the string
646 length length of the string
647 Pindex The pointer of pointer to the next parse character in the string
648
649 Returns:
650
651 BOOLEAN If string is a valid factor, return TRUE, otherwise FALSE
652
653
654 --*/
655 {
656 INT8 *Pin;
657
658 Pin = *Pindex;
659 LeftTrim (Pbegin, length, Pindex);
660
661 //
662 // <factor> ::= '('<bool>')'<rightfactor>
663 //
664 if (strncmp (*Pindex, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {
665 *Pindex += strlen (OPERATOR_LEFT_PARENTHESIS);
666 LeftTrim (Pbegin, length, Pindex);
667
668 if (!ParseBool (Pbegin, length, Pindex)) {
669 *Pindex = Pin;
670 } else {
671 LeftTrim (Pbegin, length, Pindex);
672
673 if (strncmp (*Pindex, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {
674 *Pindex += strlen (OPERATOR_RIGHT_PARENTHESIS);
675 LeftTrim (Pbegin, length, Pindex);
676
677 if (ParseRightFactor (Pbegin, length, Pindex)) {
678 return TRUE;
679 } else {
680 *Pindex = Pin;
681 }
682 }
683 }
684 }
685 //
686 // <factor> ::= NOT <factor> <rightbool> <rightfactor>
687 //
688 if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {
689 *Pindex += strlen (OPERATOR_NOT);
690 LeftTrim (Pbegin, length, Pindex);
691
692 if (ParseFactor (Pbegin, length, Pindex)) {
693 LeftTrim (Pbegin, length, Pindex);
694
695 if (ParseRightBool (Pbegin, length, Pindex)) {
696 LeftTrim (Pbegin, length, Pindex);
697
698 if (ParseRightFactor (Pbegin, length, Pindex)) {
699 return TRUE;
700 } else {
701 *Pindex = Pin;
702 }
703 } else {
704 *Pindex = Pin;
705 }
706 } else {
707 *Pindex = Pin;
708 }
709 }
710 //
711 // <factor> ::= TRUE <rightfactor>
712 //
713 if (strncmp (*Pindex, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {
714 *Pindex += strlen (OPERATOR_TRUE);
715 LeftTrim (Pbegin, length, Pindex);
716
717 if (ParseRightFactor (Pbegin, length, Pindex)) {
718 return TRUE;
719 } else {
720 *Pindex = Pin;
721 }
722 }
723 //
724 // <factor> ::= FALSE <rightfactor>
725 //
726 if (strncmp (*Pindex, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {
727 *Pindex += strlen (OPERATOR_FALSE);
728 LeftTrim (Pbegin, length, Pindex);
729
730 if (ParseRightFactor (Pbegin, length, Pindex)) {
731 return TRUE;
732 } else {
733 *Pindex = Pin;
734 }
735 }
736 //
737 // <factor> ::= <guid> <rightfactor>
738 //
739 if (ParseGuid (Pbegin, length, Pindex)) {
740 LeftTrim (Pbegin, length, Pindex);
741
742 if (ParseRightFactor (Pbegin, length, Pindex)) {
743 return TRUE;
744 } else {
745 *Pindex = Pin;
746 return FALSE;
747 }
748 } else {
749 *Pindex = Pin;
750 return FALSE;
751 }
752 }
753
754 BOOLEAN
755 ParseTerm (
756 IN INT8 *Pbegin,
757 IN UINT32 length,
758 IN OUT INT8 **Pindex
759 )
760 /*++
761
762 Routine Description:
763
764 Parse term in bool expression.
765
766 Arguments:
767
768 Pbegin The pointer to the string
769 length length of the string
770 Pindex The pointer of pointer to the next parse character in the string
771
772 Returns:
773
774 BOOLEAN If string is a valid term, return TRUE, otherwise FALSE
775
776
777 --*/
778 {
779 INT8 *Pin;
780
781 Pin = *Pindex;
782 LeftTrim (Pbegin, length, Pindex);
783
784 //
785 // <term> ::= NOT <factor>
786 //
787 if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {
788 *Pindex += strlen (OPERATOR_NOT);
789 LeftTrim (Pbegin, length, Pindex);
790
791 if (!ParseFactor (Pbegin, length, Pindex)) {
792 *Pindex = Pin;
793 } else {
794 return TRUE;
795 }
796 }
797 //
798 // <term> ::=<factor>
799 //
800 if (ParseFactor (Pbegin, length, Pindex)) {
801 return TRUE;
802 } else {
803 *Pindex = Pin;
804 return FALSE;
805 }
806 }
807
808 BOOLEAN
809 ParseBool (
810 IN INT8 *Pbegin,
811 IN UINT32 length,
812 IN OUT INT8 **Pindex
813 )
814 /*++
815
816 Routine Description:
817
818 Parse bool expression.
819
820 Arguments:
821
822 Pbegin The pointer to the string
823 length length of the string
824 Pindex The pointer of pointer to the next parse character in the string
825
826 Returns:
827
828 BOOLEAN If string is a valid bool expression, return TRUE, otherwise FALSE
829
830
831 --*/
832 {
833 INT8 *Pin;
834 Pin = *Pindex;
835 LeftTrim (Pbegin, length, Pindex);
836
837 if (ParseTerm (Pbegin, length, Pindex)) {
838 LeftTrim (Pbegin, length, Pindex);
839
840 if (!ParseRightBool (Pbegin, length, Pindex)) {
841 *Pindex = Pin;
842 return FALSE;
843 } else {
844 return TRUE;
845 }
846 } else {
847 *Pindex = Pin;
848 return FALSE;
849 }
850 }
851
852 BOOLEAN
853 ParseDepex (
854 IN INT8 *Pbegin,
855 IN UINT32 length
856 )
857 /*++
858
859 Routine Description:
860
861 Parse whole dependency expression.
862
863 Arguments:
864
865 Pbegin The pointer to the string
866 length length of the string
867
868 Returns:
869
870 BOOLEAN If string is a valid dependency expression, return TRUE, otherwise FALSE
871
872
873 --*/
874 {
875 BOOLEAN Result;
876 INT8 **Pindex;
877 INT8 *temp;
878
879 Result = FALSE;
880 temp = Pbegin;
881 Pindex = &temp;
882
883 LeftTrim (Pbegin, length, Pindex);
884 if (strncmp (*Pindex, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {
885 (*Pindex) += strlen (OPERATOR_BEFORE);
886 Result = ParseGuid (Pbegin, length, Pindex);
887
888 } else if (strncmp (*Pindex, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {
889 (*Pindex) += strlen (OPERATOR_AFTER);
890 Result = ParseGuid (Pbegin, length, Pindex);
891
892 } else if (strncmp (*Pindex, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {
893 (*Pindex) += strlen (OPERATOR_SOR);
894 Result = ParseBool (Pbegin, length, Pindex);
895
896 } else {
897 Result = ParseBool (Pbegin, length, Pindex);
898
899 }
900
901 LeftTrim (Pbegin, length, Pindex);
902 return (BOOLEAN) (Result && (*Pindex) >= (Pbegin + length));
903 }