本文整理汇总了C#中CharStream.SkipAnyIfPossible方法的典型用法代码示例。如果您正苦于以下问题:C# CharStream.SkipAnyIfPossible方法的具体用法?C# CharStream.SkipAnyIfPossible怎么用?C# CharStream.SkipAnyIfPossible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharStream
的用法示例。
在下文中一共展示了CharStream.SkipAnyIfPossible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
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: Parse
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);
}
}