graphically browse s-expression output from antlr4 - antlr

Is there a way to take the S-Expression output from Antlr4 and display it graphically as a treeview in Windows 10?
here's my grammar file for antlr4:
https://github.com/antlr/grammars-v4/blob/master/vhdl/vhdl.g4
here's my vhdl program to parse with antrl4:
entity testbench is
end entity;
architecture beh of testbench is
begin
end architecture;
Here's my S-Expression Output from Antlr4 for the vhdl file:
(design_file (design_unit context_clause (library_unit (primary_unit
(entity_declaration entity
(identifier testbench) is entity_header entity_declarative_part end entity ;))))
(design_unit context_clause (library_unit
(secondary_unit (architecture_body architecture (identifier beh) of
(identifier testbench) is architecture_declarative_part
begin architecture_statement_part end architecture ;)))) <EOF>)
I want to see the s-expression output from antlr in a treeview with collapable nodes, something like this:
https://www.c-sharpcorner.com/article/treeview-control-in-C-Sharp/
Is there a windows 10 program for graphically browsing the s-expressions output of antrl4 as a graphical treeview?
Ideally I want something that reads the antrl s-expressions generated by -tree flag, and the tokens list generated by -tokens flag, and merges them together for display in a GUI treeview so that when i click on a node of the s-expression in the tree and i get the information in the token file as well...

For Java target, use Trees.inspect(tree, parser). It'll pop up a window with the tree view. Or use Intellij/jetbrains plugin

Related

Pocketspinx, russian language and keywordspotting

The goal is:
Control smart house via predefined text commands. Without any activation word like okay google, it always listening.
What's done:
pocketsphinx_continuous -inmic yes -hmm /path/zero_ru.cd_cont_4000 -dict /path/my_dictionary_out -lm /path/lmbase.lm.DMP
Where my_dictionary_out has using words one by one. And it works, but I think KWS mode might be better. So I've written a text file like:
включи свет комнате /1e-50/
выключи свет комнате /1e-50/
and trying to run sphinx without language model (-lm option), but got nothing. It doesn't recognize commands from keywords file.
What's wrong?

Finete State machine visualizer

I need an application that prints/visualizes input/output pairs during the FST runs. I mean, for each state of the fst, it needs to print out a tuple that contains input for that state and output of the state. Right now I can generate fst files that is compatible with foma,hfst and xfst fst tools. So, I guess the visualization tool I need should be enough to compatible with any of them. Is there anyone who knows such a tool ?
foma can produce dot format files that can be visualized by graphviz. On Debian/Ubuntu, install graphviz with
$ sudo apt-get install graphviz
foma can read att format files (produced with hfst-fst2txt for anything HFST can read, or lt-print for anything from lttoolbox); assuming you've got such a file named myfst.att, you can do
$ foma
foma[0]: read att myfst.att
foma[1]: view
to display the full FST. That will show each input/output pair on each edge between states of the FST.
But you say "during runs" – are you talking about also showing the queue of "live states"? If so, I don't know of a tool that does this, that would be nice! One thing you could do is to modify the HFST source to output the list of live states and string vectors as it's processing, and then combine that with the dot file to e.g. colour in the live states. (If so, you may want to take this to the #hfst channel on irc.freenode.net.)
There is also a script att2dot.py on https://ftyers.github.io/2017-%D0%9A%D0%9B_%D0%9C%D0%9A%D0%9B/hfst.html that can be used on the command line like
hfst-fst2txt chv.lexc.hfst | python3 att2dot.py | dot -Tpng -ochv.lexc.png if you prefer something more scriptable. If you use that from the Python library of HFST, you might be able to get the "live states" for every part of an analysis more easily.

How to run post-synthesis simulation with the IceStorm iCE40 FPGA flow

It is good design practice to not only verify Verilog designs with regular pre-synthesis (behavioral) simulation, but also using post-synthesis simulation. This is practically mandatory when debugging mismatches between simulation and hardware. How can this be achieved with the open source IceStorm flow for iCE40 FPGAs?
See https://github.com/cliffordwolf/icestorm/tree/master/examples/icestick for an example. The "rs232demo" project comes with a test bench and the Makefile contains rules for pre- and post-synthesis simulation:
make rs232demo_tb.vcd # pre-synthesis simulation
make rs232demo_syntb.vcd # post-synthesis simulation
Use a VCD viewer like gtkwave to view the VCD files generated by this two commands.
In order to run post-synthesis simulation one must first convert the BLIF netlist (synthesis output) to a Verilog netlist: yosys -p 'read_blif -wideports example.blif; write_verilog example_syn.v'
This netlist will instantiate iCE40 device primitives. Yosys comes with simulation models for those primitives. Run the command yosys-config --datdir/ice40/cells_sim.v to print the full path name of that simulation library. Use this Verilog file when compiling your simulation.
Edit: Two additional FAQs regarding post-synthesis simulation:
(1) The clock should not have a clock edge at timestamp 0 as this can result in a race condition between clocked register updates and register initialization. I.e. the following test bench code for generating the clock is problematic:
reg clk = 1;
always #5 clk = ~clk;
Instead you should use something like the following, that leaves the clock signal undefined for an initial period:
reg clk;
always #5 clk = (clk === 1'b0);
(2) Some signals (or individual bits of a vector) can be optimized away during synthesis. This bits may be set to a constant value (usually x) or left floating by the tool. This can be confusing when trying to inspect post-synthesis simulation results. Set the keep attribute on nets that you want the tool to preserve:
(* keep *) reg [31:0] foobar;

Moving the "cursor" back a line for stdout

I have a little command line tool (written in Objective C, runs under MacOS) that tracks changes to folders and applies rules to files. This tool also informs the user about the progress. It says like:
"Found 3 files of type Z and applied rule"
"Found 6 files of typ x and applied rules"
Currently, the tool outputs the feedback as an endless list but this does not look very handy. What I'm after is a solution to only type the line per file type once and then update the number in the terminal if the tool finds another file of that type. Very similar to how "top" under Unix gives the feedback.
However, to do so, I'll need to move the cursor in the terminal backwards to the beginning of the line and also one or multiple lines backwards.
Is this possible and does anybody know, how to do so?
Thanks
Norbert

literal string expected error

Please have a look at the following code
with text_io;
use text_io;
procedure hello is
begin
put_line("hello");
new_line(3);
end hello;
When I click "build all" in GPS IDE, I get this error
gnatmake -d -PC:\Users\yohan\firstprogram.gpr
firstprogram.gpr:1:06: literal string expected
firstprogram.gpr:2:01: "end" expected
gnatmake: "C:\Users\yohan\firstprogram.gpr" processing failed
[2013-04-03 13:29:58] process exited with status 4 (elapsed time: 00.47s)
I am very new to Ada, as you can see, this is my first program. Please help.
On the command line, gnatmake will happily compile a file which contains Ada code but has the extension .gpr. GPS knows "better" than that, and insists on treating myfirstprogram.gpr as a GNAT Project file, which of course it isn't.
You'll find life with GNAT much easier if you stick with its file naming conventions: .ads for a spec, .adb for a body, and the file name needs to be the unit name in lower case. In your case, the file should have been called hello.adb.
The simplest approach to creating a GNAT project file in GPS is to go to the Project menu and select New. The only places where you must enter data are on the "Naming the project" page (you might choose firstproject!) and the "Main files" page, where you'd click on the blue + to add hello.adb; you can Forward through the others.
After adding the main file, you can click Apply to install the new project file; now you can Build all and Run.
You may find the GPS tutorial helpful (Help menu, GPS ...)