Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error with graphviz with -d option #161

Open
dtrckd opened this issue Mar 9, 2020 · 0 comments
Open

syntax error with graphviz with -d option #161

dtrckd opened this issue Mar 9, 2020 · 0 comments

Comments

@dtrckd
Copy link
Contributor

dtrckd commented Mar 9, 2020

Hi,

I got this error when trying to generate the diagram of a grammar (the grammar is below):

python3 -m tatsu gram/graphql.ebnf -d --outfile p
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/dtrckd/.local/lib/python3.7/site-packages/tatsu/__main__.py", line 6, in <module>
    tatsu.main()
  File "/home/dtrckd/.local/lib/python3.7/site-packages/tatsu/tool.py", line 238, in main
    diagrams.draw(outfile, model)
  File "/home/dtrckd/.local/lib/python3.7/site-packages/tatsu/diagrams.py", line 17, in draw
    traverser.draw(filename)
  File "/home/dtrckd/.local/lib/python3.7/site-packages/tatsu/diagrams.py", line 36, in draw
    self.graph.layout(prog='dot')
  File "/home/dtrckd/.local/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1399, in layout
    data = self._run_prog(prog, ' '.join([args, "-T", fmt]))
  File "/home/dtrckd/.local/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1364, in _run_prog
    raise IOError(b"".join(errors).decode(self.encoding))
OSError: Error: <stdin>: syntax error in line 327 near '\'

Versions:
python 3.7
pygraphviz 1.5
tatsu 4.4.0

@@grammar::GRAPHQL


document
    =
    {definition}+ 
    ;


definition
    =
    executable_definition | type_system_definition  | LINE_COMMENT
    ;


executable_definition
    =
    operation_definition | fragment_definition
    ;


operation_definition
    =
    | operation_type [name] [variable_definitions] [directives] selection_set
    | selection_set
    ;


operation_type
    =
    'query' | 'mutation' | 'subscription'
    ;


selection_set
    =
    '{' {selection}+ '}'
    ;


selection
    =
    field | fragment_spread | inline_fragment
    ;


field
    =
    [alias] name [arguments] [directives] [selection_set]
    ;


arguments
    =
    '(' {argument}+ ')'
    ;


argument
    =
    name ':' (value | '[' value ']' )
    ;


alias
    =
    name ':'
    ;


fragment_spread
    =
    '...' fragment_name [directives]
    ;


fragment_definition
    =
    'fragment' fragment_name 'on' type_condition [directives] selection_set
    ;


fragment_name
    =
    name
    ;


type_condition
    =
    'on' named_type
    ;


inline_fragment
    =
    '...' [type_condition] [directives] selection_set
    ;


value
    =
    | variable
    | int_value
    | float_value
    | string_value
    | boolean_value
    | null_value
    | enum_value
    | list_value
    | object_value
    ;


int_value
    =
    int
    ;


float_value
    =
    float
    ;


boolean_value
    =
    'true' | 'false'
    ;


string_value
    =
    STRING | BLOCK_STRING
    ;


null_value
    =
    'null'
    ;


enum_value
    =
    name
    ;


list_value
    =
    '[' /[][]/ {value}+ ']'
    ;


object_value
    =
    '{' /[}{]/ object_field '}'
    ;


object_field
    =
    name ':' value
    ;


variable
    =
    '$' name
    ;


variable_definitions
    =
    '(' {variable_definition}+ ')'
    ;


variable_definition
    =
    variable ':' type_ [default_value]
    ;


default_value
    =
    '=' value
    ;

type_ = type:_type_;

_type_
    =
    named_type ['!'] | list_type ['!']
    ;


named_type
    =
    name
    ;


list_type
    =
    '[' type_ ']'
    ;


directives
    =
    {directive}+
    ;

directive = directive:directive_;

directive_
    =
    '@' name [arguments]
    ;


type_system_definition
    =
    | schema_definition:schema_definition
    | directive_definition:directive_definition
    | interface_definition:interface_type_definition
    | enum_definition:enum_type_definition
    | type_definition:object_type_definition
    | extension_definition:type_system_extension
    | input_definition:input_object_type_definition
    | union_definition:union_type_definition
    | scalar_definition:scalar_type_definition
    ;




type_system_extension
    =
    schema_extension | type_extension
    ;


schema_definition
    =
    'schema' [directives] '{' {root_operation_type_definition}+ '}'
    ;


root_operation_type_definition
    =
    operation_type ':' named_type
    ;


schema_extension
    =
    | 'extend' 'schema' [directives] '{' {_operation_type_definition}+ '}'
    | 'extend' 'schema' directives
    ;

_operation_type_definition
    =
    field:operation_type_definition
;

operation_type_definition
    =
    operation_type ':' named_type
    ;


description
    =
    string_value
    ;


type_extension
    =
    | scalar_type_extension
    | object_type_extension
    | interface_type_extension
    | union_type_extension
    | enum_type_extension
    | input_object_type_extension
    ;


scalar_type_definition
    =
    [description] 'scalar' name [directives]
    ;


scalar_type_extension
    =
    'extends' 'scalar' name directives
    ;


