This project implements a compiler for a C-like language using Flex (for lexical analysis) and Yacc (for parsing). It includes semantic checks and builds an abstract syntax tree (AST).
Ensure you have the following tools installed:
flex– lexical analyzer generator -yacc– parser generatorgcc– C compiler
for building the compiler:
- yacc -d -v parser.y
- flex lexer.l
- gcc lex.yy.c y.tab.c -o myc -lm
To run the compiler on a source file:
- make sure you have a file name: file.txt
- run on the terminal: ./myc < file.txt