Skip to content

Commit

Permalink
correctly decode ()
Browse files Browse the repository at this point in the history
  • Loading branch information
ying-jeanne committed Jul 18, 2024
1 parent a93f747 commit 7ba728d
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 388 deletions.
5 changes: 2 additions & 3 deletions model/textparse/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type Parser interface {
// The returned byte slices become invalid after the next call to Next.
Unit() ([]byte, []byte)

// Identifiers returns the identifiers for info metrics
Identifiers() []string
// IdentifyingLabels returns the identifying labels for info metrics
IdentifyingLabels() []string

// Comment returns the text of the current comment.
// Must only be called after Next returned a comment entry.
Expand Down Expand Up @@ -113,5 +113,4 @@ const (
EntryComment Entry = 3
EntryUnit Entry = 4
EntryHistogram Entry = 5 // A series with a native histogram as a value.
EntryIdent Entry = 6
)
15 changes: 8 additions & 7 deletions model/textparse/openmetricslex.l
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func (l *openMetricsLexer) Lex() token {
D [0-9]
L [a-zA-Z_]
M [a-zA-Z_:]
C [^\n]
C [^\n()]
S [ ]

%x sComment sMeta1 sMeta2 sLabels sLValue sValue sTimestamp sExemplar sEValue sETimestamp sMeta3
%x sComment sMeta1 sMeta2 sLabels sLValue sValue sTimestamp sExemplar sEValue sETimestamp sIdens

%yyc c
%yyn c = l.next()
Expand All @@ -50,13 +50,14 @@ S [ ]
<sComment>TYPE{S} l.state = sMeta1; return tType
<sComment>UNIT{S} l.state = sMeta1; return tUnit
<sComment>"EOF"\n? l.state = sInit; return tEOFWord
<sComment>ID{S} l.state = sMeta3; return tIdens
<sMeta1>\"(\\.|[^\\"])*\" l.state = sMeta2; return tMName
<sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName
<sMeta2>{S}{C}*\n l.state = sInit; return tText
<sMeta3>{L}* return tLName
<sMeta3>, return tComma
<sMeta3>\n l.state = sInit; return tLinebreak
<sMeta2>{S}{C}* l.state = sMeta2; return tText
<sMeta2>\( l.state = sIdens; return tParentOpen
<sIdens>{L}({L}|{D})* return tLName
<sIdens>, return tComma
<sIdens>\) l.state = sMeta2; return tParentClose
<sMeta2>\n l.state = sInit; return tLinebreak
{M}({M}|{D})* l.state = sValue; return tMName
<sValue>\{ l.state = sLabels; return tBraceOpen
Expand Down
Loading

0 comments on commit 7ba728d

Please sign in to comment.