本文整理汇总了C#中Lexer.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.Seek方法的具体用法?C# Lexer.Seek怎么用?C# Lexer.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer.Seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNonTerminal
public override bool CreateNonTerminal(Lexer lex, ProductionStorage ps)
{
Mex1 m1;
if (ps.MatchProduction<Mex1>(out m1))
{
result = m1;
//( operator mex-1 | operand * operator KUhE? ) *
while (true)
{
Operator op;
Mex1 m12;
List<NonTerminal> o = new List<NonTerminal>();
//( operator mex1 )
int save = lex.Position;
if (ps.MatchProduction<Operator>(out op) && ps.MatchProduction<Mex1>(out m12))
{
//if we're done this, then we have the whole bracket.
//turn it into an infix
result = new Infix(result, op, m12);
}
//(operand * operator KUhE?)
else
{
//undo any damage from the first bit
lex.Seek(save);
//put the leading mex1 into the operand list
o.Add(m1);
//operand *
while (true)
{
Operand oper;
if(ps.MatchProduction<Operand>(out oper))
o.Add(oper);
else
break;
}
//operator
if (ps.MatchProduction<Operator>(out op))
{
result = new RP(o, op);
}
else
{
lex.Seek(save);
break; // havent matched an infix or an rp
}
ps.MatchProduction(Selmaho.KUhE);
}
}
return true;
}
else
return false; //you have to match a Mex1 first
}
示例2: CreateNonTerminal
public override bool CreateNonTerminal(Lexer lex, ProductionStorage ps)
{
int save = lex.Position;
//try to match an option PEhO
ps.MatchProduction(Selmaho.PEhO);
if (ps.MatchProduction<Operator>(out _operator))
{
//try to get as many op as we can
do
{
Operand _o;
if (ps.MatchProduction<Operand>(out _o))
{
_args.Add(_o);
}
else
break;
}
while (true);
// Polish expressions have to have at least one argument
if (_args.Count == 0)
{
lex.Seek(save);
return false;
}
//try to grab an optional KUhE
ps.MatchProduction(Selmaho.KUhE);
return true;
}
//we failed.
return false;
}