diff --git a/grammars/c/c.peg b/grammars/c/c.peg index 47a6011..acdd58a 100644 --- a/grammars/c/c.peg +++ b/grammars/c/c.peg @@ -104,6 +104,9 @@ # A.2.4 External definitions #------------------------------------------------------------------------- +#go:build grammars +# +build grammars + package main type C Peg { diff --git a/grammars/calculator/calculator.peg b/grammars/calculator/calculator.peg index bdd57fe..bde7774 100644 --- a/grammars/calculator/calculator.peg +++ b/grammars/calculator/calculator.peg @@ -2,6 +2,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +#go:build grammars +# +build grammars + package main type Calculator Peg { diff --git a/grammars/calculator_ast/calculator.peg b/grammars/calculator_ast/calculator.peg index ac5f2aa..0393c55 100644 --- a/grammars/calculator_ast/calculator.peg +++ b/grammars/calculator_ast/calculator.peg @@ -2,6 +2,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +#go:build grammars +# +build grammars + package main type Calculator Peg { diff --git a/grammars/fexl/fexl.peg b/grammars/fexl/fexl.peg index 82167cf..0179868 100644 --- a/grammars/fexl/fexl.peg +++ b/grammars/fexl/fexl.peg @@ -1,3 +1,8 @@ +# fexl + +#go:build grammars +# +build grammars + package main type Fexl Peg { diff --git a/grammars/java/java_1_7.peg b/grammars/java/java_1_7.peg index bfe66b9..f3ee6b5 100644 --- a/grammars/java/java_1_7.peg +++ b/grammars/java/java_1_7.peg @@ -91,6 +91,9 @@ # Compilation Unit #------------------------------------------------------------------------- +#go:build grammars +# +build grammars + package main type Java Peg { diff --git a/grammars/long_test/long.peg b/grammars/long_test/long.peg index 211c2cf..7e43423 100644 --- a/grammars/long_test/long.peg +++ b/grammars/long_test/long.peg @@ -2,6 +2,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +#go:build grammars +# +build grammars + package main type Long Peg { diff --git a/peg.peg b/peg.peg index 36b0a7e..2648e65 100644 --- a/peg.peg +++ b/peg.peg @@ -19,7 +19,7 @@ type Peg Peg { } # Hierarchical syntax -Grammar <- Spacing 'package' MustSpacing Identifier { p.AddPackage(text) } +Grammar <- Header 'package' MustSpacing Identifier { p.AddPackage(text) } Import* 'type' MustSpacing Identifier { p.AddPeg(text) } 'Peg' Spacing Action { p.AddState(text) } @@ -118,6 +118,9 @@ Spacing <- SpaceComment* MustSpacing <- SpaceComment+ Comment <- ('#' / '//') (!EndOfLine .)* EndOfLine Space <- ' ' / '\t' / EndOfLine +Header <- HeaderSpaceComment* +HeaderSpaceComment <- (HeaderComment / { p.AddSpace(text) } ) +HeaderComment <- ('#' / '//') <(!EndOfLine .)*> { p.AddComment(text) } EndOfLine EndOfLine <- '\r\n' / '\n' / '\r' EndOfFile <- !. Action <- '{' < ActionBody* > '}' Spacing diff --git a/peg.peg.go b/peg.peg.go index a26aa3b..fe58771 100644 --- a/peg.peg.go +++ b/peg.peg.go @@ -1,5 +1,15 @@ // Code generated by peg -inline -switch peg.peg. DO NOT EDIT. +// PE Grammar for PE Grammars +// +// Adapted from [1] by Ian Piumarta . +// +// Best viewed using 140 columns monospaced with tabs every 8. +// +// [1] Bryan Ford. "Parsing Expression Grammars: A Recognition-Based Syntactic +// Foundation." Symposium on Principles of Programming Languages, +// January 14--16, 2004, Venice, Italy. + package main import ( @@ -57,6 +67,9 @@ const ( ruleMustSpacing ruleComment ruleSpace + ruleHeader + ruleHeaderSpaceComment + ruleHeaderComment ruleEndOfLine ruleEndOfFile ruleAction @@ -113,6 +126,8 @@ const ( ruleAction46 ruleAction47 ruleAction48 + ruleAction49 + ruleAction50 ) var rul3s = [...]string{ @@ -155,6 +170,9 @@ var rul3s = [...]string{ "MustSpacing", "Comment", "Space", + "Header", + "HeaderSpaceComment", + "HeaderComment", "EndOfLine", "EndOfFile", "Action", @@ -211,6 +229,8 @@ var rul3s = [...]string{ "Action46", "Action47", "Action48", + "Action49", + "Action50", } type token32 struct { @@ -327,7 +347,7 @@ type Peg struct { Buffer string buffer []rune - rules [95]func() bool + rules [100]func() bool parse func(rule ...int) error reset func() Pretty bool @@ -533,6 +553,10 @@ func (p *Peg) Execute() { p.AddOctalCharacter(text) case ruleAction48: p.AddCharacter("\\") + case ruleAction49: + p.AddSpace(text) + case ruleAction50: + p.AddComment(text) } } @@ -673,7 +697,7 @@ func (p *Peg) Init(options ...func(*Peg) error) error { _rules = [...]func() bool{ nil, - /* 0 Grammar <- <(Spacing ('p' 'a' 'c' 'k' 'a' 'g' 'e') MustSpacing Identifier Action0 Import* ('t' 'y' 'p' 'e') MustSpacing Identifier Action1 ('P' 'e' 'g') Spacing Action Action2 Definition+ EndOfFile)> */ + /* 0 Grammar <- <(Header ('p' 'a' 'c' 'k' 'a' 'g' 'e') MustSpacing Identifier Action0 Import* ('t' 'y' 'p' 'e') MustSpacing Identifier Action1 ('P' 'e' 'g') Spacing Action Action2 Definition+ EndOfFile)> */ func() bool { if memoized, ok := memoization[memoKey{0, position}]; ok { return memoizedResult(memoized) @@ -681,8 +705,99 @@ func (p *Peg) Init(options ...func(*Peg) error) error { position0, tokenIndex0 := position, tokenIndex { position1 := position - if !_rules[ruleSpacing]() { - goto l0 + { + position2 := position + l3: + { + position4, tokenIndex4 := position, tokenIndex + { + position5 := position + { + position6, tokenIndex6 := position, tokenIndex + { + position8 := position + { + position9, tokenIndex9 := position, tokenIndex + if buffer[position] != rune('#') { + goto l10 + } + position++ + goto l9 + l10: + position, tokenIndex = position9, tokenIndex9 + if buffer[position] != rune('/') { + goto l7 + } + position++ + if buffer[position] != rune('/') { + goto l7 + } + position++ + } + l9: + { + position11 := position + l12: + { + position13, tokenIndex13 := position, tokenIndex + { + position14, tokenIndex14 := position, tokenIndex + if !_rules[ruleEndOfLine]() { + goto l14 + } + goto l13 + l14: + position, tokenIndex = position14, tokenIndex14 + } + if !matchDot() { + goto l13 + } + goto l12 + l13: + position, tokenIndex = position13, tokenIndex13 + } + add(rulePegText, position11) + } + { + add(ruleAction50, position) + } + if !_rules[ruleEndOfLine]() { + goto l7 + } + add(ruleHeaderComment, position8) + } + goto l6 + l7: + position, tokenIndex = position6, tokenIndex6 + { + position16 := position + if !_rules[ruleSpace]() { + goto l4 + } + l17: + { + position18, tokenIndex18 := position, tokenIndex + if !_rules[ruleSpace]() { + goto l18 + } + goto l17 + l18: + position, tokenIndex = position18, tokenIndex18 + } + add(rulePegText, position16) + } + { + add(ruleAction49, position) + } + } + l6: + add(ruleHeaderSpaceComment, position5) + } + goto l3 + l4: + position, tokenIndex = position4, tokenIndex4 + } + add(ruleHeader, position2) } if buffer[position] != rune('p') { goto l0 @@ -721,95 +836,95 @@ func (p *Peg) Init(options ...func(*Peg) error) error { { add(ruleAction0, position) } - l3: + l21: { - position4, tokenIndex4 := position, tokenIndex + position22, tokenIndex22 := position, tokenIndex { - position5 := position + position23 := position if buffer[position] != rune('i') { - goto l4 + goto l22 } position++ if buffer[position] != rune('m') { - goto l4 + goto l22 } position++ if buffer[position] != rune('p') { - goto l4 + goto l22 } position++ if buffer[position] != rune('o') { - goto l4 + goto l22 } position++ if buffer[position] != rune('r') { - goto l4 + goto l22 } position++ if buffer[position] != rune('t') { - goto l4 + goto l22 } position++ if !_rules[ruleSpacing]() { - goto l4 + goto l22 } { - position6, tokenIndex6 := position, tokenIndex + position24, tokenIndex24 := position, tokenIndex { - position8 := position + position26 := position if buffer[position] != rune('(') { - goto l7 + goto l25 } position++ if !_rules[ruleSpacing]() { - goto l7 + goto l25 } - l9: + l27: { - position10, tokenIndex10 := position, tokenIndex + position28, tokenIndex28 := position, tokenIndex if !_rules[ruleImportName]() { - goto l10 + goto l28 } if buffer[position] != rune('\n') { - goto l10 + goto l28 } position++ if !_rules[ruleSpacing]() { - goto l10 + goto l28 } - goto l9 - l10: - position, tokenIndex = position10, tokenIndex10 + goto l27 + l28: + position, tokenIndex = position28, tokenIndex28 } if !_rules[ruleSpacing]() { - goto l7 + goto l25 } if buffer[position] != rune(')') { - goto l7 + goto l25 } position++ - add(ruleMultiImport, position8) + add(ruleMultiImport, position26) } - goto l6 - l7: - position, tokenIndex = position6, tokenIndex6 + goto l24 + l25: + position, tokenIndex = position24, tokenIndex24 { - position11 := position + position29 := position if !_rules[ruleImportName]() { - goto l4 + goto l22 } - add(ruleSingleImport, position11) + add(ruleSingleImport, position29) } } - l6: + l24: if !_rules[ruleSpacing]() { - goto l4 + goto l22 } - add(ruleImport, position5) + add(ruleImport, position23) } - goto l3 - l4: - position, tokenIndex = position4, tokenIndex4 + goto l21 + l22: + position, tokenIndex = position22, tokenIndex22 } if buffer[position] != rune('t') { goto l0 @@ -858,7 +973,7 @@ func (p *Peg) Init(options ...func(*Peg) error) error { add(ruleAction2, position) } { - position16 := position + position34 := position if !_rules[ruleIdentifier]() { goto l0 } @@ -875,97 +990,97 @@ func (p *Peg) Init(options ...func(*Peg) error) error { add(ruleAction5, position) } { - position19, tokenIndex19 := position, tokenIndex + position37, tokenIndex37 := position, tokenIndex { - position20, tokenIndex20 := position, tokenIndex + position38, tokenIndex38 := position, tokenIndex if !_rules[ruleIdentifier]() { - goto l21 + goto l39 } if !_rules[ruleLeftArrow]() { - goto l21 + goto l39 } - goto l20 - l21: - position, tokenIndex = position20, tokenIndex20 + goto l38 + l39: + position, tokenIndex = position38, tokenIndex38 { - position22, tokenIndex22 := position, tokenIndex + position40, tokenIndex40 := position, tokenIndex if !matchDot() { - goto l22 + goto l40 } goto l0 - l22: - position, tokenIndex = position22, tokenIndex22 + l40: + position, tokenIndex = position40, tokenIndex40 } } - l20: - position, tokenIndex = position19, tokenIndex19 + l38: + position, tokenIndex = position37, tokenIndex37 } - add(ruleDefinition, position16) + add(ruleDefinition, position34) } - l14: + l32: { - position15, tokenIndex15 := position, tokenIndex + position33, tokenIndex33 := position, tokenIndex { - position23 := position + position41 := position if !_rules[ruleIdentifier]() { - goto l15 + goto l33 } { add(ruleAction4, position) } if !_rules[ruleLeftArrow]() { - goto l15 + goto l33 } if !_rules[ruleExpression]() { - goto l15 + goto l33 } { add(ruleAction5, position) } { - position26, tokenIndex26 := position, tokenIndex + position44, tokenIndex44 := position, tokenIndex { - position27, tokenIndex27 := position, tokenIndex + position45, tokenIndex45 := position, tokenIndex if !_rules[ruleIdentifier]() { - goto l28 + goto l46 } if !_rules[ruleLeftArrow]() { - goto l28 + goto l46 } - goto l27 - l28: - position, tokenIndex = position27, tokenIndex27 + goto l45 + l46: + position, tokenIndex = position45, tokenIndex45 { - position29, tokenIndex29 := position, tokenIndex + position47, tokenIndex47 := position, tokenIndex if !matchDot() { - goto l29 + goto l47 } - goto l15 - l29: - position, tokenIndex = position29, tokenIndex29 + goto l33 + l47: + position, tokenIndex = position47, tokenIndex47 } } - l27: - position, tokenIndex = position26, tokenIndex26 + l45: + position, tokenIndex = position44, tokenIndex44 } - add(ruleDefinition, position23) + add(ruleDefinition, position41) } - goto l14 - l15: - position, tokenIndex = position15, tokenIndex15 + goto l32 + l33: + position, tokenIndex = position33, tokenIndex33 } { - position30 := position + position48 := position { - position31, tokenIndex31 := position, tokenIndex + position49, tokenIndex49 := position, tokenIndex if !matchDot() { - goto l31 + goto l49 } goto l0 - l31: - position, tokenIndex = position31, tokenIndex31 + l49: + position, tokenIndex = position49, tokenIndex49 } - add(ruleEndOfFile, position30) + add(ruleEndOfFile, position48) } add(ruleGrammar, position1) } @@ -987,15 +1102,15 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{4, position}]; ok { return memoizedResult(memoized) } - position35, tokenIndex35 := position, tokenIndex + position53, tokenIndex53 := position, tokenIndex { - position36 := position + position54 := position if buffer[position] != rune('"') { - goto l35 + goto l53 } position++ { - position37 := position + position55 := position { switch buffer[position] { case '-': @@ -1012,15 +1127,15 @@ func (p *Peg) Init(options ...func(*Peg) error) error { position++ default: if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l35 + goto l53 } position++ } } - l38: + l56: { - position39, tokenIndex39 := position, tokenIndex + position57, tokenIndex57 := position, tokenIndex { switch buffer[position] { case '-': @@ -1037,32 +1152,32 @@ func (p *Peg) Init(options ...func(*Peg) error) error { position++ default: if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l39 + goto l57 } position++ } } - goto l38 - l39: - position, tokenIndex = position39, tokenIndex39 + goto l56 + l57: + position, tokenIndex = position57, tokenIndex57 } - add(rulePegText, position37) + add(rulePegText, position55) } if buffer[position] != rune('"') { - goto l35 + goto l53 } position++ { add(ruleAction3, position) } - add(ruleImportName, position36) + add(ruleImportName, position54) } - memoize(4, position35, tokenIndex35, true) + memoize(4, position53, tokenIndex53, true) return true - l35: - memoize(4, position35, tokenIndex35, false) - position, tokenIndex = position35, tokenIndex35 + l53: + memoize(4, position53, tokenIndex53, false) + position, tokenIndex = position53, tokenIndex53 return false }, /* 5 Definition <- <(Identifier Action4 LeftArrow Expression Action5 &((Identifier LeftArrow) / !.))> */ @@ -1072,54 +1187,54 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{6, position}]; ok { return memoizedResult(memoized) } - position44, tokenIndex44 := position, tokenIndex + position62, tokenIndex62 := position, tokenIndex { - position45 := position + position63 := position { - position46, tokenIndex46 := position, tokenIndex + position64, tokenIndex64 := position, tokenIndex if !_rules[ruleSequence]() { - goto l47 + goto l65 } - l48: + l66: { - position49, tokenIndex49 := position, tokenIndex + position67, tokenIndex67 := position, tokenIndex if !_rules[ruleSlash]() { - goto l49 + goto l67 } if !_rules[ruleSequence]() { - goto l49 + goto l67 } { add(ruleAction6, position) } - goto l48 - l49: - position, tokenIndex = position49, tokenIndex49 + goto l66 + l67: + position, tokenIndex = position67, tokenIndex67 } { - position51, tokenIndex51 := position, tokenIndex + position69, tokenIndex69 := position, tokenIndex if !_rules[ruleSlash]() { - goto l51 + goto l69 } { add(ruleAction7, position) } - goto l52 - l51: - position, tokenIndex = position51, tokenIndex51 + goto l70 + l69: + position, tokenIndex = position69, tokenIndex69 } - l52: - goto l46 - l47: - position, tokenIndex = position46, tokenIndex46 + l70: + goto l64 + l65: + position, tokenIndex = position64, tokenIndex64 { add(ruleAction8, position) } } - l46: - add(ruleExpression, position45) + l64: + add(ruleExpression, position63) } - memoize(6, position44, tokenIndex44, true) + memoize(6, position62, tokenIndex62, true) return true }, /* 7 Sequence <- <(Prefix (Prefix Action9)*)> */ @@ -1127,32 +1242,32 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{7, position}]; ok { return memoizedResult(memoized) } - position55, tokenIndex55 := position, tokenIndex + position73, tokenIndex73 := position, tokenIndex { - position56 := position + position74 := position if !_rules[rulePrefix]() { - goto l55 + goto l73 } - l57: + l75: { - position58, tokenIndex58 := position, tokenIndex + position76, tokenIndex76 := position, tokenIndex if !_rules[rulePrefix]() { - goto l58 + goto l76 } { add(ruleAction9, position) } - goto l57 - l58: - position, tokenIndex = position58, tokenIndex58 + goto l75 + l76: + position, tokenIndex = position76, tokenIndex76 } - add(ruleSequence, position56) + add(ruleSequence, position74) } - memoize(7, position55, tokenIndex55, true) + memoize(7, position73, tokenIndex73, true) return true - l55: - memoize(7, position55, tokenIndex55, false) - position, tokenIndex = position55, tokenIndex55 + l73: + memoize(7, position73, tokenIndex73, false) + position, tokenIndex = position73, tokenIndex73 return false }, /* 8 Prefix <- <((And Action Action10) / (Not Action Action11) / ((&('!') (Not Suffix Action13)) | (&('&') (And Suffix Action12)) | (&('"' | '\'' | '(' | '.' | '<' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '[' | '_' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | '{') Suffix)))> */ @@ -1160,73 +1275,73 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{8, position}]; ok { return memoizedResult(memoized) } - position60, tokenIndex60 := position, tokenIndex + position78, tokenIndex78 := position, tokenIndex { - position61 := position + position79 := position { - position62, tokenIndex62 := position, tokenIndex + position80, tokenIndex80 := position, tokenIndex if !_rules[ruleAnd]() { - goto l63 + goto l81 } if !_rules[ruleAction]() { - goto l63 + goto l81 } { add(ruleAction10, position) } - goto l62 - l63: - position, tokenIndex = position62, tokenIndex62 + goto l80 + l81: + position, tokenIndex = position80, tokenIndex80 if !_rules[ruleNot]() { - goto l65 + goto l83 } if !_rules[ruleAction]() { - goto l65 + goto l83 } { add(ruleAction11, position) } - goto l62 - l65: - position, tokenIndex = position62, tokenIndex62 + goto l80 + l83: + position, tokenIndex = position80, tokenIndex80 { switch buffer[position] { case '!': if !_rules[ruleNot]() { - goto l60 + goto l78 } if !_rules[ruleSuffix]() { - goto l60 + goto l78 } { add(ruleAction13, position) } case '&': if !_rules[ruleAnd]() { - goto l60 + goto l78 } if !_rules[ruleSuffix]() { - goto l60 + goto l78 } { add(ruleAction12, position) } default: if !_rules[ruleSuffix]() { - goto l60 + goto l78 } } } } - l62: - add(rulePrefix, position61) + l80: + add(rulePrefix, position79) } - memoize(8, position60, tokenIndex60, true) + memoize(8, position78, tokenIndex78, true) return true - l60: - memoize(8, position60, tokenIndex60, false) - position, tokenIndex = position60, tokenIndex60 + l78: + memoize(8, position78, tokenIndex78, false) + position, tokenIndex = position78, tokenIndex78 return false }, /* 9 Suffix <- <(Primary ((&('+') (Plus Action16)) | (&('*') (Star Action15)) | (&('?') (Question Action14)))?)> */ @@ -1234,303 +1349,303 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{9, position}]; ok { return memoizedResult(memoized) } - position70, tokenIndex70 := position, tokenIndex + position88, tokenIndex88 := position, tokenIndex { - position71 := position + position89 := position { - position72 := position + position90 := position { switch buffer[position] { case '<': { - position74 := position + position92 := position position++ if !_rules[ruleSpacing]() { - goto l70 + goto l88 } - add(ruleBegin, position74) + add(ruleBegin, position92) } if !_rules[ruleExpression]() { - goto l70 + goto l88 } { - position75 := position + position93 := position if buffer[position] != rune('>') { - goto l70 + goto l88 } position++ if !_rules[ruleSpacing]() { - goto l70 + goto l88 } - add(ruleEnd, position75) + add(ruleEnd, position93) } { add(ruleAction20, position) } case '{': if !_rules[ruleAction]() { - goto l70 + goto l88 } { add(ruleAction19, position) } case '.': { - position78 := position + position96 := position position++ if !_rules[ruleSpacing]() { - goto l70 + goto l88 } - add(ruleDot, position78) + add(ruleDot, position96) } { add(ruleAction18, position) } case '[': { - position80 := position + position98 := position { - position81, tokenIndex81 := position, tokenIndex + position99, tokenIndex99 := position, tokenIndex position++ if buffer[position] != rune('[') { - goto l82 + goto l100 } position++ { - position83, tokenIndex83 := position, tokenIndex + position101, tokenIndex101 := position, tokenIndex { - position85, tokenIndex85 := position, tokenIndex + position103, tokenIndex103 := position, tokenIndex if buffer[position] != rune('^') { - goto l86 + goto l104 } position++ if !_rules[ruleDoubleRanges]() { - goto l86 + goto l104 } { add(ruleAction23, position) } - goto l85 - l86: - position, tokenIndex = position85, tokenIndex85 + goto l103 + l104: + position, tokenIndex = position103, tokenIndex103 if !_rules[ruleDoubleRanges]() { - goto l83 + goto l101 } } - l85: - goto l84 - l83: - position, tokenIndex = position83, tokenIndex83 + l103: + goto l102 + l101: + position, tokenIndex = position101, tokenIndex101 } - l84: + l102: if buffer[position] != rune(']') { - goto l82 + goto l100 } position++ if buffer[position] != rune(']') { - goto l82 + goto l100 } position++ - goto l81 - l82: - position, tokenIndex = position81, tokenIndex81 + goto l99 + l100: + position, tokenIndex = position99, tokenIndex99 if buffer[position] != rune('[') { - goto l70 + goto l88 } position++ { - position88, tokenIndex88 := position, tokenIndex + position106, tokenIndex106 := position, tokenIndex { - position90, tokenIndex90 := position, tokenIndex + position108, tokenIndex108 := position, tokenIndex if buffer[position] != rune('^') { - goto l91 + goto l109 } position++ if !_rules[ruleRanges]() { - goto l91 + goto l109 } { add(ruleAction24, position) } - goto l90 - l91: - position, tokenIndex = position90, tokenIndex90 + goto l108 + l109: + position, tokenIndex = position108, tokenIndex108 if !_rules[ruleRanges]() { - goto l88 + goto l106 } } - l90: - goto l89 - l88: - position, tokenIndex = position88, tokenIndex88 + l108: + goto l107 + l106: + position, tokenIndex = position106, tokenIndex106 } - l89: + l107: if buffer[position] != rune(']') { - goto l70 + goto l88 } position++ } - l81: + l99: if !_rules[ruleSpacing]() { - goto l70 + goto l88 } - add(ruleClass, position80) + add(ruleClass, position98) } case '"', '\'': { - position93 := position + position111 := position { - position94, tokenIndex94 := position, tokenIndex + position112, tokenIndex112 := position, tokenIndex if buffer[position] != rune('\'') { - goto l95 + goto l113 } position++ { - position96, tokenIndex96 := position, tokenIndex + position114, tokenIndex114 := position, tokenIndex { - position98, tokenIndex98 := position, tokenIndex + position116, tokenIndex116 := position, tokenIndex if buffer[position] != rune('\'') { - goto l98 + goto l116 } position++ - goto l96 - l98: - position, tokenIndex = position98, tokenIndex98 + goto l114 + l116: + position, tokenIndex = position116, tokenIndex116 } if !_rules[ruleChar]() { - goto l96 + goto l114 } - goto l97 - l96: - position, tokenIndex = position96, tokenIndex96 + goto l115 + l114: + position, tokenIndex = position114, tokenIndex114 } - l97: - l99: + l115: + l117: { - position100, tokenIndex100 := position, tokenIndex + position118, tokenIndex118 := position, tokenIndex { - position101, tokenIndex101 := position, tokenIndex + position119, tokenIndex119 := position, tokenIndex if buffer[position] != rune('\'') { - goto l101 + goto l119 } position++ - goto l100 - l101: - position, tokenIndex = position101, tokenIndex101 + goto l118 + l119: + position, tokenIndex = position119, tokenIndex119 } if !_rules[ruleChar]() { - goto l100 + goto l118 } { add(ruleAction21, position) } - goto l99 - l100: - position, tokenIndex = position100, tokenIndex100 + goto l117 + l118: + position, tokenIndex = position118, tokenIndex118 } if buffer[position] != rune('\'') { - goto l95 + goto l113 } position++ if !_rules[ruleSpacing]() { - goto l95 + goto l113 } - goto l94 - l95: - position, tokenIndex = position94, tokenIndex94 + goto l112 + l113: + position, tokenIndex = position112, tokenIndex112 if buffer[position] != rune('"') { - goto l70 + goto l88 } position++ { - position103, tokenIndex103 := position, tokenIndex + position121, tokenIndex121 := position, tokenIndex { - position105, tokenIndex105 := position, tokenIndex + position123, tokenIndex123 := position, tokenIndex if buffer[position] != rune('"') { - goto l105 + goto l123 } position++ - goto l103 - l105: - position, tokenIndex = position105, tokenIndex105 + goto l121 + l123: + position, tokenIndex = position123, tokenIndex123 } if !_rules[ruleDoubleChar]() { - goto l103 + goto l121 } - goto l104 - l103: - position, tokenIndex = position103, tokenIndex103 + goto l122 + l121: + position, tokenIndex = position121, tokenIndex121 } - l104: - l106: + l122: + l124: { - position107, tokenIndex107 := position, tokenIndex + position125, tokenIndex125 := position, tokenIndex { - position108, tokenIndex108 := position, tokenIndex + position126, tokenIndex126 := position, tokenIndex if buffer[position] != rune('"') { - goto l108 + goto l126 } position++ - goto l107 - l108: - position, tokenIndex = position108, tokenIndex108 + goto l125 + l126: + position, tokenIndex = position126, tokenIndex126 } if !_rules[ruleDoubleChar]() { - goto l107 + goto l125 } { add(ruleAction22, position) } - goto l106 - l107: - position, tokenIndex = position107, tokenIndex107 + goto l124 + l125: + position, tokenIndex = position125, tokenIndex125 } if buffer[position] != rune('"') { - goto l70 + goto l88 } position++ if !_rules[ruleSpacing]() { - goto l70 + goto l88 } } - l94: - add(ruleLiteral, position93) + l112: + add(ruleLiteral, position111) } case '(': { - position110 := position + position128 := position position++ if !_rules[ruleSpacing]() { - goto l70 + goto l88 } - add(ruleOpen, position110) + add(ruleOpen, position128) } if !_rules[ruleExpression]() { - goto l70 + goto l88 } { - position111 := position + position129 := position if buffer[position] != rune(')') { - goto l70 + goto l88 } position++ if !_rules[ruleSpacing]() { - goto l70 + goto l88 } - add(ruleClose, position111) + add(ruleClose, position129) } default: if !_rules[ruleIdentifier]() { - goto l70 + goto l88 } { - position112, tokenIndex112 := position, tokenIndex + position130, tokenIndex130 := position, tokenIndex if !_rules[ruleLeftArrow]() { - goto l112 + goto l130 } - goto l70 - l112: - position, tokenIndex = position112, tokenIndex112 + goto l88 + l130: + position, tokenIndex = position130, tokenIndex130 } { add(ruleAction17, position) @@ -1538,47 +1653,47 @@ func (p *Peg) Init(options ...func(*Peg) error) error { } } - add(rulePrimary, position72) + add(rulePrimary, position90) } { - position114, tokenIndex114 := position, tokenIndex + position132, tokenIndex132 := position, tokenIndex { switch buffer[position] { case '+': { - position117 := position + position135 := position position++ if !_rules[ruleSpacing]() { - goto l114 + goto l132 } - add(rulePlus, position117) + add(rulePlus, position135) } { add(ruleAction16, position) } case '*': { - position119 := position + position137 := position position++ if !_rules[ruleSpacing]() { - goto l114 + goto l132 } - add(ruleStar, position119) + add(ruleStar, position137) } { add(ruleAction15, position) } default: { - position121 := position + position139 := position if buffer[position] != rune('?') { - goto l114 + goto l132 } position++ if !_rules[ruleSpacing]() { - goto l114 + goto l132 } - add(ruleQuestion, position121) + add(ruleQuestion, position139) } { add(ruleAction14, position) @@ -1586,18 +1701,18 @@ func (p *Peg) Init(options ...func(*Peg) error) error { } } - goto l115 - l114: - position, tokenIndex = position114, tokenIndex114 + goto l133 + l132: + position, tokenIndex = position132, tokenIndex132 } - l115: - add(ruleSuffix, position71) + l133: + add(ruleSuffix, position89) } - memoize(9, position70, tokenIndex70, true) + memoize(9, position88, tokenIndex88, true) return true - l70: - memoize(9, position70, tokenIndex70, false) - position, tokenIndex = position70, tokenIndex70 + l88: + memoize(9, position88, tokenIndex88, false) + position, tokenIndex = position88, tokenIndex88 return false }, /* 10 Primary <- <((&('<') (Begin Expression End Action20)) | (&('{') (Action Action19)) | (&('.') (Dot Action18)) | (&('[') Class) | (&('"' | '\'') Literal) | (&('(') (Open Expression Close)) | (&('A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '_' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z') (Identifier !LeftArrow Action17)))> */ @@ -1607,51 +1722,51 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{11, position}]; ok { return memoizedResult(memoized) } - position124, tokenIndex124 := position, tokenIndex + position142, tokenIndex142 := position, tokenIndex { - position125 := position + position143 := position { - position126 := position + position144 := position if !_rules[ruleIdentStart]() { - goto l124 + goto l142 } - l127: + l145: { - position128, tokenIndex128 := position, tokenIndex + position146, tokenIndex146 := position, tokenIndex { - position129 := position + position147 := position { - position130, tokenIndex130 := position, tokenIndex + position148, tokenIndex148 := position, tokenIndex if !_rules[ruleIdentStart]() { - goto l131 + goto l149 } - goto l130 - l131: - position, tokenIndex = position130, tokenIndex130 + goto l148 + l149: + position, tokenIndex = position148, tokenIndex148 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l128 + goto l146 } position++ } - l130: - add(ruleIdentCont, position129) + l148: + add(ruleIdentCont, position147) } - goto l127 - l128: - position, tokenIndex = position128, tokenIndex128 + goto l145 + l146: + position, tokenIndex = position146, tokenIndex146 } - add(rulePegText, position126) + add(rulePegText, position144) } if !_rules[ruleSpacing]() { - goto l124 + goto l142 } - add(ruleIdentifier, position125) + add(ruleIdentifier, position143) } - memoize(11, position124, tokenIndex124, true) + memoize(11, position142, tokenIndex142, true) return true - l124: - memoize(11, position124, tokenIndex124, false) - position, tokenIndex = position124, tokenIndex124 + l142: + memoize(11, position142, tokenIndex142, false) + position, tokenIndex = position142, tokenIndex142 return false }, /* 12 IdentStart <- <((&('_') '_') | (&('A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z') [A-Z]) | (&('a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z') [a-z]))> */ @@ -1659,9 +1774,9 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{12, position}]; ok { return memoizedResult(memoized) } - position132, tokenIndex132 := position, tokenIndex + position150, tokenIndex150 := position, tokenIndex { - position133 := position + position151 := position { switch buffer[position] { case '_': @@ -1670,19 +1785,19 @@ func (p *Peg) Init(options ...func(*Peg) error) error { position++ default: if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l132 + goto l150 } position++ } } - add(ruleIdentStart, position133) + add(ruleIdentStart, position151) } - memoize(12, position132, tokenIndex132, true) + memoize(12, position150, tokenIndex150, true) return true - l132: - memoize(12, position132, tokenIndex132, false) - position, tokenIndex = position132, tokenIndex132 + l150: + memoize(12, position150, tokenIndex150, false) + position, tokenIndex = position150, tokenIndex150 return false }, /* 13 IdentCont <- <(IdentStart / [0-9])> */ @@ -1696,52 +1811,52 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{16, position}]; ok { return memoizedResult(memoized) } - position138, tokenIndex138 := position, tokenIndex + position156, tokenIndex156 := position, tokenIndex { - position139 := position + position157 := position { - position140, tokenIndex140 := position, tokenIndex + position158, tokenIndex158 := position, tokenIndex if buffer[position] != rune(']') { - goto l140 + goto l158 } position++ - goto l138 - l140: - position, tokenIndex = position140, tokenIndex140 + goto l156 + l158: + position, tokenIndex = position158, tokenIndex158 } if !_rules[ruleRange]() { - goto l138 + goto l156 } - l141: + l159: { - position142, tokenIndex142 := position, tokenIndex + position160, tokenIndex160 := position, tokenIndex { - position143, tokenIndex143 := position, tokenIndex + position161, tokenIndex161 := position, tokenIndex if buffer[position] != rune(']') { - goto l143 + goto l161 } position++ - goto l142 - l143: - position, tokenIndex = position143, tokenIndex143 + goto l160 + l161: + position, tokenIndex = position161, tokenIndex161 } if !_rules[ruleRange]() { - goto l142 + goto l160 } { add(ruleAction25, position) } - goto l141 - l142: - position, tokenIndex = position142, tokenIndex142 + goto l159 + l160: + position, tokenIndex = position160, tokenIndex160 } - add(ruleRanges, position139) + add(ruleRanges, position157) } - memoize(16, position138, tokenIndex138, true) + memoize(16, position156, tokenIndex156, true) return true - l138: - memoize(16, position138, tokenIndex138, false) - position, tokenIndex = position138, tokenIndex138 + l156: + memoize(16, position156, tokenIndex156, false) + position, tokenIndex = position156, tokenIndex156 return false }, /* 17 DoubleRanges <- <(!(']' ']') DoubleRange (!(']' ']') DoubleRange Action26)*)> */ @@ -1749,60 +1864,60 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{17, position}]; ok { return memoizedResult(memoized) } - position145, tokenIndex145 := position, tokenIndex + position163, tokenIndex163 := position, tokenIndex { - position146 := position + position164 := position { - position147, tokenIndex147 := position, tokenIndex + position165, tokenIndex165 := position, tokenIndex if buffer[position] != rune(']') { - goto l147 + goto l165 } position++ if buffer[position] != rune(']') { - goto l147 + goto l165 } position++ - goto l145 - l147: - position, tokenIndex = position147, tokenIndex147 + goto l163 + l165: + position, tokenIndex = position165, tokenIndex165 } if !_rules[ruleDoubleRange]() { - goto l145 + goto l163 } - l148: + l166: { - position149, tokenIndex149 := position, tokenIndex + position167, tokenIndex167 := position, tokenIndex { - position150, tokenIndex150 := position, tokenIndex + position168, tokenIndex168 := position, tokenIndex if buffer[position] != rune(']') { - goto l150 + goto l168 } position++ if buffer[position] != rune(']') { - goto l150 + goto l168 } position++ - goto l149 - l150: - position, tokenIndex = position150, tokenIndex150 + goto l167 + l168: + position, tokenIndex = position168, tokenIndex168 } if !_rules[ruleDoubleRange]() { - goto l149 + goto l167 } { add(ruleAction26, position) } - goto l148 - l149: - position, tokenIndex = position149, tokenIndex149 + goto l166 + l167: + position, tokenIndex = position167, tokenIndex167 } - add(ruleDoubleRanges, position146) + add(ruleDoubleRanges, position164) } - memoize(17, position145, tokenIndex145, true) + memoize(17, position163, tokenIndex163, true) return true - l145: - memoize(17, position145, tokenIndex145, false) - position, tokenIndex = position145, tokenIndex145 + l163: + memoize(17, position163, tokenIndex163, false) + position, tokenIndex = position163, tokenIndex163 return false }, /* 18 Range <- <((Char '-' Char Action27) / Char)> */ @@ -1810,39 +1925,39 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{18, position}]; ok { return memoizedResult(memoized) } - position152, tokenIndex152 := position, tokenIndex + position170, tokenIndex170 := position, tokenIndex { - position153 := position + position171 := position { - position154, tokenIndex154 := position, tokenIndex + position172, tokenIndex172 := position, tokenIndex if !_rules[ruleChar]() { - goto l155 + goto l173 } if buffer[position] != rune('-') { - goto l155 + goto l173 } position++ if !_rules[ruleChar]() { - goto l155 + goto l173 } { add(ruleAction27, position) } - goto l154 - l155: - position, tokenIndex = position154, tokenIndex154 + goto l172 + l173: + position, tokenIndex = position172, tokenIndex172 if !_rules[ruleChar]() { - goto l152 + goto l170 } } - l154: - add(ruleRange, position153) + l172: + add(ruleRange, position171) } - memoize(18, position152, tokenIndex152, true) + memoize(18, position170, tokenIndex170, true) return true - l152: - memoize(18, position152, tokenIndex152, false) - position, tokenIndex = position152, tokenIndex152 + l170: + memoize(18, position170, tokenIndex170, false) + position, tokenIndex = position170, tokenIndex170 return false }, /* 19 DoubleRange <- <((Char '-' Char Action28) / DoubleChar)> */ @@ -1850,39 +1965,39 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{19, position}]; ok { return memoizedResult(memoized) } - position157, tokenIndex157 := position, tokenIndex + position175, tokenIndex175 := position, tokenIndex { - position158 := position + position176 := position { - position159, tokenIndex159 := position, tokenIndex + position177, tokenIndex177 := position, tokenIndex if !_rules[ruleChar]() { - goto l160 + goto l178 } if buffer[position] != rune('-') { - goto l160 + goto l178 } position++ if !_rules[ruleChar]() { - goto l160 + goto l178 } { add(ruleAction28, position) } - goto l159 - l160: - position, tokenIndex = position159, tokenIndex159 + goto l177 + l178: + position, tokenIndex = position177, tokenIndex177 if !_rules[ruleDoubleChar]() { - goto l157 + goto l175 } } - l159: - add(ruleDoubleRange, position158) + l177: + add(ruleDoubleRange, position176) } - memoize(19, position157, tokenIndex157, true) + memoize(19, position175, tokenIndex175, true) return true - l157: - memoize(19, position157, tokenIndex157, false) - position, tokenIndex = position157, tokenIndex157 + l175: + memoize(19, position175, tokenIndex175, false) + position, tokenIndex = position175, tokenIndex175 return false }, /* 20 Char <- <(Escape / (!'\\' <.> Action29))> */ @@ -1890,46 +2005,46 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{20, position}]; ok { return memoizedResult(memoized) } - position162, tokenIndex162 := position, tokenIndex + position180, tokenIndex180 := position, tokenIndex { - position163 := position + position181 := position { - position164, tokenIndex164 := position, tokenIndex + position182, tokenIndex182 := position, tokenIndex if !_rules[ruleEscape]() { - goto l165 + goto l183 } - goto l164 - l165: - position, tokenIndex = position164, tokenIndex164 + goto l182 + l183: + position, tokenIndex = position182, tokenIndex182 { - position166, tokenIndex166 := position, tokenIndex + position184, tokenIndex184 := position, tokenIndex if buffer[position] != rune('\\') { - goto l166 + goto l184 } position++ - goto l162 - l166: - position, tokenIndex = position166, tokenIndex166 + goto l180 + l184: + position, tokenIndex = position184, tokenIndex184 } { - position167 := position + position185 := position if !matchDot() { - goto l162 + goto l180 } - add(rulePegText, position167) + add(rulePegText, position185) } { add(ruleAction29, position) } } - l164: - add(ruleChar, position163) + l182: + add(ruleChar, position181) } - memoize(20, position162, tokenIndex162, true) + memoize(20, position180, tokenIndex180, true) return true - l162: - memoize(20, position162, tokenIndex162, false) - position, tokenIndex = position162, tokenIndex162 + l180: + memoize(20, position180, tokenIndex180, false) + position, tokenIndex = position180, tokenIndex180 return false }, /* 21 DoubleChar <- <(Escape / (<([a-z] / [A-Z])> Action30) / (!'\\' <.> Action31))> */ @@ -1937,71 +2052,71 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{21, position}]; ok { return memoizedResult(memoized) } - position169, tokenIndex169 := position, tokenIndex + position187, tokenIndex187 := position, tokenIndex { - position170 := position + position188 := position { - position171, tokenIndex171 := position, tokenIndex + position189, tokenIndex189 := position, tokenIndex if !_rules[ruleEscape]() { - goto l172 + goto l190 } - goto l171 - l172: - position, tokenIndex = position171, tokenIndex171 + goto l189 + l190: + position, tokenIndex = position189, tokenIndex189 { - position174 := position + position192 := position { - position175, tokenIndex175 := position, tokenIndex + position193, tokenIndex193 := position, tokenIndex if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l176 + goto l194 } position++ - goto l175 - l176: - position, tokenIndex = position175, tokenIndex175 + goto l193 + l194: + position, tokenIndex = position193, tokenIndex193 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l173 + goto l191 } position++ } - l175: - add(rulePegText, position174) + l193: + add(rulePegText, position192) } { add(ruleAction30, position) } - goto l171 - l173: - position, tokenIndex = position171, tokenIndex171 + goto l189 + l191: + position, tokenIndex = position189, tokenIndex189 { - position178, tokenIndex178 := position, tokenIndex + position196, tokenIndex196 := position, tokenIndex if buffer[position] != rune('\\') { - goto l178 + goto l196 } position++ - goto l169 - l178: - position, tokenIndex = position178, tokenIndex178 + goto l187 + l196: + position, tokenIndex = position196, tokenIndex196 } { - position179 := position + position197 := position if !matchDot() { - goto l169 + goto l187 } - add(rulePegText, position179) + add(rulePegText, position197) } { add(ruleAction31, position) } } - l171: - add(ruleDoubleChar, position170) + l189: + add(ruleDoubleChar, position188) } - memoize(21, position169, tokenIndex169, true) + memoize(21, position187, tokenIndex187, true) return true - l169: - memoize(21, position169, tokenIndex169, false) - position, tokenIndex = position169, tokenIndex169 + l187: + memoize(21, position187, tokenIndex187, false) + position, tokenIndex = position187, tokenIndex187 return false }, /* 22 Escape <- <(('\\' ('a' / 'A') Action32) / ('\\' ('b' / 'B') Action33) / ('\\' ('e' / 'E') Action34) / ('\\' ('f' / 'F') Action35) / ('\\' ('n' / 'N') Action36) / ('\\' ('r' / 'R') Action37) / ('\\' ('t' / 'T') Action38) / ('\\' ('v' / 'V') Action39) / ('\\' '\'' Action40) / ('\\' '"' Action41) / ('\\' '[' Action42) / ('\\' ']' Action43) / ('\\' '-' Action44) / ('\\' ('0' ('x' / 'X')) <((&('A' | 'B' | 'C' | 'D' | 'E' | 'F') [A-F]) | (&('a' | 'b' | 'c' | 'd' | 'e' | 'f') [a-f]) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') [0-9]))+> Action45) / ('\\' <([0-3] [0-7] [0-7])> Action46) / ('\\' <([0-7] [0-7]?)> Action47) / ('\\' '\\' Action48))> */ @@ -2009,306 +2124,306 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{22, position}]; ok { return memoizedResult(memoized) } - position181, tokenIndex181 := position, tokenIndex + position199, tokenIndex199 := position, tokenIndex { - position182 := position + position200 := position { - position183, tokenIndex183 := position, tokenIndex + position201, tokenIndex201 := position, tokenIndex if buffer[position] != rune('\\') { - goto l184 + goto l202 } position++ { - position185, tokenIndex185 := position, tokenIndex + position203, tokenIndex203 := position, tokenIndex if buffer[position] != rune('a') { - goto l186 + goto l204 } position++ - goto l185 - l186: - position, tokenIndex = position185, tokenIndex185 + goto l203 + l204: + position, tokenIndex = position203, tokenIndex203 if buffer[position] != rune('A') { - goto l184 + goto l202 } position++ } - l185: + l203: { add(ruleAction32, position) } - goto l183 - l184: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l202: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l188 + goto l206 } position++ { - position189, tokenIndex189 := position, tokenIndex + position207, tokenIndex207 := position, tokenIndex if buffer[position] != rune('b') { - goto l190 + goto l208 } position++ - goto l189 - l190: - position, tokenIndex = position189, tokenIndex189 + goto l207 + l208: + position, tokenIndex = position207, tokenIndex207 if buffer[position] != rune('B') { - goto l188 + goto l206 } position++ } - l189: + l207: { add(ruleAction33, position) } - goto l183 - l188: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l206: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l192 + goto l210 } position++ { - position193, tokenIndex193 := position, tokenIndex + position211, tokenIndex211 := position, tokenIndex if buffer[position] != rune('e') { - goto l194 + goto l212 } position++ - goto l193 - l194: - position, tokenIndex = position193, tokenIndex193 + goto l211 + l212: + position, tokenIndex = position211, tokenIndex211 if buffer[position] != rune('E') { - goto l192 + goto l210 } position++ } - l193: + l211: { add(ruleAction34, position) } - goto l183 - l192: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l210: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l196 + goto l214 } position++ { - position197, tokenIndex197 := position, tokenIndex + position215, tokenIndex215 := position, tokenIndex if buffer[position] != rune('f') { - goto l198 + goto l216 } position++ - goto l197 - l198: - position, tokenIndex = position197, tokenIndex197 + goto l215 + l216: + position, tokenIndex = position215, tokenIndex215 if buffer[position] != rune('F') { - goto l196 + goto l214 } position++ } - l197: + l215: { add(ruleAction35, position) } - goto l183 - l196: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l214: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l200 + goto l218 } position++ { - position201, tokenIndex201 := position, tokenIndex + position219, tokenIndex219 := position, tokenIndex if buffer[position] != rune('n') { - goto l202 + goto l220 } position++ - goto l201 - l202: - position, tokenIndex = position201, tokenIndex201 + goto l219 + l220: + position, tokenIndex = position219, tokenIndex219 if buffer[position] != rune('N') { - goto l200 + goto l218 } position++ } - l201: + l219: { add(ruleAction36, position) } - goto l183 - l200: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l218: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l204 + goto l222 } position++ { - position205, tokenIndex205 := position, tokenIndex + position223, tokenIndex223 := position, tokenIndex if buffer[position] != rune('r') { - goto l206 + goto l224 } position++ - goto l205 - l206: - position, tokenIndex = position205, tokenIndex205 + goto l223 + l224: + position, tokenIndex = position223, tokenIndex223 if buffer[position] != rune('R') { - goto l204 + goto l222 } position++ } - l205: + l223: { add(ruleAction37, position) } - goto l183 - l204: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l222: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l208 + goto l226 } position++ { - position209, tokenIndex209 := position, tokenIndex + position227, tokenIndex227 := position, tokenIndex if buffer[position] != rune('t') { - goto l210 + goto l228 } position++ - goto l209 - l210: - position, tokenIndex = position209, tokenIndex209 + goto l227 + l228: + position, tokenIndex = position227, tokenIndex227 if buffer[position] != rune('T') { - goto l208 + goto l226 } position++ } - l209: + l227: { add(ruleAction38, position) } - goto l183 - l208: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l226: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l212 + goto l230 } position++ { - position213, tokenIndex213 := position, tokenIndex + position231, tokenIndex231 := position, tokenIndex if buffer[position] != rune('v') { - goto l214 + goto l232 } position++ - goto l213 - l214: - position, tokenIndex = position213, tokenIndex213 + goto l231 + l232: + position, tokenIndex = position231, tokenIndex231 if buffer[position] != rune('V') { - goto l212 + goto l230 } position++ } - l213: + l231: { add(ruleAction39, position) } - goto l183 - l212: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l230: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l216 + goto l234 } position++ if buffer[position] != rune('\'') { - goto l216 + goto l234 } position++ { add(ruleAction40, position) } - goto l183 - l216: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l234: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l218 + goto l236 } position++ if buffer[position] != rune('"') { - goto l218 + goto l236 } position++ { add(ruleAction41, position) } - goto l183 - l218: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l236: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l220 + goto l238 } position++ if buffer[position] != rune('[') { - goto l220 + goto l238 } position++ { add(ruleAction42, position) } - goto l183 - l220: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l238: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l222 + goto l240 } position++ if buffer[position] != rune(']') { - goto l222 + goto l240 } position++ { add(ruleAction43, position) } - goto l183 - l222: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l240: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l224 + goto l242 } position++ if buffer[position] != rune('-') { - goto l224 + goto l242 } position++ { add(ruleAction44, position) } - goto l183 - l224: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l242: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l226 + goto l244 } position++ if buffer[position] != rune('0') { - goto l226 + goto l244 } position++ { - position227, tokenIndex227 := position, tokenIndex + position245, tokenIndex245 := position, tokenIndex if buffer[position] != rune('x') { - goto l228 + goto l246 } position++ - goto l227 - l228: - position, tokenIndex = position227, tokenIndex227 + goto l245 + l246: + position, tokenIndex = position245, tokenIndex245 if buffer[position] != rune('X') { - goto l226 + goto l244 } position++ } - l227: + l245: { - position229 := position + position247 := position { switch buffer[position] { case 'A', 'B', 'C', 'D', 'E', 'F': @@ -2317,15 +2432,15 @@ func (p *Peg) Init(options ...func(*Peg) error) error { position++ default: if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l226 + goto l244 } position++ } } - l230: + l248: { - position231, tokenIndex231 := position, tokenIndex + position249, tokenIndex249 := position, tokenIndex { switch buffer[position] { case 'A', 'B', 'C', 'D', 'E', 'F': @@ -2334,99 +2449,99 @@ func (p *Peg) Init(options ...func(*Peg) error) error { position++ default: if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l231 + goto l249 } position++ } } - goto l230 - l231: - position, tokenIndex = position231, tokenIndex231 + goto l248 + l249: + position, tokenIndex = position249, tokenIndex249 } - add(rulePegText, position229) + add(rulePegText, position247) } { add(ruleAction45, position) } - goto l183 - l226: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l244: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l235 + goto l253 } position++ { - position236 := position + position254 := position if c := buffer[position]; c < rune('0') || c > rune('3') { - goto l235 + goto l253 } position++ if c := buffer[position]; c < rune('0') || c > rune('7') { - goto l235 + goto l253 } position++ if c := buffer[position]; c < rune('0') || c > rune('7') { - goto l235 + goto l253 } position++ - add(rulePegText, position236) + add(rulePegText, position254) } { add(ruleAction46, position) } - goto l183 - l235: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l253: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l238 + goto l256 } position++ { - position239 := position + position257 := position if c := buffer[position]; c < rune('0') || c > rune('7') { - goto l238 + goto l256 } position++ { - position240, tokenIndex240 := position, tokenIndex + position258, tokenIndex258 := position, tokenIndex if c := buffer[position]; c < rune('0') || c > rune('7') { - goto l240 + goto l258 } position++ - goto l241 - l240: - position, tokenIndex = position240, tokenIndex240 + goto l259 + l258: + position, tokenIndex = position258, tokenIndex258 } - l241: - add(rulePegText, position239) + l259: + add(rulePegText, position257) } { add(ruleAction47, position) } - goto l183 - l238: - position, tokenIndex = position183, tokenIndex183 + goto l201 + l256: + position, tokenIndex = position201, tokenIndex201 if buffer[position] != rune('\\') { - goto l181 + goto l199 } position++ if buffer[position] != rune('\\') { - goto l181 + goto l199 } position++ { add(ruleAction48, position) } } - l183: - add(ruleEscape, position182) + l201: + add(ruleEscape, position200) } - memoize(22, position181, tokenIndex181, true) + memoize(22, position199, tokenIndex199, true) return true - l181: - memoize(22, position181, tokenIndex181, false) - position, tokenIndex = position181, tokenIndex181 + l199: + memoize(22, position199, tokenIndex199, false) + position, tokenIndex = position199, tokenIndex199 return false }, /* 23 LeftArrow <- <((('<' '-') / '←') Spacing)> */ @@ -2434,38 +2549,38 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{23, position}]; ok { return memoizedResult(memoized) } - position244, tokenIndex244 := position, tokenIndex + position262, tokenIndex262 := position, tokenIndex { - position245 := position + position263 := position { - position246, tokenIndex246 := position, tokenIndex + position264, tokenIndex264 := position, tokenIndex if buffer[position] != rune('<') { - goto l247 + goto l265 } position++ if buffer[position] != rune('-') { - goto l247 + goto l265 } position++ - goto l246 - l247: - position, tokenIndex = position246, tokenIndex246 + goto l264 + l265: + position, tokenIndex = position264, tokenIndex264 if buffer[position] != rune('←') { - goto l244 + goto l262 } position++ } - l246: + l264: if !_rules[ruleSpacing]() { - goto l244 + goto l262 } - add(ruleLeftArrow, position245) + add(ruleLeftArrow, position263) } - memoize(23, position244, tokenIndex244, true) + memoize(23, position262, tokenIndex262, true) return true - l244: - memoize(23, position244, tokenIndex244, false) - position, tokenIndex = position244, tokenIndex244 + l262: + memoize(23, position262, tokenIndex262, false) + position, tokenIndex = position262, tokenIndex262 return false }, /* 24 Slash <- <('/' Spacing)> */ @@ -2473,23 +2588,23 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{24, position}]; ok { return memoizedResult(memoized) } - position248, tokenIndex248 := position, tokenIndex + position266, tokenIndex266 := position, tokenIndex { - position249 := position + position267 := position if buffer[position] != rune('/') { - goto l248 + goto l266 } position++ if !_rules[ruleSpacing]() { - goto l248 + goto l266 } - add(ruleSlash, position249) + add(ruleSlash, position267) } - memoize(24, position248, tokenIndex248, true) + memoize(24, position266, tokenIndex266, true) return true - l248: - memoize(24, position248, tokenIndex248, false) - position, tokenIndex = position248, tokenIndex248 + l266: + memoize(24, position266, tokenIndex266, false) + position, tokenIndex = position266, tokenIndex266 return false }, /* 25 And <- <('&' Spacing)> */ @@ -2497,23 +2612,23 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{25, position}]; ok { return memoizedResult(memoized) } - position250, tokenIndex250 := position, tokenIndex + position268, tokenIndex268 := position, tokenIndex { - position251 := position + position269 := position if buffer[position] != rune('&') { - goto l250 + goto l268 } position++ if !_rules[ruleSpacing]() { - goto l250 + goto l268 } - add(ruleAnd, position251) + add(ruleAnd, position269) } - memoize(25, position250, tokenIndex250, true) + memoize(25, position268, tokenIndex268, true) return true - l250: - memoize(25, position250, tokenIndex250, false) - position, tokenIndex = position250, tokenIndex250 + l268: + memoize(25, position268, tokenIndex268, false) + position, tokenIndex = position268, tokenIndex268 return false }, /* 26 Not <- <('!' Spacing)> */ @@ -2521,23 +2636,23 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{26, position}]; ok { return memoizedResult(memoized) } - position252, tokenIndex252 := position, tokenIndex + position270, tokenIndex270 := position, tokenIndex { - position253 := position + position271 := position if buffer[position] != rune('!') { - goto l252 + goto l270 } position++ if !_rules[ruleSpacing]() { - goto l252 + goto l270 } - add(ruleNot, position253) + add(ruleNot, position271) } - memoize(26, position252, tokenIndex252, true) + memoize(26, position270, tokenIndex270, true) return true - l252: - memoize(26, position252, tokenIndex252, false) - position, tokenIndex = position252, tokenIndex252 + l270: + memoize(26, position270, tokenIndex270, false) + position, tokenIndex = position270, tokenIndex270 return false }, /* 27 Question <- <('?' Spacing)> */ @@ -2557,85 +2672,71 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{33, position}]; ok { return memoizedResult(memoized) } - position260, tokenIndex260 := position, tokenIndex + position278, tokenIndex278 := position, tokenIndex { - position261 := position + position279 := position { - position262, tokenIndex262 := position, tokenIndex - { - position264 := position - { - switch buffer[position] { - case '\t': - position++ - case ' ': - position++ - default: - if !_rules[ruleEndOfLine]() { - goto l263 - } - } - } - - add(ruleSpace, position264) + position280, tokenIndex280 := position, tokenIndex + if !_rules[ruleSpace]() { + goto l281 } - goto l262 - l263: - position, tokenIndex = position262, tokenIndex262 + goto l280 + l281: + position, tokenIndex = position280, tokenIndex280 { - position266 := position + position282 := position { - position267, tokenIndex267 := position, tokenIndex + position283, tokenIndex283 := position, tokenIndex if buffer[position] != rune('#') { - goto l268 + goto l284 } position++ - goto l267 - l268: - position, tokenIndex = position267, tokenIndex267 + goto l283 + l284: + position, tokenIndex = position283, tokenIndex283 if buffer[position] != rune('/') { - goto l260 + goto l278 } position++ if buffer[position] != rune('/') { - goto l260 + goto l278 } position++ } - l267: - l269: + l283: + l285: { - position270, tokenIndex270 := position, tokenIndex + position286, tokenIndex286 := position, tokenIndex { - position271, tokenIndex271 := position, tokenIndex + position287, tokenIndex287 := position, tokenIndex if !_rules[ruleEndOfLine]() { - goto l271 + goto l287 } - goto l270 - l271: - position, tokenIndex = position271, tokenIndex271 + goto l286 + l287: + position, tokenIndex = position287, tokenIndex287 } if !matchDot() { - goto l270 + goto l286 } - goto l269 - l270: - position, tokenIndex = position270, tokenIndex270 + goto l285 + l286: + position, tokenIndex = position286, tokenIndex286 } if !_rules[ruleEndOfLine]() { - goto l260 + goto l278 } - add(ruleComment, position266) + add(ruleComment, position282) } } - l262: - add(ruleSpaceComment, position261) + l280: + add(ruleSpaceComment, position279) } - memoize(33, position260, tokenIndex260, true) + memoize(33, position278, tokenIndex278, true) return true - l260: - memoize(33, position260, tokenIndex260, false) - position, tokenIndex = position260, tokenIndex260 + l278: + memoize(33, position278, tokenIndex278, false) + position, tokenIndex = position278, tokenIndex278 return false }, /* 34 Spacing <- */ @@ -2643,22 +2744,22 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{34, position}]; ok { return memoizedResult(memoized) } - position272, tokenIndex272 := position, tokenIndex + position288, tokenIndex288 := position, tokenIndex { - position273 := position - l274: + position289 := position + l290: { - position275, tokenIndex275 := position, tokenIndex + position291, tokenIndex291 := position, tokenIndex if !_rules[ruleSpaceComment]() { - goto l275 + goto l291 } - goto l274 - l275: - position, tokenIndex = position275, tokenIndex275 + goto l290 + l291: + position, tokenIndex = position291, tokenIndex291 } - add(ruleSpacing, position273) + add(ruleSpacing, position289) } - memoize(34, position272, tokenIndex272, true) + memoize(34, position288, tokenIndex288, true) return true }, /* 35 MustSpacing <- */ @@ -2666,290 +2767,328 @@ func (p *Peg) Init(options ...func(*Peg) error) error { if memoized, ok := memoization[memoKey{35, position}]; ok { return memoizedResult(memoized) } - position276, tokenIndex276 := position, tokenIndex + position292, tokenIndex292 := position, tokenIndex { - position277 := position + position293 := position if !_rules[ruleSpaceComment]() { - goto l276 + goto l292 } - l278: + l294: { - position279, tokenIndex279 := position, tokenIndex + position295, tokenIndex295 := position, tokenIndex if !_rules[ruleSpaceComment]() { - goto l279 + goto l295 } - goto l278 - l279: - position, tokenIndex = position279, tokenIndex279 + goto l294 + l295: + position, tokenIndex = position295, tokenIndex295 } - add(ruleMustSpacing, position277) + add(ruleMustSpacing, position293) } - memoize(35, position276, tokenIndex276, true) + memoize(35, position292, tokenIndex292, true) return true - l276: - memoize(35, position276, tokenIndex276, false) - position, tokenIndex = position276, tokenIndex276 + l292: + memoize(35, position292, tokenIndex292, false) + position, tokenIndex = position292, tokenIndex292 return false }, /* 36 Comment <- <(('#' / ('/' '/')) (!EndOfLine .)* EndOfLine)> */ nil, /* 37 Space <- <((&('\t') '\t') | (&(' ') ' ') | (&('\n' | '\r') EndOfLine))> */ + func() bool { + if memoized, ok := memoization[memoKey{37, position}]; ok { + return memoizedResult(memoized) + } + position297, tokenIndex297 := position, tokenIndex + { + position298 := position + { + switch buffer[position] { + case '\t': + position++ + case ' ': + position++ + default: + if !_rules[ruleEndOfLine]() { + goto l297 + } + } + } + + add(ruleSpace, position298) + } + memoize(37, position297, tokenIndex297, true) + return true + l297: + memoize(37, position297, tokenIndex297, false) + position, tokenIndex = position297, tokenIndex297 + return false + }, + /* 38 Header <- */ nil, - /* 38 EndOfLine <- <(('\r' '\n') / '\n' / '\r')> */ + /* 39 HeaderSpaceComment <- <(HeaderComment / ( Action49))> */ + nil, + /* 40 HeaderComment <- <(('#' / ('/' '/')) <(!EndOfLine .)*> Action50 EndOfLine)> */ + nil, + /* 41 EndOfLine <- <(('\r' '\n') / '\n' / '\r')> */ func() bool { - if memoized, ok := memoization[memoKey{38, position}]; ok { + if memoized, ok := memoization[memoKey{41, position}]; ok { return memoizedResult(memoized) } - position282, tokenIndex282 := position, tokenIndex + position303, tokenIndex303 := position, tokenIndex { - position283 := position + position304 := position { - position284, tokenIndex284 := position, tokenIndex + position305, tokenIndex305 := position, tokenIndex if buffer[position] != rune('\r') { - goto l285 + goto l306 } position++ if buffer[position] != rune('\n') { - goto l285 + goto l306 } position++ - goto l284 - l285: - position, tokenIndex = position284, tokenIndex284 + goto l305 + l306: + position, tokenIndex = position305, tokenIndex305 if buffer[position] != rune('\n') { - goto l286 + goto l307 } position++ - goto l284 - l286: - position, tokenIndex = position284, tokenIndex284 + goto l305 + l307: + position, tokenIndex = position305, tokenIndex305 if buffer[position] != rune('\r') { - goto l282 + goto l303 } position++ } - l284: - add(ruleEndOfLine, position283) + l305: + add(ruleEndOfLine, position304) } - memoize(38, position282, tokenIndex282, true) + memoize(41, position303, tokenIndex303, true) return true - l282: - memoize(38, position282, tokenIndex282, false) - position, tokenIndex = position282, tokenIndex282 + l303: + memoize(41, position303, tokenIndex303, false) + position, tokenIndex = position303, tokenIndex303 return false }, - /* 39 EndOfFile <- */ + /* 42 EndOfFile <- */ nil, - /* 40 Action <- <('{' '}' Spacing)> */ + /* 43 Action <- <('{' '}' Spacing)> */ func() bool { - if memoized, ok := memoization[memoKey{40, position}]; ok { + if memoized, ok := memoization[memoKey{43, position}]; ok { return memoizedResult(memoized) } - position288, tokenIndex288 := position, tokenIndex + position309, tokenIndex309 := position, tokenIndex { - position289 := position + position310 := position if buffer[position] != rune('{') { - goto l288 + goto l309 } position++ { - position290 := position - l291: + position311 := position + l312: { - position292, tokenIndex292 := position, tokenIndex + position313, tokenIndex313 := position, tokenIndex if !_rules[ruleActionBody]() { - goto l292 + goto l313 } - goto l291 - l292: - position, tokenIndex = position292, tokenIndex292 + goto l312 + l313: + position, tokenIndex = position313, tokenIndex313 } - add(rulePegText, position290) + add(rulePegText, position311) } if buffer[position] != rune('}') { - goto l288 + goto l309 } position++ if !_rules[ruleSpacing]() { - goto l288 + goto l309 } - add(ruleAction, position289) + add(ruleAction, position310) } - memoize(40, position288, tokenIndex288, true) + memoize(43, position309, tokenIndex309, true) return true - l288: - memoize(40, position288, tokenIndex288, false) - position, tokenIndex = position288, tokenIndex288 + l309: + memoize(43, position309, tokenIndex309, false) + position, tokenIndex = position309, tokenIndex309 return false }, - /* 41 ActionBody <- <((!('{' / '}') .) / ('{' ActionBody* '}'))> */ + /* 44 ActionBody <- <((!('{' / '}') .) / ('{' ActionBody* '}'))> */ func() bool { - if memoized, ok := memoization[memoKey{41, position}]; ok { + if memoized, ok := memoization[memoKey{44, position}]; ok { return memoizedResult(memoized) } - position293, tokenIndex293 := position, tokenIndex + position314, tokenIndex314 := position, tokenIndex { - position294 := position + position315 := position { - position295, tokenIndex295 := position, tokenIndex + position316, tokenIndex316 := position, tokenIndex { - position297, tokenIndex297 := position, tokenIndex + position318, tokenIndex318 := position, tokenIndex { - position298, tokenIndex298 := position, tokenIndex + position319, tokenIndex319 := position, tokenIndex if buffer[position] != rune('{') { - goto l299 + goto l320 } position++ - goto l298 - l299: - position, tokenIndex = position298, tokenIndex298 + goto l319 + l320: + position, tokenIndex = position319, tokenIndex319 if buffer[position] != rune('}') { - goto l297 + goto l318 } position++ } - l298: - goto l296 - l297: - position, tokenIndex = position297, tokenIndex297 + l319: + goto l317 + l318: + position, tokenIndex = position318, tokenIndex318 } if !matchDot() { - goto l296 + goto l317 } - goto l295 - l296: - position, tokenIndex = position295, tokenIndex295 + goto l316 + l317: + position, tokenIndex = position316, tokenIndex316 if buffer[position] != rune('{') { - goto l293 + goto l314 } position++ - l300: + l321: { - position301, tokenIndex301 := position, tokenIndex + position322, tokenIndex322 := position, tokenIndex if !_rules[ruleActionBody]() { - goto l301 + goto l322 } - goto l300 - l301: - position, tokenIndex = position301, tokenIndex301 + goto l321 + l322: + position, tokenIndex = position322, tokenIndex322 } if buffer[position] != rune('}') { - goto l293 + goto l314 } position++ } - l295: - add(ruleActionBody, position294) + l316: + add(ruleActionBody, position315) } - memoize(41, position293, tokenIndex293, true) + memoize(44, position314, tokenIndex314, true) return true - l293: - memoize(41, position293, tokenIndex293, false) - position, tokenIndex = position293, tokenIndex293 + l314: + memoize(44, position314, tokenIndex314, false) + position, tokenIndex = position314, tokenIndex314 return false }, - /* 42 Begin <- <('<' Spacing)> */ + /* 45 Begin <- <('<' Spacing)> */ + nil, + /* 46 End <- <('>' Spacing)> */ + nil, + /* 48 Action0 <- <{ p.AddPackage(text) }> */ nil, - /* 43 End <- <('>' Spacing)> */ + /* 49 Action1 <- <{ p.AddPeg(text) }> */ nil, - /* 45 Action0 <- <{ p.AddPackage(text) }> */ + /* 50 Action2 <- <{ p.AddState(text) }> */ nil, - /* 46 Action1 <- <{ p.AddPeg(text) }> */ nil, - /* 47 Action2 <- <{ p.AddState(text) }> */ + /* 52 Action3 <- <{ p.AddImport(text) }> */ nil, + /* 53 Action4 <- <{ p.AddRule(text) }> */ nil, - /* 49 Action3 <- <{ p.AddImport(text) }> */ + /* 54 Action5 <- <{ p.AddExpression() }> */ nil, - /* 50 Action4 <- <{ p.AddRule(text) }> */ + /* 55 Action6 <- <{ p.AddAlternate() }> */ nil, - /* 51 Action5 <- <{ p.AddExpression() }> */ + /* 56 Action7 <- <{ p.AddNil(); p.AddAlternate() }> */ nil, - /* 52 Action6 <- <{ p.AddAlternate() }> */ + /* 57 Action8 <- <{ p.AddNil() }> */ nil, - /* 53 Action7 <- <{ p.AddNil(); p.AddAlternate() }> */ + /* 58 Action9 <- <{ p.AddSequence() }> */ nil, - /* 54 Action8 <- <{ p.AddNil() }> */ + /* 59 Action10 <- <{ p.AddPredicate(text) }> */ nil, - /* 55 Action9 <- <{ p.AddSequence() }> */ + /* 60 Action11 <- <{ p.AddStateChange(text) }> */ nil, - /* 56 Action10 <- <{ p.AddPredicate(text) }> */ + /* 61 Action12 <- <{ p.AddPeekFor() }> */ nil, - /* 57 Action11 <- <{ p.AddStateChange(text) }> */ + /* 62 Action13 <- <{ p.AddPeekNot() }> */ nil, - /* 58 Action12 <- <{ p.AddPeekFor() }> */ + /* 63 Action14 <- <{ p.AddQuery() }> */ nil, - /* 59 Action13 <- <{ p.AddPeekNot() }> */ + /* 64 Action15 <- <{ p.AddStar() }> */ nil, - /* 60 Action14 <- <{ p.AddQuery() }> */ + /* 65 Action16 <- <{ p.AddPlus() }> */ nil, - /* 61 Action15 <- <{ p.AddStar() }> */ + /* 66 Action17 <- <{ p.AddName(text) }> */ nil, - /* 62 Action16 <- <{ p.AddPlus() }> */ + /* 67 Action18 <- <{ p.AddDot() }> */ nil, - /* 63 Action17 <- <{ p.AddName(text) }> */ + /* 68 Action19 <- <{ p.AddAction(text) }> */ nil, - /* 64 Action18 <- <{ p.AddDot() }> */ + /* 69 Action20 <- <{ p.AddPush() }> */ nil, - /* 65 Action19 <- <{ p.AddAction(text) }> */ + /* 70 Action21 <- <{ p.AddSequence() }> */ nil, - /* 66 Action20 <- <{ p.AddPush() }> */ + /* 71 Action22 <- <{ p.AddSequence() }> */ nil, - /* 67 Action21 <- <{ p.AddSequence() }> */ + /* 72 Action23 <- <{ p.AddPeekNot(); p.AddDot(); p.AddSequence() }> */ nil, - /* 68 Action22 <- <{ p.AddSequence() }> */ + /* 73 Action24 <- <{ p.AddPeekNot(); p.AddDot(); p.AddSequence() }> */ nil, - /* 69 Action23 <- <{ p.AddPeekNot(); p.AddDot(); p.AddSequence() }> */ + /* 74 Action25 <- <{ p.AddAlternate() }> */ nil, - /* 70 Action24 <- <{ p.AddPeekNot(); p.AddDot(); p.AddSequence() }> */ + /* 75 Action26 <- <{ p.AddAlternate() }> */ nil, - /* 71 Action25 <- <{ p.AddAlternate() }> */ + /* 76 Action27 <- <{ p.AddRange() }> */ nil, - /* 72 Action26 <- <{ p.AddAlternate() }> */ + /* 77 Action28 <- <{ p.AddDoubleRange() }> */ nil, - /* 73 Action27 <- <{ p.AddRange() }> */ + /* 78 Action29 <- <{ p.AddCharacter(text) }> */ nil, - /* 74 Action28 <- <{ p.AddDoubleRange() }> */ + /* 79 Action30 <- <{ p.AddDoubleCharacter(text) }> */ nil, - /* 75 Action29 <- <{ p.AddCharacter(text) }> */ + /* 80 Action31 <- <{ p.AddCharacter(text) }> */ nil, - /* 76 Action30 <- <{ p.AddDoubleCharacter(text) }> */ + /* 81 Action32 <- <{ p.AddCharacter("\a") }> */ nil, - /* 77 Action31 <- <{ p.AddCharacter(text) }> */ + /* 82 Action33 <- <{ p.AddCharacter("\b") }> */ nil, - /* 78 Action32 <- <{ p.AddCharacter("\a") }> */ + /* 83 Action34 <- <{ p.AddCharacter("\x1B") }> */ nil, - /* 79 Action33 <- <{ p.AddCharacter("\b") }> */ + /* 84 Action35 <- <{ p.AddCharacter("\f") }> */ nil, - /* 80 Action34 <- <{ p.AddCharacter("\x1B") }> */ + /* 85 Action36 <- <{ p.AddCharacter("\n") }> */ nil, - /* 81 Action35 <- <{ p.AddCharacter("\f") }> */ + /* 86 Action37 <- <{ p.AddCharacter("\r") }> */ nil, - /* 82 Action36 <- <{ p.AddCharacter("\n") }> */ + /* 87 Action38 <- <{ p.AddCharacter("\t") }> */ nil, - /* 83 Action37 <- <{ p.AddCharacter("\r") }> */ + /* 88 Action39 <- <{ p.AddCharacter("\v") }> */ nil, - /* 84 Action38 <- <{ p.AddCharacter("\t") }> */ + /* 89 Action40 <- <{ p.AddCharacter("'") }> */ nil, - /* 85 Action39 <- <{ p.AddCharacter("\v") }> */ + /* 90 Action41 <- <{ p.AddCharacter("\"") }> */ nil, - /* 86 Action40 <- <{ p.AddCharacter("'") }> */ + /* 91 Action42 <- <{ p.AddCharacter("[") }> */ nil, - /* 87 Action41 <- <{ p.AddCharacter("\"") }> */ + /* 92 Action43 <- <{ p.AddCharacter("]") }> */ nil, - /* 88 Action42 <- <{ p.AddCharacter("[") }> */ + /* 93 Action44 <- <{ p.AddCharacter("-") }> */ nil, - /* 89 Action43 <- <{ p.AddCharacter("]") }> */ + /* 94 Action45 <- <{ p.AddHexaCharacter(text) }> */ nil, - /* 90 Action44 <- <{ p.AddCharacter("-") }> */ + /* 95 Action46 <- <{ p.AddOctalCharacter(text) }> */ nil, - /* 91 Action45 <- <{ p.AddHexaCharacter(text) }> */ + /* 96 Action47 <- <{ p.AddOctalCharacter(text) }> */ nil, - /* 92 Action46 <- <{ p.AddOctalCharacter(text) }> */ + /* 97 Action48 <- <{ p.AddCharacter("\\") }> */ nil, - /* 93 Action47 <- <{ p.AddOctalCharacter(text) }> */ + /* 98 Action49 <- <{ p.AddSpace(text) }> */ nil, - /* 94 Action48 <- <{ p.AddCharacter("\\") }> */ + /* 99 Action50 <- <{ p.AddComment(text) }> */ nil, } p.rules = _rules diff --git a/tree/peg.go b/tree/peg.go index 0eaf2a3..4ab9fed 100644 --- a/tree/peg.go +++ b/tree/peg.go @@ -25,6 +25,8 @@ import ( const pegHeaderTemplate = `// Code generated by {{.Generator}}. DO NOT EDIT. +{{.Comments}} + package {{.PackageName}} import ( @@ -463,6 +465,8 @@ const ( TypeStateChange TypeCommit TypeAction + TypeSpace + TypeComment TypePackage TypeImport TypeState @@ -493,6 +497,8 @@ var TypeMap = [...]string{ "TypeStateChange", "TypeCommit", "TypeAction", + "TypeSpace", + "TypeComment", "TypePackage", "TypeImport", "TypeState", @@ -683,6 +689,7 @@ type Tree struct { Generator string RuleNames []Node + Comments string PackageName string Imports []string EndSymbol rune @@ -752,6 +759,8 @@ func (t *Tree) AddStateChange(text string) { t.PushFront(&node{Type: TypeStateCh func (t *Tree) AddNil() { t.PushFront(&node{Type: TypeNil, string: ""}) } func (t *Tree) AddAction(text string) { t.PushFront(&node{Type: TypeAction, string: text}) } func (t *Tree) AddPackage(text string) { t.PushBack(&node{Type: TypePackage, string: text}) } +func (t *Tree) AddSpace(text string) { t.PushBack(&node{Type: TypeSpace, string: text}) } +func (t *Tree) AddComment(text string) { t.PushBack(&node{Type: TypeComment, string: text}) } func (t *Tree) AddImport(text string) { t.PushBack(&node{Type: TypeImport, string: text}) } func (t *Tree) AddState(text string) { peg := t.PopFront() @@ -1361,6 +1370,7 @@ func (t *Tree) Compile(file string, args []string, out io.Writer) (err error) { _print("<") printRule(n.Front()) _print(">") + case TypeComment: case TypeNil: default: warn(fmt.Errorf("illegal node type: %v", n.GetType())) @@ -1593,6 +1603,7 @@ func (t *Tree) Compile(file string, args []string, out io.Writer) (err error) { printLabel(out) printRestore(out) printEnd() + case TypeComment: case TypeNil: default: warn(fmt.Errorf("illegal node type: %v", n.GetType())) @@ -1603,6 +1614,11 @@ func (t *Tree) Compile(file string, args []string, out io.Writer) (err error) { /* lets figure out which jump labels are going to be used with this dry compile */ printTemp, _print := _print, func(_ string, _ ...any) {} for _, element := range t.Slice() { + if element.GetType() == TypeComment { + t.Comments += "//" + element.String() + "\n" + } else if element.GetType() == TypeSpace { + t.Comments += element.String() + } if element.GetType() != TypeRule { continue } @@ -1620,7 +1636,6 @@ func (t *Tree) Compile(file string, args []string, out io.Writer) (err error) { compile(expression, ko) } _print, label = printTemp, 0 - dryCompile = false /* now for the real compile pass */