Author: msierad
Date: 2007-01-19 13:04:33 -0500 (Fri, 19 Jan 2007)
New Revision: 71350

Modified:
   trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
   
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionTokenizer.cs
   trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
   trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
   trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Token.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/conditions.jay
Log:
2007-01-19  Marek Sieradzki  <[EMAIL PROTECTED]>

        * Token.cs: Commented Transform and LiteralSubExpression and added
        FunctionName token.

        * ConditionParser.cs: Removed redundant casts, rewrote
        ParseFactorExpression () and added parsing of '!'.

        * ConditionTokenizer.cs: Always skip whitespaces when getting next
        token (no IgnoreWhiteSpace property). Don't create a token from '->'.
        Moved ReadChar () in front of all ifs.



Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog    
    2007-01-19 18:03:50 UTC (rev 71349)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog    
    2007-01-19 18:04:33 UTC (rev 71350)
@@ -1,3 +1,15 @@
+2007-01-19  Marek Sieradzki  <[EMAIL PROTECTED]>
+
+       * Token.cs: Commented Transform and LiteralSubExpression and added
+       FunctionName token.
+
+       * ConditionParser.cs: Removed redundant casts, rewrote
+       ParseFactorExpression () and added parsing of '!'.
+
+       * ConditionTokenizer.cs: Always skip whitespaces when getting next
+       token (no IgnoreWhiteSpace property). Don't create a token from '->'.
+       Moved ReadChar () in front of all ifs.
+
 2007-01-16  Marek Sieradzki  <[EMAIL PROTECTED]>
 
        * BuildItem.cs (SetMetadata): Escape when we get virtual item or item

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs
       2007-01-19 18:03:50 UTC (rev 71349)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionParser.cs
       2007-01-19 18:04:33 UTC (rev 71350)
@@ -37,10 +37,11 @@
 
        internal class ConditionParser {
        
-               ConditionTokenizer tokenizer = new ConditionTokenizer ();
+               ConditionTokenizer tokenizer;
                
                ConditionParser (string condition)
                {
+                       tokenizer = new ConditionTokenizer ();
                        tokenizer.Tokenize (condition);
                }
                
@@ -63,7 +64,7 @@
                        ConditionExpression e = parser.ParseExpression ();
                        
                        if (!parser.tokenizer.IsEOF ())
-                               throw new ExpressionParseException 
(String.Format ("Unexpected token: {0}", parser.tokenizer.Token.Value));
+                               throw new ExpressionParseException 
(String.Format ("Unexpected token: \"{0}\"", parser.tokenizer.Token.Value));
                        
                        return e;
                }
@@ -84,7 +85,7 @@
                        
                        while (tokenizer.IsToken (TokenType.And)) {
                                tokenizer.GetNextToken ();
-                               e = new ConditionAndExpression 
((ConditionExpression) e, (ConditionExpression) ParseBooleanOr ());
+                               e = new ConditionAndExpression (e, 
ParseBooleanOr ());
                        }
                        
                        return e;
@@ -96,7 +97,7 @@
                        
                        while (tokenizer.IsToken (TokenType.Or)) {
                                tokenizer.GetNextToken ();
-                               e = new ConditionOrExpression 
((ConditionExpression) e, (ConditionExpression) ParseRelationalExpression ());
+                               e = new ConditionOrExpression (e, 
ParseRelationalExpression ());
                        }
                        
                        return e;
@@ -141,23 +142,48 @@
                                        throw new ExpressionParseException 
(String.Format ("Wrong relation operator {0}", opToken.Value));
                                }
                                
-                               e =  new ConditionRelationalExpression 
((ConditionExpression) e, ParseFactorExpression (), op);
+                               e =  new ConditionRelationalExpression (e, 
ParseFactorExpression (), op);
                        }
                        
                        return e;
                }
                
-               // FIXME: parse sub expression in parens, parse TokenType.Not, 
parse functions
                ConditionExpression ParseFactorExpression ()
                {
+                       ConditionExpression e;
                        Token token = tokenizer.Token;
                        tokenizer.GetNextToken ();
-                       
-                       if (token.Type != TokenType.String && token.Type != 
TokenType.Number)
+
+                       if (token.Type == TokenType.LeftParen) {
+                               e = ParseExpression ();
+                               tokenizer.Expect (TokenType.RightParen);
+                       } else if (token.Type == TokenType.String)
+                               e = new ConditionFactorExpression (token);
+                       else if (token.Type == TokenType.Number)
+                               e = new ConditionFactorExpression (token);
+                       else if (token.Type == TokenType.FunctionName) {
+                               e = ParseFunctionExpression ();
+                       } else if (token.Type == TokenType.Item) {
+                               throw new NotImplementedException ();
+                       } else if (token.Type == TokenType.Property) {
+                               throw new NotImplementedException ();
+                       } else if (token.Type == TokenType.Not) {
+                               e = ParseNotExpression ();
+                       } else
                                throw new ExpressionParseException 
(String.Format ("Unexpected token type {0}.", token.Type));
                        
-                       return new ConditionFactorExpression (token);
+                       return e;
                }
