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


C# Parsing.ParsingContext类代码示例

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


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

示例1: Init

        public override void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);

            foreach (var node in parseNode.ChildNodes)
            {
                if (node.AstNode is Function)
                {
                    AddFunction(node.AstNode as Function);
                }
                else if (node.AstNode is AuxiliaryNode)
                {
                    var ids = (node.AstNode as AuxiliaryNode).ChildNodes.OfType<IdentifierNode>();

                    foreach (var id in ids)
                    {
                        ExternalFunction ef = new ExternalFunction();
                        ef.SetSpan(id.Span);
                        ef.Name = id.Symbol;
                        AddFunction(ef);
                    }
                }
            }

            AsString = "Refal-5 program";
        }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:26,代码来源:Program.cs

示例2: DirectInit

 public void DirectInit(ParsingContext context, ParseTreeNode parseNode)
 {
     var idChain = ((IDNode)parseNode.ChildNodes[2].AstNode).IDChainDefinition;
     var tupleDefinition = ((TupleNode)parseNode.ChildNodes[3].AstNode).TupleDefinition;
     var AttrName = parseNode.ChildNodes[2].FirstChild.FirstChild.Token.ValueString;
     ToBeRemovedList = new AttributeRemoveList(idChain, AttrName, tupleDefinition);
 }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:RemoveFromListAttrUpdateAddToRemoveFromNode.cs

示例3: CreateIncompleteToken

 private Token CreateIncompleteToken(ParsingContext context, ISourceStream source) {
   source.PreviewPosition = source.Text.Length;
   Token result = source.CreateToken(this.OutputTerminal);
   result.Flags |= TokenFlags.IsIncomplete;
   context.VsLineScanState.TerminalIndex = this.MultilineIndex;
   return result; 
 }
开发者ID:kayateia,项目名称:climoo,代码行数:7,代码来源:CommentTerminal.cs

示例4: TryMatch

 public override Token TryMatch(ParsingContext context, ISourceStream source) {
   Match m = _expression.Match(source.Text, source.PreviewPosition);
   if (!m.Success || m.Index != source.PreviewPosition) 
     return null;
   source.PreviewPosition += m.Length;
   return source.CreateToken(this.OutputTerminal); 
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:RegExBasedTerminal.cs

示例5: Init

 public void Init(ParsingContext context, ParseTreeNode parseNode)
 {
     if (HasChildNodes(parseNode))
     {
         BinExprNode = (BinaryExpressionNode)parseNode.ChildNodes[1].AstNode;
     }
 }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:HavingExpressionNode.cs

示例6: ReadQuotedBody

 private static string ReadQuotedBody(ParsingContext context, ISourceStream source)
 {
     const char dQuoute = '"';
       StringBuilder sb = null;
       var from = source.Location.Position + 1; //skip initial double quote
       while(true) {
     var until  = source.Text.IndexOf(dQuoute, from);
     if (until < 0)
       throw new Exception(Resources.ErrDsvNoClosingQuote); // "Could not find a closing quote for quoted value."
     source.PreviewPosition = until; //now points at double-quote
     var piece = source.Text.Substring(from, until - from);
     source.PreviewPosition++; //move after double quote
     if (source.PreviewChar != dQuoute && sb == null)
       return piece; //quick path - if sb (string builder) was not created yet, we are looking at the very first segment;
                 // and if we found a standalone dquote, then we are done - the "piece" is the result.
     if (sb == null)
       sb = new StringBuilder(100);
     sb.Append(piece);
     if (source.PreviewChar != dQuoute)
       return sb.ToString();
     //we have doubled double-quote; add a single double-quoute char to the result and move over both symbols
     sb.Append(dQuoute);
     from = source.PreviewPosition + 1;
       }
 }
开发者ID:dbremner,项目名称:irony,代码行数:25,代码来源:DsvLiteral.cs

示例7: Init

 public override void Init(ParsingContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode);
   TargetRef = AddChild("Target", treeNode.ChildNodes[0]);
   _targetName = treeNode.ChildNodes[0].FindTokenAndGetText(); 
   Arguments = AddChild("Args", treeNode.ChildNodes[1]);
   AsString = "Call " + _targetName;
 }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:FunctionCallNode.cs

