1 /++ 2 This module was automatically generated from the following grammar: 3 4 5 # Comments and include directive are not part of this grammar. 6 # They must be handled before the input is given to the PEG parser 7 8 Config: 9 Document < eoi / Setting+ 10 11 Setting < Name (':' / '=') Value (';' / ',')? 12 13 Value <- Scalar / Array / List / Group 14 Scalar <- Bool / Float / Integer / String # Float MUST be before Integer 15 Array < '[' ( Scalar (',' Scalar)* )? ']' 16 List < '(' ( Value (',' Value)* )? ')' 17 Group < '{' Setting* '}' 18 19 Name <~ [A-Za-z] ( [-A-Za-z0-9_] )* 20 21 Bool <~ [Tt] [Rr] [Uu] [Ee] / [Ff] [Aa] [Ll] [Ss] [Ee] 22 23 Integer <- (Hex / Dec) ('LL' / 'L')? 24 Hex <~ :'0' :[Xx] hexDigit+ 25 Dec <~ [-+]? digits 26 27 Float <~ ( [-+]? digit* ^'.' digit* ( [eE] [-+]? digits )? ) / 28 ( [-+]? digit+ (^'.' digit*)? [eE] [-+]? digits ) 29 30 StringQuot <~ :doublequote ( 31 backslash backslash / 32 backslash doublequote / 33 backslash ^'f' / 34 backslash ^'n' / 35 backslash ^'r' / 36 backslash ^'t' / 37 !doublequote !backslash . 38 )* :doublequote 39 40 String <~ (StringQuot spacing?)+ 41 42 43 +/ 44 module config.grammar; 45 46 public import pegged.peg; 47 import std.algorithm: startsWith; 48 import std.functional: toDelegate; 49 50 struct GenericConfig(TParseTree) 51 { 52 import std.functional : toDelegate; 53 import pegged.dynamic.grammar; 54 static import pegged.peg; 55 struct Config 56 { 57 enum name = "Config"; 58 static ParseTree delegate(ParseTree)[string] before; 59 static ParseTree delegate(ParseTree)[string] after; 60 static ParseTree delegate(ParseTree)[string] rules; 61 import std.typecons:Tuple, tuple; 62 static TParseTree[Tuple!(string, size_t)] memo; 63 static this() 64 { 65 rules["Document"] = toDelegate(&Document); 66 rules["Setting"] = toDelegate(&Setting); 67 rules["Value"] = toDelegate(&Value); 68 rules["Scalar"] = toDelegate(&Scalar); 69 rules["Array"] = toDelegate(&Array); 70 rules["List"] = toDelegate(&List); 71 rules["Group"] = toDelegate(&Group); 72 rules["Name"] = toDelegate(&Name); 73 rules["Bool"] = toDelegate(&Bool); 74 rules["Integer"] = toDelegate(&Integer); 75 rules["Hex"] = toDelegate(&Hex); 76 rules["Dec"] = toDelegate(&Dec); 77 rules["Float"] = toDelegate(&Float); 78 rules["StringQuot"] = toDelegate(&StringQuot); 79 rules["String"] = toDelegate(&String); 80 rules["Spacing"] = toDelegate(&Spacing); 81 } 82 83 template hooked(alias r, string name) 84 { 85 static ParseTree hooked(ParseTree p) 86 { 87 ParseTree result; 88 89 if (name in before) 90 { 91 result = before[name](p); 92 if (result.successful) 93 return result; 94 } 95 96 result = r(p); 97 if (result.successful || name !in after) 98 return result; 99 100 result = after[name](p); 101 return result; 102 } 103 104 static ParseTree hooked(string input) 105 { 106 return hooked!(r, name)(ParseTree("",false,[],input)); 107 } 108 } 109 110 static void addRuleBefore(string parentRule, string ruleSyntax) 111 { 112 // enum name is the current grammar name 113 DynamicGrammar dg = pegged.dynamic.grammar.grammar(name ~ ": " ~ ruleSyntax, rules); 114 foreach(ruleName,rule; dg.rules) 115 if (ruleName != "Spacing") // Keep the local Spacing rule, do not overwrite it 116 rules[ruleName] = rule; 117 before[parentRule] = rules[dg.startingRule]; 118 } 119 120 static void addRuleAfter(string parentRule, string ruleSyntax) 121 { 122 // enum name is the current grammar named 123 DynamicGrammar dg = pegged.dynamic.grammar.grammar(name ~ ": " ~ ruleSyntax, rules); 124 foreach(name,rule; dg.rules) 125 { 126 if (name != "Spacing") 127 rules[name] = rule; 128 } 129 after[parentRule] = rules[dg.startingRule]; 130 } 131 132 static bool isRule(string s) 133 { 134 import std.algorithm : startsWith; 135 return s.startsWith("Config."); 136 } 137 mixin decimateTree; 138 139 alias spacing Spacing; 140 141 static TParseTree Document(TParseTree p) 142 { 143 if(__ctfe) 144 { 145 return pegged.peg.defined!(pegged.peg.or!(pegged.peg.wrapAround!(Spacing, eoi, Spacing), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing))), "Config.Document")(p); 146 } 147 else 148 { 149 if (auto m = tuple(`Document`, p.end) in memo) 150 return *m; 151 else 152 { 153 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.or!(pegged.peg.wrapAround!(Spacing, eoi, Spacing), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing))), "Config.Document"), "Document")(p); 154 memo[tuple(`Document`, p.end)] = result; 155 return result; 156 } 157 } 158 } 159 160 static TParseTree Document(string s) 161 { 162 if(__ctfe) 163 { 164 return pegged.peg.defined!(pegged.peg.or!(pegged.peg.wrapAround!(Spacing, eoi, Spacing), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing))), "Config.Document")(TParseTree("", false,[], s)); 165 } 166 else 167 { 168 forgetMemo(); 169 return hooked!(pegged.peg.defined!(pegged.peg.or!(pegged.peg.wrapAround!(Spacing, eoi, Spacing), pegged.peg.oneOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing))), "Config.Document"), "Document")(TParseTree("", false,[], s)); 170 } 171 } 172 static string Document(GetName g) 173 { 174 return "Config.Document"; 175 } 176 177 static TParseTree Setting(TParseTree p) 178 { 179 if(__ctfe) 180 { 181 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Name, Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(":"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("="), Spacing)), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(";"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing)), Spacing))), "Config.Setting")(p); 182 } 183 else 184 { 185 if (auto m = tuple(`Setting`, p.end) in memo) 186 return *m; 187 else 188 { 189 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Name, Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(":"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("="), Spacing)), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(";"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing)), Spacing))), "Config.Setting"), "Setting")(p); 190 memo[tuple(`Setting`, p.end)] = result; 191 return result; 192 } 193 } 194 } 195 196 static TParseTree Setting(string s) 197 { 198 if(__ctfe) 199 { 200 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Name, Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(":"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("="), Spacing)), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(";"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing)), Spacing))), "Config.Setting")(TParseTree("", false,[], s)); 201 } 202 else 203 { 204 forgetMemo(); 205 return hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Name, Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(":"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("="), Spacing)), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.or!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(";"), Spacing), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing)), Spacing))), "Config.Setting"), "Setting")(TParseTree("", false,[], s)); 206 } 207 } 208 static string Setting(GetName g) 209 { 210 return "Config.Setting"; 211 } 212 213 static TParseTree Value(TParseTree p) 214 { 215 if(__ctfe) 216 { 217 return pegged.peg.defined!(pegged.peg.or!(Scalar, Array, List, Group), "Config.Value")(p); 218 } 219 else 220 { 221 if (auto m = tuple(`Value`, p.end) in memo) 222 return *m; 223 else 224 { 225 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.or!(Scalar, Array, List, Group), "Config.Value"), "Value")(p); 226 memo[tuple(`Value`, p.end)] = result; 227 return result; 228 } 229 } 230 } 231 232 static TParseTree Value(string s) 233 { 234 if(__ctfe) 235 { 236 return pegged.peg.defined!(pegged.peg.or!(Scalar, Array, List, Group), "Config.Value")(TParseTree("", false,[], s)); 237 } 238 else 239 { 240 forgetMemo(); 241 return hooked!(pegged.peg.defined!(pegged.peg.or!(Scalar, Array, List, Group), "Config.Value"), "Value")(TParseTree("", false,[], s)); 242 } 243 } 244 static string Value(GetName g) 245 { 246 return "Config.Value"; 247 } 248 249 static TParseTree Scalar(TParseTree p) 250 { 251 if(__ctfe) 252 { 253 return pegged.peg.defined!(pegged.peg.or!(Bool, Float, Integer, String), "Config.Scalar")(p); 254 } 255 else 256 { 257 if (auto m = tuple(`Scalar`, p.end) in memo) 258 return *m; 259 else 260 { 261 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.or!(Bool, Float, Integer, String), "Config.Scalar"), "Scalar")(p); 262 memo[tuple(`Scalar`, p.end)] = result; 263 return result; 264 } 265 } 266 } 267 268 static TParseTree Scalar(string s) 269 { 270 if(__ctfe) 271 { 272 return pegged.peg.defined!(pegged.peg.or!(Bool, Float, Integer, String), "Config.Scalar")(TParseTree("", false,[], s)); 273 } 274 else 275 { 276 forgetMemo(); 277 return hooked!(pegged.peg.defined!(pegged.peg.or!(Bool, Float, Integer, String), "Config.Scalar"), "Scalar")(TParseTree("", false,[], s)); 278 } 279 } 280 static string Scalar(GetName g) 281 { 282 return "Config.Scalar"; 283 } 284 285 static TParseTree Array(TParseTree p) 286 { 287 if(__ctfe) 288 { 289 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("["), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Scalar, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Scalar, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("]"), Spacing)), "Config.Array")(p); 290 } 291 else 292 { 293 if (auto m = tuple(`Array`, p.end) in memo) 294 return *m; 295 else 296 { 297 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("["), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Scalar, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Scalar, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("]"), Spacing)), "Config.Array"), "Array")(p); 298 memo[tuple(`Array`, p.end)] = result; 299 return result; 300 } 301 } 302 } 303 304 static TParseTree Array(string s) 305 { 306 if(__ctfe) 307 { 308 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("["), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Scalar, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Scalar, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("]"), Spacing)), "Config.Array")(TParseTree("", false,[], s)); 309 } 310 else 311 { 312 forgetMemo(); 313 return hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("["), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Scalar, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Scalar, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("]"), Spacing)), "Config.Array"), "Array")(TParseTree("", false,[], s)); 314 } 315 } 316 static string Array(GetName g) 317 { 318 return "Config.Array"; 319 } 320 321 static TParseTree List(TParseTree p) 322 { 323 if(__ctfe) 324 { 325 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("("), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(")"), Spacing)), "Config.List")(p); 326 } 327 else 328 { 329 if (auto m = tuple(`List`, p.end) in memo) 330 return *m; 331 else 332 { 333 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("("), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(")"), Spacing)), "Config.List"), "List")(p); 334 memo[tuple(`List`, p.end)] = result; 335 return result; 336 } 337 } 338 } 339 340 static TParseTree List(string s) 341 { 342 if(__ctfe) 343 { 344 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("("), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(")"), Spacing)), "Config.List")(TParseTree("", false,[], s)); 345 } 346 else 347 { 348 forgetMemo(); 349 return hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("("), Spacing), pegged.peg.option!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, Value, Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(","), Spacing), pegged.peg.wrapAround!(Spacing, Value, Spacing)), Spacing))), Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!(")"), Spacing)), "Config.List"), "List")(TParseTree("", false,[], s)); 350 } 351 } 352 static string List(GetName g) 353 { 354 return "Config.List"; 355 } 356 357 static TParseTree Group(TParseTree p) 358 { 359 if(__ctfe) 360 { 361 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing)), "Config.Group")(p); 362 } 363 else 364 { 365 if (auto m = tuple(`Group`, p.end) in memo) 366 return *m; 367 else 368 { 369 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing)), "Config.Group"), "Group")(p); 370 memo[tuple(`Group`, p.end)] = result; 371 return result; 372 } 373 } 374 } 375 376 static TParseTree Group(string s) 377 { 378 if(__ctfe) 379 { 380 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing)), "Config.Group")(TParseTree("", false,[], s)); 381 } 382 else 383 { 384 forgetMemo(); 385 return hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("{"), Spacing), pegged.peg.zeroOrMore!(pegged.peg.wrapAround!(Spacing, Setting, Spacing)), pegged.peg.wrapAround!(Spacing, pegged.peg.literal!("}"), Spacing)), "Config.Group"), "Group")(TParseTree("", false,[], s)); 386 } 387 } 388 static string Group(GetName g) 389 { 390 return "Config.Group"; 391 } 392 393 static TParseTree Name(TParseTree p) 394 { 395 if(__ctfe) 396 { 397 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.or!(pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z')), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z'), pegged.peg.charRange!('0', '9'), pegged.peg.literal!("_"))))), "Config.Name")(p); 398 } 399 else 400 { 401 if (auto m = tuple(`Name`, p.end) in memo) 402 return *m; 403 else 404 { 405 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.or!(pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z')), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z'), pegged.peg.charRange!('0', '9'), pegged.peg.literal!("_"))))), "Config.Name"), "Name")(p); 406 memo[tuple(`Name`, p.end)] = result; 407 return result; 408 } 409 } 410 } 411 412 static TParseTree Name(string s) 413 { 414 if(__ctfe) 415 { 416 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.or!(pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z')), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z'), pegged.peg.charRange!('0', '9'), pegged.peg.literal!("_"))))), "Config.Name")(TParseTree("", false,[], s)); 417 } 418 else 419 { 420 forgetMemo(); 421 return hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.or!(pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z')), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.charRange!('A', 'Z'), pegged.peg.charRange!('a', 'z'), pegged.peg.charRange!('0', '9'), pegged.peg.literal!("_"))))), "Config.Name"), "Name")(TParseTree("", false,[], s)); 422 } 423 } 424 static string Name(GetName g) 425 { 426 return "Config.Name"; 427 } 428 429 static TParseTree Bool(TParseTree p) 430 { 431 if(__ctfe) 432 { 433 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("T"), pegged.peg.literal!("t")), pegged.peg.or!(pegged.peg.literal!("R"), pegged.peg.literal!("r")), pegged.peg.or!(pegged.peg.literal!("U"), pegged.peg.literal!("u")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))), pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("F"), pegged.peg.literal!("f")), pegged.peg.or!(pegged.peg.literal!("A"), pegged.peg.literal!("a")), pegged.peg.or!(pegged.peg.literal!("L"), pegged.peg.literal!("l")), pegged.peg.or!(pegged.peg.literal!("S"), pegged.peg.literal!("s")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))))), "Config.Bool")(p); 434 } 435 else 436 { 437 if (auto m = tuple(`Bool`, p.end) in memo) 438 return *m; 439 else 440 { 441 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("T"), pegged.peg.literal!("t")), pegged.peg.or!(pegged.peg.literal!("R"), pegged.peg.literal!("r")), pegged.peg.or!(pegged.peg.literal!("U"), pegged.peg.literal!("u")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))), pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("F"), pegged.peg.literal!("f")), pegged.peg.or!(pegged.peg.literal!("A"), pegged.peg.literal!("a")), pegged.peg.or!(pegged.peg.literal!("L"), pegged.peg.literal!("l")), pegged.peg.or!(pegged.peg.literal!("S"), pegged.peg.literal!("s")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))))), "Config.Bool"), "Bool")(p); 442 memo[tuple(`Bool`, p.end)] = result; 443 return result; 444 } 445 } 446 } 447 448 static TParseTree Bool(string s) 449 { 450 if(__ctfe) 451 { 452 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("T"), pegged.peg.literal!("t")), pegged.peg.or!(pegged.peg.literal!("R"), pegged.peg.literal!("r")), pegged.peg.or!(pegged.peg.literal!("U"), pegged.peg.literal!("u")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))), pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("F"), pegged.peg.literal!("f")), pegged.peg.or!(pegged.peg.literal!("A"), pegged.peg.literal!("a")), pegged.peg.or!(pegged.peg.literal!("L"), pegged.peg.literal!("l")), pegged.peg.or!(pegged.peg.literal!("S"), pegged.peg.literal!("s")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))))), "Config.Bool")(TParseTree("", false,[], s)); 453 } 454 else 455 { 456 forgetMemo(); 457 return hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("T"), pegged.peg.literal!("t")), pegged.peg.or!(pegged.peg.literal!("R"), pegged.peg.literal!("r")), pegged.peg.or!(pegged.peg.literal!("U"), pegged.peg.literal!("u")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))), pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("F"), pegged.peg.literal!("f")), pegged.peg.or!(pegged.peg.literal!("A"), pegged.peg.literal!("a")), pegged.peg.or!(pegged.peg.literal!("L"), pegged.peg.literal!("l")), pegged.peg.or!(pegged.peg.literal!("S"), pegged.peg.literal!("s")), pegged.peg.or!(pegged.peg.literal!("E"), pegged.peg.literal!("e"))))), "Config.Bool"), "Bool")(TParseTree("", false,[], s)); 458 } 459 } 460 static string Bool(GetName g) 461 { 462 return "Config.Bool"; 463 } 464 465 static TParseTree Integer(TParseTree p) 466 { 467 if(__ctfe) 468 { 469 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.or!(Hex, Dec), pegged.peg.option!(pegged.peg.keywords!("LL", "L"))), "Config.Integer")(p); 470 } 471 else 472 { 473 if (auto m = tuple(`Integer`, p.end) in memo) 474 return *m; 475 else 476 { 477 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.or!(Hex, Dec), pegged.peg.option!(pegged.peg.keywords!("LL", "L"))), "Config.Integer"), "Integer")(p); 478 memo[tuple(`Integer`, p.end)] = result; 479 return result; 480 } 481 } 482 } 483 484 static TParseTree Integer(string s) 485 { 486 if(__ctfe) 487 { 488 return pegged.peg.defined!(pegged.peg.and!(pegged.peg.or!(Hex, Dec), pegged.peg.option!(pegged.peg.keywords!("LL", "L"))), "Config.Integer")(TParseTree("", false,[], s)); 489 } 490 else 491 { 492 forgetMemo(); 493 return hooked!(pegged.peg.defined!(pegged.peg.and!(pegged.peg.or!(Hex, Dec), pegged.peg.option!(pegged.peg.keywords!("LL", "L"))), "Config.Integer"), "Integer")(TParseTree("", false,[], s)); 494 } 495 } 496 static string Integer(GetName g) 497 { 498 return "Config.Integer"; 499 } 500 501 static TParseTree Hex(TParseTree p) 502 { 503 if(__ctfe) 504 { 505 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.literal!("0")), pegged.peg.discard!(pegged.peg.or!(pegged.peg.literal!("X"), pegged.peg.literal!("x"))), pegged.peg.oneOrMore!(hexDigit))), "Config.Hex")(p); 506 } 507 else 508 { 509 if (auto m = tuple(`Hex`, p.end) in memo) 510 return *m; 511 else 512 { 513 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.literal!("0")), pegged.peg.discard!(pegged.peg.or!(pegged.peg.literal!("X"), pegged.peg.literal!("x"))), pegged.peg.oneOrMore!(hexDigit))), "Config.Hex"), "Hex")(p); 514 memo[tuple(`Hex`, p.end)] = result; 515 return result; 516 } 517 } 518 } 519 520 static TParseTree Hex(string s) 521 { 522 if(__ctfe) 523 { 524 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.literal!("0")), pegged.peg.discard!(pegged.peg.or!(pegged.peg.literal!("X"), pegged.peg.literal!("x"))), pegged.peg.oneOrMore!(hexDigit))), "Config.Hex")(TParseTree("", false,[], s)); 525 } 526 else 527 { 528 forgetMemo(); 529 return hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(pegged.peg.literal!("0")), pegged.peg.discard!(pegged.peg.or!(pegged.peg.literal!("X"), pegged.peg.literal!("x"))), pegged.peg.oneOrMore!(hexDigit))), "Config.Hex"), "Hex")(TParseTree("", false,[], s)); 530 } 531 } 532 static string Hex(GetName g) 533 { 534 return "Config.Hex"; 535 } 536 537 static TParseTree Dec(TParseTree p) 538 { 539 if(__ctfe) 540 { 541 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits)), "Config.Dec")(p); 542 } 543 else 544 { 545 if (auto m = tuple(`Dec`, p.end) in memo) 546 return *m; 547 else 548 { 549 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits)), "Config.Dec"), "Dec")(p); 550 memo[tuple(`Dec`, p.end)] = result; 551 return result; 552 } 553 } 554 } 555 556 static TParseTree Dec(string s) 557 { 558 if(__ctfe) 559 { 560 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits)), "Config.Dec")(TParseTree("", false,[], s)); 561 } 562 else 563 { 564 forgetMemo(); 565 return hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits)), "Config.Dec"), "Dec")(TParseTree("", false,[], s)); 566 } 567 } 568 static string Dec(GetName g) 569 { 570 return "Config.Dec"; 571 } 572 573 static TParseTree Float(TParseTree p) 574 { 575 if(__ctfe) 576 { 577 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.zeroOrMore!(digit), pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.oneOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit))), pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), "Config.Float")(p); 578 } 579 else 580 { 581 if (auto m = tuple(`Float`, p.end) in memo) 582 return *m; 583 else 584 { 585 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.zeroOrMore!(digit), pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.oneOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit))), pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), "Config.Float"), "Float")(p); 586 memo[tuple(`Float`, p.end)] = result; 587 return result; 588 } 589 } 590 } 591 592 static TParseTree Float(string s) 593 { 594 if(__ctfe) 595 { 596 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.zeroOrMore!(digit), pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.oneOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit))), pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), "Config.Float")(TParseTree("", false,[], s)); 597 } 598 else 599 { 600 forgetMemo(); 601 return hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.or!(pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.zeroOrMore!(digit), pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), pegged.peg.and!(pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), pegged.peg.oneOrMore!(digit), pegged.peg.option!(pegged.peg.and!(pegged.peg.keep!(pegged.peg.literal!(".")), pegged.peg.zeroOrMore!(digit))), pegged.peg.or!(pegged.peg.literal!("e"), pegged.peg.literal!("E")), pegged.peg.option!(pegged.peg.or!(pegged.peg.literal!("-"), pegged.peg.literal!("+"))), digits))), "Config.Float"), "Float")(TParseTree("", false,[], s)); 602 } 603 } 604 static string Float(GetName g) 605 { 606 return "Config.Float"; 607 } 608 609 static TParseTree StringQuot(TParseTree p) 610 { 611 if(__ctfe) 612 { 613 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(doublequote), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.and!(backslash, backslash), pegged.peg.and!(backslash, doublequote), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("f"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("n"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("r"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("t"))), pegged.peg.and!(pegged.peg.negLookahead!(doublequote), pegged.peg.negLookahead!(backslash), pegged.peg.any))), pegged.peg.discard!(doublequote))), "Config.StringQuot")(p); 614 } 615 else 616 { 617 if (auto m = tuple(`StringQuot`, p.end) in memo) 618 return *m; 619 else 620 { 621 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(doublequote), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.and!(backslash, backslash), pegged.peg.and!(backslash, doublequote), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("f"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("n"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("r"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("t"))), pegged.peg.and!(pegged.peg.negLookahead!(doublequote), pegged.peg.negLookahead!(backslash), pegged.peg.any))), pegged.peg.discard!(doublequote))), "Config.StringQuot"), "StringQuot")(p); 622 memo[tuple(`StringQuot`, p.end)] = result; 623 return result; 624 } 625 } 626 } 627 628 static TParseTree StringQuot(string s) 629 { 630 if(__ctfe) 631 { 632 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(doublequote), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.and!(backslash, backslash), pegged.peg.and!(backslash, doublequote), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("f"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("n"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("r"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("t"))), pegged.peg.and!(pegged.peg.negLookahead!(doublequote), pegged.peg.negLookahead!(backslash), pegged.peg.any))), pegged.peg.discard!(doublequote))), "Config.StringQuot")(TParseTree("", false,[], s)); 633 } 634 else 635 { 636 forgetMemo(); 637 return hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.and!(pegged.peg.discard!(doublequote), pegged.peg.zeroOrMore!(pegged.peg.or!(pegged.peg.and!(backslash, backslash), pegged.peg.and!(backslash, doublequote), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("f"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("n"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("r"))), pegged.peg.and!(backslash, pegged.peg.keep!(pegged.peg.literal!("t"))), pegged.peg.and!(pegged.peg.negLookahead!(doublequote), pegged.peg.negLookahead!(backslash), pegged.peg.any))), pegged.peg.discard!(doublequote))), "Config.StringQuot"), "StringQuot")(TParseTree("", false,[], s)); 638 } 639 } 640 static string StringQuot(GetName g) 641 { 642 return "Config.StringQuot"; 643 } 644 645 static TParseTree String(TParseTree p) 646 { 647 if(__ctfe) 648 { 649 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.oneOrMore!(pegged.peg.and!(StringQuot, pegged.peg.option!(spacing)))), "Config.String")(p); 650 } 651 else 652 { 653 if (auto m = tuple(`String`, p.end) in memo) 654 return *m; 655 else 656 { 657 TParseTree result = hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.oneOrMore!(pegged.peg.and!(StringQuot, pegged.peg.option!(spacing)))), "Config.String"), "String")(p); 658 memo[tuple(`String`, p.end)] = result; 659 return result; 660 } 661 } 662 } 663 664 static TParseTree String(string s) 665 { 666 if(__ctfe) 667 { 668 return pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.oneOrMore!(pegged.peg.and!(StringQuot, pegged.peg.option!(spacing)))), "Config.String")(TParseTree("", false,[], s)); 669 } 670 else 671 { 672 forgetMemo(); 673 return hooked!(pegged.peg.defined!(pegged.peg.fuse!(pegged.peg.oneOrMore!(pegged.peg.and!(StringQuot, pegged.peg.option!(spacing)))), "Config.String"), "String")(TParseTree("", false,[], s)); 674 } 675 } 676 static string String(GetName g) 677 { 678 return "Config.String"; 679 } 680 681 static TParseTree opCall(TParseTree p) 682 { 683 TParseTree result = decimateTree(Document(p)); 684 result.children = [result]; 685 result.name = "Config"; 686 return result; 687 } 688 689 static TParseTree opCall(string input) 690 { 691 if(__ctfe) 692 { 693 return Config(TParseTree(``, false, [], input, 0, 0)); 694 } 695 else 696 { 697 forgetMemo(); 698 return Config(TParseTree(``, false, [], input, 0, 0)); 699 } 700 } 701 static string opCall(GetName g) 702 { 703 return "Config"; 704 } 705 706 707 static void forgetMemo() 708 { 709 memo = null; 710 } 711 } 712 } 713 714 alias GenericConfig!(ParseTree).Config Config; 715