| Crates.io | gabelang |
| lib.rs | gabelang |
| version | 3.1.0 |
| created_at | 2025-02-11 18:07:24.919938+00 |
| updated_at | 2025-04-01 17:11:52.022426+00 |
| description | A high level, interpretted and garbage collected programming language |
| homepage | |
| repository | https://github.com/buxogabriel/gabelang |
| max_upload_size | |
| id | 1551761 |
| size | 113,855 |
This is a language I am writing in rust for fun and to learn more about lexers, parsers, interpreters, and to dymistify programming languages in general. The Writing an Interpreter in Go book by Thorsten Ball was used as a reference and insperation for this project as well as mkdb by Antonio Sarosi.
<program> = <statement> | <program> <statement>
<statement> = <let_statement> | <if_statement> | <while_loop> | <func_decl> | <expression>
<let_statement> = let <identifier> = <expression>;
<assign_statement> = <assignable> = <expression>;
<if_statement> = if <expression> <code_block>
<while_loop> = while <expression> <code_block>
<for_loop> = for(<statement> <expression>; <statement>) <code_block>
<func_decl> = fn <identifier> <param_idents> <codeblock>
<code_block> = {<program>}
<param_idents> = (<_param_idents>)
<_param_idents> = <identifier> | <_param_idents>, <_param_idents>
<identifier> = <ident_char> | <ident_char><identifier>
<indent_char> = <ALPHACHAR> | _
<expression> = <group_expression> | <operation_expression> | <assignable> | <func_call> | <object_literal> | <array_literal> | <number_literal>
<group_expression> = (<expression>)
<operation_expression> = <expression> <op> <expression>
<op> = + | - | * | /
<assignable> = <identifier> | <array_index> | <object_prop>
<array_index> = <assignable>[<expression>]
<object_prop> = <assignable>.<identifier>
<func_call> = <assignable>(<expression_list>)
<object_literal> = {<object_field_literals>}
<object_field_literals> = <identifier>: <expression> | <object_field_literals>, <object_field_literals>
<array_literal> = [<expression_list>]
<expression_list> = <expression> | <expression_list>, <expression_list>
<number_literal> = <number> | <number><number_literal>
<number> = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0
Comment your code using the //comment syntax
Any text to the right of a double slash does not make it to the parser or interpretter and will not be evaluated as code
// This function doubles a number
fn double_num(num) {
// Multiplies num by 2 to get the answer
return num * 2;
}
len(obj) -> number
reverse(obj) -> number
abs(number) -> number
Build with
cargo build --release
Requires wasm-pack to be installed
cargo install wasm-pack
Build with
wasm-pack build --features wasm
Requires cargo to be installed
Install gabelang with
cargo install gabelang
Run as repl with
gabelang
or run a script with
gabelang --file [script name]
Run tests with
cargo test