added structure & interpreter & lexer & first ast stucture

This commit is contained in:
edraft
2020-05-22 22:08:37 +02:00
commit ed97118df0
22 changed files with 481 additions and 0 deletions

29
doc/definition.txt Normal file
View File

@@ -0,0 +1,29 @@
keywords:
builtin-functions:
output
input
range
length
pass
if
elseif
else
global vars:
error:
code
msg
sys:
os_name
data types:
empty
any
string
number
bool
list
dict

13
doc/error_codes.txt Normal file
View File

@@ -0,0 +1,13 @@
Interpreter:
1.0 Start failed
1.1 File not found
Runtime:
2.0 Unknown keyword
2.1 Unknown type
2.2 Unknown variable
2.3 Unknown function
2.4 Unknown class
2.5 Unknown library
2.6 Access error: no export
2.7 Expression error

16
doc/target/main.bl Normal file
View File

@@ -0,0 +1,16 @@
use test1 from Tests;
use test2 as test3 from Tests;
lib Main {
class Program {
func Main(args: list): void {
test_a = test1();
test_a.dec_vars();
test_a.is_error();
if (!error) {
test_b = test3();
test3.continue();
}
}
}
}

33
doc/target/test.bl Normal file
View File

@@ -0,0 +1,33 @@
lib Tests
{
/*
declaration of some tests
*/
export class test1
{
export test_string: string = 'Hello';
export test_string_2: string = "Hello World";
export test_num: num = 1;
export test_num_2: num = 1.0;
export test_num_3: num = this.test_num + this.test_num_2;
export func dec_vars(): void
{
test_bool: bool = true;
test_bool_2: bool = false;
test_bool_3: bool = test_bool != test_bool_2; # true
}
export is_error(): bool
{
if (error != empty)
{
output(error.code + ' ' + error.message);
}
else
{
output('continue');
}
}
}
}

12
doc/target/test2.bl Normal file
View File

@@ -0,0 +1,12 @@
lib Tests {
export class test2 {
string_a = string1();
export func continue() {
input(string_a.string1 + ': ');
}
}
class strings {
public string1 = "hello world";
}
}

31
doc/test.bl Normal file
View File

@@ -0,0 +1,31 @@
// hi1
# hi2
/*
hi3
*/
lib Main {
class Program {
func Main() {
testBool: bool;
testEmpty: emptyType = empty;
output('Hello World');
output(66);
output(3 + 3);
test: string = input('# ');
output(test);
output(false);
if (testBool != empty) {
output(testEmpty);
}
test1234(range(0, 10));
}
public func test1234(param: list) {
for i in range(0, length(param)) {
output(i);
}
}
}
}