mike-lischke / vscode-antlr4

ANTLR4 language support for Visual Studio Code
http://www.soft-gems.net
MIT License
433 stars 60 forks source link

Interactive Debugger view #32

Open robertical opened 6 years ago

robertical commented 6 years ago

Having a textbox in where you can type and see the parsing results while typing could be very helpful. Also the other way around, in where the input text gets parsed while the grammar is being updated.

Not sure if it can be done, but it could be helpful.

mike-lischke commented 6 years ago

I'm thinking of supporting the debug console, which would allow to run the interpreter with some sample input and print the parse tree (or similar).

Not clear what you mean with your second idea however. Do you mean the input should be constantly watched while debugging and reloaded when it changes? That would be tricky because the lexing step is done completely before the parser runs. Hence when you start debugging you can no longer modify the lexer input.

robertical commented 6 years ago

The second idea is basically the same as the first one, but build and display the updated tree at the same time you update the grammar or lexer. As soon as the grammar reaches a valid state, then it updates the tree with the input value being debugged. The first idea was to build the tree when the input changes, but with this one the input remains constant and the grammar or lexer is what it is changed. Maybe even without needing to save the file.

This can be handy once you have already the grammar almost ready and you want to test altering the order of some rules or doing minor changes in the lexer or parser to see how that affects the end tree resulting from parsing an input.

Even better it could be if the parsing trees could be pinned in a separate tab so you can compare results side by side before and after the changes. This would speed up the debugging of the grammar, As sometime I find myself doing copies of the grammar in a separate file just to achieve that.