mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
parser: remake generated_parser output (#13923)
In a previous PR, the generated parser was created using an old version of goyacc. Also adds -l to disable line directives, which fixes debug processing and reduces diffs at the expense of making it more difficult to reason about the generated output. Signed-off-by: Owen Williams <owen.williams@grafana.com>
This commit is contained in:
parent
4ec5c25393
commit
4a6f8704ef
2
Makefile
2
Makefile
|
@ -86,7 +86,7 @@ ifeq (, $(shell command -v goyacc 2> /dev/null))
|
|||
@echo "goyacc not installed so skipping"
|
||||
@echo "To install: go install golang.org/x/tools/cmd/goyacc@v0.6.0"
|
||||
else
|
||||
goyacc -o promql/parser/generated_parser.y.go promql/parser/generated_parser.y
|
||||
goyacc -l -o promql/parser/generated_parser.y.go promql/parser/generated_parser.y
|
||||
endif
|
||||
|
||||
.PHONY: test
|
||||
|
|
|
@ -225,7 +225,7 @@ const yyEofCode = 1
|
|||
const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
var yyExca = [...]int{
|
||||
var yyExca = [...]int16{
|
||||
-1, 1,
|
||||
1, -1,
|
||||
-2, 0,
|
||||
|
@ -376,7 +376,7 @@ const yyPrivate = 57344
|
|||
|
||||
const yyLast = 742
|
||||
|
||||
var yyAct = [...]int{
|
||||
var yyAct = [...]int16{
|
||||
151, 322, 320, 268, 327, 148, 221, 37, 187, 144,
|
||||
281, 280, 152, 113, 77, 173, 104, 102, 101, 6,
|
||||
128, 223, 105, 193, 155, 194, 195, 196, 339, 262,
|
||||
|
@ -454,7 +454,7 @@ var yyAct = [...]int{
|
|||
0, 98,
|
||||
}
|
||||
|
||||
var yyPact = [...]int{
|
||||
var yyPact = [...]int16{
|
||||
17, 153, 541, 541, 385, 500, -1000, -1000, -1000, 146,
|
||||
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
|
||||
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
|
||||
|
@ -492,7 +492,7 @@ var yyPact = [...]int{
|
|||
-1000, -1000,
|
||||
}
|
||||
|
||||
var yyPgo = [...]int{
|
||||
var yyPgo = [...]int16{
|
||||
0, 353, 13, 352, 6, 15, 350, 263, 349, 347,
|
||||
344, 209, 265, 343, 14, 342, 10, 11, 341, 337,
|
||||
8, 336, 3, 4, 333, 2, 1, 0, 332, 12,
|
||||
|
@ -501,7 +501,7 @@ var yyPgo = [...]int{
|
|||
290, 249, 9, 271, 270, 268,
|
||||
}
|
||||
|
||||
var yyR1 = [...]int{
|
||||
var yyR1 = [...]int8{
|
||||
0, 54, 54, 54, 54, 54, 54, 54, 37, 37,
|
||||
37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
|
||||
32, 32, 32, 32, 33, 33, 35, 35, 35, 35,
|
||||
|
@ -528,7 +528,7 @@ var yyR1 = [...]int{
|
|||
17, 17,
|
||||
}
|
||||
|
||||
var yyR2 = [...]int{
|
||||
var yyR2 = [...]int8{
|
||||
0, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
3, 3, 2, 2, 2, 2, 4, 4, 4, 4,
|
||||
|
@ -555,7 +555,7 @@ var yyR2 = [...]int{
|
|||
0, 1,
|
||||
}
|
||||
|
||||
var yyChk = [...]int{
|
||||
var yyChk = [...]int16{
|
||||
-1000, -54, 88, 89, 90, 91, 2, 10, -12, -7,
|
||||
-11, 60, 61, 75, 62, 63, 64, 12, 45, 46,
|
||||
49, 65, 18, 66, 79, 67, 68, 69, 70, 71,
|
||||
|
@ -593,7 +593,7 @@ var yyChk = [...]int{
|
|||
21, -27,
|
||||
}
|
||||
|
||||
var yyDef = [...]int{
|
||||
var yyDef = [...]int16{
|
||||
0, -2, 125, 125, 0, 0, 7, 6, 1, 125,
|
||||
99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
|
||||
109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
|
||||
|
@ -631,11 +631,11 @@ var yyDef = [...]int{
|
|||
166, 168,
|
||||
}
|
||||
|
||||
var yyTok1 = [...]int{
|
||||
var yyTok1 = [...]int8{
|
||||
1,
|
||||
}
|
||||
|
||||
var yyTok2 = [...]int{
|
||||
var yyTok2 = [...]int8{
|
||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
||||
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
|
@ -648,7 +648,7 @@ var yyTok2 = [...]int{
|
|||
92,
|
||||
}
|
||||
|
||||
var yyTok3 = [...]int{
|
||||
var yyTok3 = [...]int8{
|
||||
0,
|
||||
}
|
||||
|
||||
|
@ -728,9 +728,9 @@ func yyErrorMessage(state, lookAhead int) string {
|
|||
expected := make([]int, 0, 4)
|
||||
|
||||
// Look for shiftable tokens.
|
||||
base := yyPact[state]
|
||||
base := int(yyPact[state])
|
||||
for tok := TOKSTART; tok-1 < len(yyToknames); tok++ {
|
||||
if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok {
|
||||
if n := base + tok; n >= 0 && n < yyLast && int(yyChk[int(yyAct[n])]) == tok {
|
||||
if len(expected) == cap(expected) {
|
||||
return res
|
||||
}
|
||||
|
@ -740,13 +740,13 @@ func yyErrorMessage(state, lookAhead int) string {
|
|||
|
||||
if yyDef[state] == -2 {
|
||||
i := 0
|
||||
for yyExca[i] != -1 || yyExca[i+1] != state {
|
||||
for yyExca[i] != -1 || int(yyExca[i+1]) != state {
|
||||
i += 2
|
||||
}
|
||||
|
||||
// Look for tokens that we accept or reduce.
|
||||
for i += 2; yyExca[i] >= 0; i += 2 {
|
||||
tok := yyExca[i]
|
||||
tok := int(yyExca[i])
|
||||
if tok < TOKSTART || yyExca[i+1] == 0 {
|
||||
continue
|
||||
}
|
||||
|
@ -777,30 +777,30 @@ func yylex1(lex yyLexer, lval *yySymType) (char, token int) {
|
|||
token = 0
|
||||
char = lex.Lex(lval)
|
||||
if char <= 0 {
|
||||
token = yyTok1[0]
|
||||
token = int(yyTok1[0])
|
||||
goto out
|
||||
}
|
||||
if char < len(yyTok1) {
|
||||
token = yyTok1[char]
|
||||
token = int(yyTok1[char])
|
||||
goto out
|
||||
}
|
||||
if char >= yyPrivate {
|
||||
if char < yyPrivate+len(yyTok2) {
|
||||
token = yyTok2[char-yyPrivate]
|
||||
token = int(yyTok2[char-yyPrivate])
|
||||
goto out
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(yyTok3); i += 2 {
|
||||
token = yyTok3[i+0]
|
||||
token = int(yyTok3[i+0])
|
||||
if token == char {
|
||||
token = yyTok3[i+1]
|
||||
token = int(yyTok3[i+1])
|
||||
goto out
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if token == 0 {
|
||||
token = yyTok2[1] /* unknown char */
|
||||
token = int(yyTok2[1]) /* unknown char */
|
||||
}
|
||||
if yyDebug >= 3 {
|
||||
__yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char))
|
||||
|
@ -855,7 +855,7 @@ yystack:
|
|||
yyS[yyp].yys = yystate
|
||||
|
||||
yynewstate:
|
||||
yyn = yyPact[yystate]
|
||||
yyn = int(yyPact[yystate])
|
||||
if yyn <= yyFlag {
|
||||
goto yydefault /* simple state */
|
||||
}
|
||||
|
@ -866,8 +866,8 @@ yynewstate:
|
|||
if yyn < 0 || yyn >= yyLast {
|
||||
goto yydefault
|
||||
}
|
||||
yyn = yyAct[yyn]
|
||||
if yyChk[yyn] == yytoken { /* valid shift */
|
||||
yyn = int(yyAct[yyn])
|
||||
if int(yyChk[yyn]) == yytoken { /* valid shift */
|
||||
yyrcvr.char = -1
|
||||
yytoken = -1
|
||||
yyVAL = yyrcvr.lval
|
||||
|
@ -880,7 +880,7 @@ yynewstate:
|
|||
|
||||
yydefault:
|
||||
/* default state action */
|
||||
yyn = yyDef[yystate]
|
||||
yyn = int(yyDef[yystate])
|
||||
if yyn == -2 {
|
||||
if yyrcvr.char < 0 {
|
||||
yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
|
||||
|
@ -889,18 +889,18 @@ yydefault:
|
|||
/* look through exception table */
|
||||
xi := 0
|
||||
for {
|
||||
if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate {
|
||||
if yyExca[xi+0] == -1 && int(yyExca[xi+1]) == yystate {
|
||||
break
|
||||
}
|
||||
xi += 2
|
||||
}
|
||||
for xi += 2; ; xi += 2 {
|
||||
yyn = yyExca[xi+0]
|
||||
yyn = int(yyExca[xi+0])
|
||||
if yyn < 0 || yyn == yytoken {
|
||||
break
|
||||
}
|
||||
}
|
||||
yyn = yyExca[xi+1]
|
||||
yyn = int(yyExca[xi+1])
|
||||
if yyn < 0 {
|
||||
goto ret0
|
||||
}
|
||||
|
@ -922,10 +922,10 @@ yydefault:
|
|||
|
||||
/* find a state where "error" is a legal shift action */
|
||||
for yyp >= 0 {
|
||||
yyn = yyPact[yyS[yyp].yys] + yyErrCode
|
||||
yyn = int(yyPact[yyS[yyp].yys]) + yyErrCode
|
||||
if yyn >= 0 && yyn < yyLast {
|
||||
yystate = yyAct[yyn] /* simulate a shift of "error" */
|
||||
if yyChk[yystate] == yyErrCode {
|
||||
yystate = int(yyAct[yyn]) /* simulate a shift of "error" */
|
||||
if int(yyChk[yystate]) == yyErrCode {
|
||||
goto yystack
|
||||
}
|
||||
}
|
||||
|
@ -961,7 +961,7 @@ yydefault:
|
|||
yypt := yyp
|
||||
_ = yypt // guard against "declared and not used"
|
||||
|
||||
yyp -= yyR2[yyn]
|
||||
yyp -= int(yyR2[yyn])
|
||||
// yyp is now the index of $0. Perform the default action. Iff the
|
||||
// reduced production is ε, $1 is possibly out of range.
|
||||
if yyp+1 >= len(yyS) {
|
||||
|
@ -972,16 +972,16 @@ yydefault:
|
|||
yyVAL = yyS[yyp+1]
|
||||
|
||||
/* consult goto table to find next state */
|
||||
yyn = yyR1[yyn]
|
||||
yyg := yyPgo[yyn]
|
||||
yyn = int(yyR1[yyn])
|
||||
yyg := int(yyPgo[yyn])
|
||||
yyj := yyg + yyS[yyp].yys + 1
|
||||
|
||||
if yyj >= yyLast {
|
||||
yystate = yyAct[yyg]
|
||||
yystate = int(yyAct[yyg])
|
||||
} else {
|
||||
yystate = yyAct[yyj]
|
||||
if yyChk[yystate] != -yyn {
|
||||
yystate = yyAct[yyg]
|
||||
yystate = int(yyAct[yyj])
|
||||
if int(yyChk[yystate]) != -yyn {
|
||||
yystate = int(yyAct[yyg])
|
||||
}
|
||||
}
|
||||
// dummy call; replaced with literal code
|
||||
|
|
Loading…
Reference in a new issue