-
Notifications
You must be signed in to change notification settings - Fork 740
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
Improvements to Make lexer #1285
Conversation
\s matches newline characters which are syntacically distinct from whitespace in makefiles
Both are valid for both variable expansions and function invocations, wherever they occur.
…e, endif These can occur both inside and outside recipes (called block_body state here) without causing the recipe to end.
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.
@bavison Thanks for submitting a PR!
In addition to these comments, could you update the visual sample to include some of the syntax that should now work with this lexer? It would be good to visually confirm that's working as intended.
This is required in order to handle user-defined function definitions
This one is typically used for RISC OS makefiles. The comma is not a typo.
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 looking good! I think this might be the last thing.
Thanks for the work on this one, too, @bavison! Writing that commit message really brought home how much this is an improvement on the previous version of the lexer O_O |
This commit improves the Make lexer in the following ways: - use`\t` in place of` \s`; - support syntax variant `${}` as well as `$()`; - support all built-in functions, not just `$(shell...)`; - support include directive; - support conditional directives `ifdef`, `ifndef`, `ifeq`, `ifneq`, `else`, `endif`; - support substitution references when expanding variables; - permit macro names to start with digits; and - register additional filename extensions.
This is still far from handling the full syntax of makefiles, but it handles far more of the examples I threw at it than the previous version.
If I have one main remaining observation, it's that variable expansions and function invocations (i.e.
$(thing)
) is actually valid at any point in a makefile, but they are only being fully lexed when they occur within a recipe line. For example, in the following slightly contrived example,the only
$(shell...)
function that is differentially coloured into its component parts is the one on the penultimate line (and in fact lexing fails if you try it on the left-hand side of an assignment). By contrast, I note that GitHub's colouring above treats them all the same.I'm not sure how consistency can be efficiently achieved.