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.
529 lines
12 KiB
529 lines
12 KiB
// Generated by golex
|
|
package rules
|
|
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"os"
|
|
"regexp"
|
|
"sort"
|
|
)
|
|
import (
|
|
"github.com/prometheus/prometheus/model"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
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_COMMENTS yystartcondition = 1024
|
|
var yystartconditionexclmap = map[yystartcondition]bool{S_COMMENTS: true, }
|
|
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("permanent"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
if r != "yyREJECT" {
|
|
panic(r)
|
|
}
|
|
yyar.returnType = yyRT_REJECT
|
|
}
|
|
}()
|
|
{
|
|
return yyactionreturn{PERMANENT, yyRT_USER_RETURN}
|
|
}
|
|
return yyactionreturn{0, yyRT_FALLTHROUGH}
|
|
}}, {regexp.MustCompile("BY|by"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
if r != "yyREJECT" {
|
|
panic(r)
|
|
}
|
|
yyar.returnType = yyRT_REJECT
|
|
}
|
|
}()
|
|
{
|
|
return yyactionreturn{GROUP_OP, yyRT_USER_RETURN}
|
|
}
|
|
return yyactionreturn{0, yyRT_FALLTHROUGH}
|
|
}}, {regexp.MustCompile("AVG|SUM|MAX|MIN"), 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{AGGR_OP, yyRT_USER_RETURN}
|
|
}
|
|
return yyactionreturn{0, yyRT_FALLTHROUGH}
|
|
}}, {regexp.MustCompile("avg|sum|max|min"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
if r != "yyREJECT" {
|
|
panic(r)
|
|
}
|
|
yyar.returnType = yyRT_REJECT
|
|
}
|
|
}()
|
|
{
|
|
yylval.str = strings.ToUpper(yytext)
|
|
return yyactionreturn{AGGR_OP, yyRT_USER_RETURN}
|
|
}
|
|
return yyactionreturn{0, yyRT_FALLTHROUGH}
|
|
}}, {regexp.MustCompile("\\<|>|AND|OR"), 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{CMP_OP, 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
|
|
}
|
|
}()
|
|
{
|
|
yylval.str = yytext
|
|
return yyactionreturn{CMP_OP, 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
|
|
}
|
|
}()
|
|
{
|
|
yylval.str = yytext
|
|
return yyactionreturn{ADDITIVE_OP, 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
|
|
}
|
|
}()
|
|
{
|
|
yylval.str = yytext
|
|
return yyactionreturn{MULT_OP, yyRT_USER_RETURN}
|
|
}
|
|
return yyactionreturn{0, yyRT_FALLTHROUGH}
|
|
}}, {regexp.MustCompile("([0-9])+([smhdwy])"), 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{DURATION, yyRT_USER_RETURN}
|
|
}
|
|
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("\\-?([0-9])+(\\.([0-9])*)?"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
if r != "yyREJECT" {
|
|
panic(r)
|
|
}
|
|
yyar.returnType = yyRT_REJECT
|
|
}
|
|
}()
|
|
{
|
|
num, err := strconv.ParseFloat(yytext, 32)
|
|
if err != nil && err.(*strconv.NumError).Err == strconv.ErrSyntax {
|
|
panic("Invalid float")
|
|
}
|
|
yylval.num = model.SampleValue(num)
|
|
return yyactionreturn{NUMBER, 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)) {}
|