Skip to content

lexy-language/lexy-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lexy-dotnet v0.1

Build lexy-dotnet Coverage

Implementation of the lexy-language parser and compiler in dotnet (c#). Check the lexy-language or the online demo to understand the philosophy and use cases of Lexy.

NuGet .NET package: todo

Contribution

Check lexy-language for more information about how to contribute.

Known improvements

  • Code: get rid of all warnings
  • Benchmarking: add performance tests for compilation and execution across compilers and improve compilation time
  • Packaging: publish NuGet package from GitHub Actions

Future ideas

  • Compilation: provide api to store compiled scripts (and assembly) on filesystem (or in db), and to execute them later without compiling.
  • Compilation: allow to include pre-compiled lexy scripts
  • Compilation: partial compilantion of single files without the need to recompile eveything
  • Compilation: create api for code completion: funciton names, variables (per function), function overloads

Implementations notes

Compiler implementation

The .net compiler is the main compiler implementation. Why? Because it's the most elegant and type safe language according to Tim's personal experience ;-)

It is developed by practicing test-driven development (TDD), or more specific, behavior-driven development (BDD). Since the initial commits (.net language) the first lexy specifications scenarios (tests) of Lexy were written before the code was implemented. During the development more specifications (tests) were added, and the code was continuously refactored to improve the design of the compiler and the language. The specifications are also written in Lexy and document the whole language and most features of the compiler. Every change to the compiler should be discussed first and implemented in all other compilers.

The compiler itself process Lexy code in different phases:

  • Parser: Parses Lexy scrips into a language model (class Lexy.Compiler.Parser.LexyParser method Parse)
  • Tokenizer: Parses a Lexy script code line into token (class Lexy.Compiler.Parser.Tokens.Tokenizer method Tokenize)
  • Language: AST model (Abstract syntax tree) generated by the parser represents the Lexy language described in the code. (namespace Lexy.Compiler.Language)
  • Dependency checker: check whether there a circular dependencies in the AST model
  • Validation: Validates whether the parsed AST can be compiled and enriches the AST model with info needed for the compilation
  • Compilation: Generates a .NET assembly. Uses the Roslyn compiler API under the hood. (class Lexy.Compiler.Compiler.LexyCompiler)

Run locally

Ensure .NET 7 (or later) is installed. Tested with .NET 7.0.410

Run build 'dotnet build' Run automated tests 'dotnet test'

Submodules

lexy-language and lexy-editor are both included as git submodules.

  • lexy-language is used in the automated tests to ensure that the parser and compiler are running against the latest lexy language specifications.
  • lexy-editor is included in Lexy.Web.Editor which is a starting point for a dotnet backend for the editor web app. This is still an empty project atm.

You can use yarn update-submodules to pull the latest content from git.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages