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


C# Token.ToInt方法代码示例

本文整理汇总了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());
 }
开发者ID:jzabroski,项目名称:YUICompressor.NET,代码行数:4,代码来源:Decompiler.cs

示例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;
     }
 }
开发者ID:komiga,项目名称:duct-sharp,代码行数:99,代码来源:ScriptFormatter.cs


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