What are the tools for semantic analysis phase of compiler construction?

喜欢而已 提交于 2020-02-27 09:21:49

问题


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:


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.



来源:https://stackoverflow.com/questions/46694806/what-are-the-tools-for-semantic-analysis-phase-of-compiler-construction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!