Skip to content
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

Support nested categories #22

Merged
merged 16 commits into from
Oct 22, 2024

Conversation

sungshik
Copy link
Collaborator

@sungshik sungshik commented Oct 9, 2024

This PR adds support for nested categories to the converter. Concretely:

  • There is a new module lang::rascal::grammar::analyze::Categories that has some functions to analyze which categories might be active for each production
  • There is a new test module to test combinations of nested categories

Also:

  • One function was renamed (new name: prodsOf) to make its name more consistent with another new function. It's used throughout the project, though, so there are a few extra files changed because of this.
  • I enabled "Trim Trailing Whitespace", so maybe better to turn off whitespace in the diffs.

@sungshik sungshik force-pushed the ignore-category-production-inside-category-production branch from 7dbad78 to eb9b78a Compare October 9, 2024 07:45
? true
: any(p <- prodsOf(g, delabel(s)),
/Symbol child := p.symbols,
isRecursive(g, child, checking = checking + s));

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a refactoring to make the code simpler (no more nested functions)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

it can also be written as:

= s in checking || any(...)

Copy link
Collaborator Author

@sungshik sungshik Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new tests check the intended highlighting when four symbols with/without categories are organized in a diamond like this:

  A
 / \
B   C
 \ /
  D

The .rsc file defines the grammar; the .test file (below) checks the tokenizations

@sungshik sungshik marked this pull request as ready for review October 9, 2024 12:19
@DavyLandman
Copy link
Member

I enabled "Trim Trailing Whitespace", so maybe better to turn off whitespace in the diffs.

please commit an editor config file (and mark it as a suggested extension in the .vscode folder

? true
: any(p <- prodsOf(g, delabel(s)),
/Symbol child := p.symbols,
isRecursive(g, child, checking = checking + s));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

it can also be written as:

= s in checking || any(...)

lexical C12 = D12 [\ ] "baz12";
lexical D12 = "foo12";

Grammar rsc = preprocess(grammar(#Start));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch, what a grammar 🗡️

@sungshik sungshik merged commit 5c325a5 into main Oct 22, 2024
2 checks passed
@sungshik sungshik deleted the ignore-category-production-inside-category-production branch October 22, 2024 08:40
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.

2 participants