|
|
|
@ -23,22 +23,22 @@ import (
|
|
|
|
|
"github.com/prometheus/prometheus/pkg/value" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
lstateInit = iota |
|
|
|
|
lstateName |
|
|
|
|
lstateValue |
|
|
|
|
lstateTimestamp |
|
|
|
|
lstateLabels |
|
|
|
|
lstateLName |
|
|
|
|
lstateLValue |
|
|
|
|
lstateLValueIn |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// Lex is called by the parser generated by "go tool yacc" to obtain each |
|
|
|
|
// token. The method is opened before the matching rules block and closed at |
|
|
|
|
// the end of the file. |
|
|
|
|
func (l *lexer) Lex() int { |
|
|
|
|
const ( |
|
|
|
|
lstateInit = iota |
|
|
|
|
lstateName |
|
|
|
|
lstateValue |
|
|
|
|
lstateTimestamp |
|
|
|
|
lstateLabels |
|
|
|
|
lstateLName |
|
|
|
|
lstateLValue |
|
|
|
|
lstateLValueIn |
|
|
|
|
) |
|
|
|
|
s := lstateInit |
|
|
|
|
l.state = lstateInit |
|
|
|
|
|
|
|
|
|
if l.i >= len(l.b) { |
|
|
|
|
return eof |
|
|
|
@ -60,7 +60,7 @@ M [a-zA-Z_:]
|
|
|
|
|
|
|
|
|
|
%yyc c |
|
|
|
|
%yyn c = l.next() |
|
|
|
|
%yyt s |
|
|
|
|
%yyt l.state |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%% |
|
|
|
@ -69,29 +69,29 @@ M [a-zA-Z_:]
|
|
|
|
|
#[^\r\n]*\n l.mstart = l.i |
|
|
|
|
[\r\n \t]+ l.mstart = l.i |
|
|
|
|
|
|
|
|
|
{S}({M}|{D})* s = lstateName |
|
|
|
|
{S}({M}|{D})* l.state = lstateName |
|
|
|
|
l.offsets = append(l.offsets, l.i) |
|
|
|
|
l.mend = l.i |
|
|
|
|
|
|
|
|
|
<lstateName>([ \t]*)\{ s = lstateLabels |
|
|
|
|
<lstateName>([ \t]*)\{ l.state = lstateLabels |
|
|
|
|
|
|
|
|
|
<lstateName>[ \t]+ s = lstateValue |
|
|
|
|
<lstateName>[ \t]+ l.state = lstateValue |
|
|
|
|
l.vstart = l.i |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<lstateLabels>[ \t]+ |
|
|
|
|
<lstateLabels>,?\} s = lstateValue |
|
|
|
|
<lstateLabels>,?\} l.state = lstateValue |
|
|
|
|
l.mend = l.i |
|
|
|
|
<lstateLabels>(,?[ \t]*) s = lstateLName |
|
|
|
|
<lstateLabels>(,?[ \t]*) l.state = lstateLName |
|
|
|
|
l.offsets = append(l.offsets, l.i) |
|
|
|
|
|
|
|
|
|
<lstateLName>{S}({L}|{D})* l.offsets = append(l.offsets, l.i) |
|
|
|
|
<lstateLName>[ \t]*= s = lstateLValue |
|
|
|
|
<lstateLName>[ \t]*= l.state = lstateLValue |
|
|
|
|
|
|
|
|
|
<lstateLValue>[ \t]+ |
|
|
|
|
<lstateLValue>\" s = lstateLValueIn |
|
|
|
|
<lstateLValue>\" l.state = lstateLValueIn |
|
|
|
|
l.offsets = append(l.offsets, l.i) |
|
|
|
|
<lstateLValueIn>(\\.|[^\\"]|\0)*\" s = lstateLabels |
|
|
|
|
<lstateLValueIn>(\\.|[^\\"])*\" l.state = lstateLabels |
|
|
|
|
if !utf8.Valid(l.b[l.offsets[len(l.offsets)-1]:l.i-1]) { |
|
|
|
|
l.err = fmt.Errorf("Invalid UTF-8 label value.") |
|
|
|
|
return -1 |
|
|
|
@ -100,7 +100,7 @@ M [a-zA-Z_:]
|
|
|
|
|
|
|
|
|
|
<lstateValue>[ \t]+ l.vstart = l.i |
|
|
|
|
<lstateValue>(NaN) l.val = math.Float64frombits(value.NormalNaN) |
|
|
|
|
s = lstateTimestamp |
|
|
|
|
l.state = lstateTimestamp |
|
|
|
|
|
|
|
|
|
<lstateValue>[^\n \t\r]+ // We don't parse strictly correct floats as the conversion |
|
|
|
|
// repeats the effort anyway. |
|
|
|
@ -108,7 +108,7 @@ M [a-zA-Z_:]
|
|
|
|
|
if l.err != nil { |
|
|
|
|
return -1 |
|
|
|
|
} |
|
|
|
|
s = lstateTimestamp |
|
|
|
|
l.state = lstateTimestamp |
|
|
|
|
|
|
|
|
|
<lstateTimestamp>[ \t]+ l.tstart = l.i |
|
|
|
|
<lstateTimestamp>{D}+ ts, err := strconv.ParseInt(yoloString(l.b[l.tstart:l.i]), 10, 64) |
|
|
|
|