-
Notifications
You must be signed in to change notification settings - Fork 52
feat(parser): improve rule detection, inline recipe parsing, and PHONY handling #184
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
Conversation
|
This covers most of the complains in #61 but parser still has limitations and a different approach might be needed. |
4d37ef4 to
8730380
Compare
|
With latest changes:
|
8730380 to
4db823a
Compare
|
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 <mikel@olasagasti.info>
fcef697 to
1cbeee0
Compare
|
As this PR improves detection multi-line recipe bodies, it causes Now: Before: |
obnoxxx
left a comment
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.
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 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.