Skip to content

Feature request: Using subparsers #24

@jonahbeckford

Description

@jonahbeckford

I'm embedding sublanguages (ex. POSIX shell commands) inside a parent language (ex. JSON). I didn't see a natural way to do this so implemented the following:

https://gitlab.com/dkml/build-tools/MlFront/-/blob/d6735dca8f0580584d5ba36feaf02dafb8cb68c4/src/MlFront_Thunk/ThunkParsers.ml#L351-L524

and made the lexer configuration driven:

https://gitlab.com/dkml/build-tools/MlFront/-/blob/d6735dca8f0580584d5ba36feaf02dafb8cb68c4/src/MlFront_Thunk/ThunkLexers.ml#L326-L379

and finally did the embedding here:

https://gitlab.com/dkml/build-tools/MlFront/-/blob/d6735dca8f0580584d5ba36feaf02dafb8cb68c4/src/MlFront_Thunk/ThunkCommand.ml#L1028-L1047

It works, but I suspect that there may be a better pattern for this.

Random factoid: The JSON parser inside ThunkParsers and ThunkLexers was based initially on your JSON parser example, but should now fully implement the JSON spec.

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