
Explore building a C compiler in JavaScript by configuring TypeScript tooling, creating a makefile, and implementing a lexer with token definitions, to turn TypeScript into JavaScript.
Code a C compiler in JavaScript by building a lexer that turns C code into tokens, parse a C file, with NodeJS setup and token types like int and identifier.
Covers building a lexer in JavaScript and TypeScript and defining a C grammar in BNF, including production rules, terminals, nonterminals, and a file lexer with tokens and error handling.
Lex input into tokens and parse with a context-free grammar, then implement a minimal Rex regex engine in JavaScript supporting question mark, star, and capture groups.
Build a regex-like engine with wild cards, star handling, and capture groups in TypeScript to empower a parser for a JavaScript-based C compiler.
Episode five guides building a parser and an abstract syntax tree for the C compiler in JavaScript, detailing return statements, expressions, and number constants.
Finish building the AST by defining code block, function, and program nodes, then assemble a version one compiler pipeline in JavaScript.
Build a C compiler workflow in JavaScript by filtering whitespace tokens in the lexer, removing the parser, and creating a TypeScript pre-compiler bash script to translate ts plus to ts.
Refine complex regular expressions to parse C-like tokens, handling double and single dollar signs, hash symbols, identifiers, keywords, and punctuation with capture groups.
Episode nine guides you through parsing tokens into an AST function and program, validating open round and close round tokens and code blocks until end-of-file.
Explore implementing a code generator in a javascript-based c compiler, including register set design, scratch register management, and 16-bit to 64-bit x86 multi-target support.
Refactor the compiler's state management into a functional state object, add label tracking with uniqueness checks, explore interfaces for labels, and outline assembly and code generation.
Episode twelve builds a two-part assembler by adding header and body handling, expression and return statement processing, and a simple ast to assembly pipeline with scratch registers.
Develop a JavaScript-based C compiler by generating assembly for multi-function programs. Learn to implement function prologues and epilogues, handle returns, and validate code through assembly generation and testing.
Episode 14 refactors the compiler into a single class that orchestrates lexing, parsing, AST creation, and code generation to assembly, producing an executable via optional stop stages.
Debug a JavaScript C compiler by inspecting the lexer and tokens to fix parse errors. Learn to wire command line options -s -c -o, handle input files and assembly output.
Coding a C compiler in Javascript
In this exciting new project we'll be coding a real C compiler in Javascript.
The first version will be able to parse a few commands and when all the steps are done (lexing, defining grammar, parsing, generating an AST, emitting code and writing the compiler driver) we will add new functionality, one command at the time.
You will learn every step of compiler design in this 15 episode course. In addition to this, you will also learn how to build your own, datatype-independent regular expression library and also a transpiler/pre-compiler for JS/TS code.
Prerequisites
To follow along in this project you need a basic understanding of Javascript. That's it. Everything Node- or C or Typescript related will be explained at every step.
Operating systems
This project will work equally well in Windows, Mac OS X or Linux. All you need is Node.js and Nasm. Just follow the instructions from the intro. Happy coding!
About the author
Dr. Jonas is an experienced instructor who's been coding for 25 years and teaching for almost ten years. His popular Youtube channel has almost 50 000 subscribers and he's also running his own web TV channel with programming content. He's an appreciated teacher with stunning reviews and several programming courses of different kind.
Enroll Today! Or check out the two hours of free previews.