Fixed tons of bugs
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 9 Apr 2008 07:17:57 +0000 (07:17 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 9 Apr 2008 07:17:57 +0000 (07:17 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1132 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/AutoGen/Depex.g [new file with mode: 0644]
Source/Python/AutoGen/DepexLexer.py [new file with mode: 0644]
Source/Python/AutoGen/DepexParser.py [new file with mode: 0644]
Source/Python/AutoGen/GenDepex.py
Source/Python/Workspace/MetaFileParser.py
Source/Python/Workspace/WorkspaceDatabase.py
Source/Python/build/build.py

diff --git a/Source/Python/AutoGen/Depex.g b/Source/Python/AutoGen/Depex.g
new file mode 100644 (file)
index 0000000..13ad7a1
--- /dev/null
@@ -0,0 +1,202 @@
+grammar Depex;\r
+options {\r
+    language=Python;\r
+//    output=AST;\r
+//    ASTLabelType=CommonTree;\r
+//    backtrack=true;\r
+//    memoize=true;\r
+//    k=2;\r
+}\r
+\r
+@header {\r
+    from Common.BuildToolError import *\r
+    from Common import EdkLogger as EdkLogger\r
+}\r
+\r
+@init {\r
+    self._DepexFile = ''\r
+    self._ExclusiveOpcode = ["BEFORE", "AFTER"]\r
+    self._AboveAllOpcode = ["SOR", "BEFORE", "AFTER"]\r
+    self._ExpressionType = -1\r
+    self._Parentheses = 0\r
+    self.PostfixNotation = []\r
+    self.TokenList = [t.text for t in self.input.tokens]\r
+    self.OpcodeList = []\r
+    self._DepexString = ' '.join(self.TokenList)\r
+}\r
+\r
+@members {\r
+    EXPRESSION_BEFORE = 0\r
+    EXPRESSION_AFTER = 1\r
+    EXPRESSION_SOR = 2\r
+    EXPRESSION_BOOL = 3\r
+}\r
+\r
+@rulecatch {\r
+except BaseException,e:\r
+    raise\r
+}\r
+\r
+// Rule Start\r
+start [FilePath]\r
+@init {self._DepexFile=FilePath}\r
+    : depex_expression\r
+{\r
+    # there should be no more tokens left\r
+    if self.input.LT(1).text != None:\r
+        raise RecognitionException("Ending error")\r
+    if self.PostfixNotation[-1] != 'END':\r
+        self.PostfixNotation.append('END')\r
+}\r
+    ;\r
+catch [RecognitionException, e] {\r
+    LastToken = self.input.LT(-1)\r
+    if LastToken != None:\r
+        LastToken = LastToken.text\r
+    NextToken = self.input.LT(1)\r
+    if NextToken != None:\r
+        NextToken = NextToken.text\r
+    if self._Parentheses != 0:\r
+        Msg = "Parentheses mismatched"\r
+    elif LastToken == 'END':\r
+        Msg = "No more opcode or operand after END"\r
+    elif self._ExpressionType in [self.EXPRESSION_BEFORE, self.EXPRESSION_AFTER]:\r
+        Msg = "Unnecessary expression after [\%s]" \% LastToken\r
+    elif NextToken in ['SOR', 'BEFORE', 'AFTER']:\r
+        Msg = "[\%s] is not expected." \% NextToken\r
+    elif NextToken in ['AND', 'OR']:\r
+        Msg = "Missing operand near [\%s]" \% NextToken\r
+    elif NextToken in [')', '(']:\r
+        Msg = "Parentheses mismatched"\r
+    else:\r
+        Msg = "Missing opcode or operand between [\%s] and [\%s]" \% (LastToken, NextToken)\r
+    EdkLogger.error("GenDepex", PARAMETER_INVALID, Msg, ExtraData=self._DepexString, File=self._DepexFile)\r
+}\r
+catch [] {\r
+    raise\r
+}\r
+\r
+depex_expression\r
+    :   'DEPENDENCY_START'?\r
+       (before_expression|after_expression|sor_expression|bool_expression)\r
+       'END'?\r
+       'DEPENDENCY_END'?\r
+    ;\r
+\r
+before_expression\r
+    :    Op='BEFORE' V=guid {\r
+self.PostfixNotation.append($Op.text)\r
+self.PostfixNotation.append(V)\r
+self.OpcodeList.append($Op.text)\r
+self._ExpressionType = self.EXPRESSION_BEFORE\r
+}\r
+    ;\r
+\r
+after_expression\r
+    :    Op='AFTER' V=guid\r
+{\r
+self.PostfixNotation.append($Op.text)\r
+self.PostfixNotation.append(V)\r
+self.OpcodeList.append($Op.text)\r
+self._ExpressionType = self.EXPRESSION_AFTER\r
+}\r
+    ;\r
+\r
+sor_expression\r
+    :    Op='SOR' Expr=bool_statement\r
+{\r
+self.PostfixNotation.append($Op.text)\r
+self.PostfixNotation.extend(Expr)\r
+self.OpcodeList.append($Op.text)\r
+self._ExpressionType = self.EXPRESSION_SOR\r
+}\r
+    ;\r
+    \r
+bool_expression\r
+    :    Expr=bool_statement\r
+{\r
+self.PostfixNotation.extend(Expr)\r
+self._ExpressionType = self.EXPRESSION_BOOL\r
+}\r
+;\r
+    \r
+bool_statement returns [ExpressionList]\r
+@init {\r
+ExpressionList=[]\r
+} :\r
+    SubExpr=bool_factor {ExpressionList.extend(SubExpr)}\r
+    (    'AND' SubExpr=bool_statement {ExpressionList.extend(SubExpr);ExpressionList.append('AND');self.OpcodeList.append('AND')}\r
+        |'OR' SubExpr=bool_statement {ExpressionList.extend(SubExpr);ExpressionList.append('OR');self.OpcodeList.append('OR')}\r
+    )*\r
+;\r
+\r
+bool_factor returns [ExpressionList]\r
+@init {\r
+ExpressionList=[]\r
+} :\r
+        Bl='TRUE' {ExpressionList.append($Bl.text)}\r
+    |    Bl='FALSE' {ExpressionList.append($Bl.text)}\r
+    |    Op='NOT' Be=bool_statement {ExpressionList.extend(Be);ExpressionList.append($Op.text)}\r
+    |    ( '(' {self._Parentheses+=1} ) Be=bool_statement {ExpressionList.extend(Be)} ( ')' {self._Parentheses-=1} )\r
+    |    V=guid {ExpressionList.append('PUSH');ExpressionList.append(V)}\r
+    ;\r
+    \r
+guid returns [GuidValue]\r
+@init {\r
+GuidValue = None\r
+} :\r
+    GuidName\r
+{\r
+EdkLogger.error("GenDepex", RESOURCE_NOT_AVAILABLE, "Value of GUID [\%s] is not available" \% $GuidName.text, ExtraData=self._DepexString, File=self._DepexFile)\r
+}\r
+    |    guid_value\r
+{\r
+GuidValue=$guid_value.text\r
+}\r
+    ;\r
+\r
+guid_value\r
+    :    '{' Hex ',' Hex ',' Hex ',' '{'? Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex '}'? '}'\r
+    ;\r
+\r
+\r
+// Token Rules\r
+OpCode\r
+    :    'BEFORE'\r
+    |    'AFTER'\r
+    |    'SOR'\r
+    |    'TRUE'\r
+    |    'FALSE'\r
+    |    'AND'\r
+    |    'OR'\r
+    |    'NOT'\r
+    |    'PUSH'\r
+    |    'END'    \r
+    ;\r
+    \r
+COMMENT\r
+    :    '#' ~('\n'|'\r')* '\r'? '\n' {self.skip()};\r
+\r
+WS    :    Whitespace {self.skip()};\r
+\r
+GuidName\r
+    :    (Letter|'_') (AlphaNumeric|'_')*\r
+    ;\r
+\r
+Hex:    '0' ('x'|'X') ('0'..'9'|'a'..'f'|'A'..'F')+;\r
+\r
+fragment\r
+AlphaNumeric\r
+    :    (Letter|'0'..'9')\r
+    ;\r
+\r
+fragment\r
+Letter\r
+    :    'A'..'Z'\r
+    |    'a'..'z'\r
+    ;\r
+\r
+fragment\r
+Whitespace\r
+    :    (' '|'\t'|'\r'|'\n')\r
+    ;\r
diff --git a/Source/Python/AutoGen/DepexLexer.py b/Source/Python/AutoGen/DepexLexer.py
new file mode 100644 (file)
index 0000000..bc9e117
--- /dev/null
@@ -0,0 +1,1285 @@
+# $ANTLR 3.0.1 H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g 2008-04-09 15:15:36
+
+from antlr3 import *
+from antlr3.compat import set, frozenset
+
+
+# for convenience in actions
+HIDDEN = BaseRecognizer.HIDDEN
+
+# token types
+T21=21
+T14=14
+GuidName=4
+T22=22
+AlphaNumeric=11
+WS=9
+Hex=5
+T12=12
+T23=23
+COMMENT=7
+T13=13
+T20=20
+OpCode=6
+T25=25
+Letter=10
+T18=18
+T26=26
+T15=15
+EOF=-1
+Whitespace=8
+T17=17
+Tokens=28
+T16=16
+T27=27
+T24=24
+T19=19
+
+class DepexLexer(Lexer):
+
+    grammarFileName = "H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g"
+
+    def __init__(self, input=None):
+        Lexer.__init__(self, input)
+
+
+
+
+
+    # $ANTLR start T12
+    def mT12(self, ):
+
+        try:
+            self.type = T12
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:7:5: ( 'DEPENDENCY_START' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:7:7: 'DEPENDENCY_START'
+            self.match("DEPENDENCY_START")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T12
+
+
+
+    # $ANTLR start T13
+    def mT13(self, ):
+
+        try:
+            self.type = T13
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:8:5: ( 'END' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:8:7: 'END'
+            self.match("END")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T13
+
+
+
+    # $ANTLR start T14
+    def mT14(self, ):
+
+        try:
+            self.type = T14
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:9:5: ( 'DEPENDENCY_END' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:9:7: 'DEPENDENCY_END'
+            self.match("DEPENDENCY_END")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T14
+
+
+
+    # $ANTLR start T15
+    def mT15(self, ):
+
+        try:
+            self.type = T15
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:10:5: ( 'BEFORE' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:10:7: 'BEFORE'
+            self.match("BEFORE")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T15
+
+
+
+    # $ANTLR start T16
+    def mT16(self, ):
+
+        try:
+            self.type = T16
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:11:5: ( 'AFTER' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:11:7: 'AFTER'
+            self.match("AFTER")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T16
+
+
+
+    # $ANTLR start T17
+    def mT17(self, ):
+
+        try:
+            self.type = T17
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:12:5: ( 'SOR' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:12:7: 'SOR'
+            self.match("SOR")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T17
+
+
+
+    # $ANTLR start T18
+    def mT18(self, ):
+
+        try:
+            self.type = T18
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:13:5: ( 'AND' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:13:7: 'AND'
+            self.match("AND")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T18
+
+
+
+    # $ANTLR start T19
+    def mT19(self, ):
+
+        try:
+            self.type = T19
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:14:5: ( 'OR' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:14:7: 'OR'
+            self.match("OR")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T19
+
+
+
+    # $ANTLR start T20
+    def mT20(self, ):
+
+        try:
+            self.type = T20
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:15:5: ( 'TRUE' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:15:7: 'TRUE'
+            self.match("TRUE")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T20
+
+
+
+    # $ANTLR start T21
+    def mT21(self, ):
+
+        try:
+            self.type = T21
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:16:5: ( 'FALSE' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:16:7: 'FALSE'
+            self.match("FALSE")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T21
+
+
+
+    # $ANTLR start T22
+    def mT22(self, ):
+
+        try:
+            self.type = T22
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:17:5: ( 'NOT' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:17:7: 'NOT'
+            self.match("NOT")
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T22
+
+
+
+    # $ANTLR start T23
+    def mT23(self, ):
+
+        try:
+            self.type = T23
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:18:5: ( '(' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:18:7: '('
+            self.match(u'(')
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T23
+
+
+
+    # $ANTLR start T24
+    def mT24(self, ):
+
+        try:
+            self.type = T24
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:19:5: ( ')' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:19:7: ')'
+            self.match(u')')
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T24
+
+
+
+    # $ANTLR start T25
+    def mT25(self, ):
+
+        try:
+            self.type = T25
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:20:5: ( '{' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:20:7: '{'
+            self.match(u'{')
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T25
+
+
+
+    # $ANTLR start T26
+    def mT26(self, ):
+
+        try:
+            self.type = T26
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:21:5: ( ',' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:21:7: ','
+            self.match(u',')
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T26
+
+
+
+    # $ANTLR start T27
+    def mT27(self, ):
+
+        try:
+            self.type = T27
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:22:5: ( '}' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:22:7: '}'
+            self.match(u'}')
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end T27
+
+
+
+    # $ANTLR start OpCode
+    def mOpCode(self, ):
+
+        try:
+            self.type = OpCode
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:165:5: ( 'BEFORE' | 'AFTER' | 'SOR' | 'TRUE' | 'FALSE' | 'AND' | 'OR' | 'NOT' | 'PUSH' | 'END' )
+            alt1 = 10
+            LA1 = self.input.LA(1)
+            if LA1 == u'B':
+                alt1 = 1
+            elif LA1 == u'A':
+                LA1_2 = self.input.LA(2)
+
+                if (LA1_2 == u'F') :
+                    alt1 = 2
+                elif (LA1_2 == u'N') :
+                    alt1 = 6
+                else:
+                    nvae = NoViableAltException("164:1: OpCode : ( 'BEFORE' | 'AFTER' | 'SOR' | 'TRUE' | 'FALSE' | 'AND' | 'OR' | 'NOT' | 'PUSH' | 'END' );", 1, 2, self.input)
+
+                    raise nvae
+
+            elif LA1 == u'S':
+                alt1 = 3
+            elif LA1 == u'T':
+                alt1 = 4
+            elif LA1 == u'F':
+                alt1 = 5
+            elif LA1 == u'O':
+                alt1 = 7
+            elif LA1 == u'N':
+                alt1 = 8
+            elif LA1 == u'P':
+                alt1 = 9
+            elif LA1 == u'E':
+                alt1 = 10
+            else:
+                nvae = NoViableAltException("164:1: OpCode : ( 'BEFORE' | 'AFTER' | 'SOR' | 'TRUE' | 'FALSE' | 'AND' | 'OR' | 'NOT' | 'PUSH' | 'END' );", 1, 0, self.input)
+
+                raise nvae
+
+            if alt1 == 1:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:165:10: 'BEFORE'
+                self.match("BEFORE")
+
+
+
+
+            elif alt1 == 2:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:166:10: 'AFTER'
+                self.match("AFTER")
+
+
+
+
+            elif alt1 == 3:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:167:10: 'SOR'
+                self.match("SOR")
+
+
+
+
+            elif alt1 == 4:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:168:10: 'TRUE'
+                self.match("TRUE")
+
+
+
+
+            elif alt1 == 5:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:169:10: 'FALSE'
+                self.match("FALSE")
+
+
+
+
+            elif alt1 == 6:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:170:10: 'AND'
+                self.match("AND")
+
+
+
+
+            elif alt1 == 7:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:171:10: 'OR'
+                self.match("OR")
+
+
+
+
+            elif alt1 == 8:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:172:10: 'NOT'
+                self.match("NOT")
+
+
+
+
+            elif alt1 == 9:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:173:10: 'PUSH'
+                self.match("PUSH")
+
+
+
+
+            elif alt1 == 10:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:174:10: 'END'
+                self.match("END")
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end OpCode
+
+
+
+    # $ANTLR start COMMENT
+    def mCOMMENT(self, ):
+
+        try:
+            self.type = COMMENT
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:178:5: ( '#' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:178:10: '#' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n'
+            self.match(u'#')
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:178:14: (~ ( '\\n' | '\\r' ) )*
+            while True: #loop2
+                alt2 = 2
+                LA2_0 = self.input.LA(1)
+
+                if ((u'\u0000' <= LA2_0 <= u'\t') or (u'\u000B' <= LA2_0 <= u'\f') or (u'\u000E' <= LA2_0 <= u'\uFFFE')) :
+                    alt2 = 1
+
+
+                if alt2 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:178:14: ~ ( '\\n' | '\\r' )
+                    if (u'\u0000' <= self.input.LA(1) <= u'\t') or (u'\u000B' <= self.input.LA(1) <= u'\f') or (u'\u000E' <= self.input.LA(1) <= u'\uFFFE'):
+                        self.input.consume();
+
+                    else:
+                        mse = MismatchedSetException(None, self.input)
+                        self.recover(mse)
+                        raise mse
+
+
+
+
+                else:
+                    break #loop2
+
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:178:28: ( '\\r' )?
+            alt3 = 2
+            LA3_0 = self.input.LA(1)
+
+            if (LA3_0 == u'\r') :
+                alt3 = 1
+            if alt3 == 1:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:178:28: '\\r'
+                self.match(u'\r')
+
+
+
+
+            self.match(u'\n')
+
+            #action start
+            self.skip()
+            #action end
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end COMMENT
+
+
+
+    # $ANTLR start WS
+    def mWS(self, ):
+
+        try:
+            self.type = WS
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:180:7: ( Whitespace )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:180:12: Whitespace
+            self.mWhitespace()
+
+            #action start
+            self.skip()
+            #action end
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end WS
+
+
+
+    # $ANTLR start GuidName
+    def mGuidName(self, ):
+
+        try:
+            self.type = GuidName
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:183:5: ( ( Letter | '_' ) ( AlphaNumeric | '_' )* )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:183:10: ( Letter | '_' ) ( AlphaNumeric | '_' )*
+            if (u'A' <= self.input.LA(1) <= u'Z') or self.input.LA(1) == u'_' or (u'a' <= self.input.LA(1) <= u'z'):
+                self.input.consume();
+
+            else:
+                mse = MismatchedSetException(None, self.input)
+                self.recover(mse)
+                raise mse
+
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:183:23: ( AlphaNumeric | '_' )*
+            while True: #loop4
+                alt4 = 2
+                LA4_0 = self.input.LA(1)
+
+                if ((u'0' <= LA4_0 <= u'9') or (u'A' <= LA4_0 <= u'Z') or LA4_0 == u'_' or (u'a' <= LA4_0 <= u'z')) :
+                    alt4 = 1
+
+
+                if alt4 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:
+                    if (u'0' <= self.input.LA(1) <= u'9') or (u'A' <= self.input.LA(1) <= u'Z') or self.input.LA(1) == u'_' or (u'a' <= self.input.LA(1) <= u'z'):
+                        self.input.consume();
+
+                    else:
+                        mse = MismatchedSetException(None, self.input)
+                        self.recover(mse)
+                        raise mse
+
+
+
+
+                else:
+                    break #loop4
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end GuidName
+
+
+
+    # $ANTLR start Hex
+    def mHex(self, ):
+
+        try:
+            self.type = Hex
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:186:4: ( '0' ( 'x' | 'X' ) ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:186:9: '0' ( 'x' | 'X' ) ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+
+            self.match(u'0')
+
+            if self.input.LA(1) == u'X' or self.input.LA(1) == u'x':
+                self.input.consume();
+
+            else:
+                mse = MismatchedSetException(None, self.input)
+                self.recover(mse)
+                raise mse
+
+
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:186:23: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+
+            cnt5 = 0
+            while True: #loop5
+                alt5 = 2
+                LA5_0 = self.input.LA(1)
+
+                if ((u'0' <= LA5_0 <= u'9') or (u'A' <= LA5_0 <= u'F') or (u'a' <= LA5_0 <= u'f')) :
+                    alt5 = 1
+
+
+                if alt5 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:
+                    if (u'0' <= self.input.LA(1) <= u'9') or (u'A' <= self.input.LA(1) <= u'F') or (u'a' <= self.input.LA(1) <= u'f'):
+                        self.input.consume();
+
+                    else:
+                        mse = MismatchedSetException(None, self.input)
+                        self.recover(mse)
+                        raise mse
+
+
+
+
+                else:
+                    if cnt5 >= 1:
+                        break #loop5
+
+                    eee = EarlyExitException(5, self.input)
+                    raise eee
+
+                cnt5 += 1
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end Hex
+
+
+
+    # $ANTLR start AlphaNumeric
+    def mAlphaNumeric(self, ):
+
+        try:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:190:5: ( ( Letter | '0' .. '9' ) )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:190:10: ( Letter | '0' .. '9' )
+            if (u'0' <= self.input.LA(1) <= u'9') or (u'A' <= self.input.LA(1) <= u'Z') or (u'a' <= self.input.LA(1) <= u'z'):
+                self.input.consume();
+
+            else:
+                mse = MismatchedSetException(None, self.input)
+                self.recover(mse)
+                raise mse
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end AlphaNumeric
+
+
+
+    # $ANTLR start Letter
+    def mLetter(self, ):
+
+        try:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:195:5: ( 'A' .. 'Z' | 'a' .. 'z' )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:
+            if (u'A' <= self.input.LA(1) <= u'Z') or (u'a' <= self.input.LA(1) <= u'z'):
+                self.input.consume();
+
+            else:
+                mse = MismatchedSetException(None, self.input)
+                self.recover(mse)
+                raise mse
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end Letter
+
+
+
+    # $ANTLR start Whitespace
+    def mWhitespace(self, ):
+
+        try:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:201:5: ( ( ' ' | '\\t' | '\\r' | '\\n' ) )
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:201:10: ( ' ' | '\\t' | '\\r' | '\\n' )
+            if (u'\t' <= self.input.LA(1) <= u'\n') or self.input.LA(1) == u'\r' or self.input.LA(1) == u' ':
+                self.input.consume();
+
+            else:
+                mse = MismatchedSetException(None, self.input)
+                self.recover(mse)
+                raise mse
+
+
+
+
+
+
+        finally:
+
+            pass
+
+    # $ANTLR end Whitespace
+
+
+
+    def mTokens(self):
+        # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:8: ( T12 | T13 | T14 | T15 | T16 | T17 | T18 | T19 | T20 | T21 | T22 | T23 | T24 | T25 | T26 | T27 | OpCode | COMMENT | WS | GuidName | Hex )
+        alt6 = 21
+        LA6 = self.input.LA(1)
+        if LA6 == u'D':
+            LA6_1 = self.input.LA(2)
+
+            if (LA6_1 == u'E') :
+                LA6_20 = self.input.LA(3)
+
+                if (LA6_20 == u'P') :
+                    LA6_31 = self.input.LA(4)
+
+                    if (LA6_31 == u'E') :
+                        LA6_42 = self.input.LA(5)
+
+                        if (LA6_42 == u'N') :
+                            LA6_52 = self.input.LA(6)
+
+                            if (LA6_52 == u'D') :
+                                LA6_58 = self.input.LA(7)
+
+                                if (LA6_58 == u'E') :
+                                    LA6_62 = self.input.LA(8)
+
+                                    if (LA6_62 == u'N') :
+                                        LA6_64 = self.input.LA(9)
+
+                                        if (LA6_64 == u'C') :
+                                            LA6_65 = self.input.LA(10)
+
+                                            if (LA6_65 == u'Y') :
+                                                LA6_66 = self.input.LA(11)
+
+                                                if (LA6_66 == u'_') :
+                                                    LA6 = self.input.LA(12)
+                                                    if LA6 == u'S':
+                                                        LA6_68 = self.input.LA(13)
+
+                                                        if (LA6_68 == u'T') :
+                                                            LA6_70 = self.input.LA(14)
+
+                                                            if (LA6_70 == u'A') :
+                                                                LA6_72 = self.input.LA(15)
+
+                                                                if (LA6_72 == u'R') :
+                                                                    LA6_74 = self.input.LA(16)
+
+                                                                    if (LA6_74 == u'T') :
+                                                                        LA6_76 = self.input.LA(17)
+
+                                                                        if ((u'0' <= LA6_76 <= u'9') or (u'A' <= LA6_76 <= u'Z') or LA6_76 == u'_' or (u'a' <= LA6_76 <= u'z')) :
+                                                                            alt6 = 20
+                                                                        else:
+                                                                            alt6 = 1
+                                                                    else:
+                                                                        alt6 = 20
+                                                                else:
+                                                                    alt6 = 20
+                                                            else:
+                                                                alt6 = 20
+                                                        else:
+                                                            alt6 = 20
+                                                    elif LA6 == u'E':
+                                                        LA6_69 = self.input.LA(13)
+
+                                                        if (LA6_69 == u'N') :
+                                                            LA6_71 = self.input.LA(14)
+
+                                                            if (LA6_71 == u'D') :
+                                                                LA6_73 = self.input.LA(15)
+
+                                                                if ((u'0' <= LA6_73 <= u'9') or (u'A' <= LA6_73 <= u'Z') or LA6_73 == u'_' or (u'a' <= LA6_73 <= u'z')) :
+                                                                    alt6 = 20
+                                                                else:
+                                                                    alt6 = 3
+                                                            else:
+                                                                alt6 = 20
+                                                        else:
+                                                            alt6 = 20
+                                                    else:
+                                                        alt6 = 20
+                                                else:
+                                                    alt6 = 20
+                                            else:
+                                                alt6 = 20
+                                        else:
+                                            alt6 = 20
+                                    else:
+                                        alt6 = 20
+                                else:
+                                    alt6 = 20
+                            else:
+                                alt6 = 20
+                        else:
+                            alt6 = 20
+                    else:
+                        alt6 = 20
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'E':
+            LA6_2 = self.input.LA(2)
+
+            if (LA6_2 == u'N') :
+                LA6_21 = self.input.LA(3)
+
+                if (LA6_21 == u'D') :
+                    LA6_32 = self.input.LA(4)
+
+                    if ((u'0' <= LA6_32 <= u'9') or (u'A' <= LA6_32 <= u'Z') or LA6_32 == u'_' or (u'a' <= LA6_32 <= u'z')) :
+                        alt6 = 20
+                    else:
+                        alt6 = 2
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'B':
+            LA6_3 = self.input.LA(2)
+
+            if (LA6_3 == u'E') :
+                LA6_22 = self.input.LA(3)
+
+                if (LA6_22 == u'F') :
+                    LA6_33 = self.input.LA(4)
+
+                    if (LA6_33 == u'O') :
+                        LA6_44 = self.input.LA(5)
+
+                        if (LA6_44 == u'R') :
+                            LA6_53 = self.input.LA(6)
+
+                            if (LA6_53 == u'E') :
+                                LA6_59 = self.input.LA(7)
+
+                                if ((u'0' <= LA6_59 <= u'9') or (u'A' <= LA6_59 <= u'Z') or LA6_59 == u'_' or (u'a' <= LA6_59 <= u'z')) :
+                                    alt6 = 20
+                                else:
+                                    alt6 = 4
+                            else:
+                                alt6 = 20
+                        else:
+                            alt6 = 20
+                    else:
+                        alt6 = 20
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'A':
+            LA6 = self.input.LA(2)
+            if LA6 == u'F':
+                LA6_23 = self.input.LA(3)
+
+                if (LA6_23 == u'T') :
+                    LA6_34 = self.input.LA(4)
+
+                    if (LA6_34 == u'E') :
+                        LA6_45 = self.input.LA(5)
+
+                        if (LA6_45 == u'R') :
+                            LA6_54 = self.input.LA(6)
+
+                            if ((u'0' <= LA6_54 <= u'9') or (u'A' <= LA6_54 <= u'Z') or LA6_54 == u'_' or (u'a' <= LA6_54 <= u'z')) :
+                                alt6 = 20
+                            else:
+                                alt6 = 5
+                        else:
+                            alt6 = 20
+                    else:
+                        alt6 = 20
+                else:
+                    alt6 = 20
+            elif LA6 == u'N':
+                LA6_24 = self.input.LA(3)
+
+                if (LA6_24 == u'D') :
+                    LA6_35 = self.input.LA(4)
+
+                    if ((u'0' <= LA6_35 <= u'9') or (u'A' <= LA6_35 <= u'Z') or LA6_35 == u'_' or (u'a' <= LA6_35 <= u'z')) :
+                        alt6 = 20
+                    else:
+                        alt6 = 7
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'S':
+            LA6_5 = self.input.LA(2)
+
+            if (LA6_5 == u'O') :
+                LA6_25 = self.input.LA(3)
+
+                if (LA6_25 == u'R') :
+                    LA6_36 = self.input.LA(4)
+
+                    if ((u'0' <= LA6_36 <= u'9') or (u'A' <= LA6_36 <= u'Z') or LA6_36 == u'_' or (u'a' <= LA6_36 <= u'z')) :
+                        alt6 = 20
+                    else:
+                        alt6 = 6
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'O':
+            LA6_6 = self.input.LA(2)
+
+            if (LA6_6 == u'R') :
+                LA6_26 = self.input.LA(3)
+
+                if ((u'0' <= LA6_26 <= u'9') or (u'A' <= LA6_26 <= u'Z') or LA6_26 == u'_' or (u'a' <= LA6_26 <= u'z')) :
+                    alt6 = 20
+                else:
+                    alt6 = 8
+            else:
+                alt6 = 20
+        elif LA6 == u'T':
+            LA6_7 = self.input.LA(2)
+
+            if (LA6_7 == u'R') :
+                LA6_27 = self.input.LA(3)
+
+                if (LA6_27 == u'U') :
+                    LA6_38 = self.input.LA(4)
+
+                    if (LA6_38 == u'E') :
+                        LA6_48 = self.input.LA(5)
+
+                        if ((u'0' <= LA6_48 <= u'9') or (u'A' <= LA6_48 <= u'Z') or LA6_48 == u'_' or (u'a' <= LA6_48 <= u'z')) :
+                            alt6 = 20
+                        else:
+                            alt6 = 9
+                    else:
+                        alt6 = 20
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'F':
+            LA6_8 = self.input.LA(2)
+
+            if (LA6_8 == u'A') :
+                LA6_28 = self.input.LA(3)
+
+                if (LA6_28 == u'L') :
+                    LA6_39 = self.input.LA(4)
+
+                    if (LA6_39 == u'S') :
+                        LA6_49 = self.input.LA(5)
+
+                        if (LA6_49 == u'E') :
+                            LA6_56 = self.input.LA(6)
+
+                            if ((u'0' <= LA6_56 <= u'9') or (u'A' <= LA6_56 <= u'Z') or LA6_56 == u'_' or (u'a' <= LA6_56 <= u'z')) :
+                                alt6 = 20
+                            else:
+                                alt6 = 10
+                        else:
+                            alt6 = 20
+                    else:
+                        alt6 = 20
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'N':
+            LA6_9 = self.input.LA(2)
+
+            if (LA6_9 == u'O') :
+                LA6_29 = self.input.LA(3)
+
+                if (LA6_29 == u'T') :
+                    LA6_40 = self.input.LA(4)
+
+                    if ((u'0' <= LA6_40 <= u'9') or (u'A' <= LA6_40 <= u'Z') or LA6_40 == u'_' or (u'a' <= LA6_40 <= u'z')) :
+                        alt6 = 20
+                    else:
+                        alt6 = 11
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'(':
+            alt6 = 12
+        elif LA6 == u')':
+            alt6 = 13
+        elif LA6 == u'{':
+            alt6 = 14
+        elif LA6 == u',':
+            alt6 = 15
+        elif LA6 == u'}':
+            alt6 = 16
+        elif LA6 == u'P':
+            LA6_15 = self.input.LA(2)
+
+            if (LA6_15 == u'U') :
+                LA6_30 = self.input.LA(3)
+
+                if (LA6_30 == u'S') :
+                    LA6_41 = self.input.LA(4)
+
+                    if (LA6_41 == u'H') :
+                        LA6_51 = self.input.LA(5)
+
+                        if ((u'0' <= LA6_51 <= u'9') or (u'A' <= LA6_51 <= u'Z') or LA6_51 == u'_' or (u'a' <= LA6_51 <= u'z')) :
+                            alt6 = 20
+                        else:
+                            alt6 = 17
+                    else:
+                        alt6 = 20
+                else:
+                    alt6 = 20
+            else:
+                alt6 = 20
+        elif LA6 == u'#':
+            alt6 = 18
+        elif LA6 == u'\t' or LA6 == u'\n' or LA6 == u'\r' or LA6 == u' ':
+            alt6 = 19
+        elif LA6 == u'C' or LA6 == u'G' or LA6 == u'H' or LA6 == u'I' or LA6 == u'J' or LA6 == u'K' or LA6 == u'L' or LA6 == u'M' or LA6 == u'Q' or LA6 == u'R' or LA6 == u'U' or LA6 == u'V' or LA6 == u'W' or LA6 == u'X' or LA6 == u'Y' or LA6 == u'Z' or LA6 == u'_' or LA6 == u'a' or LA6 == u'b' or LA6 == u'c' or LA6 == u'd' or LA6 == u'e' or LA6 == u'f' or LA6 == u'g' or LA6 == u'h' or LA6 == u'i' or LA6 == u'j' or LA6 == u'k' or LA6 == u'l' or LA6 == u'm' or LA6 == u'n' or LA6 == u'o' or LA6 == u'p' or LA6 == u'q' or LA6 == u'r' or LA6 == u's' or LA6 == u't' or LA6 == u'u' or LA6 == u'v' or LA6 == u'w' or LA6 == u'x' or LA6 == u'y' or LA6 == u'z':
+            alt6 = 20
+        elif LA6 == u'0':
+            alt6 = 21
+        else:
+            nvae = NoViableAltException("1:1: Tokens : ( T12 | T13 | T14 | T15 | T16 | T17 | T18 | T19 | T20 | T21 | T22 | T23 | T24 | T25 | T26 | T27 | OpCode | COMMENT | WS | GuidName | Hex );", 6, 0, self.input)
+
+            raise nvae
+
+        if alt6 == 1:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:10: T12
+            self.mT12()
+
+
+
+        elif alt6 == 2:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:14: T13
+            self.mT13()
+
+
+
+        elif alt6 == 3:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:18: T14
+            self.mT14()
+
+
+
+        elif alt6 == 4:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:22: T15
+            self.mT15()
+
+
+
+        elif alt6 == 5:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:26: T16
+            self.mT16()
+
+
+
+        elif alt6 == 6:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:30: T17
+            self.mT17()
+
+
+
+        elif alt6 == 7:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:34: T18
+            self.mT18()
+
+
+
+        elif alt6 == 8:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:38: T19
+            self.mT19()
+
+
+
+        elif alt6 == 9:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:42: T20
+            self.mT20()
+
+
+
+        elif alt6 == 10:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:46: T21
+            self.mT21()
+
+
+
+        elif alt6 == 11:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:50: T22
+            self.mT22()
+
+
+
+        elif alt6 == 12:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:54: T23
+            self.mT23()
+
+
+
+        elif alt6 == 13:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:58: T24
+            self.mT24()
+
+
+
+        elif alt6 == 14:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:62: T25
+            self.mT25()
+
+
+
+        elif alt6 == 15:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:66: T26
+            self.mT26()
+
+
+
+        elif alt6 == 16:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:70: T27
+            self.mT27()
+
+
+
+        elif alt6 == 17:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:74: OpCode
+            self.mOpCode()
+
+
+
+        elif alt6 == 18:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:81: COMMENT
+            self.mCOMMENT()
+
+
+
+        elif alt6 == 19:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:89: WS
+            self.mWS()
+
+
+
+        elif alt6 == 20:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:92: GuidName
+            self.mGuidName()
+
+
+
+        elif alt6 == 21:
+            # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:1:101: Hex
+            self.mHex()
+
+
+
+
+
+
+
+
+
diff --git a/Source/Python/AutoGen/DepexParser.py b/Source/Python/AutoGen/DepexParser.py
new file mode 100644 (file)
index 0000000..876ff52
--- /dev/null
@@ -0,0 +1,848 @@
+# $ANTLR 3.0.1 H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g 2008-04-09 15:15:35
+
+from antlr3 import *
+from antlr3.compat import set, frozenset
+         \r
+from Common.BuildToolError import *\r
+from Common import EdkLogger as EdkLogger\r
+
+
+
+# for convenience in actions
+HIDDEN = BaseRecognizer.HIDDEN
+
+# token types
+OpCode=6
+Letter=10
+GuidName=4
+AlphaNumeric=11
+WS=9
+EOF=-1
+Hex=5
+Whitespace=8
+COMMENT=7
+
+# token names
+tokenNames = [
+    "<invalid>", "<EOR>", "<DOWN>", "<UP>", 
+    "GuidName", "Hex", "OpCode", "COMMENT", "Whitespace", "WS", "Letter", 
+    "AlphaNumeric", "'DEPENDENCY_START'", "'END'", "'DEPENDENCY_END'", "'BEFORE'", 
+    "'AFTER'", "'SOR'", "'AND'", "'OR'", "'TRUE'", "'FALSE'", "'NOT'", "'('", 
+    "')'", "'{'", "','", "'}'"
+]
+
+
+
+class DepexParser(Parser):
+    grammarFileName = "H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g"
+    tokenNames = tokenNames
+
+    def __init__(self, input):
+        Parser.__init__(self, input)
+
+
+               \r
+        self._DepexFile = ''\r
+        self._ExclusiveOpcode = ["BEFORE", "AFTER"]\r
+        self._AboveAllOpcode = ["SOR", "BEFORE", "AFTER"]\r
+        self._ExpressionType = -1\r
+        self._Parentheses = 0\r
+        self.PostfixNotation = []\r
+        self.TokenList = [t.text for t in self.input.tokens]\r
+        self.OpcodeList = []\r
+        self._DepexString = ' '.join(self.TokenList)\r
+
+
+                
+
+
+              \r
+    EXPRESSION_BEFORE = 0\r
+    EXPRESSION_AFTER = 1\r
+    EXPRESSION_SOR = 2\r
+    EXPRESSION_BOOL = 3\r
+
+
+
+    # $ANTLR start start
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:41:1: start[FilePath] : depex_expression ;
+    def start(self, FilePath):
+
+        self._DepexFile=FilePath
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:43:5: ( depex_expression )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:43:7: depex_expression
+                self.following.append(self.FOLLOW_depex_expression_in_start64)
+                self.depex_expression()
+                self.following.pop()
+
+                #action start
+                 \r
+                # there should be no more tokens left\r
+                if self.input.LT(1).text != None:\r
+                    raise RecognitionException("Ending error")\r
+                if self.PostfixNotation[-1] != 'END':\r
+                    self.PostfixNotation.append('END')\r
+
+                #action end
+
+
+
+
+            except RecognitionException, e:
+                                                 \r
+                LastToken = self.input.LT(-1)\r
+                if LastToken != None:\r
+                    LastToken = LastToken.text\r
+                NextToken = self.input.LT(1)\r
+                if NextToken != None:\r
+                    NextToken = NextToken.text\r
+                if self._Parentheses != 0:\r
+                    Msg = "Parentheses mismatched"\r
+                elif LastToken == 'END':\r
+                    Msg = "No more opcode or operand after END"\r
+                elif self._ExpressionType in [self.EXPRESSION_BEFORE, self.EXPRESSION_AFTER]:\r
+                    Msg = "Unnecessary expression after [%s]" % LastToken\r
+                elif NextToken in ['SOR', 'BEFORE', 'AFTER']:\r
+                    Msg = "[%s] is not expected." % NextToken\r
+                elif NextToken in ['AND', 'OR']:\r
+                    Msg = "Missing operand near [%s]" % NextToken\r
+                elif NextToken in [')', '(']:\r
+                    Msg = "Parentheses mismatched"\r
+                else:\r
+                    Msg = "Missing opcode or operand between [%s] and [%s]" % (LastToken, NextToken)\r
+                EdkLogger.error("GenDepex", PARAMETER_INVALID, Msg, ExtraData=self._DepexString, File=self._DepexFile)\r
+
+
+            except :
+                          \r
+                raise\r
+
+
+        finally:
+
+            pass
+
+        return 
+
+    # $ANTLR end start
+
+
+    # $ANTLR start depex_expression
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:79:1: depex_expression : ( 'DEPENDENCY_START' )? ( before_expression | after_expression | sor_expression | bool_expression ) ( 'END' )? ( 'DEPENDENCY_END' )? ;
+    def depex_expression(self, ):
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:80:5: ( ( 'DEPENDENCY_START' )? ( before_expression | after_expression | sor_expression | bool_expression ) ( 'END' )? ( 'DEPENDENCY_END' )? )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:80:9: ( 'DEPENDENCY_START' )? ( before_expression | after_expression | sor_expression | bool_expression ) ( 'END' )? ( 'DEPENDENCY_END' )?
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:80:9: ( 'DEPENDENCY_START' )?
+                alt1 = 2
+                LA1_0 = self.input.LA(1)
+
+                if (LA1_0 == 12) :
+                    alt1 = 1
+                if alt1 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:80:9: 'DEPENDENCY_START'
+                    self.match(self.input, 12, self.FOLLOW_12_in_depex_expression97)
+
+
+
+
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:81:6: ( before_expression | after_expression | sor_expression | bool_expression )
+                alt2 = 4
+                LA2 = self.input.LA(1)
+                if LA2 == 15:
+                    alt2 = 1
+                elif LA2 == 16:
+                    alt2 = 2
+                elif LA2 == 17:
+                    alt2 = 3
+                elif LA2 == GuidName or LA2 == 20 or LA2 == 21 or LA2 == 22 or LA2 == 23 or LA2 == 25:
+                    alt2 = 4
+                else:
+                    nvae = NoViableAltException("81:6: ( before_expression | after_expression | sor_expression | bool_expression )", 2, 0, self.input)
+
+                    raise nvae
+
+                if alt2 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:81:7: before_expression
+                    self.following.append(self.FOLLOW_before_expression_in_depex_expression106)
+                    self.before_expression()
+                    self.following.pop()
+
+
+
+                elif alt2 == 2:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:81:25: after_expression
+                    self.following.append(self.FOLLOW_after_expression_in_depex_expression108)
+                    self.after_expression()
+                    self.following.pop()
+
+
+
+                elif alt2 == 3:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:81:42: sor_expression
+                    self.following.append(self.FOLLOW_sor_expression_in_depex_expression110)
+                    self.sor_expression()
+                    self.following.pop()
+
+
+
+                elif alt2 == 4:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:81:57: bool_expression
+                    self.following.append(self.FOLLOW_bool_expression_in_depex_expression112)
+                    self.bool_expression()
+                    self.following.pop()
+
+
+
+
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:82:6: ( 'END' )?
+                alt3 = 2
+                LA3_0 = self.input.LA(1)
+
+                if (LA3_0 == 13) :
+                    alt3 = 1
+                if alt3 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:82:6: 'END'
+                    self.match(self.input, 13, self.FOLLOW_13_in_depex_expression120)
+
+
+
+
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:83:6: ( 'DEPENDENCY_END' )?
+                alt4 = 2
+                LA4_0 = self.input.LA(1)
+
+                if (LA4_0 == 14) :
+                    alt4 = 1
+                if alt4 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:83:6: 'DEPENDENCY_END'
+                    self.match(self.input, 14, self.FOLLOW_14_in_depex_expression128)
+
+
+
+
+
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return 
+
+    # $ANTLR end depex_expression
+
+
+    # $ANTLR start before_expression
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:86:1: before_expression : Op= 'BEFORE' V= guid ;
+    def before_expression(self, ):
+
+        Op = None
+        V = None
+
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:87:5: (Op= 'BEFORE' V= guid )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:87:10: Op= 'BEFORE' V= guid
+                Op = self.input.LT(1)
+                self.match(self.input, 15, self.FOLLOW_15_in_before_expression151)
+
+                self.following.append(self.FOLLOW_guid_in_before_expression155)
+                V = self.guid()
+                self.following.pop()
+
+                #action start
+                                             \r
+                self.PostfixNotation.append(Op.text)\r
+                self.PostfixNotation.append(V)\r
+                self.OpcodeList.append(Op.text)\r
+                self._ExpressionType = self.EXPRESSION_BEFORE\r
+
+                #action end
+
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return 
+
+    # $ANTLR end before_expression
+
+
+    # $ANTLR start after_expression
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:95:1: after_expression : Op= 'AFTER' V= guid ;
+    def after_expression(self, ):
+
+        Op = None
+        V = None
+
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:96:5: (Op= 'AFTER' V= guid )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:96:10: Op= 'AFTER' V= guid
+                Op = self.input.LT(1)
+                self.match(self.input, 16, self.FOLLOW_16_in_after_expression179)
+
+                self.following.append(self.FOLLOW_guid_in_after_expression183)
+                V = self.guid()
+                self.following.pop()
+
+                #action start
+                 \r
+                self.PostfixNotation.append(Op.text)\r
+                self.PostfixNotation.append(V)\r
+                self.OpcodeList.append(Op.text)\r
+                self._ExpressionType = self.EXPRESSION_AFTER\r
+
+                #action end
+
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return 
+
+    # $ANTLR end after_expression
+
+
+    # $ANTLR start sor_expression
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:105:1: sor_expression : Op= 'SOR' Expr= bool_statement ;
+    def sor_expression(self, ):
+
+        Op = None
+        Expr = None
+
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:106:5: (Op= 'SOR' Expr= bool_statement )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:106:10: Op= 'SOR' Expr= bool_statement
+                Op = self.input.LT(1)
+                self.match(self.input, 17, self.FOLLOW_17_in_sor_expression207)
+
+                self.following.append(self.FOLLOW_bool_statement_in_sor_expression211)
+                Expr = self.bool_statement()
+                self.following.pop()
+
+                #action start
+                 \r
+                self.PostfixNotation.append(Op.text)\r
+                self.PostfixNotation.extend(Expr)\r
+                self.OpcodeList.append(Op.text)\r
+                self._ExpressionType = self.EXPRESSION_SOR\r
+
+                #action end
+
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return 
+
+    # $ANTLR end sor_expression
+
+
+    # $ANTLR start bool_expression
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:115:1: bool_expression : Expr= bool_statement ;
+    def bool_expression(self, ):
+
+        Expr = None
+
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:116:5: (Expr= bool_statement )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:116:10: Expr= bool_statement
+                self.following.append(self.FOLLOW_bool_statement_in_bool_expression239)
+                Expr = self.bool_statement()
+                self.following.pop()
+
+                #action start
+                 \r
+                self.PostfixNotation.extend(Expr)\r
+                self._ExpressionType = self.EXPRESSION_BOOL\r
+
+                #action end
+
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return 
+
+    # $ANTLR end bool_expression
+
+
+    # $ANTLR start bool_statement
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:123:1: bool_statement returns [ExpressionList] : SubExpr= bool_factor ( 'AND' SubExpr= bool_statement | 'OR' SubExpr= bool_statement )* ;
+    def bool_statement(self, ):
+
+        ExpressionList = None
+
+        SubExpr = None
+
+
+               \r
+        ExpressionList=[]\r
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:126:3: (SubExpr= bool_factor ( 'AND' SubExpr= bool_statement | 'OR' SubExpr= bool_statement )* )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:127:5: SubExpr= bool_factor ( 'AND' SubExpr= bool_statement | 'OR' SubExpr= bool_statement )*
+                self.following.append(self.FOLLOW_bool_factor_in_bool_statement269)
+                SubExpr = self.bool_factor()
+                self.following.pop()
+
+                #action start
+                ExpressionList.extend(SubExpr)
+                #action end
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:128:5: ( 'AND' SubExpr= bool_statement | 'OR' SubExpr= bool_statement )*
+                while True: #loop5
+                    alt5 = 3
+                    LA5_0 = self.input.LA(1)
+
+                    if (LA5_0 == 18) :
+                        alt5 = 1
+                    elif (LA5_0 == 19) :
+                        alt5 = 2
+
+
+                    if alt5 == 1:
+                        # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:128:10: 'AND' SubExpr= bool_statement
+                        self.match(self.input, 18, self.FOLLOW_18_in_bool_statement282)
+
+                        self.following.append(self.FOLLOW_bool_statement_in_bool_statement286)
+                        SubExpr = self.bool_statement()
+                        self.following.pop()
+
+                        #action start
+                        ExpressionList.extend(SubExpr);ExpressionList.append('AND');self.OpcodeList.append('AND')
+                        #action end
+
+
+                    elif alt5 == 2:
+                        # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:129:10: 'OR' SubExpr= bool_statement
+                        self.match(self.input, 19, self.FOLLOW_19_in_bool_statement299)
+
+                        self.following.append(self.FOLLOW_bool_statement_in_bool_statement303)
+                        SubExpr = self.bool_statement()
+                        self.following.pop()
+
+                        #action start
+                        ExpressionList.extend(SubExpr);ExpressionList.append('OR');self.OpcodeList.append('OR')
+                        #action end
+
+
+                    else:
+                        break #loop5
+
+
+
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return ExpressionList
+
+    # $ANTLR end bool_statement
+
+
+    # $ANTLR start bool_factor
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:133:1: bool_factor returns [ExpressionList] : (Bl= 'TRUE' | Bl= 'FALSE' | Op= 'NOT' Be= bool_statement | ( '(' ) Be= bool_statement ( ')' ) | V= guid );
+    def bool_factor(self, ):
+
+        ExpressionList = None
+
+        Bl = None
+        Op = None
+        Be = None
+
+        V = None
+
+
+               \r
+        ExpressionList=[]\r
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:136:3: (Bl= 'TRUE' | Bl= 'FALSE' | Op= 'NOT' Be= bool_statement | ( '(' ) Be= bool_statement ( ')' ) | V= guid )
+                alt6 = 5
+                LA6 = self.input.LA(1)
+                if LA6 == 20:
+                    alt6 = 1
+                elif LA6 == 21:
+                    alt6 = 2
+                elif LA6 == 22:
+                    alt6 = 3
+                elif LA6 == 23:
+                    alt6 = 4
+                elif LA6 == GuidName or LA6 == 25:
+                    alt6 = 5
+                else:
+                    nvae = NoViableAltException("133:1: bool_factor returns [ExpressionList] : (Bl= 'TRUE' | Bl= 'FALSE' | Op= 'NOT' Be= bool_statement | ( '(' ) Be= bool_statement ( ')' ) | V= guid );", 6, 0, self.input)
+
+                    raise nvae
+
+                if alt6 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:137:9: Bl= 'TRUE'
+                    Bl = self.input.LT(1)
+                    self.match(self.input, 20, self.FOLLOW_20_in_bool_factor340)
+
+                    #action start
+                    ExpressionList.append(Bl.text)
+                    #action end
+
+
+                elif alt6 == 2:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:138:10: Bl= 'FALSE'
+                    Bl = self.input.LT(1)
+                    self.match(self.input, 21, self.FOLLOW_21_in_bool_factor355)
+
+                    #action start
+                    ExpressionList.append(Bl.text)
+                    #action end
+
+
+                elif alt6 == 3:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:139:10: Op= 'NOT' Be= bool_statement
+                    Op = self.input.LT(1)
+                    self.match(self.input, 22, self.FOLLOW_22_in_bool_factor370)
+
+                    self.following.append(self.FOLLOW_bool_statement_in_bool_factor374)
+                    Be = self.bool_statement()
+                    self.following.pop()
+
+                    #action start
+                    ExpressionList.extend(Be);ExpressionList.append(Op.text)
+                    #action end
+
+
+                elif alt6 == 4:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:140:10: ( '(' ) Be= bool_statement ( ')' )
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:140:10: ( '(' )
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:140:12: '('
+                    self.match(self.input, 23, self.FOLLOW_23_in_bool_factor389)
+
+                    #action start
+                    self._Parentheses+=1
+                    #action end
+
+
+
+                    self.following.append(self.FOLLOW_bool_statement_in_bool_factor397)
+                    Be = self.bool_statement()
+                    self.following.pop()
+
+                    #action start
+                    ExpressionList.extend(Be)
+                    #action end
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:140:87: ( ')' )
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:140:89: ')'
+                    self.match(self.input, 24, self.FOLLOW_24_in_bool_factor403)
+
+                    #action start
+                    self._Parentheses-=1
+                    #action end
+
+
+
+
+
+                elif alt6 == 5:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:141:10: V= guid
+                    self.following.append(self.FOLLOW_guid_in_bool_factor420)
+                    V = self.guid()
+                    self.following.pop()
+
+                    #action start
+                    ExpressionList.append('PUSH');ExpressionList.append(V)
+                    #action end
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return ExpressionList
+
+    # $ANTLR end bool_factor
+
+
+    # $ANTLR start guid
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:144:1: guid returns [GuidValue] : ( GuidName | guid_value );
+    def guid(self, ):
+
+        GuidValue = None
+
+        GuidName1 = None
+        guid_value2 = None
+
+
+               \r
+        GuidValue = None\r
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:147:3: ( GuidName | guid_value )
+                alt7 = 2
+                LA7_0 = self.input.LA(1)
+
+                if (LA7_0 == GuidName) :
+                    alt7 = 1
+                elif (LA7_0 == 25) :
+                    alt7 = 2
+                else:
+                    nvae = NoViableAltException("144:1: guid returns [GuidValue] : ( GuidName | guid_value );", 7, 0, self.input)
+
+                    raise nvae
+
+                if alt7 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:148:5: GuidName
+                    GuidName1 = self.input.LT(1)
+                    self.match(self.input, GuidName, self.FOLLOW_GuidName_in_guid452)
+
+                    #action start
+                     \r
+                    EdkLogger.error("GenDepex", RESOURCE_NOT_AVAILABLE, "Value of GUID [%s] is not available" % GuidName1.text, ExtraData=self._DepexString, File=self._DepexFile)\r
+
+                    #action end
+
+
+                elif alt7 == 2:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:152:10: guid_value
+                    self.following.append(self.FOLLOW_guid_value_in_guid465)
+                    guid_value2 = self.guid_value()
+                    self.following.pop()
+
+                    #action start
+                     \r
+                    GuidValue=self.input.toString(guid_value2.start,guid_value2.stop)\r
+
+                    #action end
+
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return GuidValue
+
+    # $ANTLR end guid
+
+    class guid_value_return(object):
+        def __init__(self):
+            self.start = None
+            self.stop = None
+
+
+
+    # $ANTLR start guid_value
+    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:158:1: guid_value : '{' Hex ',' Hex ',' Hex ',' ( '{' )? Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ( '}' )? '}' ;
+    def guid_value(self, ):
+
+        retval = self.guid_value_return()
+        retval.start = self.input.LT(1)
+
+        try:
+            try:
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:159:5: ( '{' Hex ',' Hex ',' Hex ',' ( '{' )? Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ( '}' )? '}' )
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:159:10: '{' Hex ',' Hex ',' Hex ',' ( '{' )? Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ',' Hex ( '}' )? '}'
+                self.match(self.input, 25, self.FOLLOW_25_in_guid_value487)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value489)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value491)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value493)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value495)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value497)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value499)
+
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:159:38: ( '{' )?
+                alt8 = 2
+                LA8_0 = self.input.LA(1)
+
+                if (LA8_0 == 25) :
+                    alt8 = 1
+                if alt8 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:159:38: '{'
+                    self.match(self.input, 25, self.FOLLOW_25_in_guid_value501)
+
+
+
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value504)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value506)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value508)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value510)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value512)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value514)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value516)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value518)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value520)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value522)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value524)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value526)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value528)
+
+                self.match(self.input, 26, self.FOLLOW_26_in_guid_value530)
+
+                self.match(self.input, Hex, self.FOLLOW_Hex_in_guid_value532)
+
+                # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:159:103: ( '}' )?
+                alt9 = 2
+                LA9_0 = self.input.LA(1)
+
+                if (LA9_0 == 27) :
+                    LA9_1 = self.input.LA(2)
+
+                    if (LA9_1 == 27) :
+                        alt9 = 1
+                if alt9 == 1:
+                    # H:\\dev\\BugFix\\Source\\Python\\AutoGen\\Depex.g:159:103: '}'
+                    self.match(self.input, 27, self.FOLLOW_27_in_guid_value534)
+
+
+
+
+                self.match(self.input, 27, self.FOLLOW_27_in_guid_value537)
+
+
+
+
+                retval.stop = self.input.LT(-1)
+
+
+                        \r
+            except BaseException,e:\r
+                raise\r
+        finally:
+
+            pass
+
+        return retval
+
+    # $ANTLR end guid_value
+
+
+
+    FOLLOW_depex_expression_in_start64 = frozenset([1])
+    FOLLOW_12_in_depex_expression97 = frozenset([4, 15, 16, 17, 20, 21, 22, 23, 25])
+    FOLLOW_before_expression_in_depex_expression106 = frozenset([1, 13, 14])
+    FOLLOW_after_expression_in_depex_expression108 = frozenset([1, 13, 14])
+    FOLLOW_sor_expression_in_depex_expression110 = frozenset([1, 13, 14])
+    FOLLOW_bool_expression_in_depex_expression112 = frozenset([1, 13, 14])
+    FOLLOW_13_in_depex_expression120 = frozenset([1, 14])
+    FOLLOW_14_in_depex_expression128 = frozenset([1])
+    FOLLOW_15_in_before_expression151 = frozenset([4, 25])
+    FOLLOW_guid_in_before_expression155 = frozenset([1])
+    FOLLOW_16_in_after_expression179 = frozenset([4, 25])
+    FOLLOW_guid_in_after_expression183 = frozenset([1])
+    FOLLOW_17_in_sor_expression207 = frozenset([4, 20, 21, 22, 23, 25])
+    FOLLOW_bool_statement_in_sor_expression211 = frozenset([1])
+    FOLLOW_bool_statement_in_bool_expression239 = frozenset([1])
+    FOLLOW_bool_factor_in_bool_statement269 = frozenset([1, 18, 19])
+    FOLLOW_18_in_bool_statement282 = frozenset([4, 20, 21, 22, 23, 25])
+    FOLLOW_bool_statement_in_bool_statement286 = frozenset([1, 18, 19])
+    FOLLOW_19_in_bool_statement299 = frozenset([4, 20, 21, 22, 23, 25])
+    FOLLOW_bool_statement_in_bool_statement303 = frozenset([1, 18, 19])
+    FOLLOW_20_in_bool_factor340 = frozenset([1])
+    FOLLOW_21_in_bool_factor355 = frozenset([1])
+    FOLLOW_22_in_bool_factor370 = frozenset([4, 20, 21, 22, 23, 25])
+    FOLLOW_bool_statement_in_bool_factor374 = frozenset([1])
+    FOLLOW_23_in_bool_factor389 = frozenset([4, 20, 21, 22, 23, 25])
+    FOLLOW_bool_statement_in_bool_factor397 = frozenset([24])
+    FOLLOW_24_in_bool_factor403 = frozenset([1])
+    FOLLOW_guid_in_bool_factor420 = frozenset([1])
+    FOLLOW_GuidName_in_guid452 = frozenset([1])
+    FOLLOW_guid_value_in_guid465 = frozenset([1])
+    FOLLOW_25_in_guid_value487 = frozenset([5])
+    FOLLOW_Hex_in_guid_value489 = frozenset([26])
+    FOLLOW_26_in_guid_value491 = frozenset([5])
+    FOLLOW_Hex_in_guid_value493 = frozenset([26])
+    FOLLOW_26_in_guid_value495 = frozenset([5])
+    FOLLOW_Hex_in_guid_value497 = frozenset([26])
+    FOLLOW_26_in_guid_value499 = frozenset([5, 25])
+    FOLLOW_25_in_guid_value501 = frozenset([5])
+    FOLLOW_Hex_in_guid_value504 = frozenset([26])
+    FOLLOW_26_in_guid_value506 = frozenset([5])
+    FOLLOW_Hex_in_guid_value508 = frozenset([26])
+    FOLLOW_26_in_guid_value510 = frozenset([5])
+    FOLLOW_Hex_in_guid_value512 = frozenset([26])
+    FOLLOW_26_in_guid_value514 = frozenset([5])
+    FOLLOW_Hex_in_guid_value516 = frozenset([26])
+    FOLLOW_26_in_guid_value518 = frozenset([5])
+    FOLLOW_Hex_in_guid_value520 = frozenset([26])
+    FOLLOW_26_in_guid_value522 = frozenset([5])
+    FOLLOW_Hex_in_guid_value524 = frozenset([26])
+    FOLLOW_26_in_guid_value526 = frozenset([5])
+    FOLLOW_Hex_in_guid_value528 = frozenset([26])
+    FOLLOW_26_in_guid_value530 = frozenset([5])
+    FOLLOW_Hex_in_guid_value532 = frozenset([27])
+    FOLLOW_27_in_guid_value534 = frozenset([27])
+    FOLLOW_27_in_guid_value537 = frozenset([1])
+
index 881be4a..cf11121 100644 (file)
 import sys\r
 import os\r
 import re\r
+import traceback\r
+\r
 from StringIO import StringIO\r
 from struct import pack\r
-from Common.EdkIIWorkspace import CreateDirectory\r
 from Common.BuildToolError import *\r
 from Common.Misc import SaveFileOnChange\r
 from Common import EdkLogger as EdkLogger\r
 \r
+import antlr3\r
+from DepexLexer import DepexLexer\r
+from DepexParser import DepexParser\r
+\r
 ## Mapping between module type and EFI phase\r
 gType2Phase = {\r
     "BASE"              :   None,\r
@@ -81,137 +86,42 @@ class DependencyExpression:
     # all supported op codes and operands\r
     SupportedOpcode = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "END", "SOR"]\r
     SupportedOperand = ["TRUE", "FALSE"]\r
-\r
-    # op code that should not be the last one\r
-    NonEndingOpcode = ["AND", "OR", "NOT"]\r
-    # op code must not present at the same time\r
-    ExclusiveOpcode = ["BEFORE", "AFTER"]\r
-    # op code that should be the first one if it presents\r
-    AboveAllOpcode = ["SOR", "BEFORE", "AFTER"]\r
-\r
-    #\r
-    # open and close brace must be taken as individual tokens\r
-    #\r
-    TokenPattern = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")\r
-\r
     ## Constructor\r
     # \r
     #   @param  Expression  The list or string of dependency expression\r
     #   @param  ModuleType  The type of the module using the dependency expression\r
     # \r
-    def __init__(self, Expression, ModuleType, Optimize=False):\r
+    def __init__(self, Expression, ModuleType, Optimize=False, File=''):\r
         self.Phase = gType2Phase[ModuleType]\r
         if type(Expression) == type([]):\r
             self.ExpressionString = " ".join(Expression)\r
-            self.TokenList = Expression\r
         else:\r
             self.ExpressionString = Expression\r
-            self.GetExpressionTokenList()\r
+\r
+        self.File = File\r
+        self.Tokens = None\r
+        self.Parser = None\r
 \r
         self.PostfixNotation = []\r
+        self.TokenList = []\r
         self.OpcodeList = []\r
 \r
-        self.GetPostfixNotation()\r
-        self.ValidateOpcode()\r
+        self.Parse()\r
         if Optimize:\r
             self.Optimize()\r
 \r
     def __str__(self):\r
-        return " ".join(self.TokenList)\r
-\r
-    ## Split the expression string into token list\r
-    def GetExpressionTokenList(self):\r
-        self.TokenList = self.TokenPattern.findall(self.ExpressionString)\r
-\r
-    ## Convert token list into postfix notation\r
-    def GetPostfixNotation(self):\r
-        Stack = []\r
-        LastToken = 'AND'\r
-        for Token in self.TokenList:\r
-            if Token == "(":\r
-                if LastToken not in self.SupportedOpcode:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator",\r
-                                    ExtraData=str(self))\r
-                Stack.append(Token)\r
-            elif Token == ")":\r
-                if '(' not in Stack:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: mismatched parentheses",\r
-                                    ExtraData=str(self))\r
-                while len(Stack) > 0:\r
-                    if Stack[-1] == '(':\r
-                        Stack.pop()\r
-                        break\r
-                    self.PostfixNotation.append(Stack.pop())\r
-            elif Token in self.OpcodePriority:\r
-                if Token == "NOT" and LastToken not in self.SupportedOpcode:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator before NOT",\r
-                                    ExtraData=str(self))\r
-                elif Token in self.SupportedOpcode and LastToken in self.SupportedOpcode:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operand before " + Token,\r
-                                    ExtraData=str(self))\r
-\r
-                while len(Stack) > 0:\r
-                    if Stack[-1] == "(" or self.OpcodePriority[Token] >= self.OpcodePriority[Stack[-1]]:\r
-                        break\r
-                    self.PostfixNotation.append(Stack.pop())\r
-                Stack.append(Token)\r
-                self.OpcodeList.append(Token)\r
-            else:\r
-                # not OP, take it as GUID\r
-                if Token not in self.SupportedOpcode:\r
-                    if LastToken not in self.SupportedOpcode + ['(', ')']:\r
-                        EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator",\r
-                                        ExtraData=str(self))\r
-                    if len(self.OpcodeList) == 0 or self.OpcodeList[-1] not in self.ExclusiveOpcode:\r
-                        if Token not in self.SupportedOperand:\r
-                            self.PostfixNotation.append("PUSH")\r
-                # check if OP is valid in this phase\r
-                elif Token in self.Opcode[self.Phase]:\r
-                    if Token == "END":\r
-                        break\r
-                    self.OpcodeList.append(Token)\r
-                else:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, \r
-                                    "Opcode=%s doesn't supported in %s stage " % (Op, self.Phase),\r
-                                    ExtraData=str(self))\r
-                self.PostfixNotation.append(Token)\r
-            LastToken = Token\r
-\r
-        # there should not be parentheses in Stack\r
-        if '(' in Stack or ')' in Stack:\r
-            EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: mismatched parentheses",\r
-                            ExtraData=str(self))\r
-        while len(Stack) > 0:\r
-            self.PostfixNotation.append(Stack.pop())\r
-        self.PostfixNotation.append("END")\r
-\r
-    ## Validate the dependency expression\r
-    def ValidateOpcode(self):\r
-        for Op in self.AboveAllOpcode:\r
-            if Op in self.PostfixNotation:\r
-                if Op != self.PostfixNotation[0]:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Opcode=%s should be the first opcode in the expression" % Op,\r
-                                    ExtraData=str(self))\r
-                if len(self.PostfixNotation) < 3:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Missing operand for %s" % Op,\r
-                                    ExtraData=str(self))\r
-        for Op in self.ExclusiveOpcode:\r
-            if Op in self.OpcodeList:\r
-                if len(self.OpcodeList) > 1:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Opcode=%s should be the only opcode in the expression" % Op,\r
-                                    ExtraData=str(self))\r
-                if len(self.PostfixNotation) < 3:\r
-                    EdkLogger.error("GenDepex", PARSER_ERROR, "Missing operand for %s" % Op,\r
-                                    ExtraData=str(self))\r
-        if self.TokenList[-1] != 'END' and self.TokenList[-1] in self.NonEndingOpcode:\r
-            EdkLogger.error("GenDepex", PARSER_ERROR, "Extra %s at the end of the dependency expression" % self.TokenList[-1],\r
-                            ExtraData=str(self))\r
-        if self.TokenList[-1] == 'END' and self.TokenList[-2] in self.NonEndingOpcode:\r
-            EdkLogger.error("GenDepex", PARSER_ERROR, "Extra %s at the end of the dependency expression" % self.TokenList[-2],\r
-                            ExtraData=str(self))\r
-        if "END" in self.TokenList and "END" != self.TokenList[-1]:\r
-            EdkLogger.error("GenDepex", PARSER_ERROR, "Extra expressions after END", \r
-                            ExtraData=str(self))\r
+        return " ".join(self.PostfixNotation)\r
+\r
+    def Parse(self):\r
+        self.Tokens = antlr3.CommonTokenStream(DepexLexer(antlr3.ANTLRStringStream(self.ExpressionString)))\r
+        self.Tokens.fillBuffer()\r
+        self.Parser = DepexParser(self.Tokens)\r
+        self.Parser.start(self.File)\r
+\r
+        self.PostfixNotation = self.Parser.PostfixNotation\r
+        self.TokenList = self.Parser.TokenList\r
+        self.OpcodeList = self.Parser.OpcodeList\r
 \r
     ## Simply optimize the dependency expression by removing duplicated operands\r
     def Optimize(self):\r
