EASY language compiler The repository contains a compiler for the educational programming language called Easy, as described in the book Etudes for Programmers (1978) by Charles Wetherell. NOTE: The compiler is also educational only. The compiler was written from scratch, and I had no compiler-writing experience before. My purpose was to learn compiler implementations and runtimes. EASY language intro The program below is from the book. It is intended to demonstrate the gist of the EASY language. This code was my very first milestone when developing the compiler: Here is the source of the program and also the output of the compiler. Implementation The compiler is implemented in Typescript. The compiler emits C code, which Clang or GCC then compiles into the native binary. The runtime.c file is a bare minimum runtime support. In the x subfolders of the tests, there are test.c files, representing the output of the compiler. The compiler requires a Javascript runtime (Node 24+ or Bun) and Clang 17+. To compile and run a program in Easy, you run "easyc run filename.easy", for example: easyc run life.easy or step by step: node easyc.ts life.easy && cc life.c -o test -I . && ./test easyc.ts compiles life.easy to life.c, and then Clang compiles easy.c to the executable. The Easy language syntax is fully supported, according to the book. However, there are a few points worth mentioning. EXTERNAL subroutines and NAME aliases are allowed but not supported semantically. Multiple PROGRAM segments are not supported, and the program should have only one PROGRAM segment, which becomes its entry point. The identifiers (types, variables, subroutines) from the PROGRAM segment are hoisted to the global namespace and visible in all parts of the Easy program. According to the book, Easy is a copy semantics language. It means that copying a primitive type, a structure, or an array always makes a full, deep copy. The subroutine arguments and the function return value are also copied deepl...
First seen: 2025-10-23 15:31
Last seen: 2025-10-23 18:32