-
Notifications
You must be signed in to change notification settings - Fork 10
/
line-protocol.ebnf
49 lines (36 loc) · 2.01 KB
/
line-protocol.ebnf
1
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// This file holds a grammar for the line-protocol syntax.
// The grammar is in EBNF format as used in the Go specification.
lines = line { [ "\r" ] "\n" line } [ "\r" ] .
space_char = " " .
whitespace = space_char { space_char } .
nonprintable_char = "\u0000"…"\u001f" | "\u007f" .
line = { space_char } [ point | comment ] .
point = measurement { "," tag } whitespace field { "," field } [ whitespace timestamp ] { space_char } .
comment = "#" { not(nonprintable_char) | "\t" } .
measurement = measurement_start { measurement_elem } .
// Note: the start character is different from other measurement characters
// because it can't be a # character (otherwise it would match a comment).
measurement_start = not(nonprintable_char | space_char | `\` | "," | "#" ) | measurement_escape_seq .
measurement_elem = measurement_regular_char | measurement_escape_seq .
measurement_regular_char = not(nonprintable_char | space_char | `\` | "," ) .
measurement_escape_seq = `\` { `\` } not ( `\` | nonprintable_char ).
key = key_elem { key_elem } .
key_elem = key_regular_char | key_escape_seq .
key_regular_char = not(nonprintable_char | space_char | `\` | "," | "=" ) .
key_escape_seq = `\` { `\` } not ( `\` | nonprintable_char ) .
tag = key "=" key .
field = key "=" fieldval .
fieldval = boolfield | stringfield | intfield | uintfield | floatfield .
decimal_digits = decimal_digit { decimal_digit } .
decimal_digit = "0" … "9" .
boolfield = "t" | "T" | "true" | "True" | "TRUE" | "f" | "F" | "false" | "False" | "FALSE" .
intfield = [ "-" ] decimal_digits "i" .
uintfield = decimal_digits "u" .
floatfield = [ "-" ] non_negative_float .
non_negative_float = decimal_digits [ "." [ decimal_digits ] [ decimal_exponent ] ] |
decimal_digits decimal_exponent |
"." decimal_digits [ decimal_exponent ] .
decimal_exponent = ( "e" | "E" ) [ "+" | "-" ] decimal_digits .
stringfield = `"` { not(`"` | `\`) | `\` any_char } `"` .
any_char = "\u0000" … "\U0010FFFF" .
timestamp = [ "-" ] decimal_digits .