Skip to content

Compiler for the Cool classroom language, written in Rust.

License

Notifications You must be signed in to change notification settings

AndreiDuma/Coolr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coolr – A Cool Compiler Written in Rust – WIP

This is a work in progress! Follow this repository over the next couple of months to see a Cool compiler come to life.

Plan

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 into regex::Asts;
    • nfa::NFA: represent Thompson NFAs;
    • nfa::build: turn a list of regex::Asts into an nfa::NFA via Thompson's construction;
    • nfa::search: execute an NFA on a given string haystack;
    • dfa::DFA: represent a deterministic automata;
    • dfa::build: construct a dfa::DFA from a Thompson nfa::NFA using the powerset construction;
    • dfa::minimize: perform DFA minimization on a dfa::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 a gen::Lexer from a lex::Config;
  • parser: turn a stream of tokens into an ast::Ast;
  • ast::Ast: abstract syntax tree type;
  • interpreter: directly interpret an AST;
  • ... to be added later.

Useful references

About

Compiler for the Cool classroom language, written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages