web-stack-project/bong_grammar.txt

131 lines
2.6 KiB
Plaintext
Raw Normal View History

2023-01-17 00:21:19 +00:00
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
2023-01-17 00:21:19 +00:00
| element_property
| value
2023-01-17 09:44:56 +00:00
element_property -> Name _ ("=" | ":") _ value
2023-01-17 00:21:19 +00:00
single_line_fields ->
(first_single_line_field
(__sl__ single_line_field):*):? _sl_
2023-01-17 00:21:19 +00:00
first_single_line_field ->
| specifier_chain
| __sl__ single_line_element_property
| __sl__ single_line_value
2023-01-17 00:21:19 +00:00
single_line_field ->
| specifier_chain
2023-01-17 09:44:56 +00:00
| single_line_element_property
2023-01-17 00:21:19 +00:00
| single_line_value
2023-01-17 09:44:56 +00:00
single_line_element_property ->
Name _sl_ ("=" | ":") _sl_ value
2023-01-17 00:21:19 +00:00
single_line_value ->
| array
| Int
| Float
| String
| bool
| Null
specifier_chain -> specifier:+
specifier ->
| Id
| Class
2023-01-17 00:21:19 +00:00
value ->
| object
| array
| Int
| Float
| String
| bool
| Null
object -> "{" object_properties "}"
2023-01-21 02:40:08 +00:00
object_properties ->
(_ object_property (_ "," _ object_property):* _ ",":?):? _
2023-01-17 00:21:19 +00:00
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
2023-01-17 00:21:19 +00:00
_ -> 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
2023-01-17 00:21:19 +00:00
optional_whitespace -> singular_whitespace:*
2023-01-17 00:21:19 +00:00
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]*
2023-01-18 19:43:54 +00:00
Int -> [0-9]+
2023-01-17 00:21:19 +00:00
String -> "<sequence of optionally escaped characters \
and escaped special character placeholders \
terminated by an unescaped '"'>
Null -> "null"
False -> "false"
True -> "true"
2023-01-18 19:43:54 +00:00
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 -> ","