Skip to main content
YMCA Compiler banner

YMCA Compiler

Early Work
2018

About

A domain-specific language and compiler for matrix mathematics, built for ITBA's compiler-design course. Lexical analysis with Lex/Flex and grammar parsing with Yacc/Bison feed an abstract syntax tree that is translated into compilable C, letting users express matrix operations in a concise high-level syntax instead of hand-writing the equivalent C.

Key Features

  • A custom grammar for declaring matrices and expressing matrix arithmetic (addition, multiplication, transposition, and scalar operations).
  • A lexer built with Lex/Flex and a parser built with Yacc/Bison that produce an abstract syntax tree.
  • A code-generation stage that emits compilable C from the source language.
  • Compile-time semantic checks for matrix dimension compatibility.

Technical Challenges

  • Designing an unambiguous grammar that Yacc could parse cleanly without shift/reduce conflicts.
  • Validating matrix dimension compatibility at compile time rather than letting it fail at runtime.
  • Managing memory for intermediate matrix results in the generated C code.

Impact & Results

Exercised the full compiler pipeline end to end — lexing, parsing, AST construction, semantic analysis, and code generation — in a single project.

Technologies Used

C
Lex
Yacc