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.

Implement parse tree pretty-printing a la Cpp runtime in other runtimes

See original GitHub issue

The C++ runtime supports generating string representations of the parse tree in two forms: the standard all-in-one-line Lisp-ish expression, and a pretty-printed version, which splits the Lisp expression into multiple lines and indents subexpressions. None of the other runtime targets have the pretty-printing capability. It would be quite handy for human-focused results, including the unit test systems of the grammars-v4 collection.

I suggest we implement the C++ runtime behavior in all the other runtimes.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
parrtcommented, Oct 17, 2022

I have to generate json from parse trees to serialize across socket from server to client for antlr lab.

0reactions
KvanTTTcommented, Oct 18, 2022

We’ve encoutered the similar issue several times:

Yes I guess it seems like there’s really no reason to add code that I will have to support for the next decade or so, when there’s no strong need.

It’s useful feature, but I consider the suggested format with a lot of confusing parentheses is confusing. I suggest using tree with indents:

parse 
 sql_stmt_list 
  sql_stmt 
   select_stmt 
    select_core 
     select    
     result_column 
      expr 
       column_name 
        any_name 
         id
     ,    
     result_column 
      expr 
       column_name 
        any_name 
         first_name
     from    
     table_or_subquery 
      table_name 
       any_name 
        users
  ;
 <EOF>

What’s a JSON generator actually? I have to admit I haven’t heard about that before.

It’s useful feature especially for client-server scenarious and other scenarios where serilization is required. Also, it’s useful for tree comparison in tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pretty printing a parse tree to std out? - c++ - Stack Overflow
I have a class Node and it has a function printSymbol() to print its symbol. It has a std::list <Node*> m_children for its...
Read more >
CSC 460/660 Compiler Construction The Compiler Project
We use a number of different symbol tables in this phase: • The Compilation parse tree node has a symbol table that holds...
Read more >
Are errors caught during the evaluation of a programming ...
A parse tree is the output of the parse phase of the language compilation, ... The important distinction between a run-time error and...
Read more >
Improving the performance of an ANTLR parser - Strumenta
Every runtime will have different performance and potential issues. Runtimes will usually follow the performance characteristics of their respective language.
Read more >
What's New - Oracle Linux Yum Server
xdg-desktop-portal-kde-5.24.6-1.el9 - Backend implementation for ... castxml-0.4.7-1.el9 - C-family abstract syntax tree XML output tool ...
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