Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrahhal/CSharpLox
A cross-platform compiler/interpreter .NET Standard implementation of the Lox language.
https://github.com/mrahhal/CSharpLox
compiler csharp interpreter netstandard
Last synced: about 11 hours ago
JSON representation
A cross-platform compiler/interpreter .NET Standard implementation of the Lox language.
- Host: GitHub
- URL: https://github.com/mrahhal/CSharpLox
- Owner: mrahhal
- License: mit
- Created: 2018-01-03T21:43:37.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2021-11-27T11:06:58.000Z (almost 3 years ago)
- Last Synced: 2024-08-02T05:13:20.134Z (3 months ago)
- Topics: compiler, csharp, interpreter, netstandard
- Language: C#
- Homepage:
- Size: 53.7 KB
- Stars: 14
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# CSharpLox
A cross-platform compiler/interpreter .NET Standard implementation of the [Lox](https://github.com/munificent/craftinginterpreters) language.
## Build
Run the `build.ps1` script in the root of the project:
```
$ ./build
```An "artifacts" folder will be created, it contains the executables, one for each platform (windows, osx, linux).
(i.e The windows interpreter is at "artifacts/interpreter/win/cslox.exe")After building, run `basic-run.ps1` to test drive the built interpreter (on windows).
```
$ ./basic-run
Hello, World!
```## Usage
```
$ cslox [script]
```You can also enter prompt mode by not specifying a script path:
```
$ cslox
> print 41 + 1;
42
```To print the ast and exit:
```
$ cslox [script] --print-ast
```## Syntax
Lox is a simple dynamic programming language that supports object oriented aspects. It supports classes and inheritance.
A simple lox program:
```lox
class Greeter {
init(name) {
this.name = name;
}greet() {
print "Hello, " + this.name + "!";
}
}var greeter = Greeter("mrahhal");
greeter.greet();
```## Grammar
The [context-free-grammar](context-free-grammar.md) file contains the grammar of the whole language, expressed using a similar metasyntax to [EBNF](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form).
## Project Structure
- `Core`: The core project, a class lib, handles scanning and parsing and lower level operations.
- `Interpreter`: The interpreter project, a cross platform executable that evaluates the program in C#.## Further Improvements
- Modules, importing other files
- More native functions. Right now, there's only a `clock` function.
- A bytecode compiler