object_type_definition
    =
    [description]
    'type'
    name
    [implements_interfaces]
    [directives]
    [fields_definition]
    ;


implements_interfaces
    =
    'implements' ['&'] named_type | implements_interfaces '&' named_type
    ;


fields_definition
    =
    '{' {_field_definition}+ '}'
    ;

_field_definition
    =
    field:field_definition
    ;

field_definition
    =
    [description] name [arguments_definition] ':' type_ [directives]
    | LINE_COMMENT
    ;


arguments_definition
    =
    '(' {_input_value_definition}+ ')'
    ;

_input_value_definition
    =
    field:input_value_definition
    ;

input_value_definition
    =
    [description] name ':' type_ [default_value] [directives]
    ;


object_type_extension
    =
        'extend'
        'type'
        name
        [implements_interfaces]
        [directives]
        fields_definition
    |
        'extend' 'type' name [implements_interfaces] directives
    |
        'extend' 'type' name implements_interfaces
    ;


interface_type_definition
    =
    [description] 'interface' name [directives] [fields_definition]
    ;


interface_type_extension
    =
    | 'extend' 'interface' name [directives] fields_definition
    | 'extend' 'interface' name directives
    ;


union_type_definition
    =
    [description] 'union' name [directives] [union_member_types]
    ;


union_member_types
    =
    '=' ['|'] named_type {'|' named_type}
    ;


union_type_extension
    =
    | 'extend' 'union' name [directives] union_member_types
    | 'extend' 'union' name directives
    ;


enum_type_definition
    =
    [description] 'enum' name [directives] [enum_values_definition]
    ;


enum_values_definition
    =
    '{' enum_value_definition '}'
    ;

enum_value_definition
    =
    [description] enum_value [directives]
    ;


enum_type_extension
    =
    | 'extend' 'enum' name [directives] enum_values_definition
    | 'extend' 'enum' name directives
    ;


input_object_type_definition
    =
    [description] 'input' name [directives] [input_fields_definition]
    ;


input_fields_definition
    =
    '{' {_input_value_definition}+ '}'
    ;


input_object_type_extension
    =
    | 'extend' 'input' name [directives] input_fields_definition
    | 'extend' 'input' name directives
    ;


directive_definition
    =
    [description]
    'directive'
    '@'
    name
    [arguments_definition]
    'on'
    directive_locations
    ;


directive_locations
    =
    directive_location {'|' directive_location}
    ;


directive_location
    =
    executable_directive_location | type_system_directive_location
    ;


executable_directive_location
    =
    | 'QUERY'
    | 'MUTATION'
    | 'SUBSCRIPTION'
    | 'FIELD'
    | 'FRAGMENT_DEFINITION'
    | 'FRAGMENT_SPREAD'
    | 'INLINE_FRAGMENT'
    ;


type_system_directive_location
    =
    | 'SCHEMA'
    | 'SCALAR'
    | 'OBJECT'
    | 'FIELD_DEFINITION'
    | 'ARGUMENT_DEFINITION'
    | 'INTERFACE'
    | 'UNION'
    | 'ENUM'
    | 'ENUM_VALUE'
    | 'INPUT_OBJECT'
    | 'INPUT_FIELD_DEFINITION'
    ;


name = name:_name;

_name
    =
    /[_A-Za-z][_0-9A-Za-z]*/
    ;



CHARACTER
    =
    (ESC | /[^"\\]/)
    ;


STRING
    =
    '"' {CHARACTER} '"'
    ;


BLOCK_STRING
    =
    '"""' [/\w+|\S+/] '"""'
    ;


id
    =
    STRING
    ;


ESC
    =
    '\\\\' (/[\"\\\/bfnrt]/ | UNICODE)
    ;


UNICODE
    =
    'u' HEX HEX HEX HEX
    ;


HEX
    =
    /[0-9a-fA-F]/
    ;


NONZERO_DIGIT
    =
    /[1-9]/
    ;


DIGIT
    =
    /[0-9]/
    ;


FRACTIONAL_PART
    =
    '.' {DIGIT}+
    ;


EXPONENTIAL_PART
    =
    EXPONENT_INDICATOR [SIGN] {DIGIT}+
    ;


EXPONENT_INDICATOR
    =
    /[eE]/
    ;


SIGN
    =
    /[+-]/
    ;


float
    =
    | int FRACTIONAL_PART
    | int EXPONENTIAL_PART
    | int FRACTIONAL_PART EXPONENTIAL_PART
    ;


int
    =
    ['-'] '0' | ['-'] NONZERO_DIGIT {DIGIT}
    ;


punctuator
    =
    /[!$()]/ | '...' | /[:=@[]{}|]/
    ;


EXP
    =
    /[Ee][+\-]?/ int
    ;


ws
    =
    /[ \t\n\r]+/
    ;


LINE_COMMENT
    =
    comment:_LINE_COMMENT
    ;

_LINE_COMMENT
    =
    '#' /[^\r\n]*/
    ;


unicode_bom
    =
    ('\\uEFBBBF' | '\\uFEFF' | '\\u0000FEFF')
    ;


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant