-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Generate lexical information of Pair
and Pairs
as JSON
#381
Conversation
(sigh, why must unit tests still not count for coverage...) A few drive-by notes:
|
Oh, I see. Well, in order to have full control over pretty printing, there is also the possibility of using
Well, I personally think that would add too much complexity, because in order to be able to call
Well, if you prefer I could make a local enum for it, I just thought it wasn't worth the effort in this case. |
Yeah; I'd potentially go so far as to just do the
Yep, the solution here is great for this.
I'd feel better with a |
What's the current status of this pr? |
Can there be a |
One usage can be in my IDE plugin: on-the-fly syntax highlighting your code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. This looks fine, especially given that it's behind a flag. Thanks a lot!
bors r+
381: Generate lexical information of `Pair` and `Pairs` as JSON r=dragostis a=Goncalerta Closes #377 Implements the `to_json` function for both `Pair` and `Pairs` which generates a pretty-printed JSON that contains their information. I followed the sketch given in #377, but I wonder if instead of `"pos": [start, end]` it would be better to have `"start"` and `"end"` as separate fields, as in pretty-printed format I personally find it easier to read with less nesting. This is the generated string right now: ``` { "pos": [ 0, 5 ], "pairs": [ { "pos": [ 0, 3 ], "rule": "a", "inner": { "pos": [ 1, 2 ], "pairs": [ { "pos": [ 1, 2 ], "rule": "b", "inner": "b" } ] } }, { "pos": [ 4, 5 ], "rule": "c", "inner": "e" } ] } ``` This would be with `"start"` and `"end"`: ``` { "start": 0, "end": 5, "pairs": [ { "start": 0, "end": 3, "rule": "a", "inner": { "start": 1, "end": 2, "pairs": [ { "start": 1, "end": 2, "rule": "b", "inner": "b" } ] } }, { "start": 4, "end": 5, "rule": "c", "inner": "e" } ] } ``` Co-authored-by: PedroGonçaloCorreia <[email protected]>
Build succeeded |
Closes #377
Implements the
to_json
function for bothPair
andPairs
which generates a pretty-printed JSON that contains their information.I followed the sketch given in #377, but I wonder if instead of
"pos": [start, end]
it would be better to have"start"
and"end"
as separate fields, as in pretty-printed format I personally find it easier to read with less nesting.This is the generated string right now:
This would be with
"start"
and"end"
: