google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
22.58k stars 3.19k forks source link

Grammar railroad diagram #8195

Closed mingodad closed 6 days ago

mingodad commented 6 months ago

While trying to adapt the grammar shown in https://flatbuffers.dev/flatbuffers_grammar.html to https://mingodad.github.io/parsertl-playground/playground/ an online Yacc/Lex compatible editor/tester (select Flatbuffers parser from Examples then click Parse to see the parser tree for the content in Input source), I found that it is stale.

Would be nice to update it and also change the syntax for the one understood by https://www.bottlecaps.de/rr/ui that allow to generate a nice navigable railroad diagram (see example bellow generated from the grammar in https://mingodad.github.io/parsertl-playground/playground ).

//
// EBNF to be viewd at https://www.bottlecaps.de/rr/ui
//
// Copy and paste this at https://www.bottlecaps.de/rr/ui in the 'Edit Grammar' tab
// then click the 'View Diagram' tab.
//

schema::=
      include
    | decl
    | schema include
    | schema decl

decl::=
      namespace_decl
    | type_decl
    | enum_decl
    | union_decl
    | root_decl
    | file_extension_decl
    | file_identifier_decl
    | attribute_decl
    | rpc_decl
    | object

include::=
      "include" string_constant ';'
    | "native_include" string_constant ';'

namespace_decl::=
      "namespace" qualident ';'

qualident::=
      ident
    | qualident '.' ident

attribute_decl::=
      "attribute" ident ';'
    | "attribute" string_constant ';'

type_decl::=
      table_or_struct ident metadata_opt '{' field_decl_zom '}'

table_or_struct::=
      "table"
    | "struct"

enum_decl::=
      "enum" ident ':' type metadata_opt enum_decl_body

enum_decl_body::=
      '{' '}'
    | '{' enumval_decl_list '}'
    | '{' enumval_decl_list ',' '}'

union_decl::=
      "union" ident metadata_opt union_decl_body

union_decl_body::=
      '{' '}'
    | '{' unionval_decl_list '}'
    | '{' unionval_decl_list ',' '}'

root_decl::=
      "root_type" ident ';'

field_decl_zom::=
      /*%empty*/
    | field_decl_zom field_decl

field_decl::=
      ident ':' type type_assign_opt metadata_opt ';'

type_assign_opt::=
      /*%empty*/
    | '=' value

rpc_decl::=
      "rpc_service" ident '{' rpc_method_oom '}'

rpc_method_oom::=
      rpc_method
    | rpc_method_oom rpc_method

rpc_method::=
      ident '(' ident ')' ':' ident metadata ';'

type::=
      "bool"
    | "byte"
    | "ubyte"
    | "short"
    | "ushort"
    | "int"
    | "uint"
    | "float"
    | "long"
    | "ulong"
    | "double"
    | "int8"
    | "uint8"
    | "int16"
    | "uint16"
    | "int32"
    | "uint32"
    | "int64"
    | "uint64"
    | "float32"
    | "float64"
    | "string"
    | '[' type ']'
    | qualident

enumval_decl_list::=
      enumval_decl
    | enumval_decl_list ',' enumval_decl

enumval_decl::=
      qualident ident_assign_opt

ident_assign_opt::=
      /*%empty*/
    | '=' integer_constant

unionval_decl_list::=
      unionval_decl
    | unionval_decl_list ',' unionval_decl

unionval_decl::=
      qualident type_opt metadata_opt

type_opt::=
      /*%empty*/
    | ':' type

metadata_opt::=
      /*%empty*/
    | metadata

metadata::=
      '(' key_val_opt_list ')'

key_val_opt_list::=
      key_val_opt
    | key_val_opt_list ',' key_val_opt

key_val_opt::=
      ident
    | ident ':' single_value

scalar::=
      boolean_constant
    | integer_constant
    | float_constant
    | "null"

object::=
      '{' object_kv_list '}'

object_kv_list::=
      key_val
    | object_kv_list ',' key_val

key_val::=
      ident ':' value

single_value::=
      scalar
    | string_constant

value::=
      single_value
    | object
    | '[' ']'
    | '[' value_list ']'
    | ident

value_list::=
      value
    | value_list ',' value

file_extension_decl::=
      "file_extension" string_constant ';'

file_identifier_decl::=
      "file_identifier" string_constant ';'
github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] commented 6 days ago

This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.