Last active
January 16, 2020 10:18
-
-
Save lynzrand/13fb644218f6c44b6492703a32343abb to your computer and use it in GitHub Desktop.
HOCON grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EOL -> '\n' | '\r' | '\r\n' | |
Whitespace -> ' ' | '\t' | |
EscapedSequence -> | |
| '\\' [bfnrt\\] | |
| '\u' [0-9a-fA-F]{4} | |
QuotedStringElement -> | |
| [^\\"] | |
| EscapedSequence | |
QuotedString -> | |
| '"' QuotedStringElement* '"' | |
| '""' | |
UnquotedString -> [^$"{}\[\]:=,+#`\^?!@#&\\]+ | |
MultilineString -> '"""' .* '"""' | |
Numerical -> [0-9]+ | |
Number -> | |
| Numerical | |
| Numerical '.' Numerical | |
| Numerical '.' [Ee] [+-]? Numerical | |
| Numerical '.' Numerical [Ee] [+-]? Numerical | |
DurationUnit -> | |
| 'ns' | 'nanosecond' | 'nanoseconds' | |
| 'us' | 'microsecond' | 'microseconds' | |
| 'ms' | 'millisecond' | 'milliseconds' | |
| 's' | 'second' | 'seconds' | |
| 'm' | 'minute' | 'minutes' | |
| 'h' | 'hour' | 'hours' | |
| 'd' | 'day' | 'days' | |
Duration -> Number DurationUnit | |
SizeUnit -> | |
| 'B' | 'b' | 'byte' | 'bytes' | |
| ‘kB' | 'kilobyte' | 'kilobytes' | |
| ‘MB' | 'megabyte' | 'megabytes' | |
| ‘GB' | 'gigabyte' | 'gigabytes' | |
| ‘TB' | 'terabyte' | 'terabytes' | |
| ‘PB' | 'petabyte' | 'petabytes' | |
| ‘EB' | 'exabyte' | 'exabytes' | |
| ‘ZB' | 'zettabyte' | 'zettabytes' | |
| ‘YB' | 'yottabyte' | 'yottabytes' | |
| ‘K' | 'k' | 'Ki' | 'KiB' | 'kibibyte' | 'kibibytes' | |
| ‘M' | 'm' | 'Mi' | 'MiB' | 'mebibyte' | 'mebibytes' | |
| ‘G' | 'g' | 'Gi' | 'GiB' | 'gibibyte' | 'gibibytes' | |
| ‘T' | 't' | 'Ti' | 'TiB' | 'tebibyte' | 'tebibytes' | |
| ‘P' | 'p' | 'Pi' | 'PiB' | 'pebibyte' | 'pebibytes' | |
| ‘E' | 'e' | 'Ei' | 'EiB' | 'exbibyte' | 'exbibytes' | |
| ‘Z' | 'z' | 'Zi' | 'ZiB' | 'zebibyte' | 'zebibytes' | |
| ‘Y' | 'y' | 'Yi' | 'YiB' | 'yobibyte' | 'yobibytes' | |
Size -> Number SizeUnit | |
DeterminedSubstitution -> '${' Key '}' | |
NonDeterminedSubstitution -> '${?' Key '}' | |
Substitution -> | |
| DeterminedSubstitution | |
| NonDeterminedSubstitution | |
ValueSegment -> | |
| Number | |
| Duration | |
| Size | |
| List | |
| Map | |
| Substitution | |
| UnquotedString | |
| QuotedString | |
| MultilineString | |
Value -> ValueSegment ( Whitespace? ValueSegment )* | |
Separator -> ':' | '=' | |
KeyValuePair -> | |
| Key Whitespace? Separator Whitespace? Value | |
| Key Map | |
ElementSeparator -> | |
| Whitespace? EOL Whitespace? | |
| Whitespace? ',' Whitespace? | |
| Whitespace? ',' Whitespace? EOL Whitespace? | |
KeyValuePairs -> | |
| KeyValuePair | |
| KeyValuePair ElementSeparator | |
| KeyValuePair ElementSeparator KeyValuePairs | |
Map -> '{' WhiteSpace? KeyValuePairs WhiteSpace? '}' | |
Values -> | |
| Value | |
| Value ElementSeparator | |
| Value ElementSeparator Values | |
Array -> '[' Whitespace? Values Whitespace? ']' | |
Document -> | |
| Whitespace? EOF | |
| Whitespace? KeyValuePairs Whitespace? EOF | |
| Whitespace? Map Whitespace? EOF | |
| Whitespace? Array Whitespace? EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well then you possibly will be interested to know that DeterminedSubstitution should use domething like
'${' Key ('.' Key)? '}'