@@ -244,8 +154,8 @@ class DependencyExpression:
                 break\r
             self.TokenList.append(Op)\r
         self.PostfixNotation = []\r
-        self.GetPostfixNotation()\r
-\r
+        self.ExpressionString = ' '.join(self.TokenList)\r
+        self.Parse()\r
 \r
     ## Convert a GUID value in C structure format into its binary form\r
     #\r
@@ -272,6 +182,10 @@ class DependencyExpression:
         for Item in self.PostfixNotation:\r
             if Item in self.Opcode[self.Phase]:\r
                 Buffer.write(pack("B", self.Opcode[self.Phase][Item]))\r
+            elif Item in self.SupportedOpcode:\r
+                EdkLogger.error("GenDepex", FORMAT_INVALID, \r
+                                "Opcode [%s] is not expected in %s phase" % (Item, self.Phase),\r
+                                ExtraData=self.ExpressionString)\r
             else:\r
                 Buffer.write(self.GetGuidValue(Item))\r
 \r
@@ -286,9 +200,9 @@ class DependencyExpression:
         Buffer.close()\r
         return FileChangeFlag\r
 \r
-versionNumber = "0.02"\r
+versionNumber = "0.03"\r
 __version__ = "%prog Version " + versionNumber\r
-__copyright__ = "Copyright (c) 2007, Intel Corporation  All rights reserved."\r
+__copyright__ = "Copyright (c) 2007-2008, Intel Corporation  All rights reserved."\r
 __usage__ = "%prog [options] [dependency_expression_file]"\r
 \r
 ## Parse command line options\r
