EasyC — A C-Style Procedural Programming Language & Compiler
EasyC is an individual Compiler Design Laboratory project. It is a statically typed, procedural language inspired by C, with a deliberately manageable compiler scope and readable additions such as cin, cout, endl, and, or, and xor.
Core language: int, float, double, char, bool, void, string, variables, constants, expressions, arithmetic/relational/assignment operators, and, or, xor, !, conditionals, switch, loops, break/continue, functions, recursion, arrays, strings, and return.
Committed advanced features: structs, enums, unions, pointers, dynamic memory allocation, and additional C-style features.
I/O: both stream-style cin/cout/endl and C-style printf/scanf are part of the intended language.
.ezc source
|
v
Flex lexer ---> tokens
|
v
Bison parser ---> AST
|
v
Semantic analysis + symbol table
|
v
Three-address IR
|
v
Optimization
|
v
Target code generation
|
v
Executable
- Flex for lexical analysis
- Bison/Yacc-compatible grammar for parsing
- C++17 for AST, compiler driver, semantic analysis, IR, optimization and code generation
- CMake for reproducible builds
- Git recommended for version history
Requirements: C++17 compiler, CMake 3.20+, Flex and Bison.
cmake -S . -B build
cmake --build buildeasyc examples/main.ezc
easyc examples/main.ezc --lexical
easyc examples/main.ezc --syntax
easyc examples/main.ezc --semantic
easyc examples/main.ezc --ir
easyc examples/main.ezc --optimize
easyc examples/main.ezc --codegen
easyc examples/main.ezc --allAt the current milestone, the parser/AST stage is implemented. The semantic, IR, optimization and code-generation commands are explicit placeholders until those modules are implemented; the compiler does not claim to generate an executable yet.
easyc/
├── CMakeLists.txt
├── README.md
├── grammar/
│ ├── lexer.l
│ └── parser.y
├── include/easyc/
│ ├── ast.hpp
│ ├── compiler.hpp
│ └── diagnostics.hpp
├── src/
│ ├── ast.cpp
│ ├── compiler.cpp
│ ├── diagnostics.cpp
│ └── main.cpp
├── examples/
│ ├── main.ezc
│ └── advanced.ezc
└── tests/
└── README.md
The demo_outputs/ directory contains material for demonstrating the current frontend foundation:
ast_demo.txt— output produced by the C++ AST pretty-printer.cli_output.txt— current CLI help and version output contract.token_stream.txt— reference token stream corresponding to the currentgrammar/lexer.lrules.
tools/ast_demo.cpp is a small local harness used only to exercise the AST infrastructure before Flex/Bison generation is available in the current environment.