Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

A cross-platform compiler/interpreter .NET Standard implementation of the Lox language.

License

Notifications You must be signed in to change notification settings

mrahhal/CSharpLox

Open more actions menu

Repository files navigation

CSharpLox

A cross-platform compiler/interpreter .NET Standard implementation of the Lox 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:

class Greeter {
	init(name) {
		this.name = name;
	}

	greet() {
		print "Hello, " + this.name + "!";
	}
}

var greeter = Greeter("mrahhal");

greeter.greet();

Grammar

The context-free-grammar file contains the grammar of the whole language, expressed using a similar metasyntax to EBNF.

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

About

A cross-platform compiler/interpreter .NET Standard implementation of the Lox language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.