Skip to content

Commit

Permalink
docs changes from @RyanGlScott
Browse files Browse the repository at this point in the history
  • Loading branch information
m-yac committed Nov 29, 2021
1 parent 1867938 commit 6555352
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cryptol-remote-api/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Revision history for `cryptol` Python package

## 2.12.2 -- 2021-11-19
## 2.12.2 -- YYYY-MM-DD

* Add an interface for Cryptol quasiquotation using an f-string-like syntax,
see `tests/cryptol/test_quoting` for some examples.
Expand Down
14 changes: 7 additions & 7 deletions cryptol-remote-api/python/cryptol/quoting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def to_cryptol_str(val : Union[CryptolValue, str, CryptolCode]) -> str:
"""Converts a ``CryptolValue``, string literal, or ``CryptolCode`` into
a string of cryptol syntax."""
a string of Cryptol syntax."""
if isinstance(val, bool):
return 'True' if val else 'False'
elif isinstance(val, tuple):
Expand Down Expand Up @@ -42,13 +42,13 @@ def to_cryptol_str_customf(s : str, *, frames : int = 0,
filename=filename)

def cry(s : str) -> CryptolLiteral:
"""Embed a string of cryptol syntax as ``CryptolCode``"""
"""Embed a string of Cryptol syntax as ``CryptolCode``"""
return CryptolLiteral(s)

def cry_f(s : str) -> CryptolLiteral:
"""Embed a string of cryptol syntax as ``CryptolCode``, where the given
"""Embed a string of Cryptol syntax as ``CryptolCode``, where the given
string is parsed as an f-string, and the values within brackets are
converted to cryptol syntax using ``to_cryptol_str``.
converted to Cryptol syntax using ``to_cryptol_str``.
Like f-strings, values in brackets (``{``, ``}``) are parsed as python
expressions in the caller's context of local and global variables, and
Expand All @@ -61,15 +61,15 @@ def cry_f(s : str) -> CryptolLiteral:
When formatting Cryptol, it is recomended to use this function rather
than any of python's built-in methods of string formatting (e.g.
f-strings, ``str.format``) as the latter will not always produce valid
cryptol syntax. Specifically, this function differs from these methods
Cryptol syntax. Specifically, this function differs from these methods
in the cases of ``BV``s, string literals, function application (this
function will add parentheses as needed), and dicts. For example,
``cry_f('{ {"x": 5, "y": 4} }')`` equals ``cry('{x = 5, y = 4}')``
but ``f'{ {"x": 5, "y": 4} }'`` equals ``'{"x": 5, "y": 4}'``. Only
the former is valid cryptol syntax for a record.
the former is valid Cryptol syntax for a record.
Note that any conversion or format specifier will always result in the
argument being rendered as a cryptol string literal with the conversion
argument being rendered as a Cryptol string literal with the conversion
and/or formating applied. For example, `cry('f {5}')` is equal to
``cry('f 5')`` but ``cry_f('f {5!s}')`` is equal to ``cry(`f "5"`)``
and ``cry_f('f {5:+.2%}')`` is equal to ``cry('f "+500.00%"')``.
Expand Down

0 comments on commit 6555352

Please sign in to comment.