Making c\c++ compiler
A lexical analysis program aimed for C\C++ program.
A C++ version is presented in c_lex\
and a Lex version is presented in lex\
.
Lex version is in this experiment is a modified version of ANSI C grammar, Lex specification. click here.
Yaac is supposed to be accompanied with the matching lex file. That's the work to do at next stage. click here
Reference:
c++ version:
GitHub in ref\
lex version:
lex入门
lex网络教程
另一个示例
A syntactic parser of arithmetic expression with + - * / ( )
A C++ version with cmake in parse\
and a Yacc version in yacc\
- Recursive analysis is intended for example grammar.
- LL(1) analysis and SLR(1) is intended for arbitrary grammar.
- Not eliminate left-recursion yet. To avoid the endless loop, grammar must have no left-recursion in productions when doing LL(1) and recursive analysis.
Reference:
c++ version:
yacc version:
ANSI C grammar, Lex specification. ANSI yacc(2011版)