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


C# Tokens类代码示例

本文整理汇总了C#中Tokens的典型用法代码示例。如果您正苦于以下问题:C# Tokens类的具体用法?C# Tokens怎么用?C# Tokens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: HashingStringMatch

        static HashingStringMatch()
        {
            tokens = new Tokens[300];

            Random r = new Random();

            //1. Build codes for each token

            for (char c = 'A'; c <= 'Z'; c++)
            {
                Tokens t = new Tokens(c, Convert.ToUInt64(r.Next(1, Int32.MaxValue)));

                tokens[Convert.ToInt32(c)] = t;
            }
            for (char c = 'a'; c <= 'z'; c++)
            {
                Tokens t = new Tokens(c, Convert.ToUInt64(r.Next(1, Int32.MaxValue)));

                tokens[Convert.ToInt32(c)] = t;
            }
            tokens[Convert.ToInt32(' ')] = new Tokens(' ', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32('\'')] = new Tokens('\'', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32('"')] = new Tokens('"', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32('.')] = new Tokens('.', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32(',')] = new Tokens(',', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32('!')] = new Tokens('!', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32('?')] = new Tokens('?', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32('-')] = new Tokens('-', (UInt64)r.Next(1, Int32.MaxValue));
            //tokens[Convert.ToInt32(':')] = new Tokens(':', (UInt64)r.Next(1, Int32.MaxValue));

            //tokens[Convert.ToInt32('t')] = new Tokens('t', 7);
            //tokens[Convert.ToInt32('e')] = new Tokens('e', 8);
            //tokens[Convert.ToInt32('s')] = new Tokens('s', 9);
            //tokens[Convert.ToInt32('a')] = new Tokens('t', 5);
        }
开发者ID:RafaelZSF,项目名称:a-algorithms,代码行数:35,代码来源:HashingStringMatch.cs

示例2: Maek

 public static Token Maek(Tokens kind, int tokLin, int tokCol, int tokELin, int tokECol)
 {
     return new Token(
         kind,
         new SourceSpan(new SourceLocation(1, tokLin, tokCol + 1), new SourceLocation(1, tokELin, tokECol + 1))
     );
 }
开发者ID:whoisjake,项目名称:Infix,代码行数:7,代码来源:Token.cs

示例3: Parse

        public override Mediator.Intermediate.ICodeNode Parse(Tokens.Token token)
        {
            ICodeNode assignNode = IntermediateCodeFactory.CreateICodeNode("assign");
            string targetName = token.Text;
            ISymbolTableEntry symId = Stack.Find(targetName);
            if (symId == null)
                symId = Stack.EnterLocal(targetName);

            symId.AppendLineNumber(token.LineNumber);

            token = NextToken();
            ICodeNode variable = IntermediateCodeFactory.CreateICodeNode("variable");
            variable.SetAttribute("id", symId);

            assignNode.AddChild(variable);

            if (token.TokenType == "colon_equals")
            {
                token = NextToken(); //the other side i.e the thint that is the value
            }
            else
            {
                ErrorHandler.Singleton.Flag(token, "missing_colon_equals", this);
            }
            //simplify and asume constant value (int)
            ICodeNode constant = IntermediateCodeFactory.CreateICodeNode("int_const");
            constant.SetAttribute("value", token.Value);
            assignNode.AddChild(constant);

            NextToken(); //consume ;
            return assignNode;
        }
开发者ID:isakkarlsson,项目名称:ILang,代码行数:32,代码来源:AssignmentParser.cs

示例4: EvaluateOperation

 protected IPrimitiveToken EvaluateOperation(IPrimitiveToken x, IPrimitiveToken y, Tokens o)
 {
     switch(o) {
       case Tokens.EQ:
     return new BooleanToken(x.CompareTo(y) == 0);
       case Tokens.NEQ:
     return new BooleanToken(x.CompareTo(y) != 0);
       case Tokens.GT:
     return new BooleanToken(x.CompareTo(y) > 0);
       case Tokens.GEQ:
     return new BooleanToken(x.CompareTo(y) >= 0);
       case Tokens.LT:
     return new BooleanToken(x.CompareTo(y) < 0);
       case Tokens.LEQ:
     return new BooleanToken(x.CompareTo(y) <= 0);
       case Tokens.PLUS:
     return new NumberToken(x.ToDouble() + y.ToDouble());
       case Tokens.MINUS:
     return new NumberToken(x.ToDouble() - y.ToDouble());
       case Tokens.MULT:
     return new NumberToken(x.ToDouble() * y.ToDouble());
       case Tokens.DIV:
     return new NumberToken(x.ToDouble() / y.ToDouble());
       case Tokens.EXP:
     return new NumberToken(Math.Pow(x.ToDouble(), y.ToDouble()));
       case Tokens.CONCAT:
     return new StringToken(x.ToString() + y.ToString());
       default:
     throw new ArgumentException("Unknown Operator");
       }
 }
开发者ID:samplet,项目名称:CreamCheese,代码行数:31,代码来源:SemanticsBase.cs