示例8: Parser

        /// <summary>
        /// Initializes a new instance of the <see cref="Parser"/> class.
        /// </summary>
        /// <param name="language">The language.</param>
        /// <param name="scanner">The scanner.</param>
        /// <param name="root">The root.</param>
        /// <exception cref="Exception">
        ///   </exception>
        public Parser(LanguageData language, Scanner scanner, NonTerminal root)
        {
            Language = language;
            Context = new ParsingContext(this);
            Scanner = scanner ?? language.CreateScanner();

            if (Scanner != null)
            {
                Scanner.Initialize(this);
            } 
            else
            {
                Language.Errors.Add(GrammarErrorLevel.Error, null, "Scanner is not initialized for this grammar");
            }
            CoreParser = new CoreParser(this);
            Root = root;
            if (Root == null)
            {
                Root = Language.Grammar.Root;
                InitialState = Language.ParserData.InitialState;
            }
            else
            {
                if (Root != Language.Grammar.Root && !Language.Grammar.SnippetRoots.Contains(Root))
                {
                    throw new Exception(string.Format(Resources.ErrRootNotRegistered, root.Name));
                }

                InitialState = Language.ParserData.InitialStates[Root];
            }
        }
开发者ID:cg123,项目名称:xenko,代码行数:39,代码来源:Parser.cs

示例9: DirectInit

        public void DirectInit(ParsingContext context, ParseTreeNode parseNode)
        {
            var _elementsToBeAdded = (CollectionOfDBObjectsNode)parseNode.ChildNodes[3].AstNode;
            var _AttrName = parseNode.ChildNodes[2].FirstChild.FirstChild.Token.ValueString;

            AttributeUpdateList = new AttributeAssignOrUpdateList(_elementsToBeAdded.CollectionDefinition, ((IDNode)parseNode.ChildNodes[2].AstNode).IDChainDefinition, false);
        }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:AddToListAttrUpdateAddToNode.cs

示例10: InitNode

        /// <summary>
        /// Converts identifiers to compound symbols (strings in double quotes),
        /// expands character strings (in single quotes) to arrays of characters
        /// </summary>
        public static void InitNode(ParsingContext context, ParseTreeNode parseNode)
        {
            foreach (var node in parseNode.ChildNodes)
            {
                if (node.AstNode is LiteralValueNode)
                {
                    if (node.Term.Name == "Char")
                    {
                        var literal = node.AstNode as LiteralValueNode;
                        literal.Value = literal.Value.ToString().ToCharArray();
                    }

                    parseNode.AstNode = node.AstNode;
                }
                else
                {
                    // identifiers in expressions are treated as strings (True is same as "True")
                    parseNode.AstNode = new LiteralValueNode()
                    {
                        Value = node.FindTokenAndGetText(),
                        Span = node.Span
                    };
                }
            }
        }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:29,代码来源:LiteralValueNodeHelper.cs

示例11: Init

 public void Init(ParsingContext context, ParseTreeNode parseNode)
 {
     if (HasChildNodes(parseNode))
     {
         ParallelTasks = Convert.ToUInt32(parseNode.ChildNodes[1].Token.Value);
     }
 }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:ParallelTasksNode.cs