@@ -310,8 +224,7 @@ def GetOptions():
                       help="Do some simple optimization on the expression.")\r
     Parser.add_option("-v", "--verbose", dest="verbose", default=False, action="store_true",\r
                       help="build with verbose information")\r
-    Parser.add_option("-d", "--debug", dest="debug", default=False, action="store_true",\r
-                      help="build with debug information")\r
+    Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r
     Parser.add_option("-q", "--quiet", dest="quiet", default=False, action="store_true",\r
                       help="build with little information")\r
 \r
@@ -326,32 +239,46 @@ def GetOptions():
 def Main():\r
     EdkLogger.Initialize()\r
     Option, Input = GetOptions()\r
-    if Option.ModuleType == None or Option.ModuleType not in gType2Phase:\r
-        print "Module type is not specified or supported"\r
-        return 1\r
+\r
+    # Set log level\r
+    if Option.verbose != None:\r
+        EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
+    elif Option.quiet != None:\r
+        EdkLogger.SetLevel(EdkLogger.QUIET)\r
+    elif Option.debug != None:\r
+        EdkLogger.SetLevel(Option.debug + 1)\r
+    else:\r
+        EdkLogger.SetLevel(EdkLogger.INFO)\r
 \r
     try:\r
+        if Option.ModuleType == None or Option.ModuleType not in gType2Phase:\r
+            EdkLogger.error("GenDepex", OPTION_MISSING, "Module type is not specified or supported")\r
+\r
+        DxsFile = ''\r
         if len(Input) > 0 and Option.Expression == "":\r
             DxsFile = Input[0]\r
