Skip to content

Add options to the kore term pretty printer #3963

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

Merged
merged 8 commits into from
Jun 28, 2024

Conversation

goodlyrottenapple
Copy link
Contributor

@goodlyrottenapple goodlyrottenapple commented Jun 25, 2024

Add the following options when pretty printing terms:

  • decode - decode symbol labels and strip the Lbl prefix
  • truncate - truncate long domain values
  • infix - try to re-assemble infix notation from the holes in label syntax (may not always be correct). For example:
    ... Uncertain about match with rule. Remainder: #range( Eq#VarB1:SortBytes{} , Eq#VarS2:SortInt{} , Eq#VarW2:SortInt{} ) == buf("32", lookup(VarCONTRACT-FAKEETH_STORAGE:SortMap{}, keccak( buf("32", VarCALLER_ID:SortInt{}) +Bytes "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL" ))), #range( Eq#VarB1:SortBytes{} , Eq#VarS1:SortInt{} , Eq#VarW1:SortInt{} ) == buf("32", lookup(VarCONTRACT-FAKEETH_STORAGE:SortMap{}, keccak( buf("32", VarCONTRACT_ID:SortInt{}) +Bytes buf("32", keccak( buf("32", VarCALLER_ID:SortInt{}) +Bytes "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH" )) )))
    

These can now be passed to the server via the --pretty-print flag. E.g. --pretty-print truncated,decode will preserve current behaviour (and is set as default when no explicit option is provided)

@goodlyrottenapple goodlyrottenapple marked this pull request as ready for review June 26, 2024 05:14
Copy link
Member

@jberthold jberthold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly worried about the maintenance of this (very neat!) code...
@geo2a what do you think?

The other option would be to create a separate Pretty class that takes parameters that are brought in by PrettyWithModifiers here

Copy link
Contributor

@geo2a geo2a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fine to maintain @jberthold. Thanks @goodlyrottenapple!

@rv-jenkins rv-jenkins merged commit baa73d3 into master Jun 28, 2024
6 checks passed
@rv-jenkins rv-jenkins deleted the sam/prettyprinter-options branch June 28, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants