Skip to content

The first prototype of the lambda engines scripting language.

License

Notifications You must be signed in to change notification settings

lambda-sh/lamscript

Repository files navigation

Lamscript

GitHub Workflow Status

An interpreted language aimed for productivity and simplicity.

Description

Lamscript is a language I've been working on for the last couple of months with the goal of creating a programming language to further my learnings and integrate into another project, Lambda.

This language is primarily aimed to be simple, consistent, and lightweight. It may not be the best language in terms of performance, as it's developed around an being an interpreted tree-walk language that primarily relies on recursion to handle parsing, resolving, and interpretation.

This language is still currently experimental with many more features to come.

Current features with working examples.

Features to come

  • Standard library (Arrays, Lists, File I/O, threading)
  • modules (import statements like import module_name)
  • const (const x = 10;)
  • async (async func MakeHttpRequest() {...})
  • Compiling the language as a library for use in other software, providing the ability for easily binding your c++ code to the lamscript runtime.
  • Testing and an automated testing suite for other developers to use for working on or with lamscript.

And many more features that I've forgot to list or haven't thought of yet!

Setup

As of right now, I've only tested this setup on linux. However, there shouldn't be any reason to think that this shouldn't work on macos (and maybe windows if using a bash based shell). If there are issues building on any platform, please file an issue on this repository and I'll gladly look into creating a solution.

I utilize gcc 10.2 for building and gdb for debugging.

Once you've cloned the repository and are in lamscripts working directory:

linux

Dependencies

First, you need to setup any dependencies associated with the project with:

./scripts/setup.sh

This will fetch any sub modules and other dependencies that may be later added.

Building

To generate a release build of the interpreter, you need to execute:

./scripts/compile_lamscript.sh

Generating a debug build can be done with:

./scripts/compile_lamscript.sh --build Debug

And all flags associated with this and other scripts can be checked with:

./scripts/compile_lamscript.sh --help

Running an example

To run an example using the release build you've generated previously, you can execute:

./scripts/run_example.sh --example <example_name>.ls

Where example name is the name of an example inside of the examples folder.

To run an example with a debug build, you can simply execute:

./scripts/run_example.sh --example <example_name>.ls --build Debug

And lastly if you'd like to run either

Flag positioning doesn't matter and this assumes you built a debug build previously.

macos

Should be the same as linux, but I could be wrong if someone volunteers to try it out and prove me wrong!

windows

Not directly supported yet, but should be the same as linux assuming you have a bash shell and access to a c++ compiler from it.

Experimental features

If building lamscript from source, you can enable experimental features that are being being developed on but are not stable. This requires passing the flag

// If building inside of a directory inside the repo, using cmake to generate
// build files would look like:
cmake .. -DLAMSCRIPT_ENABLE_EXPERIMENTATION=ON

// Lamscripten requires experimentation to be enabled.
cmake .. -DLAMSCRIPT_ENABLE_EXPERIMENTATION=ON -DLAMSCRIPTEN_BUILD_EXECUTABLE

Lamscripten

Lamscripten is the successor language to lamscript and will feature a wide variety of added features and improvements. It is currently just a prototype and is highly unstable/experimental.

To build, utilize these flags within cmake:

// Lamscripten requires experimentation to be enabled.
cmake .. -DLAMSCRIPT_ENABLE_EXPERIMENTATION=ON -DLAMSCRIPTEN_BUILD_EXECUTABLE

If you're using bash, you can run:

./scripts/compile_lamscripten.sh

This will generate a release build of lamscripten with experimentation flags turned on.

Lamscripten can currently only be built as an executable and not a library, but there is no user interaction with said executable just yet.

Resources I used to implement this langauge

  • Crafting interpreters was used for learning the theory behind how languages work. Unfortunately, their guide is written in java while I chose to use c++ for the implementation. A lot of my core implementation has drastically changed from the tutorials, but the overall theory remains highly relevant to this project.
  • Recursive descent parsing was used for developing a programming language parser that recursively parses a series of tokens into their corresponding statements and expressions.
  • Curated language resource list is a list of programming language resources that was used for finding valuable and modern resources centered around developing a language. There are many great references to go through here if you'd like to look at all of the individual components a programming language is built from.
  • Formal langauge theory - caltech is a pdf that was used for understanding the intricacies of language and how you can mathematically describe things like utilizing a finite set of syntax to produce an infinite number of different strings.
  • cpp reference was used for all things c++ related.

License

This repository uses the MIT license to protect it's distributed works. Please make sure to include a copy of it in your works. As a personal favor, I ask that you also include this README to give credit to all of the resources and people that helped me build this project.

About

The first prototype of the lambda engines scripting language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published