Skip to content

.mark() with a filename #82

@tsani

Description

@tsani

I'm parsing a simple programming language with parsy. During parsing, I equip syntax tree nodes with their position in the file using .mark(), but this doesn't capture the filename. Then I encounter an issue when raising errors during runtime, as the reported error location doesn't mention a filename.

A workaround I can see but find extremely inelegant would be to traverse the whole syntax tree after parsing a file to equip all the nodes' locations with the right filename.

Would it make sense to augment .parse() to take an optional filename to thread through the parser? This would allow the filename to be mentioned in ParseErrors, but also via new combinator like .mark_file() for my use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions