How can I parse a file containing a decimal numbers into a List<double>
in C# using ANTLR4? A complete, working example would illustrate how all the pieces go together.
The input file looks like this:
12.34
45.67
89.10
How can I parse a file containing a decimal numbers into a List<double>
in C# using ANTLR4? A complete, working example would illustrate how all the pieces go together.
The input file looks like this:
12.34
45.67
89.10
This is an updated version of an older answer to a different question, showing one way to do this task using C# and ANTRL4.
The Grammar
The Listener
Now the class that implements the Listener pattern, now listening on number:
Main Program
And finally the main program that reads the input file, sets up everything, walks the tree, and displays the accumulated
double
values from theList<double>
exposed by the listener: