web-stack-project/bong_grammar.txt
2023-01-23 01:00:13 +01:00

131 lines
2.6 KiB
Plaintext

top_level ->
| element
| value
element -> Name single_line_fields element_body:?
element_body -> "{" element_fields "}"
element_fields -> (_ element_field (__linebreak__ element_field):*):? __linebreak__
element_field ->
| element
| specifier_chain
| element_property
| value
element_property -> Name _ ("=" | ":") _ value
single_line_fields ->
(first_single_line_field
(__sl__ single_line_field):*):? _sl_
first_single_line_field ->
| specifier_chain
| __sl__ single_line_element_property
| __sl__ single_line_value
single_line_field ->
| specifier_chain
| single_line_element_property
| single_line_value
single_line_element_property ->
Name _sl_ ("=" | ":") _sl_ value
single_line_value ->
| array
| Int
| Float
| String
| bool
| Null
specifier_chain -> specifier:+
specifier ->
| Id
| Class
value ->
| object
| array
| Int
| Float
| String
| bool
| Null
object -> "{" object_properties "}"
object_properties ->
(_ object_property (_ "," _ object_property):* _ ",":?):? _
object_property -> (Name | String) _ ("=" | ":") _ value
array -> "[" array_values "]"
array_values -> (_ value (_ "," _ value):* _ ",":?):? _
bool -> True | False
__linebreak__ -> mandatory_linebreak
__sl__ -> mandatory_single_line_whitespace
_sl_ -> optional_single_line_whitespace
__ml__ -> mandatory_whitespace
_ -> optional_whitespace
mandatory_linebreak ->
single_line_whitespace:*
line_breaker
whitespace_and_line_break:*
line_breaker -> MultiLineComment | MultiLineWhitespace | ";"
whitespace_and_line_break -> singular_whitespace | ";"
mandatory_single_line_whitespace -> single_line_whitespace:+
optional_single_line_whitespace -> single_line_whitespace:*
single_line_whitespace -> SingleLineWhitespace | MultiLineComment
optional_whitespace -> singular_whitespace:*
mandatory_whitespace -> singular_whitespace:+
singular_whitespace ->
| SingleLineComment
| MultiLineWhitespace
| SingleLineComment
| MultiLineComment
=== tokens ===
SingleLineWhitespace -> [ \t\r\f\v]+
MultiLineWhitespace -> [ \t\n\r\f\v]+
SingleLineComment -> \/\/[^\n]+
MultiLineComment -> \/\*.*?\*\/
Float -> [0-9]+\.[0-9]*
Int -> [0-9]+
String -> "<sequence of optionally escaped characters \
and escaped special character placeholders \
terminated by an unescaped '"'>
Null -> "null"
False -> "false"
True -> "true"
Name -> [a-zA-Z_][a-zA-Z0-9_]*
Id -> #[a-zA-Z0-9_]+
Class \.[a-zA-Z0-9_]+
LBrace -> "("
RBrace -> ")"
LBracket -> "["
RBracket -> "]"
Equal -> "="
Colon -> ":"
SemiColon -> ";"
Comma -> ","