This is a work in progress! Follow this repository over the next couple of months to see a Cool compiler come to life.
I'm planning to implement, "from scratch", the basic components of a classical compiler. The rough plan is as follows:
-
cmd
: CLI program to run the compiler an a set of Cool files; -
lexer
: turn a stream of characters into a stream of tokens:-
regex::Ast
: structured representation for regular expressions; -
regex::parser
: parse regex strings intoregex::Ast
s; -
nfa::NFA
: represent Thompson NFAs; -
nfa::build
: turn a list ofregex::Ast
s into annfa::NFA
via Thompson's construction; -
nfa::search
: execute an NFA on a given string haystack; -
dfa::DFA
: represent a deterministic automata; -
dfa::build
: construct adfa::DFA
from a Thompsonnfa::NFA
using the powerset construction; -
dfa::minimize
: perform DFA minimization on adfa::DFA
using Hopcroft's algorithm; -
dfa::search
: execute a DFA on a given string haystack; -
gen::Config
: define a language's lexical categories using regular expressions; -
gen::Lexer
: iterates over a character stream and produces tokens; -
gen::generate
: generates agen::Lexer
from alex::Config
;
-
-
parser
: turn a stream of tokens into anast::Ast
; -
ast::Ast
: abstract syntax tree type; -
interpreter
: directly interpret an AST; - ... to be added later.