This project aims to provide an open-source parser for VHDL 2008, staying as close to IEEE Std 1076-2008 as I could get without having left-recursion in the grammar (I'm looking at you, prefix).
It is released under the MIT license.
It is currently abandoned because I've found a better, faster way to create an AST with tree-sitter.
At this point in time:
- The code will compile and the executable should parse some VHDL'93 files (but not all) and print its Abstract Syntax Tree (AST) to the standard output.
- VHDL 2008 may partially work, but isn't fully tested.
- 'special characters' with ASCII codes of 160 or higher are not parsed properly
At best, it's a reference for multi-platform builds.
If this project starts up again, I noticed that cpp-peglib now allows you to run a parse operation starting from any point in the PEG syntax, so you don't need to try to debug from the top-level all the time ([see this link](Changing root feature · Issue #304 · yhirose/cpp-peglib · GitHub)). This is quite the game-changer and would allow for proper unit-testing to guarantee lower PEG syntax levels are working properly before trying more complex ones. The cpp-peglib.h that supports this is in this project now.
This project requires cmake and the Boost library (for 'program_options') to build.
Under Windows MSys2, pacboy find boost :p to see which libraries are available and pacman -S <package> to install.
Example for 64-bit UCRT under MSys2:
pacman -S mingw-w64-ucrt-x86_64-toolchain
pacman -S ucrt64/mingw-w64-ucrt-x86_64-boostBuilding:
Set BOOST_ROOT to point to the Boost library install folder.
mkdir build && cd build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
makeNote: MSVC buids fail because it can't cope with the really, really long string that contains the PEG definition.
This parser would not be possible without Y Hirose's cpp-peglib.h, and debugging the PEG grammar was greatly assisted by Mirko Kunze's pegdebug and the linter that's in cpp-pegilb.h.
Build the cpp-peglib.h project and copy lint/peglint into the grammar folder of this project.
Run individual tests with: ./peglint vhdl2008.peg --packrat tests/<test_name.vhd>