示例12: Init

        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            if (HasChildNodes(parseNode))
            {
                //get type
                if (parseNode.ChildNodes[1] != null && parseNode.ChildNodes[1].AstNode != null)
                {
                    _type = ((AstNode)(parseNode.ChildNodes[1].AstNode)).AsString;
                }
                else
                {
                    throw new NotImplementedQLException("");
                }

                if (parseNode.ChildNodes[3] != null && HasChildNodes(parseNode.ChildNodes[3]))
                {

                    _attributeAssignList = (parseNode.ChildNodes[3].AstNode as AttributeAssignListNode).AttributeAssigns;

                }

                if (parseNode.ChildNodes[4] != null && ((WhereExpressionNode)parseNode.ChildNodes[4].AstNode).BinaryExpressionDefinition != null)
                {
                    _whereExpression = ((WhereExpressionNode)parseNode.ChildNodes[4].AstNode).BinaryExpressionDefinition;

                }
            }   
        }
开发者ID:anukat2015,项目名称:sones,代码行数:28,代码来源:InsertOrReplaceNode.cs

示例13: Init

        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            var multiplyString = parseNode.ChildNodes[0].Token.Text.ToUpper();
            CollectionType collectionType;

            switch (multiplyString)
            {
                case SonesGQLConstants.LISTOF:

                    collectionType = CollectionType.List;
                    break;

                case SonesGQLConstants.SETOF:

                    collectionType = CollectionType.Set;
                    break;

                case SonesGQLConstants.SETOFUUIDS:

                default:
                    throw new InvalidOperationException(
                                String.Format("The specified command [{0}] is not valid.", multiplyString));
            }

            if (parseNode.ChildNodes[1].AstNode is TupleNode)
            {
                CollectionDefinition = 
                    new CollectionDefinition(collectionType, 
                                            ((TupleNode)parseNode.ChildNodes[1].AstNode).TupleDefinition);
            }
            else
            {
                throw new NotImplementedException("The following node cannot be created.");
            }
        }
开发者ID:anukat2015,项目名称:sones,代码行数:35,代码来源:CollectionOfBasicDBObjectsNode.cs

示例14: Init

        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            #region get Name

            _TypeName = parseNode.ChildNodes[0].Token.ValueString;

            #endregion

            #region get Extends

            if (HasChildNodes(parseNode.ChildNodes[1]))
                _Extends = parseNode.ChildNodes[1].ChildNodes[1].Token.ValueString;

            #endregion

            #region get myAttributes

            if (HasChildNodes(parseNode.ChildNodes[2]))
                _Attributes = GetAttributeList(parseNode.ChildNodes[2].ChildNodes[1]);

            #endregion

            #region get Comment

            if (HasChildNodes(parseNode.ChildNodes[3]))
                _Comment = parseNode.ChildNodes[3].ChildNodes[2].Token.ValueString;

            #endregion
        }
开发者ID:anukat2015,项目名称:sones,代码行数:29,代码来源:BulkEdgeTypeNode.cs

示例15: TryMatch

 public override Token TryMatch(ParsingContext context, ISourceStream source) {
   string tokenText = string.Empty;
   while (true) {
     //Find next position
     var newPos = source.Text.IndexOfAny(_stopChars, source.PreviewPosition);
     if(newPos == -1) {
       if(IsSet(FreeTextOptions.AllowEof)) {
         source.PreviewPosition = source.Text.Length;
         return source.CreateToken(this.OutputTerminal);
       }  else
         return null;
     }
     if (newPos == source.PreviewPosition)   // DC
     {
         context.AddParserError("(DC) in TryMatch, newPos == source.PreviewPosition", new object[] {});
         break;                              // DC
     }
     tokenText += source.Text.Substring(source.PreviewPosition, newPos - source.PreviewPosition);
     source.PreviewPosition = newPos;
     //if it is escape, add escaped text and continue search
     if (CheckEscape(source, ref tokenText)) 
       continue;
     //check terminators
     if (CheckTerminators(source, ref tokenText))
       break; //from while (true)        
   }
   return source.CreateToken(this.OutputTerminal, tokenText);
 }
开发者ID:pusp,项目名称:o2platform,代码行数:28,代码来源:FreeTextLiteral.cs


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