Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

building a parser with clang

Tags:

I need to build an AST using clang and the only tutorials that I found are vague and two years out of date. Could anybody point me to an example?

like image 636
Mihai Avatar asked Aug 12 '10 20:08

Mihai


People also ask

What kind of parser does Clang use?

Clang uses a recursive-descent parser for several reasons: Performance: a hand-written parser allows us to write a fast parser, optimizing the hot paths as needed, and we're always in control of that performance.

Is LLVM same as Clang?

LLVM is a backend compiler meant to build compilers on top of it. It deals with optimizations and production of code adapted to the target architecture. CLang is a front end which parses C, C++ and Objective C code and translates it into a representation suitable for LLVM.

Does Clang support C99?

You can use Clang in C99 mode with the -std=c99 option.

Does LLVM use Clang?

Clang operates in tandem with the LLVM compiler back end and has been a subproject of LLVM 2.6 and later. As with LLVM, it is free and open-source software under the Apache License 2.0 software license. Its contributors include Apple, Microsoft, Google, ARM, Sony, Intel, and AMD.


1 Answers

There are several tutorial available that demonstrate the use of the Preprocessor class and how to build an AST:

  • A CLang tutorial (a bit outdated but with a lot of explanation)
  • Code samples
like image 94
Laurent Etiemble Avatar answered Oct 09 '22 06:10

Laurent Etiemble