Skip to content

TymurLysenkoIU/il-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Project structure

ILangCompiler

Compiler's source code.

Dependency injection

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 CliAppclass (thus, this is the actual program's entrypoint).

The simplest use case. To use a class as a dependency:

  1. Create the desired class or at leas a stub for it
  2. add it to the IServiceCollection in the Program.RegisterServices method
    • for example, see how it is done with LexicalScanner:
    serviceCollection.AddTransient<LexicalScanner>();
  3. 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 by CliApp, so its constructor looks like:
    public CliApp(LexicalScanner lexicalScanner ...
    The framework will automatically instantiate the LexicalScanner, when it will be creating CliApp, thus the term dependency (LexicalScanner in this case) injection (to the CliApp in this example).
  4. 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 and LexicalScanner:
    private LexicalScanner Lexer { get; }
    
    public CliApp(LexicalScanner lexicalScanner)
    {
      Lexer = lexicalScanner;
    }
    
    public void DoSomething()
    {
      // ...
      var result = LexicalScanner.Tokenize(input);
      // ...
    }

For more information on the DI, see the docs for DI in ASP.NET Core (Microsoft's web framework for .NET Core).

Get command line arguments

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.

About

I language compiler for "Compiler construction" course of Innopolis University 2020.

Topics

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages