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