-
Notifications
You must be signed in to change notification settings - Fork 52
Iris Compiler
"Iris" is a language that will look familiar to Pascal programmers. It has the following design goals:
- Expressive enough to write interesting programs.
- Language is imperative.
- Easy to integrate with the debugger as a sample.
- As simple as possible while achieving the above goals.
Iris is not intended to be a production compiler and doesn't attempt to follow any standards. It also shouldn't be considered a 'best practice' example for implementing a .NET compiler.
Learning any programming language starts with Hello World, so here is Hello World in Iris:
program HelloWorld;
begin
writeln('Hello World');
end.
Here's a slightly more complicated program that prints the first 5 values in the Fibonacci sequence:
program Fibonacci;
function Fib(i:integer) : integer;
var
a, b : integer;
begin
Fib := 1;
if i > 2 then
begin
a := Fib(i - 1);
b := Fib(i - 2);
Fib := a + b;
end;
end
procedure Test(i:integer);
var
result : integer;
begin
result := Fib(i);
writeln(str(result));
end;
begin
Test(1);
Test(2);
Test(3);
Test(4);
Test(5);
end.
Iris can be broken down into a Front End, Back End, and an Import System.
The front end of the Iris compiler uses a recursive decent parser. For simplicity, the compiler only makes one pass over the source file. During parsing, the compiler does semantic analysis and outputs instructions and debug information via the Back End. The bulk of this code is in Translator.cs
Iris allow interchanging back ends for emitting different types of code. Each back end is an implementation of IEmitter
. There is an emitter for PE files and an emitter that writes out textual CIL code.
In order to integrate with the debugger, Iris must have the ability to import metadata into its symbol table. Iris uses System.Reflection.Metadata
as the metadata reader and implements an intermediate type system to convert between the rich .NET type system and the compiler's very limited type system.
The command line compiler for Iris is named "ic". It is built as part of Iris.sln in the Iris directory. To see the options for the compiler, run "ic" without any arguments. There is also a build.cmd file in the repo to build all ".iris" files in the Iris/Programs directory.
Concord Documentation:
- Overview
- Visual Studio 2022 support
- Concord Architecture
- Getting troubleshooting logs
- Tips for debugging extensions
- Component Discovery and Configuration
- Component Levels
- Navigating the Concord API
- Obtaining the Concord API headers, libraries, etc
- Concord Threading Model
- Data Container API
- Creating and Closing Objects
- Expression Evaluators (EEs)
- .NET language EEs
- Native language EEs
- Installing Extensions
- Cross Platform and VS Code scenarios:
- Implementing components in native code:
- Worker Process Remoting
Samples: