Minsk [http://minsk-compiler.net]
Building a compiler
This repo contains Minsk, a handwritten compiler in C#. It illustrates basic concepts of compiler construction and how one can tool the language inside of an IDE by exposing APIs for parsing and type checking. This compiler uses many of the concepts that you can find in the Microsoft C# and Visual Basic compilers, code named Roslyn.
- Basic REPL (read-eval-print loop) for an expression evaluator
- Added lexer, a parser, and an evaluator
- Handle
+
,-
,*
,/
, and parenthesized expressions - Print syntax trees
- Generalized parsing using precedences
- Support unary operators, such as
+2
and-3
- Support for Boolean literals (
false
,true
) - Support for conditions such as
1 == 3 && 2 != 3 || true
- Internal representation for type checking (
Binder
, andBoundNode
)
- Extracted compiler into a separate library
- Exposed span on diagnostics that indicate where the error occurred
- Support for assignments and variables
- Added tests for lexing all tokens and their combinations
- Added tests for parsing unary and binary operators
- Added tests for evaluating
- Added test execution to our CI
- Code clean-up
- Added
SourceText
, which allows to compute line number information
- Added colorization to REPL
- Added compilation unit
- Added chaining to compilations
- Added statements
- Added variable declaration statements
- Made evaluation tests more declarative, especially for diagnostics
- Added support for
<,
<=
,>=
, and>
- Added support for if-statements
- Added support for while-statements
- Added support for for-statements
- Ensure parser doesn't loop infinitely on malformed block
- Ensure binder doesn't crash when binding fabricated identifiers
- Add support for bitwise operators
- Add ability to output the bound tree
- Add ability to lower bound tree
- Lower
for
-statements intowhile
-statements - Print syntax and bound tree before evaluation
- Lower
if
,while
, andfor
into gotos
- Add REPL ability to edit multiple lines, have history and syntax highlighting
- Added support for string literals and type symbols
- Added support for calling built-in functions and convert between types
- Added support for explicit typing of variables and function declarations
- Added pretty printing for bound nodes as well as
break
andcontinue
statements
- Added support for return statements and control flow analysis.