-
Notifications
You must be signed in to change notification settings - Fork 87
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
Provide reservedWord
parser?
#334
Comments
Well, the amount of code you copy-paste is not that big, and different languages have different syntax with respect to what is considered identifier. So even if we add it, it'll have to take at least two parameters already, so it's really easier to simply "inline" them and have your own definition. My opinion is that this is just too-specific to a given language and won't help much if we add it to the library. |
@mrkkrp thanks for quick response, however i have to disagree - your point is applicable to any function in Text.Megaparsec.Lexer. All of them take more than two parameters and (arguably) all of them are shorter than proposed parser and some of them more or less language-specific. |
Is your
This is what keywords looked like:
The only place we ended up using a list of reserved words was in parsing identifiers:
(If we were more responsible, we'd use a set instead of a list here >.>) I'm not sure this is the best approach, but it worked well for us and did not require us to write much extra code. |
Not really. If i understand correctly - you and your coallegue are mixing lexing and parsing together, while i prefer to separate these phases - write dumb lexer to get So basically |
I'm going to close this one. I'm not a fan of this new function, but if you absolutely want it, I think we could merge a PR implementing it. |
* [mrkkrp#323] Add a JSON output format Resolves mrkkrp#323 * Update CHANGELOG * Fix Stack build
Hi, i'm mainly using Megaparsec for toy languages and was wondering why it doesn't provide some kind of parser for reserved words? I think it would nicely fit into lexer module.
Tutorial even provides a example implementation:
Can we get that into library so i could stop copypasting it everywhere?
The text was updated successfully, but these errors were encountered: