Altered expression parser to hand-written one (which was kind of anticipated) for...
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Internal / ExpressionConstructs.cs
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4
5 namespace Microsoft.Build.Internal
6 {
7         
8         class Locatable
9         {
10                 public ILocation Location { get; set; }         
11         }
12         
13         partial class ExpressionList : ILocation, IEnumerable<Expression>
14         {
15                 public ExpressionList ()
16                 {
17                 }
18                 
19                 public ExpressionList (Expression entry)
20                 {
21                         Add (entry);
22                 }
23                 
24                 //public int Line {
25                 //      get { return list.Count == 0 ? 0 : list [0].Line; }
26                 //}
27                 public int Column {
28                         get { return list.Count == 0 ? 0 : list [0].Column; }
29                 }
30                 //public string File {
31                 //      get { return list.Count == 0 ? null : list [0].File; }
32                 //}
33                 public string ToLocationString ()
34                 {
35                         return list.Count == 0 ? null : list [0].Location.ToLocationString ();
36                 }
37                         
38                 public IEnumerator<Expression> GetEnumerator ()
39                 {
40                         return list.GetEnumerator ();
41                 }
42                 
43                 IEnumerator IEnumerable.GetEnumerator ()
44                 {
45                         return list.GetEnumerator ();
46                 }
47                 
48                 List<Expression> list = new List<Expression> ();
49                 
50                 public ExpressionList Add (Expression expr)
51                 {
52                         list.Add (expr);
53                         return this;
54                 }
55                 
56                 public ExpressionList Insert (int pos, Expression expr)
57                 {
58                         list.Insert (pos, expr);
59                         return this;
60                 }
61         }
62
63         abstract partial class Expression : Locatable, ILocation
64         {
65                 //public int Line {
66                 //      get { return Location.Line; }
67                 //}
68                 public int Column {
69                         get { return Location.Column; }
70                 }
71                 //public string File {
72                 //      get { return Location.File; }
73                 //}
74                 public string ToLocationString ()
75                 {
76                         return Location.ToLocationString ();
77                 }
78         }
79         
80         partial class BooleanLiteral : Expression
81         {
82                 public bool Value { get; set; }
83         }
84
85         partial class NotExpression : Expression
86         {
87                 public Expression Negated { get; set; }
88         }
89
90         partial class PropertyAccessExpression : Expression
91         {
92                 public PropertyAccess Access { get; set; }
93         }
94         
95         enum PropertyTargetType
96         {
97                 Object,
98                 Type,
99         }
100         
101         class PropertyAccess : Locatable
102         {
103                 public NameToken Name { get; set; }
104                 public Expression Target { get; set; }
105                 public PropertyTargetType TargetType { get; set; }
106         }
107
108         partial class ItemAccessExpression : Expression
109         {
110                 public ItemApplication Application { get; set; }
111         }
112         
113         class ItemApplication : Locatable
114         {
115                 public NameToken Name { get; set; }
116                 public ExpressionList Expressions { get; set; }
117         }
118
119         partial class MetadataAccessExpression : Expression
120         {
121                 public MetadataAccess Access { get; set; }
122         }
123         
124         class MetadataAccess : Locatable
125         {
126                 public NameToken Metadata { get; set; }
127                 public NameToken Item { get; set; }
128         }
129         
130         partial class StringLiteralExpression : Expression
131         {
132                 public ExpressionList Contents { get; set; }
133         }
134
135         partial class RawStringLiteral : Expression
136         {
137                 public NameToken Value { get; set; }
138         }
139         
140         partial class FunctionCallExpression : Expression
141         {
142                 public NameToken Name { get; set; }
143                 public ExpressionList Arguments { get; set; }
144         }
145 }
146