本文整理汇总了C#中Token.ToInt方法的典型用法代码示例。如果您正苦于以下问题:C# Token.ToInt方法的具体用法?C# Token.ToInt怎么用?C# Token.ToInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.ToInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToken
public void AddToken(Token token)
{
this.AddToken(token.ToInt());
}
示例2: HandleToken
public override void HandleToken(Token<ScriptToken> token)
{
switch (token.Type) {
case ScriptToken.String:
if (!String.IsNullOrEmpty(_varname) && _equals) {
int bv=Variable.StringToBool(token.ToString());
if (bv!=-1) {
AddVariableAndReset(_currentnode, new BoolVariable(bv==1 ? true : false, _varname), false, false);
break;
} else {
AddVariableAndReset(_currentnode, new StringVariable(token.ToString(), _varname), false, false);
}
} else if ((!String.IsNullOrEmpty(_varname) || _currentiden!=null) && !_equals) {
MakeIdentifier(token);
int bv=Variable.StringToBool(token.ToString());
if (bv!=-1) {
AddVariableAndReset(_currentiden, new BoolVariable(bv==1 ? true : false), false, false);
break;
}
AddVariableAndReset(_currentiden, new StringVariable(token.ToString()), false, false);
} else {
_varname=token.ToString();
}
break;
case ScriptToken.QuotedString:
if (!String.IsNullOrEmpty(_varname) && _equals) {
AddVariableAndReset(_currentnode, new StringVariable(token.ToString(), _varname), false, false);
} else if ((!String.IsNullOrEmpty(_varname) || _currentiden!=null) && !_equals) {
MakeIdentifier(token);
AddVariableAndReset(_currentiden, new StringVariable(token.ToString()), false, false);
} else {
_varname=token.ToString();
}
break;
case ScriptToken.Number:
if (!String.IsNullOrEmpty(_varname) && _equals) {
_currentvalue=new IntVariable(token.ToInt(), _varname);
AddVariableAndReset(_currentnode, _currentvalue, false, false);
} else if ((!String.IsNullOrEmpty(_varname) || _currentiden!=null) && !_equals) {
MakeIdentifier(token);
AddVariableAndReset(_currentiden, new IntVariable(token.ToInt()), false, false);
} else {
//new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "A number cannot be an identifier");
_varname=token.ToString();
}
break;
case ScriptToken.Double:
if (!String.IsNullOrEmpty(_varname) && _equals) {
_currentvalue=new FloatVariable((float)token.ToDouble(), _varname);
AddVariableAndReset(_currentnode, _currentvalue, false, false);
} else if ((!String.IsNullOrEmpty(_varname) || _currentiden!=null) && !_equals) {
MakeIdentifier(token);
AddVariableAndReset(_currentiden, new FloatVariable((float)token.ToDouble()), false, false);
} else {
new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "A number cannot be an identifier");
_varname=token.ToString();
}
break;
case ScriptToken.Equals:
if (_currentiden!=null)
new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "Unexpected equality sign after identifier declaration");
else if (_varname.Length==0)
new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "Expected string, got equality sign");
else if (_equals)
new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "Expected value, got equality sign");
else
_equals=true;
break;
case ScriptToken.OpenBrace:
if (_currentiden!=null)
new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "Node cannot contain values (possible openbrace typo)");
Node tempnode=new Node(_varname, _currentnode);
AddVariableAndReset(_currentnode, tempnode, false, false);
_currentnode=tempnode;
break;
case ScriptToken.CloseBrace:
if (_currentnode.Parent==null) {
new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "Mismatched node brace");
} else if (_equals) {
new ScriptParserException(ScriptParserError.PARSER, "StandardScriptParserHandler.HandleToken", token, _parser, "Expected value, got close-brace");
} else {
if (_currentiden!=null)
Reset(true, true);
_currentnode=(Node)_currentnode.Parent;
}
break;
case ScriptToken.Comment:
case ScriptToken.CommentBlock:
// Do nothing
break;
case ScriptToken.EOL:
case ScriptToken.EOF:
Finish();
break;
//default:
// //DebugLog("(StandardScriptParserHandler.handleToken) Unhandled token of type "+token.typeAsString())
// break;
}
}