mirror of
https://github.com/biomejs/biome.git
synced 2025-12-23 08:21:13 +00:00
75 lines
2.3 KiB
Text
75 lines
2.3 KiB
Text
// Json Un-Grammar.
|
|
//
|
|
// This grammar specifies the structure of Rust's concrete syntax tree.
|
|
// It does not specify parsing rules (ambiguities, precedence, etc are out of scope).
|
|
// Tokens are processed -- contextual keywords are recognised, compound operators glued.
|
|
//
|
|
// Legend:
|
|
//
|
|
// // -- comment
|
|
// Name = -- non-terminal definition
|
|
// 'ident' -- token (terminal)
|
|
// A B -- sequence
|
|
// A | B -- alternation
|
|
// A* -- zero or more repetition
|
|
// (A (',' A)* ','?) -- repetition of node A separated by ',' and allowing a trailing comma
|
|
// (A (',' A)*) -- repetition of node A separated by ',' without a trailing comma
|
|
// A? -- zero or one repetition
|
|
// (A) -- same as A
|
|
// label:A -- suggested name for field of AST node
|
|
|
|
// NOTES
|
|
//
|
|
// - SyntaxNode, SyntaxToken and SyntaxElement will be stripped from the codegen
|
|
// - Bogus nodes are special nodes used to keep track of broken code; they are
|
|
// not part of the grammar but they will appear inside the green tree
|
|
|
|
|
|
///////////////
|
|
// BOGUS NODES
|
|
///////////////
|
|
// SyntaxElement is a generic data structure that is meant to track nodes and tokens
|
|
// in cases where we care about both types
|
|
//
|
|
// As Bogus* node will need to yield both tokens and nodes without discrimination,
|
|
// and their children will need to yield nodes and tokens as well.
|
|
// For this reason, SyntaxElement = SyntaxElement
|
|
|
|
SyntaxElement = SyntaxElement
|
|
|
|
JsonBogus = SyntaxElement*
|
|
JsonBogusValue = SyntaxElement*
|
|
|
|
JsonRoot =
|
|
bom: 'UNICODE_BOM'?
|
|
value: AnyJsonValue
|
|
eof: 'EOF'
|
|
|
|
AnyJsonValue =
|
|
JsonStringValue
|
|
| JsonBooleanValue
|
|
| JsonNullValue
|
|
| JsonNumberValue
|
|
| JsonArrayValue
|
|
| JsonObjectValue
|
|
| JsonBogusValue
|
|
|
|
JsonObjectValue = '{' JsonMemberList '}'
|
|
|
|
JsonMemberList = (JsonMember (',' JsonMember)* ','?)
|
|
|
|
JsonMember = name: JsonMemberName ':' value: AnyJsonValue
|
|
|
|
JsonMemberName = value: 'json_string_literal'
|
|
|
|
JsonArrayValue = '[' elements: JsonArrayElementList ']'
|
|
|
|
JsonArrayElementList = (AnyJsonValue (',' AnyJsonValue)* ','?)
|
|
|
|
JsonBooleanValue = value_token: ('true' | 'false')
|
|
|
|
JsonNullValue = value: 'null'
|
|
|
|
JsonStringValue = value: 'json_string_literal'
|
|
|
|
JsonNumberValue = value: 'json_number_literal'
|