For performance reasons, I am migrating the C # library to C ++. During normal operation, this library, among other things, needs to analyze approximately 150,000 mathematical expressions (think excel formulas) with an average length of less than 150 characters.
In the C # version, I used the GOLD parser to generate the parsing code. It can analyze all 150,000 expressions in one second.
Since we were thinking about expanding our language, I decided that switching to C ++ might be a good chance to switch to ANTLR. I ported the (simple) grammar to ANTLR and generated C code from it. Parsing 150,000 expressions takes more than 12 seconds, because for each expression I need to create a new ANTL3_INPUT_STREAM, token, lexer and parser - at least in version 3.4 there is no way to reuse them.
I would appreciate it if someone could give me a recommendation on what to use instead - GOLD, of course, an option, although creating code in C ++ or C seems a lot more complicated than C #. My grammar is compatible with LALR and LL (1). The priority is to analyze performance on small inputs.
c ++ performance antlr parser-generator gold-parser
user816098
source share