本文整理汇总了C#中StarryEyes.Filters.Parsing.TokenReader.Get方法的典型用法代码示例。如果您正苦于以下问题:C# TokenReader.Get方法的具体用法?C# TokenReader.Get怎么用?C# TokenReader.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StarryEyes.Filters.Parsing.TokenReader
的用法示例。
在下文中一共展示了TokenReader.Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetListValue
private static ListMembers GetListValue(TokenReader reader)
{
reader.AssertGet(TokenType.Period);
var user = reader.AssertGet(TokenType.Literal).Value;
reader.AssertGet(TokenType.Period);
string slug;
var slugToken = reader.Get();
switch (slugToken.Type)
{
case TokenType.String:
case TokenType.Literal:
slug = slugToken.Value;
break;
default:
throw CreateUnexpectedTokenError(slugToken.Value, reader.RemainQuery);
}
return new ListMembers(user, slug);
}
示例2: CompileFilters
/// <summary>
/// Instantiate expression tree from tokens.
/// </summary>
private static FilterExpressionRoot CompileFilters(IEnumerable<Token> token)
{
var reader = new TokenReader(token);
var op = CompileL0(reader);
if (reader.IsRemainToken)
{
throw CreateUnexpectedTokenError(reader.Get().ToString(), reader.RemainQuery);
}
return new FilterExpressionRoot { Operator = op };
}
示例3: CompileSources
/// <summary>
/// Instantiate sources from tokens.
/// </summary>
private static IEnumerable<FilterSourceBase> CompileSources(IEnumerable<Token> token)
{
// filter
// filter: "argument"
// filter: "argument1", "argument2", ... -> filter: "argument1", filter: "argument2", ...
var reader = new TokenReader(token);
while (reader.IsRemainToken)
{
var filter = reader.Get();
if (filter.Type != TokenType.Literal && filter.Type != TokenType.OperatorMultiple)
{
throw CreateUnexpectedTokenError(filter.Value, reader.RemainQuery);
}
Type fstype;
if (!FilterSourceResolver.TryGetValue(filter.Value, out fstype))
{
throw new ArgumentException(
QueryCompilerResources.QueryUnknownFilterSource + " " +
filter.Value);
}
if (reader.IsRemainToken && reader.LookAhead().Type == TokenType.Collon) // with argument
{
reader.AssertGet(TokenType.Collon);
do
{
var argument = reader.AssertGet(TokenType.String);
yield return Activator.CreateInstance(fstype, argument.Value) as FilterSourceBase;
// separated by comma
if (reader.IsRemainToken)
{
reader.AssertGet(TokenType.Comma);
}
} while (reader.IsRemainToken && reader.LookAhead().Type == TokenType.String);
}
else
{
yield return Activator.CreateInstance(fstype) as FilterSourceBase;
if (reader.IsRemainToken)
{
// filters are divided by comma
reader.AssertGet(TokenType.Comma);
}
}
}
}
示例4: CompileSources
/// <summary>
/// Instantiate sources from tokens.
/// </summary>
private static IEnumerable<FilterSourceBase> CompileSources(IEnumerable<Token> token)
{
// filter
// filter: "argument"
// filter: "argument1", "argument2", ... -> filter: "argument1", filter: "argument2", ...
var reader = new TokenReader(token);
while (reader.IsRemainToken)
{
var filter = reader.Get();
if (filter.Type != TokenType.Literal && filter.Type != TokenType.OperatorMultiple)
{
throw new ArgumentException("このトークンは無効です: " + filter.Type +
" (リテラルか \'*\' です。)");
}
Type fstype;
if (!FilterSourceResolver.TryGetValue(filter.Value, out fstype))
throw new ArgumentException("フィルタ ソースが一致しません: " + filter.Value);
if (reader.IsRemainToken && reader.LookAhead().Type == TokenType.Collon) // with argument
{
reader.AssertGet(TokenType.Collon);
do
{
var argument = reader.AssertGet(TokenType.String);
yield return Activator.CreateInstance(fstype, argument.Value) as FilterSourceBase;
// separated by comma
if (reader.IsRemainToken)
{
reader.AssertGet(TokenType.Comma);
}
} while (reader.IsRemainToken && reader.LookAhead().Type == TokenType.String);
}
else
{
yield return Activator.CreateInstance(fstype) as FilterSourceBase;
if (reader.IsRemainToken)
{
// filters are divided by comma
reader.AssertGet(TokenType.Comma);
}
}
}
}
示例5: CompileFilters
/// <summary>
/// Instantiate expression tree from tokens.
/// </summary>
private static FilterExpressionRoot CompileFilters(IEnumerable<Token> token)
{
var reader = new TokenReader(token);
var op = CompileL0(reader);
if (reader.IsRemainToken)
throw new FilterQueryException("不正なトークンです: " + reader.Get(), reader.RemainQuery);
return new FilterExpressionRoot { Operator = op };
}