mirror of https://github.com/prometheus/prometheus
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
551 lines
12 KiB
551 lines
12 KiB
// Generated by golex |
|
package config |
|
|
|
|
|
import ( |
|
"bufio" |
|
"io" |
|
"os" |
|
"regexp" |
|
"sort" |
|
) |
|
|
|
var yyin io.Reader = os.Stdin |
|
var yyout io.Writer = os.Stdout |
|
|
|
type yyrule struct { |
|
regexp *regexp.Regexp |
|
trailing *regexp.Regexp |
|
startConds []yystartcondition |
|
sol bool |
|
action func() yyactionreturn |
|
} |
|
|
|
type yyactionreturn struct { |
|
userReturn int |
|
returnType yyactionreturntype |
|
} |
|
|
|
type yyactionreturntype int |
|
const ( |
|
yyRT_FALLTHROUGH yyactionreturntype = iota |
|
yyRT_USER_RETURN |
|
yyRT_REJECT |
|
) |
|
|
|
var yydata string = "" |
|
var yyorig string |
|
var yyorigidx int |
|
|
|
var yytext string = "" |
|
var yytextrepl bool = true |
|
func yymore() { |
|
yytextrepl = false |
|
} |
|
|
|
func yyBEGIN(state yystartcondition) { |
|
YY_START = state |
|
} |
|
|
|
func yyECHO() { |
|
yyout.Write([]byte(yytext)) |
|
} |
|
|
|
func yyREJECT() { |
|
panic("yyREJECT") |
|
} |
|
|
|
var yylessed int |
|
func yyless(n int) { |
|
yylessed = len(yytext) - n |
|
} |
|
|
|
func unput(c uint8) { |
|
yyorig = yyorig[:yyorigidx] + string(c) + yyorig[yyorigidx:] |
|
yydata = yydata[:len(yytext)-yylessed] + string(c) + yydata[len(yytext)-yylessed:] |
|
} |
|
|
|
func input() int { |
|
if len(yyorig) <= yyorigidx { |
|
return EOF |
|
} |
|
c := yyorig[yyorigidx] |
|
yyorig = yyorig[:yyorigidx] + yyorig[yyorigidx+1:] |
|
yydata = yydata[:len(yytext)-yylessed] + yydata[len(yytext)-yylessed+1:] |
|
return int(c) |
|
} |
|
|
|
var EOF int = -1 |
|
type yystartcondition int |
|
|
|
var INITIAL yystartcondition = 0 |
|
var YY_START yystartcondition = INITIAL |
|
|
|
type yylexMatch struct { |
|
index int |
|
matchFunc func() yyactionreturn |
|
sortLen int |
|
advLen int |
|
} |
|
|
|
type yylexMatchList []yylexMatch |
|
|
|
func (ml yylexMatchList) Len() int { |
|
return len(ml) |
|
} |
|
|
|
func (ml yylexMatchList) Less(i, j int) bool { |
|
return ml[i].sortLen > ml[j].sortLen && ml[i].index > ml[j].index |
|
} |
|
|
|
func (ml yylexMatchList) Swap(i, j int) { |
|
ml[i], ml[j] = ml[j], ml[i] |
|
} |
|
|
|
func yylex() int { |
|
reader := bufio.NewReader(yyin) |
|
|
|
for { |
|
line, err := reader.ReadString('\n') |
|
if len(line) == 0 && err == io.EOF { |
|
break |
|
} |
|
|
|
yydata += line |
|
} |
|
|
|
yyorig = yydata |
|
yyorigidx = 0 |
|
|
|
yyactioninline(yyBEGIN) |
|
|
|
for len(yydata) > 0 { |
|
matches := yylexMatchList(make([]yylexMatch, 0, 6)) |
|
excl := yystartconditionexclmap[YY_START] |
|
|
|
for i, v := range yyrules { |
|
sol := yyorigidx == 0 || yyorig[yyorigidx-1] == '\n' |
|
|
|
if v.sol && !sol { |
|
continue |
|
} |
|
|
|
// Check start conditions. |
|
ok := false |
|
|
|
// YY_START or '*' must feature in v.startConds |
|
for _, c := range v.startConds { |
|
if c == YY_START || c == -1 { |
|
ok = true |
|
break |
|
} |
|
} |
|
|
|
if !excl { |
|
// If v.startConds is empty, this is also acceptable. |
|
if len(v.startConds) == 0 { |
|
ok = true |
|
} |
|
} |
|
|
|
if !ok { |
|
continue |
|
} |
|
|
|
idxs := v.regexp.FindStringIndex(yydata) |
|
if idxs != nil && idxs[0] == 0 { |
|
// Check the trailing context, if any. |
|
checksOk := true |
|
sortLen := idxs[1] |
|
advLen := idxs[1] |
|
|
|
if v.trailing != nil { |
|
tridxs := v.trailing.FindStringIndex(yydata[idxs[1]:]) |
|
if tridxs == nil || tridxs[0] != 0 { |
|
checksOk = false |
|
} else { |
|
sortLen += tridxs[1] |
|
} |
|
} |
|
|
|
if checksOk { |
|
matches = append(matches, yylexMatch{i, v.action, sortLen, advLen}) |
|
} |
|
} |
|
} |
|
|
|
if yytextrepl { |
|
yytext = "" |
|
} |
|
|
|
sort.Sort(matches) |
|
|
|
tryMatch: |
|
if len(matches) == 0 { |
|
yytext += yydata[:1] |
|
yydata = yydata[1:] |
|
yyorigidx += 1 |
|
|
|
yyout.Write([]byte(yytext)) |
|
} else { |
|
m := matches[0] |
|
yytext += yydata[:m.advLen] |
|
yyorigidx += m.advLen |
|
|
|
yytextrepl, yylessed = true, 0 |
|
ar := m.matchFunc() |
|
|
|
if ar.returnType != yyRT_REJECT { |
|
yydata = yydata[m.advLen-yylessed:] |
|
yyorigidx -= yylessed |
|
} |
|
|
|
switch ar.returnType { |
|
case yyRT_FALLTHROUGH: |
|
// Do nothing. |
|
case yyRT_USER_RETURN: |
|
return ar.userReturn |
|
case yyRT_REJECT: |
|
matches = matches[1:] |
|
yytext = yytext[:len(yytext)-m.advLen] |
|
yyorigidx -= m.advLen |
|
goto tryMatch |
|
} |
|
} |
|
} |
|
|
|
return 0 |
|
} |
|
var S_TARGETS yystartcondition = 1027 |
|
var S_JOB yystartcondition = 1026 |
|
var S_GLOBAL yystartcondition = 1024 |
|
var S_GLOBAL_LABELS yystartcondition = 1025 |
|
var S_COMMENTS yystartcondition = 1029 |
|
var S_TARGET_LABELS yystartcondition = 1028 |
|
var yystartconditionexclmap = map[yystartcondition]bool{S_GLOBAL: false, S_GLOBAL_LABELS: false, S_COMMENTS: true, S_TARGET_LABELS: false, S_TARGETS: false, S_JOB: false, } |
|
var yyrules []yyrule = []yyrule{{regexp.MustCompile("[^\\n]"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yypos++ |
|
yyREJECT() |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\n"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyline++ |
|
yypos = 1 |
|
yyREJECT() |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("/\\*"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_COMMENTS) |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\*/"), nil, []yystartcondition{S_COMMENTS, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(0) |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("[^\\n]"), nil, []yystartcondition{S_COMMENTS, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\/\\/[^\\r\\n]*\\n"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("global"), nil, []yystartcondition{0, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_GLOBAL) |
|
return yyactionreturn{GLOBAL, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("labels"), nil, []yystartcondition{S_GLOBAL, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_GLOBAL_LABELS) |
|
return yyactionreturn{LABELS, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("rule_files"), nil, []yystartcondition{S_GLOBAL, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
return yyactionreturn{RULE_FILES, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\}"), nil, []yystartcondition{S_GLOBAL_LABELS, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_GLOBAL) |
|
yyREJECT() |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\}"), nil, []yystartcondition{S_GLOBAL, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(0) |
|
yyREJECT() |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("job"), nil, []yystartcondition{0, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_JOB) |
|
return yyactionreturn{JOB, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("targets"), nil, []yystartcondition{S_JOB, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_TARGETS) |
|
return yyactionreturn{TARGETS, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("endpoints"), nil, []yystartcondition{S_TARGETS, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
return yyactionreturn{ENDPOINTS, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("labels"), nil, []yystartcondition{S_TARGETS, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_TARGET_LABELS) |
|
return yyactionreturn{LABELS, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\}"), nil, []yystartcondition{S_TARGET_LABELS, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_TARGETS) |
|
yyREJECT() |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\}"), nil, []yystartcondition{S_TARGETS, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(S_JOB) |
|
yyREJECT() |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\}"), nil, []yystartcondition{S_JOB, }, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yyBEGIN(0) |
|
yyREJECT() |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("([a-zA-Z_])(([a-zA-Z_])|([0-9]))+"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yylval.str = yytext |
|
return yyactionreturn{IDENTIFIER, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\\"(\\\\[^\\n]|[^\\\\\"])*\\\""), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yylval.str = yytext[1 : len(yytext)-1] |
|
return yyactionreturn{STRING, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\'(\\\\[^\\n]|[^\\\\'])*\\'"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
yylval.str = yytext[1 : len(yytext)-1] |
|
return yyactionreturn{STRING, yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("[{}\\[\\]()=,]"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
return yyactionreturn{int(yytext[0]), yyRT_USER_RETURN} |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("[^\\n]"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, {regexp.MustCompile("\\n"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) { |
|
defer func() { |
|
if r := recover(); r != nil { |
|
if r != "yyREJECT" { |
|
panic(r) |
|
} |
|
yyar.returnType = yyRT_REJECT |
|
} |
|
}() |
|
{ |
|
} |
|
return yyactionreturn{0, yyRT_FALLTHROUGH} |
|
}}, } |
|
func yyactioninline(BEGIN func(yystartcondition)) {}
|
|
|