Skip to content

Version 2 uses Perl for initialization instead of plain C (C is still used to utilize pcre2 for the final match since it's times faster)

Notifications You must be signed in to change notification settings

Netizen1234/cparser2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C Parser with PCRE2

Since no one ever has written a C parser the easy way (AKA with RegEx) I decided to do it - no hard algorithmic recursions - just plain Regex with measly one callout function that only fetch and displays named groups/diagnostics.

Obviously there were some challenges - for example the first one was distinguishing between a random sequence of text and an terminated escape sequence.

Currently the last challenge I was faced with was capturing/triggering the callbacks for right-to-left operators in the right order. I have a generic method for this now, for a single operator but it must be extended for more complex cases.

Usage

You would need to install pcre2, perl with dynamic modules and finally llvm. Of-course you would need a g++ and gcc compiler (or msvc).

Preprocessor (any of it - including #line) and attributes are not supported.

Example launch:

clear; ./cparser ./main.pl maintest.c

maintest.c is the example included in this project.

About

Version 2 uses Perl for initialization instead of plain C (C is still used to utilize pcre2 for the final match since it's times faster)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 68.3%
  • C 25.2%
  • Perl 5.4%
  • Other 1.1%