Skip to content
SohamGeniusCoderPublic

About

EasyC is a statically typed, procedural programming language inspired by C, designed with a focused feature set that is realistic for an individual compiler project. It introduces readable logical operators (and, or, xor, !), convenient cin/cout/endl stream I/O, while retaining printf and scanf. The proposed compiler will process .ezc source files

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

EasyC

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.

Agreed language scope

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.

Compiler architecture

.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

Implementation stack

  • 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

Build

Requirements: C++17 compiler, CMake 3.20+, Flex and Bison.

cmake -S . -B build
cmake --build build

CLI target

easyc 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 --all

At 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.

Repository structure

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

Current milestone demos

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 current grammar/lexer.l rules.

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.

About

EasyC is a statically typed, procedural programming language inspired by C, designed with a focused feature set that is realistic for an individual compiler project. It introduces readable logical operators (and, or, xor, !), convenient cin/cout/endl stream I/O, while retaining printf and scanf. The proposed compiler will process .ezc source files

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages