-
Notifications
You must be signed in to change notification settings - Fork 51
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
Accept top level statements #177
Conversation
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.
Please add some tests in corpus/ and regenerate the parser.c and other files
grammar.js
Outdated
)), | ||
// accept statements at top-level to enable | ||
// parsing of partial code snippets (e.g, in markdown; see #168). | ||
optional(repeat($._statement)), |
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'm not sure the statement will actually be parsed because of the optional($.text) at the top that may "eat" every tokens.
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.
Hmmm...you're right, I tried moving this line to the top of the program
but the text still swallows everything up (see failing test)
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 more complicated than I originally thought....do you have any idea on how to allow top-level statement parsing for injected code snippets while still allowing HTML?
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.
No. Maybe @maxbrunsfeld knows
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.
Might need to create another parser that only parses PHP, say phpo
(for php-only), similar to the markdown
and markdown-inline
parsers.
acb0f7c
to
2ed6877
Compare
2ed6877
to
8def205
Compare
Closing as accepting top level statements is not possible with this parser in its current state: the As mentioned in the above comment, the solution is probably to create two separate parsers in this repo (similar to the markdown parser), one which is |
Closes #168
Checklist: