antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.17k stars 3.28k forks source link

Using C++ target for ANTLR 4 #2558

Open vineeshvs opened 5 years ago

vineeshvs commented 5 years ago

I have been using Python target for Antlr4. Now I am planning to move to cpp as Antlr4 has support for cpp as the target language. Wanted to know if there are any major bugs/ performance issues etc with using cpp as the target language (since it's just been introduced recently)?

Links I have referred so far,

http://blorente.me//Antlr-,-C++-and-CMake-Wait-what.html https://github.com/DanMcLaughlin/antlr4/tree/master/runtime/Cpp

chrisaycock commented 5 years ago

I recently wrote an entire programming language using ANTLR. It took quite a bit of work upfront, but my grammar became very flexible afterwards. I haven't noticed any performance issues.

If you want a more gentle introduction to ANTLR on C++, I wrote a simple calculator example that has all of the set-up.

Nic30 commented 5 years ago

The cmake in antlr repository is not perfect, if you can use Linux packages. I do remember seeing many suboptimal and potentially broken things in cpp runtime year ago.

However as a user I did not experience any problems, performance issues only from wrong grammars. If you are planing to use cmake this may come handy (cmake script for automatic generating of a parser from .g4).