Skip to content

Python keywords as rule name #48

@ghost

Description

It is not possible to use grammars that contain any Python keywords as rule name.

Consider the following ANTLR grammar:

grammar keyword;
start: False;
False: 'anything';`

This wil procude the keywordGenerator.py with the following function:

    @depthcontrol
    def False(self, parent=None):
        current = UnlexerRule(name='False', parent=parent)
        self._enter_rule(current)
        UnlexerRule(src='anything', parent=current)
        self._exit_rule(current)
        return current
    False.min_depth = 0

Because False is a reserved keyword in Python this is not valid Python code.
The bug occurs with every keyword.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions