question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to get indented string tree

See original GitHub issue

At present time all runtimes have a method for getting result tree in lisp format toStringTree. It would be also good to have a method toStringTreeIndented. Indented output more applicable for string trees comparison (diff). See the sample output for input grammar and text below.

Grammar

grammar Test;

expression
    : <assoc=right> expression '^' expression
    | expression ('*' | '/') expression
    | expression ('+' | '-') expression
    | '(' expression ')'
    | ID
    ;
    
ID:     [a-zA-Z] [0-9a-zA-Z]*;
DIGIT:  [0-9]+;
WS:     [ \t\r\n] -> skip;

Text

a1 * (a2 + a3 + a4 - a5 ^ a6 ^ (a8 + a9 / a10)) * a11 * a12

toStringTree method

(expression (expression (expression (expression a1) * (expression ( (expression (expression (expression (expression a2) + (expression a3)) + (expression a4)) - (expression (expression a5) ^ (expression (expression a6) ^ (expression ( (expression (expression a8) + (expression (expression a9) / (expression a10))) ))))) ))) * (expression a11)) * (expression a12))

toStringTreeIndented method

(expression
  (expression
    (expression
      (expression
        'a1'
      )
      '*'
      (expression
        '('
        (expression
          (expression
            (expression
              (expression
                'a2'
              )
              '+'
              (expression
                'a3'
              )
            )
            '+'
            (expression
              'a4'
            )
          )
          '-'
          (expression
            (expression
              'a5'
            )
            '^'
            (expression
              (expression
                'a6'
              )
              '^'
              (expression
                '('
                (expression
                  (expression
                    'a8'
                  )
                  '+'
                  (expression
                    (expression
                      'a9'
                    )
                    '/'
                    (expression
                      'a10'
                    )
                  )
                )
                ')'
              )
            )
          )
        )
        ')'
      )
    )
    '*'
    (expression
      'a11'
    )
  )
  '*'
  (expression
    'a12'
  )
)

Also it is usefull to have a method that returns a tree in JSON format (tree serialization in fact).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
KvanTTTcommented, Dec 24, 2016

GUI is great, but not very comfortable for me. I am using my own tools and text editors.

0reactions
siliconvoodoocommented, Oct 19, 2018

I figured you could copy paste to emacs, go to lisp mode M-x lisp-mode. Then install https://github.com/tuhdo/semantic-refactor And run M-x srefactor-lisp-format-buffer but this package doesn’t appear in my MELPA list. so downer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guitar Shop 101: Happy Little (String) Trees
This indentation should lie exactly between the two strings. Use it as a guide for drilling the mounting screw hole.
Read more >
string - Java - Indented list from a tree - Stack Overflow
Here's a simple recursive implementation: public String toIndentedString() { StringBuilder sb = new StringBuilder(rootValue.
Read more >
String Tree Replacement - YouTube
The basic string tree on my Fender Stratocaster was causing some trouble - strings were binding on it, causing some issues with tuning ......
Read more >
String Tree Spacer Alternative - YouTube
This video is part of a series I've done on how I built my Fender Custom Shop 1962 style heavy relic Stratocaster.
Read more >
Parsing indented text into a tree structure in C# - Code Review ...
My goal is to take an input stream (text file), and then parse it into a tree node based on each line's indentation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found