本文整理汇总了C#中CharStream.SkipString方法的典型用法代码示例。如果您正苦于以下问题:C# CharStream.SkipString方法的具体用法?C# CharStream.SkipString怎么用?C# CharStream.SkipString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharStream
的用法示例。
在下文中一共展示了CharStream.SkipString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static AST.INode Parse(CharStream stream)
{
var startingPos = stream.Position;
AST.INode expression = null;
try
{
// skip opening tags
stream.SkipString("{{");
WhiteSpace.Parse(stream, true);
// parse actual expression
expression = Expression.Parse(stream);
// skip closing tags
WhiteSpace.Parse(stream, true);
stream.SkipString("}}");
return expression;
} catch (Exception e)
{
string msg = String.Format(
"something went wrong parsing an <expander> starting at {0}, expression was: {1} ({2})",
stream.ComputeDetailedPosition(startingPos),
expression != null ? expression.Display() : "<null>",
expression != null ? expression.GetType().ToString() : "null");
throw new Exceptions.ParseException(msg, e);
}
}
示例2: Parse
public static AST.INode Parse(CharStream stream)
{
var startingPos = stream.Position;
try
{
AST.INode root;
if(!Property.PeekAndParse(stream, out root)) {
root = IdentifierExpression.Parse(stream);
}
stream.SkipString("::");
// we either have an expression or a simple identifier
AST.INode identifier;
if (stream.SkipIfPossible('['))
{
identifier = Expression.Parse(stream);
stream.SkipCharacter(']');
} else
{
identifier = new AST.Identifier(Identifier.Parse(stream, false));
}
// We can also have optionally a property expression,
// starting with a simple identifier or straight away with an expression
AST.PropertyExpression propertyExpression = null;
if (stream.SkipIfPossible('.'))
{
propertyExpression = Property.Parse(stream) as AST.PropertyExpression;
}
else if (stream.SkipIfPossible('['))
{
var expression = Expression.Parse(stream);
propertyExpression = new AST.PropertyExpression(expression);
stream.SkipCharacter(']');
Property.Parse(stream, propertyExpression);
}
return new AST.AttributeExpression(root, identifier, propertyExpression);
} 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);
}
}
示例3: Parse
public static void Parse(CharStream stream, Internal.LocaleContext.Builder builder)
{
var startingPos = stream.Position;
try
{
stream.SkipString("import(");
WhiteSpace.Parse(stream, true);
var path = PureStringValue.Parse(stream);
WhiteSpace.Parse(stream, true);
stream.SkipCharacter(')');
LocalizableObjectsList.ImportAndParse(path, builder);
} catch (Exception e)
{
string msg = String.Format(
"something went wrong parsing an <import_statement> starting at {0}",
stream.ComputeDetailedPosition(startingPos));
throw new Exceptions.ParseException(msg, e);
}
}