-            DxsString = open(DxsFile, 'r').read().replace("\n", " ").replace("\r", " ")\r
-            DxsString = re.compile("DEPENDENCY_START(.+)DEPENDENCY_END").findall(DxsString)[0]\r
+            DxsString = open(DxsFile, 'r').read()\r
         elif Option.Expression != "":\r
             if Option.Expression[0] == '"':\r
                 DxsString = Option.Expression[1:-1]\r
             else:\r
                 DxsString = Option.Expression\r
         else:\r
-            print "No expression string or file given"\r
-            return 1\r
+            EdkLogger.error("GenDepex", OPTION_MISSING, "No expression string or file given")\r
 \r
-        Dpx = DependencyExpression(DxsString, Option.ModuleType, Option.Optimize)\r
+        DxsString += '\n'\r
+        Dpx = DependencyExpression(DxsString, Option.ModuleType, Option.Optimize, DxsFile)\r
 \r
         if Option.OutputFile != None:\r
             Dpx.Generate(Option.OutputFile)\r
         else:\r
             Dpx.Generate()\r
-    except Exception, e:\r
-        print e\r
+    except BaseException, X:\r
+        EdkLogger.quiet("")\r
+        if Option != None and Option.debug != None:\r
+            EdkLogger.quiet(traceback.format_exc())\r
+        else:\r
+            EdkLogger.quiet(str(X))\r
         return 1\r
 \r
     return 0\r
