-8

Are there any lexical, syntactic, semantic analyzers and optimizers available for download with the source code, preferably in C/C++...???

El Classico
  • 25
  • 1
  • 3
  • 8
  • 3
    YES (11 more to go) (I could answer {Google before asking} ... but seems rude) – Dr. belisarius Dec 18 '10 at 14:14
  • @Prasoon Saurav: I need them to understand the result of each compilation phase... – El Classico Dec 18 '10 at 14:15
  • 2
    Sometimes I wish the Captcha could detect more than just spelling... – KevenK Dec 18 '10 at 14:17
  • 1
    The baseline compiler help question is [Learning to write a compiler](http://stackoverflow.com/q/1669/2509). The various books and web pages listed therein will have some suggestions. Additionally I suggest you search Stack Overflow for questions touching on each of the components you list as they have been asked about before. However, you may find that this problems is harder than just collecting a bunch of tools and plugging them together. See the resources I pointed at for help. – dmckee --- ex-moderator kitten Dec 18 '10 at 16:47

4 Answers4

2

Do you want a C compiler? Yes there are so many available. You might wanna start with gcc.

Prasoon Saurav
  • 91,295
  • 49
  • 239
  • 345
  • 2
    Indeed, OP seems to be asking for all the pieces of a compiler as if programming is a matter of picking a few components and gluing them together. This is the kind of ridiculous idea that develops when kids learn on RAD tools and Visual Basic... – R.. GitHub STOP HELPING ICE Dec 18 '10 at 14:29
  • @R hey, I learnt on Visual Basic!! Never touched it since mind, but... –  Dec 18 '10 at 14:33
  • @R.. I'd say naive rather than ridiculous. There is nothing wrong with ambitions to reduce the complexity of programming, and it takes some experience before you can appreciate the extent to which some of the complexity is irreducible. – dmckee --- ex-moderator kitten Dec 18 '10 at 16:45
  • From the title it would appear rather than he wants to *implement* a compiler. – Clifford Dec 18 '10 at 16:51
  • This answer seems off topic. Badly worded as the question is, it does convey a plan to implement rather than use a compiler. Also, I think that it's homework. – Noufal Ibrahim Dec 18 '10 at 17:01
  • @Noufal: OP's question is about "implementing" a compiler by asking for pieces to glue together. I don't call that implementing a compiler. If you want pieces to glue together, you'll need to look at existing compilers, and gcc is a good (albeit ugly) example. – R.. GitHub STOP HELPING ICE Dec 18 '10 at 17:27
  • R: Given how crudely the question is phrased, either of us could be correct. – Noufal Ibrahim Dec 18 '10 at 17:36
2

Your question is very poorly formed. You should have googled for this.

Assuming you're writing your compiler in C (based on the tag), there's flex, quex and ragel.

To help you write your parser, there's bison.

rici
  • 234,347
  • 28
  • 237
  • 341
Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169
2

I would take a look at the LLVM project. If you're looking to build a compiler of your own, targetting this architecture is quite a good idea. LLVM itself has it's own intermediate representation for assembly syntax, for which many languages, including C and D already have frontends.

You might also want to take a look at this thread from a mailing list I am part of which discusses a number of "language backends" including Parrot etc; basically a set of processors that bring languages like C, C++, Python etc down to a common level.

I am not nearly expert enough in this area as I'd like to be, but these technologies appear to be getting the experts excited. I am seriously considering getting up to speed on them.

0

You can Check out the Java Compiler source code: http://openjdk.java.net/groups/compiler/

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124