-
Notifications
You must be signed in to change notification settings - Fork 192
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
Tolerant parsing: continue parsing when a Glimmer syntax is invalid #1666
base: main
Are you sure you want to change the base?
Conversation
I started to work on the Error node thing. I hope I can post one more commit tomorrow, and you'll tell me if I am doing this right or wrong. Thanks for the first answer and recordings 👍 |
f0076f4
to
9fc1fd3
Compare
yea, for partials, that's that a very nice output! |
9fc1fd3
to
7dd1104
Compare
@NullVoxPopuli I moved a bit forward on my locale machine, and I would like to have your opinion on something. If I have this piece of code: Parsing t results to the following structure ⬇️{
"attributes": [],
"blockParams": [],
"children": [],
"comments": [],
"modifiers": [
{
"hash": {
"pairs": [],
"type": "Hash"
},
"params": [],
"path": {
"head": {
"name": "mymodifier",
"original": "mymodifier",
"type": "VarHead"
},
"original": "mymodifier",
"tail": [],
"type": "PathExpression"
},
"type": "ElementModifierStatement"
}
],
"params": [],
"path": {
"head": {
"name": "div",
"original": "div",
"type": "VarHead"
},
"original": "div",
"tail": [],
"type": "PathExpression"
},
"selfClosing": false,
"tag": "div",
"type": "ElementNode"
} Now if I have something invalid: Where do you think the error node should go in the structure? Would it belong to 1. the list of modifiers, or 2. a list |
This PR is far from ready, it simply aims at starting a discussion.
Context
When using
ember-template-lint
, any syntax error found throws aGlimmerSyntaxError
and makes the result of the lint process invalid. On a project I've been working on with @mansona, we would have needed some sort of "tolerant mode", a way to be notified about errors without blocking the linter.The current state of this PR is just a start, and aims at gathering feedbacks about the direction it should take:
PartialStatement
as an example and doesn't throw when a Handlebars partial is found, and the resulting AST template simply doesn't contain the node.Parser
seemed cleaner and less intrusive to me than trying to implement it as parse function's argument.