#language #learning #programming-language #parser

nightly lynxlang

An educational project for learning how programming language is made

1 unstable release

0.1.1 Sep 20, 2022

#519 in Programming languages

28 downloads per month

MIT license

110KB
3K SLoC

Lynx-Lang

CI Code Coverage

🐱 Lynx-Lang is an educational project for learning how programming language is made.

Prerequisites

make sure rustup is pre-installed.

Build

cargo build --release

Test

cargo test

Coverage Test

sh coverage.sh

check coverage/index.html in the browser


lib.rs:

Lynx is an interpreter for lynx language specs derived from the noted The Monkey Language and the book ``. It is an educational crate aimed to learn how programming languages are made. Also, it is made by rookie rustaceans like me. The code in this library includes lots of comments as well as test cases. The whole idea is from the notable book The Monkey Language. I also have the idea to extend it when I am available on this project again.

In general, an interpreter consists of three major parts, as divided in separate file in src folder.

A Tokenizer will tokenize input text or stream into tokens.

Sometimes, a simple numeric can be a Number token;

1 // Token::Number

lexer

std::iter::FromIterator;
std::iter::Peekable;
std::str::CharIndices;

parser

  • pratt parsing
std::slice::Chunks
std::ops::Deref;

evaluator

// let foo1 = 2;

// outer = Env {
//     store: {
//         print: fn (),
//         foo1: 2
//     },
//     outer: None
// }

// fn call_fn(foo) {
// let bar = 1;
// return foo + bar;
// }

// call_fn(foo1)

// ScopedEnv {
//     store: {
//         bar: 1
//     },
//     outer: outer
// }

repl

No runtime deps