-
Notifications
You must be signed in to change notification settings - Fork 485
[Textual] Parse constants with parens #7391
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Changed | ||
|
|
||
| - In #7391 made the parser accept constants with extra parens in them, e.g. `(con (list data) [(I 0), (B #1234)])`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ import Data.Text qualified as T | |
| import Data.Text.Internal.Read (hexDigitToInt) | ||
| import Data.Vector.Strict (Vector) | ||
| import Data.Vector.Strict qualified as Vector | ||
| import Text.Megaparsec (customFailure, getSourcePos, takeWhileP) | ||
| import Text.Megaparsec (customFailure, getSourcePos, takeWhileP, try) | ||
| import Text.Megaparsec.Char (char, hexDigitChar, string) | ||
| import Text.Megaparsec.Char.Lexer qualified as Lex | ||
|
|
||
|
|
@@ -145,7 +145,7 @@ conBLS12_381_G2_Element = do | |
| -- | Parser for constants of the given type. | ||
| constantOf :: ExpectParens -> DefaultUni (Esc a) -> Parser a | ||
| constantOf expectParens uni = | ||
| case uni of | ||
| try (trailingWhitespace . inParens $ constantOf ExpectParensNo uni) <|> case uni of | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This now accepts and Do we really want that?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the prettyprinter still prints list elements without parentheses. I suppose we have to choose one way or the other, so that seems fine. |
||
| DefaultUniInteger -> conInteger | ||
| DefaultUniByteString -> conBS | ||
| DefaultUniString -> conText | ||
|
|
||
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 think the
expectParensparameter is useless now?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.
Nope, we still can't allow
(con data I 42), it has to be(con data (I 42)).While
(con (list data) [I 42])is fine.So the distinction still exists.