Conversation
…tests pass Co-authored-by: inducer <352067+inducer@users.noreply.github.com>
Co-authored-by: inducer <352067+inducer@users.noreply.github.com>
a1db7c3 to
16c9b71
Compare
16c9b71 to
26b54a6
Compare
There was a problem hiding this comment.
Pull request overview
Ports pycparserext to work with pycparser 3.x by replacing the old PLY-based lexer/parser integration with pycparser 3.0’s CLexer + recursive-descent CParser extension points.
Changes:
- Bump runtime requirements to
python~=3.10andpycparser>=3.0, removingply. - Rewrite GNU/OpenCL lexers as thin
CLexersubclasses that remap extension keywords to custom token types. - Rewrite GNU/OpenCL parsers as recursive-descent overrides to support attributes, asm labels/statements, GNU/OpenCL qualifiers, and GNU case ranges.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pyproject.toml |
Updates Python and dependency requirements for pycparser 3.x. |
pycparserext/ext_c_lexer.py |
Replaces PLY token rules with CLexer keyword remapping and OpenCL line-comment handling. |
pycparserext/ext_c_parser.py |
Reimplements extension parsing via recursive-descent overrides and AST extension nodes. |
.github/workflows/ci.yml |
Updates CI Python versions to align with the new minimum supported Python. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self._expect("RPAREN") | ||
| return compound | ||
| return super()._parse_primary_expression() | ||
|
|
||
| def _parse_statement(self): | ||
| tok_type = self._peek_type() | ||
| if self._is_asm_keyword_token(tok_type): |
There was a problem hiding this comment.
RangeExpression nodes created for GNU designator case ranges are missing coord information here (RangeExpression(expr, last) is called without coord), while other RangeExpression uses in this file do set coord. This results in coord=None for these nodes and makes location reporting inconsistent. Pass an appropriate coord (e.g., from the '[' token) when constructing RangeExpression in this branch.
| exprs = [self._parse_attribute()] | ||
| while self._accept("COMMA"): | ||
| exprs.append(self._parse_attribute()) | ||
| coord = exprs[0].coord if exprs else None |
There was a problem hiding this comment.
In _parse_attributes_opt, when tok is None the ExprList coord is set to self.clex.filename (a string). pycparser AST coords are expected to be Coord objects (or None), so this can break downstream code that assumes coord has file/line attributes. Consider using a Coord (e.g., self._coord(0) / self._tok_coord of the last token) or simply None for the empty list case.
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/inducer/pycparserext/sessions/d2fb57b1-f272-4ad0-9c3f-c81d8816e4a3 Co-authored-by: inducer <352067+inducer@users.noreply.github.com>
Applied both fixes in 9e5df04:
|
_parse_attributes_opt: useNonecoord instead of string when no token present_parse_designator: pass[token coord toRangeExpressionfor consistent location reportingOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.