index 8bed29a..1a29e24 100644 (file)
@@ -78,8 +78,13 @@ class MetaFileParser(object):
 \r
     def _SectionHeaderParser(self):\r
         self._Scope = []\r
+        self._SectionName = ''\r
+        ArchList = set()\r
         for Item in GetSplitValueList(self._CurrentLine[1:-1], TAB_COMMA_SPLIT):\r
             ItemList = GetSplitValueList(Item, TAB_SPLIT)\r
+            if self._SectionName != '' and self._SectionName != ItemList[0].upper():\r
+                EdkLogger.error('Parser', FORMAT_INVALID, "Different section names in the same section",\r
+                                File=self._FilePath, Line=self._LineIndex+1, ExtraData=self._CurrentLine)\r
             self._SectionName = ItemList[0].upper()\r
             if self._SectionName in self._DataType:\r
                 self._SectionType = self._DataType[self._SectionName]\r
@@ -90,6 +95,7 @@ class MetaFileParser(object):
                 S1 = ItemList[1].upper()\r
             else:\r
                 S1 = 'COMMON'\r
+            ArchList.add(S1)\r
             # S2 may be Platform or ModuleType\r
             if len(ItemList) > 2:\r
                 S2 = ItemList[2].upper()\r
@@ -97,6 +103,11 @@ class MetaFileParser(object):
                 S2 = 'COMMON'\r
             self._Scope.append([S1, S2])\r
 \r
