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

Add diagnostic for pluscal labels inserted by translation #350

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

hwayne
Copy link
Contributor

@hwayne hwayne commented Nov 19, 2024

The PlusCal translator has a -reportLabels flag. When set, it will automatically add missing labels to translations and log that in the output:

pcal.trans Version 1.11 of 31 December 2020
The following label was added:
  Lbl_1 at line 16, column 5
Parsing completed.
Translation completed.

Since it's logged, we might as well tell the user about it! This PR adds an information diagnostic. Demo:

image

image

Questions:

  • Should it be a warning instead of information?
  • In the long run should the pluscal parser use some kind of state machine?

src/parsers/pluscal.ts Outdated Show resolved Hide resolved
src/parsers/pluscal.ts Outdated Show resolved Hide resolved
src/parsers/pluscal.ts Outdated Show resolved Hide resolved
return false
}

const matcher = /^\s\s([A-Za-z0-9_]+) at line (\d+), column (\d+)$/g.exec(line)
Copy link
Member

@lemmy lemmy Nov 19, 2024

Choose a reason for hiding this comment

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

Is this robust against any valid "label root" that a user may pass with -labelRoot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not. I translating with -reportLabels -labelRoot "foo!ASD bar" and it successfully translated. No diagnostic appeared.

I'd argue this is a bug in the pluscal translator, though: it produces the operator

foo!ASD bar1 ==

Which isn't valid TLA+ in the first place. The regex does accept any valid TLA+ identifier (SS 227).

Copy link
Member

Choose a reason for hiding this comment

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

Can you please open a Pcal issue?

lemmy

This comment was marked as resolved.

@lemmy lemmy added the enhancement New feature or request label Nov 19, 2024
@lemmy lemmy merged commit a3169ad into tlaplus:master Nov 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants