Compiler Toolchain · Part of SAPHO

YANC

Yet Another Compiler

YANC is the compilation backbone of the SAPHO ecosystem. It transforms high-level CMM processor descriptions into binary executables through a two-stage pipeline: cmmcomp (CMM → Assembly) and asmcomp (Assembly → Machine Code), plus the APP auxiliary pre-processor. Written in C using Flex, Bison, and GCC.

C Language Flex Bison GCC Linux · Windows Open Source Active

Compilation Pipeline

YANC implements a classical two-stage compiler architecture. Source CMM code enters cmmcomp, where Flex tokenises the input and Bison parses the grammar into an AST. Code generation produces SAPHO assembly, which asmcomp then assembles into a binary hex file ready for FPGA loading or YAWT simulation.

1
CMM Source
.cmm — processor description in C-like syntax
2
APP — Pre-Processor
Macro expansion, include directives, constant folding
3
cmmcomp — Frontend
Flex lexer + Bison parser → SAPHO Assembly (.asm)
4
asmcomp — Backend
Two-pass assembler → Binary / Hex (.hex, .mif)
5
SAPHO Processor
Machine code → FPGA execution or YAWT simulation

Toolchain Components

cmmcomp
CMM high-level language compiler. Flex lexer + Bison LALR(1) parser. Emits SAPHO assembly with symbol table and error diagnostics.
asmcomp
Two-pass assembler for SAPHO instruction set. Resolves labels, encodes opcodes, outputs Intel HEX and Altera MIF formats.
APP
Auxiliary Pre-Processor. Handles #define, #include, and constant-folding before cmmcomp ingests the source.

CMM Language Sample

// Fibonacci — SAPHO CMM processor Fib { const int N = 10; int a = 0, b = 1, c; int i = 0; while (i < N) { c = a + b; a = b; b = c; i++; } // result in register r0 output(a); }

SAPHO Integration

YANC is the compilation engine called by SAPHO when a student clicks Compile. POLARIS bundles YANC binaries natively; AURORA relied on the same pipeline. The entire build is triggered from within the IDE with a single keystroke.

Build Dependencies

YANC is self-contained: Flex generates the lexer C source, Bison generates the parser, and GCC compiles the resulting C files. No external runtime or library dependencies are required. A standard make invocation builds all three tools.

Teaching Use

YANC is taught as part of the Digital Logic Processors (DLP) discipline at UFJF. Students learn compiler theory by reading cmmcomp's Flex and Bison sources, tracing AST construction, and extending the grammar with new operators for course assignments.

Explore YANC on GitHub

The full YANC source — Flex grammars, Bison parser rules, and Makefile — is publicly available. Issues and pull requests are welcome.

nipscernlab/yanc Back to SAPHO