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 |
This is the grammar of the C subset we used in our class, so you're right, there's no include.
…________________________________
From: Paul <[email protected]>
Sent: Thursday, January 16, 2020 4:57:24 PM
To: 01010101lzy <[email protected]>
Cc: Rynco Maekawa <[email protected]>; Author <[email protected]>
Subject: Re: 01010101lzy/grammar.txt
Is this grammar full? Can't find includes here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2F13fb644218f6c44b6492703a32343abb%3Femail_source%3Dnotifications%26email_token%3DACOIVL2MFAI2AXF7XWIUHUDQ6AOPJA5CNFSM4KHQKHO2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAF7U4K%23gistcomment-3140037&data=02%7C01%7C%7C20b33c5605ae4e318d2f08d79a621bed%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637147618472755667&sdata=qGZgg1ekFLFIlUiK3BDcgE%2BKYQ9nG3fGEl8v30izltQ%3D&reserved=0>, or unsubscribe<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACOIVL4AINFB3ABGE5BFZPTQ6AOPJANCNFSM4KHQKHOQ&data=02%7C01%7C%7C20b33c5605ae4e318d2f08d79a621bed%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637147618472765673&sdata=BmOp3h4NU%2BGHyKULRjoYt1qzO0Gn05DO7diWwy%2FDLwk%3D&reserved=0>.
Is there any description of supported/unsopported features?
Excuse me, one more question: what are your definitions of List and Key?
Oh sorry, I thought this was in another repository (that one where I wrote a C0 compiler).
For HOCON, I no longer maintain this grammar definition (and the associating parser) as they are just one of my homeworks. All supported features are the ones listed.
Key is defined as:
Key -> UnquotedString | QuotedString
List is the same as Array, I was inconsistent while writing this.
Well then you possibly will be interested to know that DeterminedSubstitution should use domething like '${' Key ('.' Key)? '}'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this grammar full? Can't find includes here.