Runi is a context-free grammar, lexer and predictive recursive descent parser for a C-like language in Go.
This implementation is a part of our laboratory project to implement lexical and syntax analyzers at BITS Pilani. We also wanted to go out of our comfort zone and choose a modern language that we had not tried before.
- gographviz, to generate the DOT specification
- Graphviz, to generate the image from the DOT specification
Please run $ go run . [file]
where [file]
represents an optional argument (which defaults to test.txt
) to parse the file. If the parser accepts the program, it will generate a DOT specification of the parse tree depicting the leftmost derivation in out.dot
. This specification can be run through Graphviz to generate the parse tree. We recommend doing $ dot -Tpng -Gdpi=300 out.dot -o out.png
.
Input files for our lexer's test suite can be found in src/tests/
. Please do go test
to run the tests.
Here are some sample generated visualizations from images/
. The program source is shown at the top of the image.
Rupanshu Soi & Nipun Wahi, Department of Computer Science, BITS Pilani - Hyderabad Campus, India.
"Rupanshu Soi"[:2] + "Nipun Wahi"[:2]