+//
+// ExpressionTokenizer.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// Copyright (C) 2013 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
using System;
using System.Collections.Generic;
using Microsoft.Build.Evaluation;
-namespace Microsoft.Build.Internal
+namespace Microsoft.Build.Internal.Expressions
{
enum ExpressionValidationType
{
error = null;
token_value = null;
- current_token_position = pos;
- SkipSpaces ();
+ while (pos < source.Length) {
+ if (spaces.IndexOf (source [pos]) >= 0)
+ pos++;
+ else
+ break;
+ }
if (pos == source.Length)
return false;
+ current_token_position = pos;
switch (source [pos++]) {
case '.':
case ',':
TokenForItemPropertyValue (",", Token.COMMA);
break;
+ case '[':
+ TokenForItemPropertyValue ("[", Token.BRACE_OPEN);
+ break;
+ case ']':
+ TokenForItemPropertyValue ("]", Token.BRACE_CLOSE);
+ break;
case '(':
+ modes.Push (TokenizerMode.Default);
TokenForItemPropertyValue ("(", Token.PAREN_OPEN);
break;
case ')':
current_token = Token.TRUE_LITERAL;
else if (val.Equals ("FALSE", StringComparison.OrdinalIgnoreCase))
current_token = Token.FALSE_LITERAL;
+ else if (val.Equals ("YES", StringComparison.OrdinalIgnoreCase))
+ current_token = Token.TRUE_LITERAL;
+ else if (val.Equals ("NO", StringComparison.OrdinalIgnoreCase))
+ current_token = Token.FALSE_LITERAL;
+ else if (val.Equals ("ON", StringComparison.OrdinalIgnoreCase))
+ current_token = Token.TRUE_LITERAL;
+ else if (val.Equals ("OFF", StringComparison.OrdinalIgnoreCase))
+ current_token = Token.FALSE_LITERAL;
else {
current_token = Token.NAME;
token_value = ProjectCollection.Unescape (val);
break;
}
- Console.Error.WriteLine ("@@@@@ [{0}]", val);
break;
}
return true;
}
string spaces = " \t\r\n";
-
- void SkipSpaces ()
- {
- while (current_token_position < source.Length) {
- if (spaces.IndexOf (source [current_token_position]) > 0)
- current_token_position++;
- else
- break;
- }
- }
- static readonly char [] token_starter_chars = ".,)-=:!><$@%\"' ".ToCharArray ();
+ static readonly char [] token_starter_chars = ".,[]()-=:!><$@%\"' ".ToCharArray ();
void ReadStringLiteral (string source, char c)
{
void TokenForItemPropertyValue (string value, int token)
{
- if (CurrentTokenizerMode == TokenizerMode.InsideItemOrProperty)
+ if (true)//CurrentTokenizerMode == TokenizerMode.InsideItemOrProperty)
current_token = token;
else {
current_token = Token.NAME;
{
//int Line { get; }
int Column { get; }
- //string File { get; }
+ string File { get; }
string ToLocationString ();
}
{
//public int Line { get; set; }
public int Column { get; set; }
- //public string File { get; set; }
+ public string File { get; set; }
public string ToLocationString ()
{