本文整理汇总了C#中Tokens类的典型用法代码示例。如果您正苦于以下问题:C# Tokens类的具体用法?C# Tokens怎么用?C# Tokens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tokens类属于命名空间,在下文中一共展示了Tokens类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: addToDisplay
void addToDisplay(Tokens token, string strToken)
{
if (resultState && token != Tokens.Operation)
allClear();
// Check if token is allowed, if the input is "-" then also check if it can be added as a UnaryMinus or an Exp sign
if (allowed(token) || strToken == "-" && (allowed(token = Tokens.UnaryMinus) || allowed(token = Tokens.ExpOperator)))
{
Display += strToken;
history.Push(new Tuple<Tokens, string>(token, strToken));
}
resultState = false;
}
开发者ID:FreddyFlares,项目名称:Calculator,代码行数:12,代码来源:ViewModel.cs
示例17: bParse_Click
private void bParse_Click(object sender, EventArgs e)
{
string script = txtGrid.ScriptBox.Text;
Tokens tokens = new Tokens();
for (int i = 0; i < script.Length; i++)
{
tokens.Add(script[i]);
}
tokens.Flush();
txtGrid.GridBox.DataSource = tokens.Content;
tokens.PrintCache();
}
开发者ID:mind0n,项目名称:hive,代码行数:12,代码来源:ParserForm.cs
示例18: Test_Score
public void Test_Score()
{
TokenCollection good = Create(new[] {"ikea", "kitchen", "mouse"});
TokenCollection bad = Create(new[] {"house", "stock", "chicken"});
Processors proc = new Processors();
const string document = "ikea kitchen mouse ikea kitchen mouse ikea kitchen mouse ikea kitchen mouse";
Tokens tokens = new Tokens(document, proc);
float score = Analyzer.Score(tokens, good, bad);
//Assert.AreEqual(0.0f, score);
}
开发者ID:mancubus,项目名称:gems-bayesian,代码行数:13,代码来源:AnalyzerTests.cs
示例19: EvaluateComplexOperation
protected override IToken EvaluateComplexOperation(IToken n, Tokens o)
{
Variable vr;
Variable vn = ConvertTokenToVariable(n);
switch(o) {
case Tokens.UMINUS:
vr = new IntVariable(_network, "-" + vn.ToString());
new IntFunc(_network, IntFunc.Negate, vr, vn);
return new VariableToken(vr);
default:
throw new ArgumentException();
}
}
开发者ID:samplet,项目名称:CreamCheese,代码行数:13,代码来源:Semantics.cs
示例20: DumpTokenDetail
public void DumpTokenDetail(TextWriter/*!*/ output, Tokenizer/*!*/ tokenizer, Tokens token)
{
TokenValue value = tokenizer.TokenValue;
output.Write("{0}: ", Parser.GetTerminalName((int)token));
switch (token) {
default:
break;
case Tokens.Identifier:
output.Write(value.String);
break;
case Tokens.Float:
output.Write("{0}D", value.Double);
break;
case Tokens.Integer:
output.Write(value.Integer1);
break;
case Tokens.BigInteger:
output.Write("{0}BI", value.BigInteger.ToString(10));
break;
case Tokens.RegexpEnd:
output.Write("RegexOptions({0})", (RubyRegexOptions)value.Integer1);
break;
case Tokens.StringContent:
if (value.StringContent is string) {
output.Write("String(\"{0}\", {1})", Parser.EscapeString((string)value.StringContent), value.Encoding);
} else {
output.Write("String({0}), {1}", BitConverter.ToString((byte[])value.StringContent), value.Encoding);
}
break;
case Tokens.StringBegin:
case Tokens.RegexpBegin:
case Tokens.ShellStringBegin:
case Tokens.SymbolBegin:
output.Write(((Tokenizer.State)tokenizer.CurrentState).CurrentSequence);
break;
}
output.Write(' ');
output.Write(tokenizer.LexicalState);
output.WriteLine();
}
开发者ID:TerabyteX,项目名称:main,代码行数:50,代码来源:TokenizerTestDriver.cs
注:本文中的Tokens类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论