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


C# Context.Clone方法代码示例

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


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

示例1: JSParser

      //---------------------------------------------------------------------------------------
      // JSParser
      //
      // create a parser with a context. The context is the code that has to be compiled.
      // Typically used by the runtime
      //---------------------------------------------------------------------------------------
      public JSParser(Context context){
        this.sourceContext = context;
        this.currentToken = context.Clone();
        this.scanner = new JSScanner(this.currentToken);
        this.noSkipTokenSet = new NoSkipTokenSet();

        this.errorToken = null;
        this.program = null;
        this.blockType = new ArrayList(16);
        this.labelTable = new SimpleHashtable(16);
        this.finallyEscaped = 0;
        this.Globals = context.document.engine.Globals;
        this.Severity = 5;
      }
开发者ID:ArildF,项目名称:masters,代码行数:20,代码来源:jsparser.cs

示例2: UpdateToken

 internal void UpdateToken(Context token)
 {
     this._token = token.Clone();
     this._color = ColorFromToken(this._token);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:5,代码来源:TokenColorInfo.cs

示例3: TokenColorInfo

 internal TokenColorInfo(Context token)
 {
     this._token = token.Clone();
     this._color = ColorFromToken(this._token);
     this._next = this;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:6,代码来源:TokenColorInfo.cs

示例4: ParsePackage

      //---------------------------------------------------------------------------------------
      // ParsePackage
      //
      //  Package :
      //    'package' QualifiedIdentifier '{' ClassList '}'
      //
      //  ClassList :
      //    <empty> |
      //    Class ClassList |
      //    Attributes Class ClassList |
      //    Attributes Enum ClassList
      //---------------------------------------------------------------------------------------
      // Because 'package' is not a reserved word in JS5 we have to deal with an ambiguity
      // in the grammar. A source sequence like the following
      // package
      // x
      // { }
      // can be legally parsed in two ways:
      // Identifier Identifier Block or
      // Package
      // we give Package priority in this situation.
      // Here is how we deal with some possible cases:
      // 1- ** package <no line break> QualifiedIdentifier ** is parsed unambiguously as a package production regardless of what comes after Identifier
      // 2- ** package <no line break> NotOneOf(Operator | '[' | '.' | '(' | Identifier) '{' ** is parsed as a package production with an error
      // 3- ** package <line break> '{' ** is parsed as a package (anonymous) with an error
      // 4- ** package <line break> Not(Identifier) ** is never parsed as a package
      private AST ParsePackage(Context packageContext){
        GetNextToken();
        AST qualid = null;
        bool gotLineBreak = this.scanner.GotEndOfLine();

        // erroneous package production
        if (JSToken.Identifier != this.currentToken.token){
          if (JSScanner.CanParseAsExpression(this.currentToken.token)){
            // it's an expression. Report a warning. package and this.currentToken can be an expression (i.e. 'package +')
            ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
            qualid = new Lookup("package", packageContext);
            // get the member expression
            qualid = MemberExpression(qualid, null);
            bool isLeftHandSide;
            qualid = ParsePostfixExpression(qualid, out isLeftHandSide);
            qualid = ParseExpression(qualid, false, isLeftHandSide, JSToken.None);
            return new Expression(qualid.context.Clone(), qualid);
          }else if (!gotLineBreak){
            if (JSToken.Increment == this.currentToken.token || JSToken.Decrement == this.currentToken.token){
              // it's a postfix expression. Report a warning
              ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
              bool dummy;
              qualid = new Lookup("package", packageContext);
              qualid = ParsePostfixExpression(qualid, out dummy);
              qualid = ParseExpression(qualid, false, false, JSToken.None);
              return new Expression(qualid.context.Clone(), qualid);
            }
          }else{
            // it's an expression. Report a warning which, as a side effect, will make the current token be the next token fetched
            ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
            return new Lookup("package", packageContext);
          }
        }else{
          // it is an identifier, parse it as a qualified identifier
          this.errorToken = this.currentToken; // this will make GetNextToken() in ParseQualifiedIdentifier() return this.currentToken
          qualid = ParseQualifiedIdentifier(JSError.NoIdentifier);
        }

        // if we are here we have:
        // ** package QualifiedIdentifier ** or
        // ** package SomeNonSenseToken **, that is a token that does not make an expression

        Context nonSenseToken = null;
        if (JSToken.LeftCurly != this.currentToken.token && qualid == null){
          // we want to peek and see whether the next token is a LeftCurly
          nonSenseToken = this.currentToken.Clone();
          GetNextToken();
        }

        if (JSToken.LeftCurly == this.currentToken.token){
          // sounds like a package, possibly with an error. If qualid is not null is actually a good package, otherwise we treat it
          // as an anonymous package and keep going.
          if (qualid == null){
            if (nonSenseToken == null)
              nonSenseToken = this.currentToken.Clone();
            ReportError(JSError.NoIdentifier, nonSenseToken, true);
          }
        }else{
          if (qualid == null){
            // this is pretty screwy, let's ignore the package keyword for a start
            ReportError(JSError.SyntaxError, packageContext);
            if (JSScanner.CanStartStatement(nonSenseToken.token)){
              // this is tricky we assign nonSenseToken to this.currentToken and call ParseStatement, because we know it is a statement start token.
              // The parser should then call GetNextToken() which will return the this.currentToken that is assigned to this.errorToken
              this.currentToken = nonSenseToken;
              return ParseStatement();
            }else{
              //ReportError(JSError.SyntaxError, nonSenseToken);
              if (JSScanner.CanStartStatement(this.currentToken.token)){
                this.errorToken = null;
                return ParseStatement();
              }else{
                ReportError(JSError.SyntaxError);
                SkipTokensAndThrow();
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:jsparser.cs

示例5: ParsePackage

        private AST ParsePackage(Context packageContext)
        {
            AST ast4;
            this.GetNextToken();
            AST expression = null;
            bool flag = this.scanner.GotEndOfLine();
            if (JSToken.Identifier != this.currentToken.token)
            {
                if (JSScanner.CanParseAsExpression(this.currentToken.token))
                {
                    bool flag2;
                    this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
                    expression = new Lookup("package", packageContext);
                    expression = this.MemberExpression(expression, null);
                    expression = this.ParsePostfixExpression(expression, out flag2);
                    expression = this.ParseExpression(expression, false, flag2, JSToken.None);
                    return new Expression(expression.context.Clone(), expression);
                }
                if (flag)
                {
                    this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
                    return new Lookup("package", packageContext);
                }
                if ((JSToken.Increment == this.currentToken.token) || (JSToken.Decrement == this.currentToken.token))
                {
                    bool flag3;
                    this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
                    expression = new Lookup("package", packageContext);
                    expression = this.ParsePostfixExpression(expression, out flag3);
                    expression = this.ParseExpression(expression, false, false, JSToken.None);
                    return new Expression(expression.context.Clone(), expression);
                }
            }
            else
            {
                this.errorToken = this.currentToken;
                expression = this.ParseQualifiedIdentifier(JSError.NoIdentifier);
            }
            Context context = null;
            if ((JSToken.LeftCurly != this.currentToken.token) && (expression == null))
            {
                context = this.currentToken.Clone();
                this.GetNextToken();
            }
            if (JSToken.LeftCurly == this.currentToken.token)
            {
                if (expression == null)
                {
                    if (context == null)
                    {
                        context = this.currentToken.Clone();
                    }
                    this.ReportError(JSError.NoIdentifier, context, true);
                }
            }
            else if (expression == null)
            {
                this.ReportError(JSError.SyntaxError, packageContext);
                if (JSScanner.CanStartStatement(context.token))
                {
                    this.currentToken = context;
                    return this.ParseStatement();
                }
                if (JSScanner.CanStartStatement(this.currentToken.token))
                {
                    this.errorToken = null;
                    return this.ParseStatement();
                }
                this.ReportError(JSError.SyntaxError);
                this.SkipTokensAndThrow();
            }
            else
            {
                if (flag)
                {
                    bool flag4;
                    this.ReportError(JSError.KeywordUsedAsIdentifier, packageContext.Clone(), true);
                    Block block = new Block(packageContext.Clone());
                    block.Append(new Lookup("package", packageContext));
                    expression = this.MemberExpression(expression, null);
                    expression = this.ParsePostfixExpression(expression, out flag4);
                    expression = this.ParseExpression(expression, false, true, JSToken.None);
                    block.Append(new Expression(expression.context.Clone(), expression));
                    block.context.UpdateWith(expression.context);
                    return block;
                }
                this.ReportError(JSError.NoLeftCurly);
            }
            PackageScope item = new PackageScope(this.Globals.ScopeStack.Peek());
            this.Globals.ScopeStack.Push(item);
            try
            {
                string name = (expression != null) ? expression.ToString() : "anonymous package";
                item.name = name;
                packageContext.UpdateWith(this.currentToken);
                ASTList classList = new ASTList(packageContext);
                this.GetNextToken();
                this.noSkipTokenSet.Add(NoSkipTokenSet.s_BlockNoSkipTokenSet);
                this.noSkipTokenSet.Add(NoSkipTokenSet.s_PackageBodyNoSkipTokenSet);
                try
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:JSParser.cs


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