meta-language 1.0.0

A self-describing links-network core for lossless language representation
Documentation
(grammar (start source_file) (matching longest) (settling tokens precedence dynamic ambiguity))
(extra (ref comment))
(extra (class plain (char %20) (char %09) (char %0A) (char %0D) (char %0C) (char %0B)))
(rule source_file normal (seq (optional (choice unordered (ref syntax) (ref edition))) (optional (repeat0 (choice unordered (ref import) (ref package) (ref option) (ref enumeration) (ref message) (ref extend) (ref service) (ref empty_statement))))) (concept grammar.source-file))
(rule empty_statement normal (literal %3B) (concept grammar.empty-statement))
(rule edition normal (seq (literal edition) (literal %3D) (capture labeled year (ref string)) (literal %3B)) (concept grammar.edition))
(rule syntax normal (seq (literal syntax) (literal %3D) (capture labeled version (ref string)) (literal %3B)) (concept grammar.syntax-statement))
(rule import normal (seq (literal import) (optional (choice unordered (literal weak) (literal public) (literal option))) (capture labeled path (ref string)) (literal %3B)) (concept grammar.import-declaration))
(rule package normal (seq (literal package) (ref full_identifier) (literal %3B)) (concept grammar.package-clause))
(rule option normal (seq (literal option) (ref option_name) (literal %3D) (ref constant) (literal %3B)) (concept grammar.option-statement))
(rule option_name silent (seq (choice unordered (ref identifier) (seq (literal %28) (optional (literal .)) (ref full_identifier) (literal %29))) (repeat0 (seq (literal .) (choice unordered (ref identifier) (seq (literal %28) (optional (literal .)) (ref full_identifier) (literal %29)))))) (concept grammar.option-name) (source-names (tree-sitter _option_name)))
(rule enumeration normal (seq (optional (choice unordered (literal export) (literal local))) (literal enum) (ref enumeration_name) (ref enumeration_body)) (concept grammar.enumeration-declaration) (source-names (tree-sitter enum)))
(rule enumeration_name normal (ref identifier) (concept grammar.enumeration-name) (source-names (tree-sitter enum_name)))
(rule enumeration_body normal (seq (literal %7B) (repeat0 (choice unordered (ref option) (ref enumeration_field) (ref empty_statement) (ref reserved))) (literal %7D)) (concept grammar.enumeration-body) (source-names (tree-sitter enum_body)))
(rule enumeration_field normal (seq (ref identifier) (literal %3D) (optional (literal -)) (ref integer_literal) (optional (seq (literal %5B) (ref enumeration_value_option) (repeat0 (seq (literal %2C) (ref enumeration_value_option))) (literal %5D))) (literal %3B)) (concept grammar.enumeration-field) (source-names (tree-sitter enum_field)))
(rule enumeration_value_option normal (seq (ref option_name) (literal %3D) (ref constant)) (concept grammar.enumeration-value-option) (source-names (tree-sitter enum_value_option)))
(rule message normal (seq (optional (choice unordered (literal export) (literal local))) (literal message) (ref message_name) (ref message_body)) (concept grammar.message))
(rule message_body normal (seq (literal %7B) (repeat0 (choice unordered (ref field) (ref enumeration) (ref message) (ref option) (ref one_of) (ref map_field) (ref reserved) (ref extensions) (ref extend) (ref group) (ref empty_statement))) (literal %7D)) (concept grammar.message-body))
(rule message_name normal (ref identifier) (concept grammar.message-name))
(rule extend normal (seq (literal extend) (optional (literal .)) (ref full_identifier) (ref message_body)) (concept grammar.message-extension))
(rule group normal (seq (optional (choice unordered (literal optional) (literal required) (literal repeated))) (literal group) (ref message_name) (literal %3D) (ref field_number) (optional (seq (literal %5B) (ref field_options) (literal %5D))) (ref message_body)) (concept grammar.group))
(rule field normal (seq (optional (choice unordered (literal optional) (literal required))) (optional (literal repeated)) (ref type) (ref identifier) (literal %3D) (ref field_number) (optional (seq (literal %5B) (ref field_options) (literal %5D))) (literal %3B)) (concept grammar.field-declaration))
(rule field_options normal (seq (ref field_option) (repeat0 (seq (literal %2C) (ref field_option)))) (concept grammar.field-option-list))
(rule field_option normal (seq (ref option_name) (literal %3D) (ref constant)) (concept grammar.field-option))
(rule one_of normal (seq (literal oneof) (ref identifier) (literal %7B) (repeat0 (choice unordered (ref option) (ref one_of_field) (ref group) (ref empty_statement))) (literal %7D)) (concept grammar.one-of-declaration) (source-names (tree-sitter oneof)))
(rule one_of_field normal (seq (ref type) (ref identifier) (literal %3D) (ref field_number) (optional (seq (literal %5B) (ref field_options) (literal %5D))) (literal %3B)) (concept grammar.one-of-field) (source-names (tree-sitter oneof_field)))
(rule map_field normal (seq (literal map) (literal %3C) (ref key_type) (literal %2C) (ref type) (literal %3E) (ref identifier) (literal %3D) (ref field_number) (optional (seq (literal %5B) (ref field_options) (literal %5D))) (literal %3B)) (concept grammar.map-field))
(rule key_type normal (choice unordered (literal int32) (literal int64) (literal uint32) (literal uint64) (literal sint32) (literal sint64) (literal fixed32) (literal fixed64) (literal sfixed32) (literal sfixed64) (literal bool) (literal string)) (concept grammar.key-type))
(rule type normal (choice unordered (literal double) (literal float) (literal int32) (literal int64) (literal uint32) (literal uint64) (literal sint32) (literal sint64) (literal fixed32) (literal fixed64) (literal sfixed32) (literal sfixed64) (literal bool) (literal string) (literal bytes) (ref message_or_enumeration_type)) (concept grammar.type))
(rule reserved normal (seq (literal reserved) (choice unordered (ref ranges) (ref reserved_field_names)) (literal %3B)) (concept grammar.reserved-statement))
(rule extensions normal (seq (literal extensions) (ref ranges) (optional (seq (literal %5B) (ref field_options) (literal %5D))) (literal %3B)) (concept grammar.extensions))
(rule ranges normal (seq (ref range) (repeat0 (seq (literal %2C) (ref range)))) (concept grammar.field-number-range-list))
(rule range normal (seq (ref integer_literal) (optional (seq (literal to) (choice unordered (ref integer_literal) (literal max))))) (concept grammar.field-number-range))
(rule reserved_field_names normal (seq (ref reserved_identifier) (repeat0 (seq (literal %2C) (ref reserved_identifier)))) (concept grammar.reserved-field-names))
(rule message_or_enumeration_type normal (seq (optional (literal .)) (repeat0 (seq (ref identifier) (literal .))) (ref identifier)) (concept grammar.message-or-enumeration-type) (source-names (tree-sitter message_or_enum_type)))
(rule field_number normal (ref integer_literal) (concept grammar.field-number))
(rule service normal (seq (literal service) (ref service_name) (literal %7B) (repeat0 (choice unordered (ref option) (ref remote_procedure_call) (ref empty_statement))) (literal %7D)) (concept grammar.service))
(rule service_name normal (ref identifier) (concept grammar.service-name))
(rule remote_procedure_call normal (seq (literal rpc) (ref remote_procedure_call_name) (literal %28) (optional (literal stream)) (ref message_or_enumeration_type) (literal %29) (literal returns) (literal %28) (optional (literal stream)) (ref message_or_enumeration_type) (literal %29) (choice unordered (seq (literal %7B) (repeat0 (choice unordered (ref option) (ref empty_statement))) (literal %7D)) (literal %3B))) (concept grammar.remote-procedure-call) (source-names (tree-sitter rpc)))
(rule remote_procedure_call_name normal (ref identifier) (concept grammar.remote-procedure-call-name) (source-names (tree-sitter rpc_name)))
(rule constant normal (choice unordered (ref full_identifier) (seq (optional (choice unordered (literal -) (literal %2B))) (ref integer_literal)) (seq (optional (choice unordered (literal -) (literal %2B))) (ref float_literal)) (ref string) (ref boolean) (ref block_literal)) (concept grammar.option-value))
(rule block_literal normal (choice unordered (seq (literal %7B) (repeat0 (ref block_field)) (literal %7D)) (seq (literal %3C) (repeat0 (ref block_field)) (literal %3E))) (concept grammar.block-literal) (source-names (tree-sitter block_lit)))
(rule block_field silent (seq (choice unordered (ref identifier) (ref extension_name)) (optional (literal %3A)) (choice unordered (ref constant) (seq (literal %5B) (optional (seq (ref constant) (repeat0 (seq (literal %2C) (ref constant))))) (literal %5D))) (optional (choice unordered (literal %2C) (literal %3B)))) (concept grammar.block-field) (source-names (tree-sitter _block_field)))
(rule extension_name normal (seq (literal %5B) (optional (literal .)) (capture labeled name (ref full_identifier)) (optional (seq (literal %2F) (capture labeled type (ref full_identifier)))) (literal %5D)) (concept grammar.extension-name))
(rule identifier token (seq (choice unordered (class plain (range a z) (range A Z)) (literal _)) (optional (repeat0 (choice unordered (class plain (range a z) (range A Z)) (class plain (range 0 9)) (literal _))))) (concept grammar.identifier))
(rule reserved_identifier token (choice unordered (seq (literal %22) (class plain (range a z) (range A Z)) (optional (repeat0 (choice unordered (class plain (range a z) (range A Z)) (class plain (range 0 9)) (literal _)))) (literal %22)) (seq (literal %27) (class plain (range a z) (range A Z)) (optional (repeat0 (choice unordered (class plain (range a z) (range A Z)) (class plain (range 0 9)) (literal _)))) (literal %27)) (seq (class plain (range a z) (range A Z)) (optional (repeat0 (choice unordered (class plain (range a z) (range A Z)) (class plain (range 0 9)) (literal _)))))) (concept grammar.quoted-field-name))
(rule full_identifier normal (seq (ref identifier) (optional (repeat0 (seq (literal .) (ref identifier))))) (concept grammar.qualified-identifier) (source-names (tree-sitter full_ident)))
(rule boolean normal (choice unordered (ref true) (ref false)) (concept grammar.boolean-value) (source-names (tree-sitter bool)))
(rule true token (literal true) (concept grammar.true-value))
(rule false token (literal false) (concept grammar.false-value))
(rule integer_literal normal (choice unordered (ref decimal_literal) (ref octal_literal) (ref hex_literal)) (concept grammar.integer-literal) (source-names (tree-sitter int_lit)))
(rule decimal_literal token (seq (class plain (range 1 9)) (repeat0 (class plain (range 0 9)))) (concept grammar.decimal-integer-literal) (source-names (tree-sitter decimal_lit)))
(rule octal_literal token (seq (literal 0) (repeat0 (class plain (range 0 7)))) (concept grammar.octal-integer-literal) (source-names (tree-sitter octal_lit)))
(rule hex_literal token (seq (literal 0) (choice unordered (literal x) (literal X)) (class plain (range 0 9) (range A F) (range a f)) (repeat0 (class plain (range 0 9) (range A F) (range a f)))) (concept grammar.hex-integer-literal) (source-names (tree-sitter hex_lit)))
(rule float_literal token (choice unordered (seq (seq (class plain (range 0 9)) (repeat0 (class plain (range 0 9)))) (literal .) (optional (seq (class plain (range 0 9)) (repeat0 (class plain (range 0 9))))) (optional (seq (choice unordered (literal e) (literal E)) (optional (choice unordered (literal %2B) (literal -))) (seq (class plain (range 0 9)) (repeat0 (class plain (range 0 9))))))) (seq (seq (class plain (range 0 9)) (repeat0 (class plain (range 0 9)))) (seq (choice unordered (literal e) (literal E)) (optional (choice unordered (literal %2B) (literal -))) (seq (class plain (range 0 9)) (repeat0 (class plain (range 0 9)))))) (seq (literal .) (seq (class plain (range 0 9)) (repeat0 (class plain (range 0 9)))) (optional (seq (choice unordered (literal e) (literal E)) (optional (choice unordered (literal %2B) (literal -))) (seq (class plain (range 0 9)) (repeat0 (class plain (range 0 9))))))) (literal inf) (literal nan)) (concept grammar.float-literal) (source-names (tree-sitter float_lit)))
(rule string normal (repeat1 (choice unordered (seq (literal %22) (repeat0 (choice unordered (alias unnamed_token (immediateToken (lexicalPrecedence 1 (repeat1 (class negated (char %22) (char %5C)))))) (ref escape_sequence))) (literal %22)) (seq (literal %27) (repeat0 (choice unordered (alias unnamed_token (immediateToken (lexicalPrecedence 1 (repeat1 (class negated (char %27) (char %5C)))))) (ref escape_sequence))) (literal %27)))) (concept grammar.string))
(rule escape_sequence silent (alias escape_sequence (immediateToken (seq (literal %5C) (choice unordered (class negated (char x) (char u) (char U)) (repeat 2 3 (class plain (range 0 9))) (seq (literal x) (repeat 2 unbounded (class plain (range 0 9) (range a f) (range A F)))) (seq (literal u) (repeat 4 4 (class plain (range 0 9) (range a f) (range A F)))) (seq (literal U) (repeat 8 8 (class plain (range 0 9) (range a f) (range A F)))))))) (concept grammar.escape-sequence))
(rule comment token (choice unordered (seq (literal %2F%2F) (repeat0 (class negated (char %0A)))) (seq (literal %2F%2A) (seq (repeat0 (class negated (char %2A))) (repeat1 (literal %2A)) (repeat0 (seq (class negated (char %2F) (char %2A)) (repeat0 (class negated (char %2A))) (repeat1 (literal %2A))))) (literal %2F))) (concept grammar.comment))