Skip to content

Refactor node-specific flags to overlap with numeric flags #570

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

Merged
merged 1 commit into from
Jul 3, 2025

Conversation

Keno
Copy link
Member

@Keno Keno commented Jul 2, 2025

As discussed in #567, this change moves node-specific flags (TRIPLE_STRING_FLAG, PARENS_FLAG, etc.) from bits 5-6 to overlap with numeric flags in bits 8-15. This is safe because:

  1. Node types that use specific flags never use numeric flags
  2. Numeric flags are only used by ncat/nrow nodes, which don't use node-specific flags
  3. The parser now passes dimensions separately to avoid flag conflicts

This solves the problem of running out of flags space for now, but there still is a concern that we may want to tweak the representation for easy of macro manipulation. As discussed in #567, I think we should wait on that until we have some more actual code to decide on APIs. However, these changes should help in any case, since they split out the dim and the flags argument until the last moment.

This change moves node-specific flags (TRIPLE_STRING_FLAG, PARENS_FLAG, etc.)
from bits 5-6 to overlap with numeric flags in bits 8-15. This is safe because:

1. Node types that use specific flags never use numeric flags
2. Numeric flags are only used by ncat/nrow nodes, which don't use node-specific flags
3. The parser now passes dimensions separately to avoid flag conflicts

Key changes:
- Moved most node-specific flags to bit 8, some to bit 9
- Refactored parse_cat/parse_array to return dimension as a separate value
- Updated emit_braces to accept dimension parameter
- Made untokenize function head-aware for proper flag display
- Simplified flag handling by removing conditionals (just OR flags together)
- Added tests for dimension 4 ncat to ensure higher dimensions work correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

codecov bot commented Jul 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.79%. Comparing base (71320ea) to head (3c6510d).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #570      +/-   ##
==========================================
- Coverage   95.56%   94.79%   -0.78%     
==========================================
  Files          15       15              
  Lines        4441     4225     -216     
==========================================
- Hits         4244     4005     -239     
- Misses        197      220      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Keno Keno merged commit e02f29f into main Jul 3, 2025
37 of 38 checks passed
@Keno Keno deleted the kf/flagsoverlap branch July 3, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant