-
Notifications
You must be signed in to change notification settings - Fork 66
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
Proposal: default token types #98
Conversation
Sounds great to me, this will make the parsing of my text based language a lot easier. Two things:
|
AFAIK the de facto rule is to do that conservatively or not at all when the exports don't contain
No; this matches the behavior of |
This is a great idea! I'll need to think about the name. 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great; thank you for writing it!
I'm concerned it makes things a bit more complicated, but I think that's okay; I'd just like to review it carefully.
Could we try renaming default
to fallback
? I'll then have a good look at this! 🙌
moo.js
Outdated
value: null, | ||
getType: null, | ||
shouldThrow: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have both shouldThrow
and error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error
is like fallback
but it consumes until the end of the buffer instead of just to the next valid token. shouldThrow
throws a syntax error instead of returning the error token.
moo.js
Outdated
var suffix = hasSticky ? '' : '|(?:)' | ||
var flags = hasSticky ? 'ym' : 'gm' | ||
var defaultRule = errorRule && errorRule.default | ||
var suffix = hasSticky || defaultRule ? '' : '|(?:)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I note this will conflict with your other PR 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased.
moo.js
Outdated
@@ -271,6 +277,8 @@ | |||
line: this.line, | |||
col: this.col, | |||
state: this.state, | |||
queued: this.queued, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: I think I'd prefer queuedToken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
@@ -123,6 +125,7 @@ | |||
return options | |||
} | |||
|
|||
var defaultErrorRule = ruleOptions('error', {lineBreaks: true, shouldThrow: true}) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
It doesn't appear in other error messages
Just to confirm: will Sent with GitHawk |
@tjvr No. The |
I love how simple this is. ❤️ |
Just tested this on my codebase, it's working as intended. |
Upon further consideration, #88 seems like a good idea. Markdown(ish) syntaxes are the obvious motivating example: arbitrary text with certain embedded sequences have special meanings, and incomplete special sequences should be passed through verbatim.
@tjvr Feel free to bikeshed the name. (
fill
might be better?)