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


C# Base.PegNode类代码示例

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


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

示例1: TreeNodeToString

	public override string TreeNodeToString(PegNode node)
        {
            string s= GetRuleNameFromId(node.id_);
            BERTreeNode berNode= node as BERTreeNode;
            if( berNode!=null ) s+= ": " + berNode.TreeNodeToString(src_);
            return s;
        }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:7,代码来源:BERTree.cs

示例2: FindNodeInParents

 public static PegNode FindNodeInParents(PegNode node, EPegGrammar id)
 {
     for(; node!=null;node=node.parent_)
     {
         if( node.id_ == (int) id ) return node;
     }
     return null;
 }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:8,代码来源:PegParserGenerator.cs

示例3: GetByPath

 public static PegNode GetByPath(PegNode node, params int[] path)
 {
     for (int i = 0; i < path.Length; ++i)
     {
         if (node == null || node.id_ != path[i]) return null;
         if (i == path.Length - 1) return node; else node = node.child_;
     }
     return node;
 }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:9,代码来源:PegParserGenerator.cs

示例4: AddTreeNode

 private void AddTreeNode(TreeNode parent, PegNode node, NodeToString nodeToString)
 {
     if (node == null) return;
     string txt = nodeToString(node);
     if (node.parent_ == null) txt = "^" + txt;
     TreeNode tn = (parent == null ? tvParseTree.Nodes.Add(txt) : parent.Nodes.Add(txt));
     tn.Tag = node;
     AddTreeNode(tn, node.child_, nodeToString);
     AddTreeNode(parent, node.next_, nodeToString);
 }
开发者ID:Tigraine,项目名称:PEG_GrammarExplorer,代码行数:10,代码来源:PegExplorer.cs

示例5: LessNodeCreator

        protected PegNode LessNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
        {
            if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
                if (parentOrCreated == null)
                    return new LessPegRootNode(id, src_);
                else
                    return new LessPegNode(parentOrCreated, id, GetRoot());

            return null;
        }
开发者ID:JasonCline,项目名称:dotless,代码行数:10,代码来源:LessImpl.cs

示例6: FindNode

 public static PegNode FindNode(PegNode node, EPegGrammar id, int nodeDistance)
 {
     if (node == null || nodeDistance<=0) return null;
     if (node.id_ == (int)id) return node;
     PegNode foundNode = FindNode(node.child_, id, nodeDistance - 1);
     if (foundNode!=null) return foundNode;
     foundNode = FindNode(node.next_, id, nodeDistance - 1);
     if (foundNode != null) return foundNode;
     return null;
 }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:10,代码来源:PegParserGenerator.cs

示例7: PegNodeToXml

 public static string PegNodeToXml(PegNode pn, string text)
 {
     var message = new StringBuilder(10000);
     var xml = XmlWriter.Create(new StringWriterWithEncoding(message, Encoding.UTF8),
                             DEFAULT_XML_WRITER_SETTINGS);
     xml.WriteStartDocument();
     PegNodeToXmlRecurse(pn, text, xml);
     xml.WriteEndDocument();
     xml.Close();
     return message.ToString();
 }
开发者ID:FreakyJ,项目名称:MediaServer-fo-MP2,代码行数:11,代码来源:ParserHelper.cs

示例8: ParserPostProcessParams

 public ParserPostProcessParams(string outputDirectory,string sourceFileTitle, string grammarFileName, PegNode root, byte[] byteSrc, TextWriter errOut)
 {
     outputDirectory_ = outputDirectory;
     sourceFileTitle_ = sourceFileTitle;
     grammarFileName_ = grammarFileName;
     root_ = root;
     src_ = null;
     byteSrc_ = byteSrc;
     errOut_ = errOut;
     maxLineLength_= 60;
     spacesPerTap_ = 4;
 }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:12,代码来源:SamplesTester.cs

示例9: Accessor

 /// <summary>
 /// accessor: accessor_name '[' accessor_key ']'; 
 /// </summary>
 /// <param name="node"></param>
 /// <param name="element"></param>
 /// <returns></returns>
 private INode Accessor(PegNode node, Element element)
 {
     var ident = node.GetAsString(Src);
     var key = node.next_.GetAsString(Src).Replace("'", "");
     var el = element.NearestAs<Element>(ident);
     if (el!=null)
     {
         var prop = el.GetAs<Property>(key);
         if (((INode)prop) != null) return prop.Value;
     }
     return new Anonymous("");
 }
开发者ID:erikvanbrakel,项目名称:nLess,代码行数:18,代码来源:TreeBuilder.cs

示例10: PegNodeToXmlRecurse

 public static void PegNodeToXmlRecurse(PegNode pn, string text, XmlWriter xml)
 {
     var name = pn.id_ > 0 ? Enum.GetName(typeof (EUPnPContentDirectorySearch), pn.id_) : "Node";
     xml.WriteStartElement(name);
     xml.WriteAttributeString("match", pn.GetAsString(text));
     if (pn.child_ != null)
     {
         PegNodeToXmlRecurse(pn.child_, text, xml);
     }
     xml.WriteEndElement();
     if (pn.next_ != null)
     {
         PegNodeToXmlRecurse(pn.next_, text, xml);
     }
 }
开发者ID:FreakyJ,项目名称:MediaServer-fo-MP2,代码行数:15,代码来源:ParserHelper.cs

