Properly parse negative numbers

This commit is contained in:
Elara 2023-10-30 15:10:55 -07:00
parent a8d536c058
commit 41adf9ce51
2 changed files with 220 additions and 192 deletions

View File

@ -129,18 +129,18 @@ var g = &grammar{
}, },
}, },
&actionExpr{ &actionExpr{
pos: position{line: 239, col: 8, offset: 5380}, pos: position{line: 239, col: 8, offset: 5390},
run: (*parser).callonRoot16, run: (*parser).callonRoot16,
expr: &seqExpr{ expr: &seqExpr{
pos: position{line: 239, col: 8, offset: 5380}, pos: position{line: 239, col: 8, offset: 5390},
exprs: []any{ exprs: []any{
&anyMatcher{ &anyMatcher{
line: 239, col: 8, offset: 5380, line: 239, col: 8, offset: 5390,
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 239, col: 10, offset: 5382}, pos: position{line: 239, col: 10, offset: 5392},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 239, col: 10, offset: 5382}, pos: position{line: 239, col: 10, offset: 5392},
val: "[^#]", val: "[^#]",
chars: []rune{'#'}, chars: []rune{'#'},
ignoreCase: false, ignoreCase: false,
@ -285,7 +285,7 @@ var g = &grammar{
}, },
}, },
}, },
leader: false, leader: true,
leftRecursive: true, leftRecursive: true,
}, },
{ {
@ -298,9 +298,9 @@ var g = &grammar{
pos: position{line: 86, col: 15, offset: 1715}, pos: position{line: 86, col: 15, offset: 1715},
exprs: []any{ exprs: []any{
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -324,9 +324,9 @@ var g = &grammar{
pos: position{line: 86, col: 44, offset: 1744}, pos: position{line: 86, col: 44, offset: 1744},
exprs: []any{ exprs: []any{
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -334,19 +334,19 @@ var g = &grammar{
}, },
}, },
&actionExpr{ &actionExpr{
pos: position{line: 218, col: 13, offset: 4946}, pos: position{line: 218, col: 13, offset: 4956},
run: (*parser).callonLogicalExpr12, run: (*parser).callonLogicalExpr12,
expr: &choiceExpr{ expr: &choiceExpr{
pos: position{line: 218, col: 14, offset: 4947}, pos: position{line: 218, col: 14, offset: 4957},
alternatives: []any{ alternatives: []any{
&litMatcher{ &litMatcher{
pos: position{line: 218, col: 14, offset: 4947}, pos: position{line: 218, col: 14, offset: 4957},
val: "||", val: "||",
ignoreCase: false, ignoreCase: false,
want: "\"||\"", want: "\"||\"",
}, },
&litMatcher{ &litMatcher{
pos: position{line: 218, col: 21, offset: 4954}, pos: position{line: 218, col: 21, offset: 4964},
val: "&&", val: "&&",
ignoreCase: false, ignoreCase: false,
want: "\"&&\"", want: "\"&&\"",
@ -355,9 +355,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -373,9 +373,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -398,9 +398,9 @@ var g = &grammar{
pos: position{line: 90, col: 18, offset: 1838}, pos: position{line: 90, col: 18, offset: 1838},
exprs: []any{ exprs: []any{
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -424,9 +424,9 @@ var g = &grammar{
pos: position{line: 90, col: 47, offset: 1867}, pos: position{line: 90, col: 47, offset: 1867},
exprs: []any{ exprs: []any{
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -434,38 +434,38 @@ var g = &grammar{
}, },
}, },
&actionExpr{ &actionExpr{
pos: position{line: 225, col: 16, offset: 5079}, pos: position{line: 225, col: 16, offset: 5089},
run: (*parser).callonComparisonExpr12, run: (*parser).callonComparisonExpr12,
expr: &choiceExpr{ expr: &choiceExpr{
pos: position{line: 225, col: 17, offset: 5080}, pos: position{line: 225, col: 17, offset: 5090},
alternatives: []any{ alternatives: []any{
&litMatcher{ &litMatcher{
pos: position{line: 225, col: 17, offset: 5080}, pos: position{line: 225, col: 17, offset: 5090},
val: "==", val: "==",
ignoreCase: false, ignoreCase: false,
want: "\"==\"", want: "\"==\"",
}, },
&litMatcher{ &litMatcher{
pos: position{line: 225, col: 24, offset: 5087}, pos: position{line: 225, col: 24, offset: 5097},
val: "<=", val: "<=",
ignoreCase: false, ignoreCase: false,
want: "\"<=\"", want: "\"<=\"",
}, },
&litMatcher{ &litMatcher{
pos: position{line: 225, col: 31, offset: 5094}, pos: position{line: 225, col: 31, offset: 5104},
val: ">=", val: ">=",
ignoreCase: false, ignoreCase: false,
want: "\">=\"", want: "\">=\"",
}, },
&charClassMatcher{ &charClassMatcher{
pos: position{line: 225, col: 38, offset: 5101}, pos: position{line: 225, col: 38, offset: 5111},
val: "[<>]", val: "[<>]",
chars: []rune{'<', '>'}, chars: []rune{'<', '>'},
ignoreCase: false, ignoreCase: false,
inverted: false, inverted: false,
}, },
&litMatcher{ &litMatcher{
pos: position{line: 225, col: 50, offset: 5113}, pos: position{line: 225, col: 50, offset: 5123},
val: "in", val: "in",
ignoreCase: true, ignoreCase: true,
want: "\"in\"i", want: "\"in\"i",
@ -474,9 +474,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -492,9 +492,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -517,9 +517,9 @@ var g = &grammar{
pos: position{line: 94, col: 18, offset: 1964}, pos: position{line: 94, col: 18, offset: 1964},
exprs: []any{ exprs: []any{
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -543,9 +543,9 @@ var g = &grammar{
pos: position{line: 94, col: 38, offset: 1984}, pos: position{line: 94, col: 38, offset: 1984},
exprs: []any{ exprs: []any{
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -553,10 +553,10 @@ var g = &grammar{
}, },
}, },
&actionExpr{ &actionExpr{
pos: position{line: 232, col: 16, offset: 5239}, pos: position{line: 232, col: 16, offset: 5249},
run: (*parser).callonArithmeticExpr12, run: (*parser).callonArithmeticExpr12,
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 232, col: 17, offset: 5240}, pos: position{line: 232, col: 17, offset: 5250},
val: "[+-/*%]", val: "[+-/*%]",
chars: []rune{'+', '-', '/', '*', '%'}, chars: []rune{'+', '-', '/', '*', '%'},
ignoreCase: false, ignoreCase: false,
@ -564,9 +564,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -582,9 +582,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -671,9 +671,9 @@ var g = &grammar{
want: "\",\"", want: "\",\"",
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -744,24 +744,24 @@ var g = &grammar{
name: "Index", name: "Index",
}, },
&actionExpr{ &actionExpr{
pos: position{line: 194, col: 10, offset: 4449}, pos: position{line: 194, col: 10, offset: 4459},
run: (*parser).callonValue11, run: (*parser).callonValue11,
expr: &seqExpr{ expr: &seqExpr{
pos: position{line: 194, col: 10, offset: 4449}, pos: position{line: 194, col: 10, offset: 4459},
exprs: []any{ exprs: []any{
&litMatcher{ &litMatcher{
pos: position{line: 194, col: 10, offset: 4449}, pos: position{line: 194, col: 10, offset: 4459},
val: "\"", val: "\"",
ignoreCase: false, ignoreCase: false,
want: "\"\\\"\"", want: "\"\\\"\"",
}, },
&labeledExpr{ &labeledExpr{
pos: position{line: 194, col: 14, offset: 4453}, pos: position{line: 194, col: 14, offset: 4463},
label: "value", label: "value",
expr: &zeroOrMoreExpr{ expr: &zeroOrMoreExpr{
pos: position{line: 194, col: 20, offset: 4459}, pos: position{line: 194, col: 20, offset: 4469},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 194, col: 20, offset: 4459}, pos: position{line: 194, col: 20, offset: 4469},
val: "[^\"]", val: "[^\"]",
chars: []rune{'"'}, chars: []rune{'"'},
ignoreCase: false, ignoreCase: false,
@ -770,7 +770,7 @@ var g = &grammar{
}, },
}, },
&litMatcher{ &litMatcher{
pos: position{line: 194, col: 26, offset: 4465}, pos: position{line: 194, col: 26, offset: 4475},
val: "\"", val: "\"",
ignoreCase: false, ignoreCase: false,
want: "\"\\\"\"", want: "\"\\\"\"",
@ -779,24 +779,24 @@ var g = &grammar{
}, },
}, },
&actionExpr{ &actionExpr{
pos: position{line: 202, col: 13, offset: 4616}, pos: position{line: 202, col: 13, offset: 4626},
run: (*parser).callonValue18, run: (*parser).callonValue18,
expr: &seqExpr{ expr: &seqExpr{
pos: position{line: 202, col: 13, offset: 4616}, pos: position{line: 202, col: 13, offset: 4626},
exprs: []any{ exprs: []any{
&litMatcher{ &litMatcher{
pos: position{line: 202, col: 13, offset: 4616}, pos: position{line: 202, col: 13, offset: 4626},
val: "`", val: "`",
ignoreCase: false, ignoreCase: false,
want: "\"`\"", want: "\"`\"",
}, },
&labeledExpr{ &labeledExpr{
pos: position{line: 202, col: 17, offset: 4620}, pos: position{line: 202, col: 17, offset: 4630},
label: "value", label: "value",
expr: &zeroOrMoreExpr{ expr: &zeroOrMoreExpr{
pos: position{line: 202, col: 23, offset: 4626}, pos: position{line: 202, col: 23, offset: 4636},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 202, col: 23, offset: 4626}, pos: position{line: 202, col: 23, offset: 4636},
val: "[^`]", val: "[^`]",
chars: []rune{'`'}, chars: []rune{'`'},
ignoreCase: false, ignoreCase: false,
@ -805,7 +805,7 @@ var g = &grammar{
}, },
}, },
&litMatcher{ &litMatcher{
pos: position{line: 202, col: 29, offset: 4632}, pos: position{line: 202, col: 29, offset: 4642},
val: "`", val: "`",
ignoreCase: false, ignoreCase: false,
want: "\"`\"", want: "\"`\"",
@ -814,38 +814,52 @@ var g = &grammar{
}, },
}, },
&actionExpr{ &actionExpr{
pos: position{line: 186, col: 9, offset: 4273}, pos: position{line: 186, col: 9, offset: 4278},
run: (*parser).callonValue25, run: (*parser).callonValue25,
expr: &labeledExpr{ expr: &seqExpr{
pos: position{line: 186, col: 9, offset: 4273}, pos: position{line: 186, col: 9, offset: 4278},
label: "value", exprs: []any{
expr: &seqExpr{ &zeroOrOneExpr{
pos: position{line: 186, col: 16, offset: 4280}, pos: position{line: 186, col: 9, offset: 4278},
exprs: []any{ expr: &litMatcher{
&oneOrMoreExpr{ pos: position{line: 186, col: 9, offset: 4278},
pos: position{line: 186, col: 16, offset: 4280}, val: "-",
expr: &charClassMatcher{
pos: position{line: 186, col: 16, offset: 4280},
val: "[0-9]",
ranges: []rune{'0', '9'},
ignoreCase: false,
inverted: false,
},
},
&litMatcher{
pos: position{line: 186, col: 23, offset: 4287},
val: ".",
ignoreCase: false, ignoreCase: false,
want: "\".\"", want: "\"-\"",
}, },
&oneOrMoreExpr{ },
pos: position{line: 186, col: 27, offset: 4291}, &labeledExpr{
expr: &charClassMatcher{ pos: position{line: 186, col: 14, offset: 4283},
pos: position{line: 186, col: 27, offset: 4291}, label: "value",
val: "[0-9]", expr: &seqExpr{
ranges: []rune{'0', '9'}, pos: position{line: 186, col: 21, offset: 4290},
ignoreCase: false, exprs: []any{
inverted: false, &oneOrMoreExpr{
pos: position{line: 186, col: 21, offset: 4290},
expr: &charClassMatcher{
pos: position{line: 186, col: 21, offset: 4290},
val: "[0-9]",
ranges: []rune{'0', '9'},
ignoreCase: false,
inverted: false,
},
},
&litMatcher{
pos: position{line: 186, col: 28, offset: 4297},
val: ".",
ignoreCase: false,
want: "\".\"",
},
&oneOrMoreExpr{
pos: position{line: 186, col: 32, offset: 4301},
expr: &charClassMatcher{
pos: position{line: 186, col: 32, offset: 4301},
val: "[0-9]",
ranges: []rune{'0', '9'},
ignoreCase: false,
inverted: false,
},
},
}, },
}, },
}, },
@ -854,100 +868,114 @@ var g = &grammar{
}, },
&actionExpr{ &actionExpr{
pos: position{line: 178, col: 11, offset: 4067}, pos: position{line: 178, col: 11, offset: 4067},
run: (*parser).callonValue33, run: (*parser).callonValue36,
expr: &choiceExpr{ expr: &seqExpr{
pos: position{line: 178, col: 12, offset: 4068}, pos: position{line: 178, col: 11, offset: 4067},
alternatives: []any{ exprs: []any{
&seqExpr{ &zeroOrOneExpr{
pos: position{line: 178, col: 12, offset: 4068}, pos: position{line: 178, col: 11, offset: 4067},
exprs: []any{ expr: &litMatcher{
&litMatcher{ pos: position{line: 178, col: 11, offset: 4067},
pos: position{line: 178, col: 12, offset: 4068}, val: "-",
val: "0x",
ignoreCase: false,
want: "\"0x\"",
},
&oneOrMoreExpr{
pos: position{line: 178, col: 17, offset: 4073},
expr: &charClassMatcher{
pos: position{line: 178, col: 17, offset: 4073},
val: "[0-9a-f]i",
ranges: []rune{'0', '9', 'a', 'f'},
ignoreCase: true,
inverted: false,
},
},
},
},
&seqExpr{
pos: position{line: 178, col: 30, offset: 4086},
exprs: []any{
&litMatcher{
pos: position{line: 178, col: 30, offset: 4086},
val: "0o",
ignoreCase: false,
want: "\"0o\"",
},
&oneOrMoreExpr{
pos: position{line: 178, col: 35, offset: 4091},
expr: &charClassMatcher{
pos: position{line: 178, col: 35, offset: 4091},
val: "[0-7]",
ranges: []rune{'0', '7'},
ignoreCase: false,
inverted: false,
},
},
},
},
&seqExpr{
pos: position{line: 178, col: 44, offset: 4100},
exprs: []any{
&litMatcher{
pos: position{line: 178, col: 44, offset: 4100},
val: "0b",
ignoreCase: false,
want: "\"0b\"",
},
&oneOrMoreExpr{
pos: position{line: 178, col: 49, offset: 4105},
expr: &charClassMatcher{
pos: position{line: 178, col: 49, offset: 4105},
val: "[01]",
chars: []rune{'0', '1'},
ignoreCase: false,
inverted: false,
},
},
},
},
&oneOrMoreExpr{
pos: position{line: 178, col: 57, offset: 4113},
expr: &charClassMatcher{
pos: position{line: 178, col: 57, offset: 4113},
val: "[0-9]",
ranges: []rune{'0', '9'},
ignoreCase: false, ignoreCase: false,
inverted: false, want: "\"-\"",
},
},
&choiceExpr{
pos: position{line: 178, col: 17, offset: 4073},
alternatives: []any{
&seqExpr{
pos: position{line: 178, col: 17, offset: 4073},
exprs: []any{
&litMatcher{
pos: position{line: 178, col: 17, offset: 4073},
val: "0x",
ignoreCase: false,
want: "\"0x\"",
},
&oneOrMoreExpr{
pos: position{line: 178, col: 22, offset: 4078},
expr: &charClassMatcher{
pos: position{line: 178, col: 22, offset: 4078},
val: "[0-9a-f]i",
ranges: []rune{'0', '9', 'a', 'f'},
ignoreCase: true,
inverted: false,
},
},
},
},
&seqExpr{
pos: position{line: 178, col: 35, offset: 4091},
exprs: []any{
&litMatcher{
pos: position{line: 178, col: 35, offset: 4091},
val: "0o",
ignoreCase: false,
want: "\"0o\"",
},
&oneOrMoreExpr{
pos: position{line: 178, col: 40, offset: 4096},
expr: &charClassMatcher{
pos: position{line: 178, col: 40, offset: 4096},
val: "[0-7]",
ranges: []rune{'0', '7'},
ignoreCase: false,
inverted: false,
},
},
},
},
&seqExpr{
pos: position{line: 178, col: 49, offset: 4105},
exprs: []any{
&litMatcher{
pos: position{line: 178, col: 49, offset: 4105},
val: "0b",
ignoreCase: false,
want: "\"0b\"",
},
&oneOrMoreExpr{
pos: position{line: 178, col: 54, offset: 4110},
expr: &charClassMatcher{
pos: position{line: 178, col: 54, offset: 4110},
val: "[01]",
chars: []rune{'0', '1'},
ignoreCase: false,
inverted: false,
},
},
},
},
&oneOrMoreExpr{
pos: position{line: 178, col: 62, offset: 4118},
expr: &charClassMatcher{
pos: position{line: 178, col: 62, offset: 4118},
val: "[0-9]",
ranges: []rune{'0', '9'},
ignoreCase: false,
inverted: false,
},
},
}, },
}, },
}, },
}, },
}, },
&actionExpr{ &actionExpr{
pos: position{line: 210, col: 8, offset: 4778}, pos: position{line: 210, col: 8, offset: 4788},
run: (*parser).callonValue49, run: (*parser).callonValue55,
expr: &choiceExpr{ expr: &choiceExpr{
pos: position{line: 210, col: 9, offset: 4779}, pos: position{line: 210, col: 9, offset: 4789},
alternatives: []any{ alternatives: []any{
&litMatcher{ &litMatcher{
pos: position{line: 210, col: 9, offset: 4779}, pos: position{line: 210, col: 9, offset: 4789},
val: "true", val: "true",
ignoreCase: true, ignoreCase: true,
want: "\"true\"i", want: "\"true\"i",
}, },
&litMatcher{ &litMatcher{
pos: position{line: 210, col: 19, offset: 4789}, pos: position{line: 210, col: 19, offset: 4799},
val: "false", val: "false",
ignoreCase: true, ignoreCase: true,
want: "\"false\"i", want: "\"false\"i",
@ -965,7 +993,7 @@ var g = &grammar{
}, },
&actionExpr{ &actionExpr{
pos: position{line: 163, col: 9, offset: 3752}, pos: position{line: 163, col: 9, offset: 3752},
run: (*parser).callonValue55, run: (*parser).callonValue61,
expr: &seqExpr{ expr: &seqExpr{
pos: position{line: 163, col: 9, offset: 3752}, pos: position{line: 163, col: 9, offset: 3752},
exprs: []any{ exprs: []any{
@ -1044,9 +1072,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -1060,9 +1088,9 @@ var g = &grammar{
want: "\"|\"", want: "\"|\"",
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -1101,9 +1129,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -1117,9 +1145,9 @@ var g = &grammar{
want: "\"?\"", want: "\"?\"",
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -1135,9 +1163,9 @@ var g = &grammar{
}, },
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -1151,9 +1179,9 @@ var g = &grammar{
want: "\":\"", want: "\":\"",
}, },
&zeroOrMoreExpr{ &zeroOrMoreExpr{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
expr: &charClassMatcher{ expr: &charClassMatcher{
pos: position{line: 241, col: 18, offset: 5468}, pos: position{line: 241, col: 18, offset: 5478},
val: "[ \\t\\r\\n]", val: "[ \\t\\r\\n]",
chars: []rune{' ', '\t', '\r', '\n'}, chars: []rune{' ', '\t', '\r', '\n'},
ignoreCase: false, ignoreCase: false,
@ -1171,7 +1199,7 @@ var g = &grammar{
}, },
}, },
}, },
leader: true, leader: false,
leftRecursive: true, leftRecursive: true,
}, },
{ {
@ -1637,7 +1665,7 @@ func (p *parser) callonValue25() (any, error) {
return p.cur.onValue25(stack["value"]) return p.cur.onValue25(stack["value"])
} }
func (c *current) onValue33() (any, error) { func (c *current) onValue36() (any, error) {
i, err := strconv.ParseInt(string(c.text), 0, 64) i, err := strconv.ParseInt(string(c.text), 0, 64)
return ast.Integer{ return ast.Integer{
Value: i, Value: i,
@ -1645,13 +1673,13 @@ func (c *current) onValue33() (any, error) {
}, err }, err
} }
func (p *parser) callonValue33() (any, error) { func (p *parser) callonValue36() (any, error) {
stack := p.vstack[len(p.vstack)-1] stack := p.vstack[len(p.vstack)-1]
_ = stack _ = stack
return p.cur.onValue33() return p.cur.onValue36()
} }
func (c *current) onValue49() (any, error) { func (c *current) onValue55() (any, error) {
b, err := strconv.ParseBool(string(c.text)) b, err := strconv.ParseBool(string(c.text))
return ast.Bool{ return ast.Bool{
Value: b, Value: b,
@ -1659,13 +1687,13 @@ func (c *current) onValue49() (any, error) {
}, err }, err
} }
func (p *parser) callonValue49() (any, error) { func (p *parser) callonValue55() (any, error) {
stack := p.vstack[len(p.vstack)-1] stack := p.vstack[len(p.vstack)-1]
_ = stack _ = stack
return p.cur.onValue49() return p.cur.onValue55()
} }
func (c *current) onValue55() (any, error) { func (c *current) onValue61() (any, error) {
return ast.Ident{ return ast.Ident{
Value: string(c.text), Value: string(c.text),
@ -1673,10 +1701,10 @@ func (c *current) onValue55() (any, error) {
}, nil }, nil
} }
func (p *parser) callonValue55() (any, error) { func (p *parser) callonValue61() (any, error) {
stack := p.vstack[len(p.vstack)-1] stack := p.vstack[len(p.vstack)-1]
_ = stack _ = stack
return p.cur.onValue55() return p.cur.onValue61()
} }
func (c *current) onValue1(not, node any) (any, error) { func (c *current) onValue1(not, node any) (any, error) {

View File

@ -175,7 +175,7 @@ FuncCall = name:Ident params:ParamList {
}, nil }, nil
} }
Integer = ("0x" [0-9a-f]i+ / "0o" [0-7]+ / "0b" [01]+ / [0-9]+) { Integer = '-'? ("0x" [0-9a-f]i+ / "0o" [0-7]+ / "0b" [01]+ / [0-9]+) {
i, err := strconv.ParseInt(string(c.text), 0, 64) i, err := strconv.ParseInt(string(c.text), 0, 64)
return ast.Integer{ return ast.Integer{
Value: i, Value: i,
@ -183,7 +183,7 @@ Integer = ("0x" [0-9a-f]i+ / "0o" [0-7]+ / "0b" [01]+ / [0-9]+) {
}, err }, err
} }
Float = value:([0-9]+ '.' [0-9]+) { Float = '-'? value:([0-9]+ '.' [0-9]+) {
f, err := strconv.ParseFloat(string(c.text), 64) f, err := strconv.ParseFloat(string(c.text), 64)
return ast.Float{ return ast.Float{
Value: f, Value: f,