示例5: intern

 internal static string intern(Tokens token)
 {
     switch (token)
     {
         case Tokens.tDOT2: return "..";
         case Tokens.tDOT3: return "...";
         case Tokens.tPOW: return "**";
         case Tokens.tUPLUS: return "[email protected]";
         case Tokens.tUMINUS: return "[email protected]";
         case Tokens.tCMP: return "<=>";
         case Tokens.tGEQ: return ">=";
         case Tokens.tLEQ: return "<=";
         case Tokens.tEQ: return "==";
         case Tokens.tEQQ: return "===";
         case Tokens.tNEQ: return "!=";
         case Tokens.tMATCH: return "=~";
         case Tokens.tNMATCH: return "!~";
         case Tokens.tAREF: return "[]";
         case Tokens.tASET: return "[]=";
         case Tokens.tLSHFT: return "<<";
         case Tokens.tRSHFT: return ">>";
         case Tokens.tCOLON2: return "::";
         case Tokens.tOROP: return "||";
         case Tokens.tANDOP: return "&&";
         default: return token.ToString();
     }
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:27,代码来源:ID.cs

示例6: MaekString

 public static Token MaekString(Tokens kind, String value, int tokLin, int tokCol, int tokELin, int tokECol)
 {
     return new Token(
         kind,
         value.Substring(1, value.Length - 2),
         new SourceSpan(new SourceLocation(1, tokLin, tokCol + 1), new SourceLocation(1, tokELin, tokECol + 1))
     );
 }
开发者ID:whoisjake,项目名称:Infix,代码行数:8,代码来源:Token.cs

示例7: Next

 public AssertTokenizer/*!*/ Next() {
     _actualToken = _tokenizer.GetNextToken();
     _actualValue = _tokenizer.TokenValue;
     _actualSpan = _tokenizer.TokenSpan;
     _allTokens.Add(_actualToken);
     _allValues.Add(_actualValue);
     return this;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:8,代码来源:AssertTokenizer.cs

示例8: Main

 // Test Tokens, TokenEnumerator
 static void Main()
 {
     // Testing Tokens by breaking the string into tokens:
       Tokens f = new Tokens("This is a well-done program.", new char[] {' ','-'});
       foreach (string item in f) {
      Console.WriteLine(item);
       }
 }
开发者ID:Jefe505,项目名称:CSharp,代码行数:9,代码来源:Main.cs

示例9: Player

 public Player(string name, Int16 number)
 {
     _name = name;
     _number = number;
     _token = Tokens.None;
     _space = 0;
     _cash = 1500;
 }
开发者ID:mgmayfield,项目名称:Monopoly,代码行数:8,代码来源:Player.cs

示例10: InterpretExpression

 public IToken InterpretExpression(IToken n, Tokens o)
 {
     n = InterpretExpression(n);
       if(n is IPrimitiveToken) {
     return EvaluateOperation((IPrimitiveToken) n, o);
       } else {
     return EvaluateComplexOperation(n, o);
       }
 }
开发者ID:samplet,项目名称:CreamCheese,代码行数:9,代码来源:SemanticsBase.cs

示例11: Main

 // 测试标记 TokenEnumerator
 static void Main()
 {
     Tokens f = new Tokens("This is a well-done program.",
      new char [] {' ','-'});
       foreach (string item in f) // 要将 string 更改为 int
       {
      Console.WriteLine(item);
       }
 }
开发者ID:jetlive,项目名称:skiaming,代码行数:10,代码来源:tokens2.cs

示例12: TokenGroup

        public TokenGroup(CA ca, Tokens token, List<int[]> liveCells)
        {
            Token = token;

            PopulationSize = ca.PopulationSize;
            NumberOfGens = ca.NumberOfGens;
            NhbdSize = ca.NhbdSize;

            Cells = liveCells;
        }
开发者ID:ncw000,项目名称:MusicCA,代码行数:10,代码来源:TokenGroup.cs

示例13: Main

 // 测试标记 TokenEnumerator
 static void Main()
 {
     // 通过将字符串分解为标记来测试标记:
       Tokens f = new Tokens("This is a well-done program.",
      new char[] {' ','-'});
       foreach (string item in f)
       {
      Console.WriteLine(item);
       }
 }
开发者ID:jetlive,项目名称:skiaming,代码行数:11,代码来源:tokens.cs

示例14: CompilerOutput

        public CompilerOutput(string input, Tokens tokens, System.Numerics.Complex returnVal, ParseTree parseTree, 
			PostfixedTokens postFixedTokens, string output)
        {
            this.Input = input;
                this.Tokens = tokens;
                this.ReturnValue = returnVal;
                this.ParseTree = parseTree;
                this.PostFixedTokens = postFixedTokens;
                this.Output = output;
        }
开发者ID:Amichai,项目名称:PhysicsPad,代码行数:10,代码来源:Expression.cs

示例15: Main

    // Test the Tokens class.
    static void Main()
    {
        // Create a Tokens instance.
        Tokens f = new Tokens("This is a sample sentence.", new char[] {' ','-'});

        // Display the tokens.
        foreach (string item in f)
        {
            System.Console.WriteLine(item);
        }
    }
开发者ID:terryjintry,项目名称:OLSource1,代码行数:12,代码来源:how-to--access-a-collection-class-with-foreach--csharp-programming-guide-_2.cs


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