3
votes

Compiler construction can be divided into several phases such as Lexical analysis, Syntax analysis, Semantic analysis and etc. In lexical analysis, there are tools such as Lex, Flex and etc. In syntax analysis, there are tools such as Yacc, Bison, etc. I'm just curious what are the tools available for semantic analysis phase?

1
@500-InternalServerError: That's flat out wrong. People have been studying semantic of programming languages using formal semantics for over 50 years. Here's a basic textbook on the topic: amazon.com/Formal-Semantics-Programming-Languages-Winskel/dp/… Further, there has been plenty of research on building full compilers from such semantics. It is true that very little of this is available to the community as tools; they are hard tools to build, and "users" of such tools generally don't want to pay for them.Ira Baxter

1 Answers

3
votes

To the best of my knowledge there are no language-agnostic tools to perform type checking and if there were, they'd certainly not be generally applicable as many language's type system's are too different and complex to be handled by generalized tools.

With scope resolution there's some room for tools to handle it for you. For example if your language has simple enough scoping rules, the XText framework can entirely take care of scope resolution for you if you add some annotations to your grammar. In more complex cases, you'll have to write some additional code yourself.

Then, if you compile to LLVM, you can use the LLVM framework to perform all kinds of control-flow analyses for you.