hanickadot / compile-time-regular-expressions

Compile Time Regular Expression in C++
https://twitter.com/hankadusikova
Apache License 2.0
3.22k stars 177 forks source link

Convert CTRE from PCRE Grammar to PEG for Compile-Time Lexer #292

Open alexios-angel opened 10 months ago

alexios-angel commented 10 months ago

Hello,

I'm impressed with your project and I'm considering repurposing some of its code to create a compile-time lexer. From my observation, to transition from the PCRE grammar to a PEG grammar, it appears that only the .gram file needs modifications.

Could you guide me on this? Here's an example I'd like to discuss:

start = expression;

expression = term ( ("+" / "-") term )*;
term       = factor ( ("*" / "/") factor )*;
factor     = NUMBER / "(" expression ")";

NUMBER     = [0-9]+ ("." [0-9]+)?;

Thank you for your time!