Skip to content

Use case for dependencies #63

@khinsen

Description

@khinsen

The guide for migration from PetitParser says "I am not aware of any use-case for dependencies, so I didn’t migrated the functionality." I think I have just hit such a use case, which I will summarize below. If there is a good way to deal with this in PetitParser2, I'd appreciate suggestions.

I have a grammar for "terms" in my language, and also a parser that generates the internal representation, implemented as a subclass, exactly like in the example from the tutorial. My plan is to have another subclass of the grammar for implementing syntax highlighting by generating "roped text" objects for use in Bloc (inside Glamorous Toolkit). So far, no problem.

But I also have higher-level syntactic structures that contain terms. This is where I would use dependencies in PetitParser. Without dependencies, I had to use subclassing (example) to include my term parser into my rule parser. But that means I cannot have a separate grammar for my rules, which I could then also use for syntax highlighting. I can use subclassing either for specializing a grammar to a parser, or for extending a parser to a higher-level syntactic structure, but not for both.

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