GithubHelp home page GithubHelp logo

olya3209 / kavascript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maximecb/kavascript

0.0 0.0 0.0 200 KB

Minimalistic dynamically-typed programming language for didactic purposes.

License: Apache License 2.0

Rust 100.00%

kavascript's Introduction

KavaScript

Simple, dynamically-typed toy programming language for fun/didactic/tutorial purposes. Implemented in Rust. The codebase is intentionally kept small, easy to read and is well-commented.

I wrote this to demonstrate how easy it is to roll your own simple and readable top-down recursive descent parser that will handle a grammar similar to C/JS/Rust/Python or Lisp. I also wanted to show that the old school distinction between parsing and lexing/tokenization is kind of arbitrary and doesn't really need to exist.

This project is also an experiment to see how far I could get with the idea of parsing source code directly into bytecode without generating an AST first. Parsing directly to bytecode can produce a faster parser but is probably not ideal for languages that want to do complex static analysis (e.g. type analysis). It should be relatively easy to modify this parser to generate an AST instead of bytecode if desired.

Features:

  • Syntax inspired by JS and C
  • Minimalistic by design
  • Top down recursive descent parser with support for infix expressions
  • No separation between parsing and tokenization/lexing
  • Source code is parsed into bytecode directly, without building an AST
  • Token-threaded, stack-based bytecode interpreter
  • Simple mark & sweep garbage collector

Limitations:

  • Currently has no arrays or objects

Installation

Clone this repository:

git clone [email protected]:maximecb/kavascript.git

Build and run the project:

# Run tests
cargo test

# Compiles project to ./target/debug/ksvm
carbo build

# For best performance, builds to ./target/release/ksvm
carbo build --release

# Run an example script
cargo run example.pls

kavascript's People

Contributors

maximecb avatar fniephaus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.