This repository contains compiler for I-Lang (pronounced as Ы-lang 😃). This is an artificial language for practicing in compiler construction, which is a course at Innopolis University. The specification is available here for registered users.
Compiler's source code.
The project uses a dependency injection pattern, so the Program
class's Main
function initializes the dependency injection framework and calls the Main
function of CliApp
class (thus, this is the actual program's entrypoint).
The simplest use case. To use a class as a dependency:
- Create the desired class or at leas a stub for it
- add it to the
IServiceCollection
in theProgram.RegisterServices
method- for example, see how it is done with
LexicalScanner
:
serviceCollection.AddTransient<LexicalScanner>();
- for example, see how it is done with
- Add this class as a parameter to constructor of the class, which needs to use the API of the created class
- e. g.
LexicalScanner
is used byCliApp
, so its constructor looks like:
The framework will automatically instantiate thepublic CliApp(LexicalScanner lexicalScanner ...
LexicalScanner
, when it will be creatingCliApp
, thus the term dependency (LexicalScanner
in this case) injection (to theCliApp
in this example). - e. g.
- You probably will want to use the injected class in the injectee's functions, so go store it in a property, which will be accessible by the class's functions
- going back to example with
CliApp
andLexicalScanner
:
private LexicalScanner Lexer { get; } public CliApp(LexicalScanner lexicalScanner) { Lexer = lexicalScanner; } public void DoSomething() { // ... var result = LexicalScanner.Tokenize(input); // ... }
- going back to example with
For more information on the DI, see the docs for DI in ASP.NET Core (Microsoft's web framework for .NET Core).
To parse command line arguments the program uses commandline library, so refer to its documentation for details.
Class that contains options is called CliOptions
. All command line options must reside there.