+
+               ConditionExpression ParseNotExpression ()
+               {
+                       return new ConditionNotExpression 
(ParseFactorExpression ());
+               }
+
+               ConditionExpression ParseFunctionExpression ()
+               {
+                       throw new NotImplementedException ();
+               }
        }
 }
 

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionTokenizer.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionTokenizer.cs
    2007-01-19 18:03:50 UTC (rev 71349)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConditionTokenizer.cs
    2007-01-19 18:04:33 UTC (rev 71350)
@@ -45,7 +45,7 @@
                
                Token   token;
                
-               bool    ignoreWhiteSpace = true;
+//             bool    ignoreWhiteSpace = true;
                
                static TokenType[] charIndexToTokenType = new TokenType[128];
                static Dictionary <string, TokenType> keywords = new Dictionary 
<string, TokenType> (StringComparer.InvariantCultureIgnoreCase);
@@ -64,7 +64,7 @@
                
                public ConditionTokenizer ()
                {
-                       this.ignoreWhiteSpace = true;
+//                     this.ignoreWhiteSpace = true;
                }
                
                public void Tokenize (string s)
@@ -79,7 +79,7 @@
                        GetNextToken ();
                }
                
-               private void SkipWhiteSpace ()
+               void SkipWhiteSpace ()
                {
                        int ch;
                        
@@ -90,7 +90,7 @@
                        }
                }
                
-               private int PeekChar ()
+               int PeekChar ()
                {
                        if (position < inputString.Length)
                                return (int) inputString [position];
@@ -98,7 +98,7 @@
                                return -1;
                }
                
