1 unstable release
0.1.1 | Sep 20, 2022 |
---|
#579 in Programming languages
110KB
3K
SLoC
Lynx-Lang
🐱 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;
- lexing by incrementing vec index
- lexing by iterating
- nom-based lexing https://blog.wadackel.me/2018/rs-monkey-lang/
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
// }