You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sauclovian-g opened this issue
Jan 20, 2025
· 2 comments
Assignees
Labels
tech debtIssues that document or involve technical debttype: bugIssues reporting bugs or unexpected/unwanted behaviorusabilityAn issue that impedes efficient understanding and use
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:
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)
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.
The text was updated successfully, but these errors were encountered:
(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.
Relatedly, if the logic in an embedded Cryptol block has multiple close-braces of its own, they need to be separated by spaces so the saw-script lexer doesn't see them as the }} ending the block. This could be fixed by counting braces, but not in lexer states; it would need something more like the current comment-skipping logic. It's not clear how workable that would be for tokens where we need the text.
A similar effect happens with string literals. The behavior of " /* " */ is the same (unexpected /) but unlike with Cryptol blocks this is consistent with expectations -- the comment character is within the string, it shouldn't comment anything out. However, the behavior of / " */ " is not: the */ is within the commented-out string so it doesn't function as an end-comment, and we get "unclosed block comment".
tech debtIssues that document or involve technical debttype: bugIssues reporting bugs or unexpected/unwanted behaviorusabilityAn issue that impedes efficient understanding and use
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:
and
(the
}}
and after is not commented out)and
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.
The text was updated successfully, but these errors were encountered: