当前位置: 首页>>代码示例>>C#>>正文


C# Seq.Peek方法代码示例

本文整理汇总了C#中Seq.Peek方法的典型用法代码示例。如果您正苦于以下问题:C# Seq.Peek方法的具体用法?C# Seq.Peek怎么用?C# Seq.Peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Seq的用法示例。


在下文中一共展示了Seq.Peek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BinaryExpression

 private Expression BinaryExpression(bool noIn, ref bool isLHS)
 {
     var e = UnaryExpression(ref isLHS);
     var stack = new Seq<SREntry>();
     while (true)
     {
         var op = default(BinaryOperator);
         switch (Current.Tag)
         {
             case InputElementTag.Times:
                 op = new BinaryOperator(Current.Loc, BinaryOp.Times);
                 break;
             case InputElementTag.Slash:
                 op = new BinaryOperator(Current.Loc, BinaryOp.Div);
                 break;
             case InputElementTag.Percent:
                 op = new BinaryOperator(Current.Loc, BinaryOp.Mod);
                 break;
             case InputElementTag.Plus:
                 op = new BinaryOperator(Current.Loc, BinaryOp.Plus);
                 break;
             case InputElementTag.Minus:
                 op = new BinaryOperator(Current.Loc, BinaryOp.Minus);
                 break;
             case InputElementTag.LTLT:
                 op = new BinaryOperator(Current.Loc, BinaryOp.LeftShift);
                 break;
             case InputElementTag.GTGT:
                 op = new BinaryOperator(Current.Loc, BinaryOp.RightShift);
                 break;
             case InputElementTag.GTGTGT:
                 op = new BinaryOperator(Current.Loc, BinaryOp.UnsignedRightShift);
                 break;
             case InputElementTag.LT:
                 op = new BinaryOperator(Current.Loc, BinaryOp.LessThan);
                 break;
             case InputElementTag.GT:
                 op = new BinaryOperator(Current.Loc, BinaryOp.GreaterThan);
                 break;
             case InputElementTag.LTEq:
                 op = new BinaryOperator(Current.Loc, BinaryOp.LessThanOrEqual);
                 break;
             case InputElementTag.GTEq:
                 op = new BinaryOperator(Current.Loc, BinaryOp.GreaterThanOrEqual);
                 break;
             case InputElementTag.Instanceof:
                 op = new BinaryOperator(Current.Loc, BinaryOp.InstanceOf);
                 break;
             case InputElementTag.In:
                 if (!noIn)
                     op = new BinaryOperator(Current.Loc, BinaryOp.In);
                 break;
             case InputElementTag.EqEq:
                 op = new BinaryOperator(Current.Loc, BinaryOp.Equals);
                 break;
             case InputElementTag.BangEq:
                 op = new BinaryOperator(Current.Loc, BinaryOp.NotEquals);
                 break;
             case InputElementTag.EqEqEq:
                 op = new BinaryOperator(Current.Loc, BinaryOp.StrictEquals);
                 break;
             case InputElementTag.BangEqEq:
                 op = new BinaryOperator(Current.Loc, BinaryOp.StrictNotEquals);
                 break;
             case InputElementTag.Amp:
                 op = new BinaryOperator(Current.Loc, BinaryOp.BitwiseAND);
                 break;
             case InputElementTag.Hat:
                 op = new BinaryOperator(Current.Loc, BinaryOp.BitwiseXOR);
                 break;
             case InputElementTag.Bar:
                 op = new BinaryOperator(Current.Loc, BinaryOp.BitwiseOR);
                 break;
             case InputElementTag.AmpAmp:
                 op = new BinaryOperator(Current.Loc, BinaryOp.LogicalAND);
                 break;
             case InputElementTag.BarBar:
                 op = new BinaryOperator(Current.Loc, BinaryOp.LogicalOR);
                 break;
             default:
                 break;
         }
         if (op == null)
         {
             while (stack.Count > 0)
                 Reduce(ref e, stack);
             return e;
         }
         else
         {
             isLHS = false;
             Consume();
             var dummy = true;
             var r = UnaryExpression(ref dummy);
             while (stack.Count > 0 && stack.Peek().Op.Precedence >= op.Precedence)
                 Reduce(ref e, stack);
             stack.Push(new SREntry() { Op = op, Exp = r });
         }
     }
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:100,代码来源:Parser.cs

示例2: Reduce

 private void Reduce(ref Expression bottom, Seq<SREntry> stack)
 {
     var top = stack.Pop();
     if (stack.Count == 0)
         bottom = new BinaryExpression(bottom.Loc.Union(top.Exp.Loc), bottom, top.Op, top.Exp);
     else
         stack.Peek().Exp = new BinaryExpression(stack.Peek().Exp.Loc.Union(top.Exp.Loc), stack.Peek().Exp, top.Op, top.Exp);
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:8,代码来源:Parser.cs


注:本文中的Seq.Peek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。