+        # 'COMMON' must not be used with specific ARCHs at the same section\r
+        if 'COMMON' in ArchList and len(ArchList) > 1:\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",\r
+                            File=self._FilePath, Line=self._LineIndex+1, ExtraData=self._CurrentLine)\r
+\r
     def _DefineParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)\r
         self._ValueList[0:len(TokenList)] = TokenList\r
index a1fb5f3..ea77d91 100644 (file)
@@ -72,6 +72,7 @@ def GuidValue(CName, PackageList):
 # into PlatformBuildClassObject form for easier use for AutoGen.\r
 #\r
 class DscBuildData(PlatformBuildClassObject):\r
+    # dict used to convert PCD type in database to string used by build tool\r
     _PCD_TYPE_STRING_ = {\r
         MODEL_PCD_FIXED_AT_BUILD        :   "FixedAtBuild",\r
         MODEL_PCD_PATCHABLE_IN_MODULE   :   "PatchableInModule",\r
@@ -86,6 +87,7 @@ class DscBuildData(PlatformBuildClassObject):
         MODEL_PCD_DYNAMIC_EX_VPD        :   "DynamicExVpd",\r
     }\r
 \r
+    # used to compose dummy library class name for those forced library instances\r
     _NullLibraryNumber = 0\r
 \r
     def __init__(self, FilePath, Table, Db, Arch='COMMON', Macros={}):\r
