feat(parser): improve rule detection, inline recipe parsing, and PHONY handling#184
Merged
mikelolasagasti merged 1 commit intocheckmake:mainfrom Nov 4, 2025
Merged
Conversation
Collaborator
Author
|
This covers most of the complains in #61 but parser still has limitations and a different approach might be needed. |
4d37ef4 to
8730380
Compare
Collaborator
Author
|
With latest changes:
|
8730380 to
4db823a
Compare
Collaborator
Author
|
With latest changes:
|
f9b35e7 to
fcef697
Compare
…Y handling
This patch significantly improves the Makefile parser and related rules:
- Parser:
- Support targets with special characters, patterns, and variables
(`%.o`, `file.ext`, `$(DIR_VAR)`, `${DIR_VAR}/subdir`)
- Add handling for inline recipes (`target: deps ; command`)
- Recognize multiple-target rules (`target1 target2 : dep`)
- Treat `.PHONY` and `.DEFAULT_GOAL` as rules (not variables)
- Extend variable parsing to support `?=`, `!=`, and `+=` operators
- Add detailed debug logging for ambiguous lines
- Rules:
- Update `phonydeclared` and `minphony` to support both parser modes
(old `.PHONY` as variable and new `.PHONY` as rule)
- Remove legacy off-by-one adjustment on PHONY line numbers. Fixes
inaccurate violation line reporting (+1 line shift)
- Preserve fallback to -1 when PHONY is missing
- Tests:
- Add new parser coverage for:
- Inline recipes
- Variable and pattern targets
- Special characters, multiple targets, and file extensions
- Other variable assignments (`?=`, `!=`, `+=`)
- Adjust expected violation line numbers (from 21 to 22) for accurate
reporting
- Confirm full backward compatibility with existing fixtures
- Skip `.PHONY` for uniquetargets rule as multiple entries is valid
Overall, this modernizes the Makefile parser for complex rule syntax
and brings line number reporting in sync with actual source positions.
Signed-off-by: Mikel Olasagasti Uranga <[email protected]>
fcef697 to
1cbeee0
Compare
Collaborator
Author
|
As this PR improves detection multi-line recipe bodies, it causes Now: Before: |
obnoxxx
reviewed
Oct 29, 2025
Collaborator
obnoxxx
left a comment
There was a problem hiding this comment.
Thanks for this PR, @mikelolasagasti !
This looks like a useful set of changes.
I would personally prefer to split this into multiple commits: one for each logical/conceptual change.
But feel free to merge it as it is if you prefer that.
This was
linked to
issues
Oct 29, 2025
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch significantly improves the Makefile parser and related rules:
Parser:
%.o,file.ext,$(DIR_VAR),${DIR_VAR}/subdir)target: deps ; command)target1 target2 : dep).PHONYand.DEFAULT_GOALas rules (not variables)?=,!=, and+=operatorsRules:
phonydeclaredandminphonyto support both parser modes (old.PHONYas variable and new.PHONYas rule)Tests:
?=,!=,+=)Overall, this modernizes the Makefile parser for complex rule syntax and brings line number reporting in sync with actual source positions.
Checklist
Not all of these might apply to your change but the more you are able to check
the easier it will be to get your contribution merged.