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

Cryptol record parsing incorrect? #704

Closed
weaversa opened this issue May 7, 2020 · 2 comments
Closed

Cryptol record parsing incorrect? #704

weaversa opened this issue May 7, 2020 · 2 comments
Labels
type: bug Issues reporting bugs or unexpected/unwanted behavior

Comments

@weaversa
Copy link
Contributor

weaversa commented May 7, 2020

Is saw miscounting curly braces? The cryptol interpreter seems to think everything is ok.

sawscript> print {{ {x=10, y=1} }}
[19:41:28.566] Assuming a = Integer
[19:41:28.566] Assuming b = Integer
[19:41:28.567] {x = 10, y = 1}
sawscript> print {{ {x=10, y={a=1, b=2}} }}
Parse error at <stdin>:1:31-1:32: Unexpected `}'
sawscript> print {{ {x=10, y={a=1, b=2} }}

user error (Cryptol parse error:
Parse error at <stdin>:2:0,
  unexpected: end of file)
Cryptol> {x=10, y=11}
Showing a specific instance of polymorphic result:
  * Using 'Integer' for type of field 'x'
  * Using 'Integer' for type of field 'y'
{x = 10, y = 11}
Cryptol> {x=10, y={a=1, b=2}}
Showing a specific instance of polymorphic result:
  * Using 'Integer' for type of field 'x'
  * Using 'Integer' for type of field 'a'
  * Using 'Integer' for type of field 'b'
{x = 10, y = {a = 1, b = 2}}
@weaversa weaversa added the type: bug Issues reporting bugs or unexpected/unwanted behavior label May 7, 2020
@brianhuffman
Copy link
Contributor

The saw-script lexer treats any occurrence of }} as the end of the Cryptol quotes. As a workaround you'll need to put a space between the two close braces in your embedded Cryptol, like this:

print {{ {x=10, y={a=1, b=2} } }}

instead of this:

print {{ {x=10, y={a=1, b=2}} }}

As for alternatives, we could:

  • Change the saw-script cryptol quotes from {{ }} to some other combination that can't occur in valid cryptol code. However this would be a major breaking change (very unwise).
  • Make the saw-script lexer count open braces in embedded cryptol syntax, and don't look for the closing }} until all internal braces are matched. A naive implementation of this rule would have problems if your cryptol code included a quoted string containing unmatched { or } characters, though, so we'd have to make the saw-script lexer pretty sophisticated.

@weaversa
Copy link
Contributor Author

weaversa commented May 8, 2020

@brianhuffman Thanks for discovering what's going on. I feel that as long as the limitations of the parser are documented somewhere (maybe this ticket is good enough) and there's an easy workaround, then we can move on.

@weaversa weaversa closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

No branches or pull requests

2 participants