示例11: WriteDefinite

 private void WriteDefinite(BinaryWriter rw, PegNode pegNode)
 {
     PegNode child;
    if (pegNode == null) return;
    WriteTag(rw, pegNode);
    WriteLength(rw, pegNode);
    if (IsComposite(pegNode, out child))
    {
        WriteDefinite(rw, child);
    }
    else
    {
        Debug.Assert(pegNode.child_ != null && pegNode.child_.next_ != null && pegNode.child_.next_.next_ != null);
        WriteContent(rw, pegNode.child_.next_.next_);
    }
    WriteDefinite(rw, pegNode.next_);
 }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:17,代码来源:BERConvert.cs

示例12: ConvertStructType

        public void ConvertStructType(PegNode blocknamenode, IBfsStructType block)
        {
            if (block == null)
                throw new AstConvertException("Type wasn't struct-like");

            block.SourceRange = GetSourceRange(blocknamenode);
            block.Name = GetNodeText(blocknamenode);

            PegNode nextNode = blocknamenode.next_;

            //If the structure has a Compression Method defined
            if ( nextNode != null && GetNodeId(nextNode) == EBinaryFileSchemaParser.compressionmethod)
            {
                block.CompressionMethod = GetNodeText(nextNode);
                block.CompressionRange = GetSourceRange(nextNode);
                nextNode = nextNode.next_;
            }

            //If a primitive type is present, then it is a comsumeable struct type
            if (nextNode != null && GetNodeId(nextNode) == EBinaryFileSchemaParser.primitivetype)
            {
                IBfsConsumptionType special = block as IBfsConsumptionType;
                special.PrimitiveType = ConvertPrimitiveType(nextNode);
                nextNode = nextNode.next_;
            }

            //For each of the fields the struct-type contains
            for(PegNode field = nextNode; field != null; field = field.next_)
            {
                if (GetNodeId(field) == EBinaryFileSchemaParser.field)
                {
                    BfsStructField fielditem = new BfsStructField();
                    fielditem.SourceRange = GetSourceRange(field);
                    ConvertStructField(field, fielditem);
                    block.StructFieldList.Add(fielditem);
                }
                else
                    if (GetNodeId(field) == EBinaryFileSchemaParser.localfield)
                        ConvertLocalField(field, block);
                    else
                        throw new AstConvertException("Node wasn't a field: " + GetNodeId(field));
            }
        }
开发者ID:Andos,项目名称:BinaryFileSchema,代码行数:43,代码来源:AstConvert.cs

示例13: GetLength

 private uint GetLength(PegNode pegNode)
 {
     if (dictLength.ContainsKey(pegNode)) return dictLength[pegNode];
     if (pegNode.id_ == (int)EBERTree.ConstructedDelimValue ||
         pegNode.id_ == (int)EBERTree.ConstructedValue)
     {
         uint length = 0;
         for (PegNode child = pegNode.child_; child != null; child = child.next_)
         {
             length += GetLength(child);
         }
         dictLength.Add(pegNode, length);
         return length;
     }
     else if (pegNode.id_ == (int)EBERTree.PrimitiveValue)
     {
         uint length= (uint)(pegNode.match_.posEnd_ - pegNode.match_.posBeg_);
         dictLength.Add(pegNode, length);
         return length;
     }
     else if (pegNode.id_ == (int)EBERTree.TLV)
     {
         Debug.Assert(pegNode.child_ != null && pegNode.child_.next_ != null);
         PegNode tag = pegNode.child_, content = tag.next_.next_;
         uint length= (uint)(pegNode.child_.match_.posEnd_ - pegNode.child_.match_.posBeg_)
             + (uint)GetLengthEncodingLength(GetLength(content))
             + GetLength(content);
         dictLength.Add(pegNode, length);
         return length;
     }
     else
     {
         Debug.Assert(false);
         return 0;
     }
 }
开发者ID:Tigraine,项目名称:PEG_GrammarExplorer,代码行数:36,代码来源:BERConvert.cs

示例14: RuleSet

 /// <summary>
 /// ruleset: selectors [{] ws prsimary ws [}] ws /  ws selectors ';' ws;
 /// </summary>
 /// <param name="node"></param>
 /// <param name="elementBlock"></param>
 private void RuleSet(PegNode node, ElementBlock elementBlock)
 {
     foreach (var el in Selectors(node.child_, els => StandardSelectors(elementBlock, els)))
         Primary(node.child_.next_, el);
 }
开发者ID:gjunge,项目名称:nLess,代码行数:10,代码来源:TreeBuilder.cs

示例15: WriteInDefinite

 private void WriteInDefinite(BinaryWriter rw, PegNode pegNode)
 {
     PegNode child;
     if (pegNode == null) return;
     bool bIsComposite = IsComposite(pegNode, out child);
     WriteTag(rw, pegNode);
     WriteLength(rw, pegNode,bIsComposite);
     if (bIsComposite)
     {
         for(;child!=null;child= child.next_)
         {
             WriteInDefinite(rw, child);
         }
         rw.Write((ushort)0x0000);
     }
     else
     {
         Debug.Assert(pegNode.child_ != null && pegNode.child_.next_ != null && pegNode.child_.next_.next_ != null);
         WriteContent(rw, pegNode.child_.next_.next_);
     }
 }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:21,代码来源:BERConvert.cs


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