CppParser code
CppParser Repository
Source code parsing using Rules and Actions
Quick Status
Code functions correctly
no known defects
Demonstration code
yes
Documentation
yes - needs more
Test cases
no, but planned
Static library
no, but planned
Build requires
C++17 option
Planned design changes
Factor Rules and Actions into
language specific sets
Fig 1. Rule-Based Parsing
1.0 Concept
CppParser executes static rule-based code parsing on specified files in a specified
directory tree. It displays results in an Abstract Syntax Tree (AST).
The scanner returns a token string that represents some grammatical construct, e.g.,
a file's opening scope with the tokens rtype fname {. That is passed
down a chain of rules. Each rule is a grammer detector, e.g., file open scope.
When a token sequence matches a rule, the rule invokes its actions on the tokens
which usually store information in an abstract syntax tree or data store.
1.1 Resources
BlogParser.html describes how the Parser works in
some detail.
2.0 Build
CppParser was built with Visual Studio Community Edition - 2019 and tested on
Windows 10.
3.0 Status
This parser has been used in several class projects and three doctoral research projects.
It is flexible and simple enough for students to understand with a few hours of study.