1 /++
2 This module was automatically generated from the following grammar:
3 
4 
5 TesterGrammar:
6 
7 Root < Node eoi
8 
9 Node <
10     / :'^' identifier
11     / identifier (%Branch)*
12 
13 Branch <
14     / OrderedBranch
15     / UnorderedBranch
16 
17 OrderedBranch <
18     / :'->' :'{' Node+ :'}'
19     / :'->' Node
20 
21 UnorderedBranch <
22     / :'~>' :'{' Node+ :'}'
23     / :'~>' Node
24 
25 Spacing <: (blank / Comment)*
26 
27 Comment <- 
28     / '//' (!eol .)* (eol)
29     / '/*' (!'*/' .)* '*/'
30     / NestedComment
31 
32 NestedComment <- '/+' (!NestedCommentEnd . / NestedComment) NestedCommentEnd
33 
34 # This is needed to make the /+ +/ nest when the grammar is placed into a D nested comment ;)
35 NestedCommentEnd <- '+/'
36 
37 
38 +/
39 module pegged.tester.testerparser;
40 
41 public import pegged.peg;
42 struct GenericTesterGrammar(TParseTree)
43 {
44     struct TesterGrammar
45     {
46     enum name = "TesterGrammar";
47     static bool isRule(string s)
48     {
49         switch(s)
50         {
51             case "TesterGrammar.Root":
52             case "TesterGrammar.Node":
53             case "TesterGrammar.Branch":
54             case "TesterGrammar.OrderedBranch":
55             case "TesterGrammar.UnorderedBranch":
56             case "TesterGrammar.Spacing":
57             case "TesterGrammar.Comment":
58             case "TesterGrammar.NestedComment":
59             case "TesterGrammar.NestedCommentEnd":
60                 return true;
61             default:
62                 return false;
63         }
64     }
65     mixin decimateTree;
66     static TParseTree Root(TParseTree p)
67     {
68          return pegged.peg.named!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Node, Spacing), pegged.peg.wrapAround!(Spacing, eoi, Spacing)), "TesterGrammar.Root")(p);
69     }
70     static TParseTree Root(string s)
71     {
72         return pegged.peg.named!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Node, Spacing), pegged.peg.wrapAround!(Spacing, eoi, Spacing)), "TesterGrammar.Root")(TParseTree("", false,[], s));
73     }
74     static string Root(GetName g)
75     {
76         return "TesterGrammar.Root";
77     }
78 
79     static TParseTree Node(TParseTree p)
80     {
81          return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("^"), Spacing)), pegged.peg.wrapAround!(Spacing, identifier, Spacing)), pegged.peg.and!(pegged.peg.wrapAround!(Spacing, identifier, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.propagate!(pegged.peg.wrapAround!(Spacing, Branch, Spacing)), Spacing)))), "TesterGrammar.Node")(p);
82     }
83     static TParseTree Node(string s)
84     {
85         return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("^"), Spacing)), pegged.peg.wrapAround!(Spacing, identifier, Spacing)), pegged.peg.and!(pegged.peg.wrapAround!(Spacing, identifier, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.propagate!(pegged.peg.wrapAround!(Spacing, Branch, Spacing)), Spacing)))), "TesterGrammar.Node")(TParseTree("", false,[], s));
86     }
87     static string Node(GetName g)
88     {
89         return "TesterGrammar.Node";
90     }
91 
92     static TParseTree Branch(TParseTree p)
93     {
94          return pegged.peg.named!(pegged.peg.or!(pegged.peg.wrapAround!(Spacing, OrderedBranch, Spacing), pegged.peg.wrapAround!(Spacing, UnorderedBranch, Spacing)), "TesterGrammar.Branch")(p);
95     }
96     static TParseTree Branch(string s)
97     {
98         return pegged.peg.named!(pegged.peg.or!(pegged.peg.wrapAround!(Spacing, OrderedBranch, Spacing), pegged.peg.wrapAround!(Spacing, UnorderedBranch, Spacing)), "TesterGrammar.Branch")(TParseTree("", false,[], s));
99     }
100     static string Branch(GetName g)
101     {
102         return "TesterGrammar.Branch";
103     }
104 
105     static TParseTree OrderedBranch(TParseTree p)
106     {
107          return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("->"), Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing)), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Node, Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing))), pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("->"), Spacing)), pegged.peg.wrapAround!(Spacing, Node, Spacing))), "TesterGrammar.OrderedBranch")(p);
108     }
109     static TParseTree OrderedBranch(string s)
110     {
111         return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("->"), Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing)), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Node, Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing))), pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("->"), Spacing)), pegged.peg.wrapAround!(Spacing, Node, Spacing))), "TesterGrammar.OrderedBranch")(TParseTree("", false,[], s));
112     }
113     static string OrderedBranch(GetName g)
114     {
115         return "TesterGrammar.OrderedBranch";
116     }
117 
118     static TParseTree UnorderedBranch(TParseTree p)
119     {
120          return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("~>"), Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing)), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Node, Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing))), pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("~>"), Spacing)), pegged.peg.wrapAround!(Spacing, Node, Spacing))), "TesterGrammar.UnorderedBranch")(p);
121     }
122     static TParseTree UnorderedBranch(string s)
123     {
124         return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("~>"), Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing)), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Node, Spacing)), pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing))), pegged.peg.and!(pegged.peg.discard!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("~>"), Spacing)), pegged.peg.wrapAround!(Spacing, Node, Spacing))), "TesterGrammar.UnorderedBranch")(TParseTree("", false,[], s));
125     }
126     static string UnorderedBranch(GetName g)
127     {
128         return "TesterGrammar.UnorderedBranch";
129     }
130 
131     static TParseTree Spacing(TParseTree p)
132     {
133          return pegged.peg.named!(pegged.peg.discard!(pegged.peg.zeroOrMore!(pegged.peg.or!(blank, Comment))), "TesterGrammar.Spacing")(p);
134     }
135     static TParseTree Spacing(string s)
136     {
137         return pegged.peg.named!(pegged.peg.discard!(pegged.peg.zeroOrMore!(pegged.peg.or!(blank, Comment))), "TesterGrammar.Spacing")(TParseTree("", false,[], s));
138     }
139     static string Spacing(GetName g)
140     {
141         return "TesterGrammar.Spacing";
142     }
143 
144     static TParseTree Comment(TParseTree p)
145     {
146          return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.literal!("//"), pegged.peg.zeroOrMore!(pegged.peg.and!(pegged.peg.negLookahead!(eol), pegged.peg.any)), eol), pegged.peg.and!(pegged.peg.literal!("/*"), pegged.peg.zeroOrMore!(pegged.peg.and!(pegged.peg.negLookahead!(pegged.peg.literal!("*/")), pegged.peg.any)), pegged.peg.literal!("*/")), NestedComment), "TesterGrammar.Comment")(p);
147     }
148     static TParseTree Comment(string s)
149     {
150         return pegged.peg.named!(pegged.peg.or!(pegged.peg.and!(pegged.peg.literal!("//"), pegged.peg.zeroOrMore!(pegged.peg.and!(pegged.peg.negLookahead!(eol), pegged.peg.any)), eol), pegged.peg.and!(pegged.peg.literal!("/*"), pegged.peg.zeroOrMore!(pegged.peg.and!(pegged.peg.negLookahead!(pegged.peg.literal!("*/")), pegged.peg.any)), pegged.peg.literal!("*/")), NestedComment), "TesterGrammar.Comment")(TParseTree("", false,[], s));
151     }
152     static string Comment(GetName g)
153     {
154         return "TesterGrammar.Comment";
155     }
156 
157     static TParseTree NestedComment(TParseTree p)
158     {
159          return pegged.peg.named!(pegged.peg.and!(pegged.peg.literal!("/+"), pegged.peg.or!(pegged.peg.and!(pegged.peg.negLookahead!(NestedCommentEnd), pegged.peg.any), NestedComment), NestedCommentEnd), "TesterGrammar.NestedComment")(p);
160     }
161     static TParseTree NestedComment(string s)
162     {
163         return pegged.peg.named!(pegged.peg.and!(pegged.peg.literal!("/+"), pegged.peg.or!(pegged.peg.and!(pegged.peg.negLookahead!(NestedCommentEnd), pegged.peg.any), NestedComment), NestedCommentEnd), "TesterGrammar.NestedComment")(TParseTree("", false,[], s));
164     }
165     static string NestedComment(GetName g)
166     {
167         return "TesterGrammar.NestedComment";
168     }
169 
170     static TParseTree NestedCommentEnd(TParseTree p)
171     {
172          return pegged.peg.named!(pegged.peg.literal!("+/"), "TesterGrammar.NestedCommentEnd")(p);
173     }
174     static TParseTree NestedCommentEnd(string s)
175     {
176         return pegged.peg.named!(pegged.peg.literal!("+/"), "TesterGrammar.NestedCommentEnd")(TParseTree("", false,[], s));
177     }
178     static string NestedCommentEnd(GetName g)
179     {
180         return "TesterGrammar.NestedCommentEnd";
181     }
182 
183     static TParseTree opCall(TParseTree p)
184     {
185         TParseTree result = decimateTree(Root(p));
186         result.children = [result];
187         result.name = "TesterGrammar";
188         return result;
189     }
190 
191     static TParseTree opCall(string input)
192     {
193         return TesterGrammar(TParseTree(``, false, [], input, 0, 0));
194 }
195     static string opCall(GetName g)
196     {
197         return "TesterGrammar";
198     }
199 
200     }
201 }
202 
203 alias GenericTesterGrammar!(ParseTree).TesterGrammar TesterGrammar;
204