Replies: 7 comments 11 replies
-
Ugh. Somebody should then mimic for other runtimes :( |
Beta Was this translation helpful? Give feedback.
-
Similar issue: #233 But I think dependency is not needed for such a straitforward task. Parse tree contains small number of node types. Moreover, JSON should be equal for all runtimes, tests are required. |
Beta Was this translation helpful? Give feedback.
-
@KvanTTT brought up using indexes for token nodes only, no text. makes sense since we need to serialize tokens too. Hmm...how about rulenames? Should they be just rule indexes in json tree? trees look like |
Beta Was this translation helpful? Give feedback.
-
Ok, @KvanTTT now it looks like:
|
Beta Was this translation helpful? Give feedback.
-
This is exploding beyond my initial thoughts haha |
Beta Was this translation helpful? Give feedback.
-
Python to load and dump:
From parse tree:
we get:
From input: and grammar:
|
Beta Was this translation helpful? Give feedback.
-
Is it necessary to include such functionality to ANTLR core now? I don't like the situation when one runtime implements functionality, but other not. |
Beta Was this translation helpful? Give feedback.
-
I need to gen json from parse tree for my antlr server. Should we include in antlr runtime? It adds dependency unless we generate json text manually (easy enough). Test currently depend on:
No matter what we need field name, structure etc...
Hmm..i'll add to Trees class so I don't break backward compatibility by adding method to ParseTree.
Ok, simple enough; just a tweak to toStringTree(). See:
#3773
JSON output from
1+2
for grammar:looks like:
Beta Was this translation helpful? Give feedback.
All reactions