-               private int ReadChar ()
+               int ReadChar ()
                {
                        if (position < inputString.Length)
                                return (int) inputString [position++];
@@ -141,12 +141,12 @@
                        if (token.Type == TokenType.EOF)
                                throw new ExpressionParseException ("Cannot 
read past the end of stream.");
                        
-                       if (IgnoreWhiteSpace)
-                               SkipWhiteSpace ();
+                       SkipWhiteSpace ();
                        
                        tokenPosition = position;
                        
-                       int i = PeekChar ();
+//                     int i = PeekChar ();
+                       int i = ReadChar ();
                        
                        if (i == -1) {
                                token = new Token (null, TokenType.EOF);
@@ -154,22 +154,7 @@
                        }
                        
                        char ch = (char) i;
-                       
-                       if (IgnoreWhiteSpace == false && Char.IsWhiteSpace 
(ch)) {
-                               StringBuilder sb = new StringBuilder ();
-                               int ch2;
 
-                               while ((ch2 = PeekChar ()) != -1)  {
-                                       if (!Char.IsWhiteSpace ((char) ch2))
-                                               break;
-
-                                       sb.Append ((char)ch2);
-                                       ReadChar();
-                               }
-                               
-                               token = new Token (sb.ToString (), 
TokenType.WhiteSpace);
-                               return;
-                       }
                        
                        // FIXME: looks like a hack: if '-' is here '->' won't 
be tokenized
                        // maybe we should treat item reference as a token
@@ -177,7 +162,6 @@
                                StringBuilder sb = new StringBuilder ();
                                
                                sb.Append (ch);
-                               ReadChar ();
                                
                                while ((i = PeekChar ()) != -1) {
                                        ch = (char) i;
@@ -189,15 +173,11 @@
                                }
                                
                                token = new Token (sb.ToString (), 
TokenType.Number);
-                               return;
-                       }
-                       
-                       if (ch == '\'') {
+                       } else if (ch == '\'') {
                                StringBuilder sb = new StringBuilder ();
                                string temp;
                                
                                sb.Append (ch);
-                               ReadChar ();
                                
                                while ((i = PeekChar ()) != -1) {
                                        ch = (char) i;
@@ -210,18 +190,12 @@
                                
                                temp = sb.ToString ();
                                
-                               // FIXME: test extreme cases
-                               // it fails on '$(something) == ''
                                token = new Token (temp.Substring (1, 
temp.Length - 2), TokenType.String);
                                
-                               return;
-                       }
-                       
-                       if (ch == '_' || Char.IsLetter (ch)) {
+                       } else  if (ch == '_' || Char.IsLetter (ch)) {
                                StringBuilder sb = new StringBuilder ();
                                
                                sb.Append ((char) ch);
-                               ReadChar ();
                                
                                while ((i = PeekChar ()) != -1) {
                                        if ((char) i == '_' || 
Char.IsLetterOrDigit ((char) i))
@@ -237,50 +211,26 @@
                                else
                                        token = new Token (temp, 
TokenType.String);
                                        
-                               return;
-                       }
-                       
-                       ReadChar ();
-                       
-                       if (ch == '!' && PeekChar () == (int) '=') {
+                       } else if (ch == '!' && PeekChar () == (int) '=') {
                                token = new Token ("!=", TokenType.NotEqual);
                                ReadChar ();
-                               return;
-                       }
-                       
-                       if (ch == '<' && PeekChar () == (int) '=') {
+                       } else if (ch == '<' && PeekChar () == (int) '=') {
                                token = new Token ("<=", TokenType.LessOrEqual);
                                ReadChar ();
-                               return;
-                       }
-                       
-                       if (ch == '>' && PeekChar () == (int) '=') {
+                       } else if (ch == '>' && PeekChar () == (int) '=') {
                                token = new Token (">=", 
TokenType.GreaterOrEqual);
                                ReadChar ();
-                               return;
-                       }
-                       
-                       if (ch == '=' && PeekChar () == (int) '=') {
+                       } else if (ch == '=' && PeekChar () == (int) '=') {
                                token = new Token ("==", TokenType.Equal);
                                ReadChar ();
-                               return;
-                       }
-                       
-                       if (ch == '-' && PeekChar () == (int) '>') {
-                               token = new Token ("->", TokenType.Transform);
-                               ReadChar ();
-                               return;
-                       }
-                       
-                       if (ch >= 32 && ch < 128) {
+                       } else if (ch >= 32 && ch < 128) {
                                if (charIndexToTokenType [ch] != 
TokenType.Invalid) {
                                        token = new Token (new String (ch, 1), 
charIndexToTokenType [ch]);
                                        return;
                                } else
                                        throw new ExpressionParseException 
(String.Format ("Invalid punctuation: {0}", ch));
-                       }
-                       
-                       throw new ExpressionParseException (String.Format 
("Invalid token: {0}", ch));
+                       } else
+                               throw new ExpressionParseException 
(String.Format ("Invalid token: {0}", ch));
                }
                
                public int TokenPosition {
@@ -291,10 +241,12 @@
                        get { return token; }
                }
                
+/*
                public bool IgnoreWhiteSpace {
                        get { return ignoreWhiteSpace; }
                        set { ignoreWhiteSpace = value; }
                }
+*/
                
                struct CharToTokenType {
                        public char ch;

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs    
    2007-01-19 18:03:50 UTC (rev 71349)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs    
    2007-01-19 18:04:33 UTC (rev 71350)
@@ -261,6 +261,7 @@
                public void UnregisterAllLoggers ()
                {
                        // FIXME: check if build succeeded
+                       // FIXME: it shouldn't be here
                        LogBuildFinished (true);
                        foreach (ILogger i in loggers) {
                                i.Shutdown ();

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs   
    2007-01-19 18:03:50 UTC (rev 71349)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs   
    2007-01-19 18:04:33 UTC (rev 71350)
@@ -122,7 +122,7 @@
                        return AddNewItem (itemName, itemInclude, false);
                }
                
-               [MonoTODO ("Not tested")]
+               [MonoTODO ("Adds item not in the same place as MS")]
                public BuildItem AddNewItem (string itemName,
                                             string itemInclude,
                                             bool treatItemIncludeAsLiteral)

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Token.cs
===================================================================
--- trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Token.cs 
2007-01-19 18:03:50 UTC (rev 71349)
+++ trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Token.cs 
2007-01-19 18:04:33 UTC (rev 71350)
@@ -62,8 +62,9 @@
                Item,
                Property,
                Metadata,
-               Transform,
-               LiteralSubExpression,
+               FunctionName,
+//             Transform,
+//             LiteralSubExpression,
 
                FirstPunct,
 

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/conditions.jay
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/conditions.jay
   2007-01-19 18:03:50 UTC (rev 71349)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/conditions.jay
   2007-01-19 18:04:33 UTC (rev 71350)
@@ -25,7 +25,7 @@
                ;
 
 Arg-list       :       Args
-               |       ε /*empty sign in utf-8 probably should be just empty*/
+               |
                ;
 
 Args           :       Arg TOKEN_COMMA Args

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to