Exemple #1
0
 public static ParserNode opt(ParserNode node)
 {
     return(new OptionalNode()
     {
         Content = node
     });
 }
Exemple #2
0
 public static ParserNode leftrecg(ParserNode first, params LeftRecursionGroupNode.Group[] nexts)
 {
     return(new LeftRecursionGroupNode()
     {
         FirstNode = first,
         Groups = nexts.ToList()
     });
 }
Exemple #3
0
 public static ParserNode list_hard <T>(ParserNode item)
 {
     return(new ListNode()
     {
         NodeType = typeof(T),
         Item = item,
         ContinueType = ListNodeContinueType.KeepGoing
     });
 }
Exemple #4
0
 public static LeftRecursionGroupNode.Group g <T>(string member, ParserNode node)
     where T : CodeNode
 {
     return(new LeftRecursionGroupNode.Group()
     {
         FirstMember = member,
         NextNode = node,
         Type = typeof(T)
     });
 }
Exemple #5
0
 public static ParserNode list <T>(ParserNode separator, ParserNode item)
 {
     return(new ListNode()
     {
         NodeType = typeof(T),
         Separator = separator,
         Item = item,
         ContinueType = ListNodeContinueType.CreateNodeType
     });
 }
Exemple #6
0
 public static ParserNode list <T>(ParserNode item, params string[] finishTokens)
 {
     return(new ListNode()
     {
         NodeType = typeof(T),
         Item = item,
         FinishTokens = finishTokens,
         ContinueType = ListNodeContinueType.StopByFinishTokens
     });
 }
Exemple #7
0
 public static ParserNode ret(ParserNode node)
 {
     if (node is RuleNode || node is TokenNode || node is TokenContentNode || node is LeftRecursionNode || node is LeftRecursionGroupNode || node is ListNode)
     {
         return(new ReturnNode()
         {
             Content = node
         });
     }
     else
     {
         throw new ArgumentException("Parser.ret can only be applied to rule, token, list or leftrec.");
     }
 }
Exemple #8
0
 public static ParserNode leftrec <T>(ParserNode first, ParserNode next)
 {
     if (first is MemberNode)
     {
         return(new LeftRecursionNode()
         {
             First = first,
             Next = next,
             NodeType = typeof(T)
         });
     }
     else
     {
         throw new ArgumentException("The first argument for Parser.leftrec should be MemberNode.");
     }
 }
Exemple #9
0
 public void Infer(ParserNode node)
 {
     this.Content = node;
 }