Skip to content

dump grammar as ebnf #5

@bloerwald

Description

@bloerwald

py3 code has dbd_grammar.py which already dumps something EBNF-y based on the parser used, but that needs manual cleanup since it is kind of ugly, uses bad names and stuff.

dbd_file            = 'COLUMNS', EOL, ( column_definition, EOL ), {column_definition, EOL}, EOL, ( definition, ( EOF | EOL ) ), {definition, ( EOF | EOL )};
column_definition   = column_type, [foreign_identifier], ? SPACE ?, column_name, ['?'], [eol_c_comment];
definition          = definition_header, {definition_header}, ( definition_entry, EOL ), {definition_entry, EOL};
column_type         = ( 'uint' | 'int' | 'string' | 'locstring' | 'float' );
foreign_identifier  = '<', identifier, '::', identifier, '>';
column_name         = identifier;
eol_c_comment       = [? SPACE ?], '//', ? rest of the line ?;
definition_header   = ( definition_BUILD | definition_LAYOUT | definition_COMMENT ), EOL;
definition_entry    = ['$', annotation, '$'], column_name, ['<', int_width, '>'], ['[', array_size, ']'], [eol_c_comment];
identifier          = ? WORD('A-Za-z_', 'A-Za-z0-9_') ?;
definition_BUILD    = 'BUILD', ? SPACE ?, build_version_range, {build_version_range};
definition_LAYOUT   = 'LAYOUT', ? SPACE ?, layout_hash, {layout_hash};
definition_COMMENT  = 'COMMENT', ? SPACE ?, ? rest of the line ?;
annotation          = identifier;
int_width           = integer;
array_size          = integer;
build_version_range = build_version, ['-', build_version];
layout_hash         = ? WORD('a-fA-F0-9') ?;
integer             = ? WORD('0-9') ?;
build_version       = integer, '.', integer, '.', integer, '.', integer;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions