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

[eval] add -D eval-pretty-print #10963

Merged
merged 1 commit into from
Feb 9, 2023
Merged

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Feb 9, 2023

Adds -D eval-pretty-print to enable basic pretty printing of eval values (indenting on object fields).

Example output with -D eval-print-depth=10 -D eval-pretty-print

Main.hx:6: {
  pos: #pos(Main.hx:6: lines 6-8),
  expr: EBlock([{
    pos: #pos(Main.hx:7: characters 3-37),
    expr: ECall({
      pos: #pos(Main.hx:7: characters 3-26),
      expr: EField({
        pos: #pos(Main.hx:7: characters 3-21),
        expr: EField({
          pos: #pos(Main.hx:7: characters 3-17),
          expr: EField(<...>,<...>,<...>)
        },baz,Normal)
      },test,Normal)
    },[{
      pos: #pos(Main.hx:7: characters 27-36),
      expr: EArrayDecl([{
        pos: #pos(Main.hx:7: characters 28-29),
        expr: EConst(<...>)
      },{
        pos: #pos(Main.hx:7: characters 31-32),
        expr: EConst(<...>)
      },{
        pos: #pos(Main.hx:7: characters 34-35),
        expr: EConst(<...>)
      }])
    }])
  }])
}

Instead of:

Main.hx:6: {pos: #pos(Main.hx:6: lines 6-8), expr: EBlock([{pos: #pos(Main.hx:7: characters 3-37), expr: ECall({pos: #pos(Main.hx:7: characters 3-26), expr: EField({pos: #pos(Main.hx:7: characters 3-21), expr: EField({pos: #pos(Main.hx:7: characters 3-17), expr: EField(<...>,<...>,<...>)},baz,Normal)},test,Normal)},[{pos: #pos(Main.hx:7: characters 27-36), expr: EArrayDecl([{pos: #pos(Main.hx:7: characters 28-29), expr: EConst(<...>)},{pos: #pos(Main.hx:7: characters 31-32), expr: EConst(<...>)},{pos: #pos(Main.hx:7: characters 34-35), expr: EConst(<...>)}])}])}])}

It also supports an optional value setting a custom indentation string, but I didn't document it because at the moment it doesn't work well with \t (printed as-is instead of printing a tab character) which I expect people to try out..

@skial skial mentioned this pull request Feb 9, 2023
1 task
@Simn Simn merged commit 9ce3d16 into development Feb 9, 2023
@kLabz kLabz deleted the feature/eval-pretty-print branch April 24, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants