Pages tagged "c++"
Using ANTLRv3 with C/C++
Introduction
Recently I had to build a parser and lexer as part of a compilers group project in college. Out group had read around a bit, and decided we would use ANTLR for our project. We also wanted to write our compiler in C++. However, although the documentation for using ANTLR with C was fairly decent, concrete examples of using ANTLR with C or C++ are few and far between. Hopefully this short guide will help you do what we found very difficult - taking the first steps towards creating a powerful lexer and parser using ANTLR in C++.
A few notes before we get into the actual code:
-
This example will use ANTLRv3.2. Although this is not the latest version, it works very well with the C target and tools like ANTLRWorks and the ANTLR Eclipse plugin. Some functions and keywords...