@@ -1566,7 +1568,10 @@ class InfBuildData(ModuleBuildClassObject):
             self._Libraries = []\r
             RecordList = self._Table.Query(MODEL_EFI_LIBRARY_INSTANCE, Arch=self._Arch, Platform=self._Platform)\r
             for Record in RecordList:\r
-                self._Libraries.append(Record[0])\r
+                # in case of name with '.lib' extension, which is unusual in R8.x inf\r
+                LibraryName = os.path.splitext(Record[0])[0]\r
+                if LibraryName not in self._Libraries:\r
+                    self._Libraries.append(LibraryName)\r
         return self._Libraries\r
 \r
     def _GetProtocols(self):\r
@@ -1615,6 +1620,10 @@ class InfBuildData(ModuleBuildClassObject):
         if self._Includes == None:\r
             self._Includes = []\r
             RecordList = self._Table.Query(MODEL_EFI_INCLUDE, Arch=self._Arch, Platform=self._Platform)\r
+            # [includes] section must be used only in old (R8.x) inf file\r
+            if self.AutoGenVersion >= 0x00010005 and len(RecordList) > 0:\r
+                EdkLogger.error('build', FORMAT_NOT_SUPPORTED, "No [include] section allowed",\r
+                                File=self.DescFilePath, Line=RecordList[0][-1]-1)\r
             for Record in RecordList:\r
                 File = NormPath(Record[0], self._Macros)\r
                 LineNo = Record[-1]\r
