Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseError thrown from TokenGrammar can't be printed #171

Closed
boringcactus opened this issue Oct 14, 2020 · 2 comments · Fixed by #203
Closed

ParseError thrown from TokenGrammar can't be printed #171

boringcactus opened this issue Oct 14, 2020 · 2 comments · Fixed by #203

Comments

@boringcactus
Copy link

I'm using Parsimonious to implement the reference compiler for a language I'm working on, and in the absence of maximally-Unicode-expressive regular expression support (would be fixed by #162 or eventually abandoning regular expressions for something more well-scoped) I'd like to use a custom tokenizer and the TokenGrammar class. However, the __str__ method on ParseError assumes its text property is a string rather than a token sequence: https://github.com/erikrose/parsimonious/blob/master/parsimonious/exceptions.py#L35

I'm not quite sure how this should be fixed, but it does make debugging and error reporting more difficult.

@habnabit
Copy link

I see at least currently you're using a custom tokenizer and parsimonius as a sequence matcher on top of that.. how is that approach? https://git.sr.ht/~boringcactus/crowbar-reference-compiler/tree/main/item/crowbar_reference_compiler/parser.py

I too want better tokenization than parsimonious seems capable of, and what you have there seems reasonable for your tasks, but I was hoping for a smaller solution for a smaller project.

@boringcactus
Copy link
Author

@habnabit that approach worked fine for that project, but i had to be extra sure my regexes were getting tested in the right order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants