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 for string constant tokens in notations #17123
Support for string constant tokens in notations #17123
Conversation
abe6804
to
a302351
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of this feature, though I agree it's unclear how often it'd be used in practice.
Certainly deserves a changelog
a302351
to
f828223
Compare
Would you add some description in the documentation? |
I will, once I have a confirmation from @JasonGross that my proposal to support both string constants with spaces and isolated double quotes is ok. |
@herbelin I think you got the confirmation you wanted. |
f828223
to
288c157
Compare
288c157
to
0d8080c
Compare
0d8080c
to
f814576
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wording suggestions
doc/changelog/03-notations/17123-master+support-for-string-constant-tokens-in-notations.rst
Outdated
Show resolved
Hide resolved
c3c4784
to
843318d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more tweaks
string, as e.g. in :g:`Notation "A ""an unended string B"`. What | ||
would be correct is typically :g:`Notation "A ""an ended string"" B`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string, as e.g. in :g:`Notation "A ""an unended string B"`. What | |
would be correct is typically :g:`Notation "A ""an ended string"" B`. | |
string, as e.g. in :g:`Notation "A ""an unended string B" := "x"`, for which the | |
user probably meant :g:`Notation "A ""an unended string"" B" := "x"`. |
To give complete commands (though I omit the period...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be ok to use "may" rather than "probably", here and below?
Do the examples really help actually? They somehow look a bit artificial (and complicated).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"May", "probably", either one is fine. But I agree the examples are not so helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest using Reserved Notation
instead of := "x"
, to make the examples slightly less artificial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Reserved
adopted.
:g:`Notation "A ""string""! B"` or `Notation "A ""string""!"" B"`. | ||
What would be correct are typically :g:`Notation "A ""string"""" ! B`, | ||
:g:`Notation "A ""string""""!"" B`, or :g:`Notation "A '""string""!' B`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:g:`Notation "A ""string""! B"` or `Notation "A ""string""!"" B"`. | |
What would be correct are typically :g:`Notation "A ""string"""" ! B`, | |
:g:`Notation "A ""string""""!"" B`, or :g:`Notation "A '""string""!' B`. | |
:g:`Notation "A ""string""! B"` or `Notation "A ""string""!"" B"`, for which | |
the user probably meant :g:`Notation "A ""string"""" ! B`, | |
:g:`Notation "A ""string""""!"" B`, or :g:`Notation "A '""string""!' B`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok (using "may").
9b48b54
to
843318d
Compare
string, as e.g. in :g:`Notation "A ""an unended string B"`. What | ||
would be correct is typically :g:`Notation "A ""an ended string"" B`. | ||
|
||
.. exn:: End of string not followed by a space in notation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. exn:: End of string not followed by a space in notation. | |
.. exn:: End of quoted string not followed by a space in notation. |
Clearer, I think--your choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, adopted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at the implementation this time, but I'm happy with the spec
@@ -74,8 +75,21 @@ lose their role as parameters. For example: | |||
|
|||
Notation "'IF' c1 'then' c2 'else' c3" := (c1 /\ c2 \/ ~ c1 /\ c3) (at level 200, right associativity). | |||
|
|||
Symbols that start with a single quote with 3 or more characters must be single quoted. | |||
For example, the symbol `'ab` is represented by `''ab'` in the notation string. | |||
Symbols that start with a single quote and followed by at least 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symbols that start with a single quote and followed by at least 2 | |
Symbols that start with a single quote followed by at least 2 |
or
Symbols that start with a single quote and followed by at least 2 | |
Symbols that start with a single quote and are followed by at least 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, first variant adopted.
double quotes without being strings themselves (as e.g. in symbol :g:`|"|`) but notations with such symbols can be | ||
used only for printing (see :ref:`Use of notations for printing <UseOfNotationsForPrinting>`). | ||
In this case, no spaces are allowed in the symbol. Also, if the | ||
symbol starts with a double quote, it should be surrounded with single |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symbol starts with a double quote, it should be surrounded with single | |
symbol starts with a double quote, it must be surrounded with single |
? Or else describe when it's permitted, or be clear that the confusion will only occur on the part of the users, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adopted
string, as e.g. in :g:`Notation "A ""an unended string B"`. What | ||
would be correct is typically :g:`Notation "A ""an ended string"" B`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest using Reserved Notation
instead of := "x"
, to make the examples slightly less artificial
The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed. |
This PR was not rebased after 30 days despite the warning, it is now closed. |
5fa615a
to
03c2357
Compare
Rebased, suggestions applied and test-suite fixed. |
We follow the same principle as numbers: - string constants can be used as part of notations - if parsing articulation points, string constants can be set as keywords Note that isolated double quotes, as in ``Notation "a "" b" := ...'' are (still) not permitted (they would be considered as the start of an unterminated string by the lexer). Co-authored-by: Jim Fehrle <jim.fehrle@gmail.com>
Co-authored-by: Jim Fehrle <jim.fehrle@gmail.com>
03c2357
to
71738f3
Compare
@coqbot merge now |
By uniformity with numerals, we allow string constant terminals in notations, as in:
It is unclear whether this would be really used in practice but the uniformity of treatment between numerals and strings is nice, and a step towards a more generic treatment of them.