Skip to content

Custom methods and initialization in the lexer and parser classes #14

@sebastianriese

Description

@sebastianriese

It would be nice if it were possible to define custom methods and custom initialization code in the lexer and parser classes. It is often useful to factor out common code from productions currently one can define functions in the %footer section, but often it would be better/cleaner if they were methods of the Parser class. Additionally often the interesting result of a parse is the assembly of a structure, which is done by method calls on the resulting object and not the semantic value of the root node. Also the %function lexaction better were a %method lexaction.

Current Workaround: Just use the methods in the actions, use derived classes of Lexer and Parser which have the init code and supply the methods.

Another Possible workaround: use stupid and complete %AST generation and derive a visitor accordingly. This may be desirable for building up legacy structures anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions