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

Unexpected interaction of comments and Cryptol blocks #2189

Open
sauclovian-g opened this issue Jan 20, 2025 · 0 comments
Open

Unexpected interaction of comments and Cryptol blocks #2189

sauclovian-g opened this issue Jan 20, 2025 · 0 comments
Assignees
Labels
tech debt Issues that document or involve technical debt type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use
Milestone

Comments

@sauclovian-g
Copy link
Contributor

The saw-script lexer treats Cryptol blocks (both terms and types) as lexemes and doesn't look inside them at all. This means comments in Cryptol blocks are handled by Cryptol's lexer downstream, and that has some odd consequences:

  1. Comments that start in Cryptol blocks end at the end of the Cryptol block.
sawscript> let x = {{ /* 3 }} */
Parse error at <stdin>:1:20-1:22: Unexpected `*/'

and

sawscript> let x = ( {{ 1 // one }}, 2)
sawscript> return x
[21:06:41.173] (\(u1217 : isort 0) ->
  \(_P : PLiteral u1217) -> ecNumber (TCNum 1) u1217 _P,2)

(the }} and after is not commented out)

  1. Comments that appear to end in Cryptol blocks actually don't, because the Cryptol block is recognized even inside a comment:
sawscript> let x = /* {{ 1 */ 2 }}
<stdin>:1:9-1:11: Unclosed block comment
Parse error at <stdin>:2:1-2:1: Unexpected `EOF'

and

let x = // {{ 3
}};
"abc";

which succeeds leaves x bound to "abc".

All this is not entirely desirable, and the last behavior is definitely confusing. On the minus side it's not clear that this is fixable without rewriting the lexer with an entirely different approach.

@sauclovian-g sauclovian-g added tech debt Issues that document or involve technical debt type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use labels Jan 20, 2025
@sauclovian-g sauclovian-g added this to the Someday milestone Jan 20, 2025
@sauclovian-g sauclovian-g self-assigned this Jan 20, 2025
sauclovian-g added a commit that referenced this issue Jan 21, 2025
(interactions of comments and Cryptol blocks)

Note: these reflect the current behavior, which as discussed in the
issue is not particularly desirable. They should be updated when/if
the behavior is improved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech debt Issues that document or involve technical debt type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use
Projects
None yet
Development

No branches or pull requests

1 participant