@@ -1626,6 +1635,8 @@ class InfBuildData(ModuleBuildClassObject):
                 #    if not ValidFile(File):\r
                 #        EdkLogger.error('build', FILE_NOT_FOUND, ExtraData=File,\r
                 #                        File=self.DescFilePath, Line=LineNo)\r
+                if File in self._Includes:\r
+                    continue\r
                 self._Includes.append(File)\r
         return self._Includes\r
 \r
index fa4f9a5..4af638f 100644 (file)
@@ -16,6 +16,7 @@
 # Import Modules\r
 #\r
 import os\r
+import re\r
 import sys\r
 import glob\r
 import time\r
@@ -38,7 +39,7 @@ import Common.EdkLogger
 import Common.GlobalData as GlobalData\r
 \r
 # Version and Copyright\r
-VersionNumber = "0.02"\r
+VersionNumber = "0.1"\r
 __version__ = "%prog Version " + VersionNumber\r
 __copyright__ = "Copyright (c) 2007, Intel Corporation  All rights reserved."\r
 \r
@@ -1182,14 +1183,6 @@ def Main():
     #\r
     (Option, Target) = MyOptionParser()\r
 \r
-    if len(Target) == 0:\r
-        Target = "all"\r
-    elif len(Target) >= 2:\r
-        EdkLogger.error("build", OPTION_NOT_SUPPORTED, "More than on targets are not supported.",\r
-                        ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget)))\r
-    else:\r
-        Target = Target[0].lower()\r
-\r
     # Set log level\r
     if Option.verbose != None:\r
         EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
@@ -1210,6 +1203,18 @@ def Main():
     ReturnCode = 0\r
     MyBuild = None\r
     try:\r
+        if len(Target) == 0:\r
+            Target = "all"\r
+        elif len(Target) >= 2:\r
+            EdkLogger.error("build", OPTION_NOT_SUPPORTED, "More than on targets is not supported.",\r
+                            ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget)))\r
+        else:\r
+            Target = Target[0].lower()\r
+    \r
+        if Target not in gSupportedTarget:\r
+            EdkLogger.error("build", OPTION_NOT_SUPPORTED, "Not supported target [%s]." % Target,\r
+                            ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget)))\r
+    \r
         # GlobalData.gGlobalDefines = ParseDefines(Option.Defines)\r
         #\r
         # Check environment variable: EDK_TOOLS_PATH, WORKSPACE, PATH\r