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

Generate proper precede requirement based on layout follow restriction #9

Merged
merged 8 commits into from
Aug 23, 2024

Conversation

DavyLandman
Copy link
Member

I noticed that on rascal we were getting stuff like int aer32 = 34 where 32 was highlighted as a number.

I got around that by using the \b separator, and rewriting the grammar a bit while doing it. It might be a worthy inspiration, but just parking it here.

@DavyLandman DavyLandman requested a review from sungshik July 22, 2024 14:23
@DavyLandman
Copy link
Member Author

In the middle of the night, while in vacation my mind suddenly jumped to: we shouldn't use \b but detect if a lexical is only used in a syntax rule, and if so, use some heuristics to detect a correct precede clause. And otherwise a user of the library has to give that character class as an argument.

@sungshik
Copy link
Collaborator

sungshik commented Aug 21, 2024

Hm, something is not quite right yet. One moment...

Fixed in the subsequent two commits.

Copy link
Collaborator

@sungshik sungshik left a comment

Choose a reason for hiding this comment

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

Hi Davy, I think this PR is now ready for review by you. The commit messages should provide a high-level summary of what changed.

I've tried to isolate the changes in a way that avoids merge conflicts with the other open branches. Notably, there's a new module with functions to compute first/last/precede/follow sets. I reckon other parts of the analysis code can be simplified a bit by using this new module, but let's do that in a separate smaller PR, when the other open branches are merged (I left a TODO in the code so as not to forget).

@DavyLandman DavyLandman changed the title Manually rewrote rascal grammar to get better highlights Generate proper precede requirement based on layout follow restriction Aug 22, 2024
? union(\set, firstOf(t))
: ret[delabel(h)];
solve (ret) {
Copy link
Member Author

Choose a reason for hiding this comment

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

nit: solve returns the solved value, so this can become: return solve(ret)...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I played a bit with this just now, but it seems solve doesn't always return a value (it doesn't in the cases of this PR). I submitted an issue basically to update the docs (it seems by design instead of a bug).

@DavyLandman
Copy link
Member Author

LGTM, @sungshik

@sungshik sungshik merged commit 6df491d into main Aug 23, 2024
2 checks passed
@sungshik sungshik deleted the better-rascal-grammar branch August 23, 2024 08:43
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