コード例 #1
0
ファイル: Property.cs プロジェクト: GlenDC/L20n.cs
					public static AST.INode Parse(CharStream stream, AST.PropertyExpression property = null)
					{
						var startingPos = stream.Position;
						
						try
						{
							if (property == null)
							{
								var obj = IdentifierExpression.Parse(stream);
								property = new AST.PropertyExpression(obj);
							}

							char c;
							// can be either a simple identifier ('.') or expression ('[')
							while (stream.SkipAnyIfPossible(new char[] {'.', '['}, out c))
							{
								if (c == '.')
								{
									property.Add(Identifier.Parse(stream, false));
								} else
								{
									WhiteSpace.Parse(stream, true);
									property.Add(Expression.Parse(stream));
									WhiteSpace.Parse(stream, true);
									stream.SkipCharacter(']');
								}
							}
							
							return property;
						} catch (Exception e)
						{
							string msg = String.Format(
								"something went wrong parsing an <property_expression> starting at {0}",
								stream.ComputeDetailedPosition(startingPos));
							throw new Exceptions.ParseException(msg, e);
						}
					}
コード例 #2
0
ファイル: Unary.cs プロジェクト: GlenDC/L20n.cs
					public static AST.INode Parse(CharStream stream)
					{
						var startingPos = stream.Position;
						
						try
						{
							char op;
							if (stream.SkipAnyIfPossible(new char[3]{'+', '-', '!'}, out op))
							{
								WhiteSpace.Parse(stream, true);
								var expression = Unary.Parse(stream);
								return new AST.UnaryOperation(expression, op);
							} else
							{
								return Member.Parse(stream);
							}
						} catch (Exception e)
						{
							string msg = String.Format(
								"something went wrong parsing an <unary_expression> starting at {0}",
								stream.ComputeDetailedPosition(startingPos));
							throw new Exceptions.ParseException(msg, e);
						}
					}