fixes
This commit is contained in:
parent
b01204fdd4
commit
9b25f36eb3
10
doc/test.bl
10
doc/test.bl
@ -13,8 +13,8 @@ lib Main {
|
||||
var testEmpty: emptyType = empty;
|
||||
var testNum: number = 3.0;
|
||||
var testBool_2: bool = 3 > 1;
|
||||
var testTest: Test = Test();
|
||||
testTest.outp();
|
||||
# var testTest: Test = Test();
|
||||
# testTest.outp();
|
||||
output('Hello World');
|
||||
output(66);
|
||||
output(3 + 3);
|
||||
@ -28,9 +28,9 @@ lib Main {
|
||||
test1234(range(0, 10));
|
||||
}
|
||||
|
||||
# public func test1234(param: list): list {
|
||||
public func test1234(): void
|
||||
{
|
||||
public func test1234(param: list): list {
|
||||
# public func test1234(): void
|
||||
# {
|
||||
/*for i in range(0, length(param)) {
|
||||
output(i);
|
||||
}*/
|
||||
|
@ -21,9 +21,13 @@ class Interpreter:
|
||||
if self.__repo.error is None:
|
||||
toks = self.__lexer.tokenize(line_str)
|
||||
|
||||
self.__repo.output_tokens(toks)
|
||||
|
||||
if self.__repo.error is None:
|
||||
self.__parser.parse(toks)
|
||||
|
||||
self.__repo.output_ast()
|
||||
|
||||
if self.__repo.error is None:
|
||||
self.__validator.validate()
|
||||
|
||||
|
@ -134,5 +134,4 @@ class Lexer:
|
||||
if line[i - 1] == '*' and c == '/':
|
||||
self.__ml_comment = False
|
||||
|
||||
# self.__repo.output_tokens(self.__toks)
|
||||
return self.__toks
|
||||
|
@ -74,6 +74,16 @@ class Parser:
|
||||
else:
|
||||
return Token('EOL', 'EOL')
|
||||
|
||||
def __add_ast(self, tok: Token) -> None:
|
||||
if self.__lib is not None and self.__class is None and self.__func is None:
|
||||
self.__lib.ast.append(tok)
|
||||
|
||||
elif self.__lib is not None and self.__class is not None and self.__func is None:
|
||||
self.__class.ast.append(tok)
|
||||
|
||||
elif self.__lib is not None and self.__class is not None and self.__func is not None:
|
||||
self.__func.ast.append(tok)
|
||||
|
||||
def __is_scope_started(self) -> bool:
|
||||
return self.__is_start_lib or self.__is_start_class or self.__is_start_func
|
||||
|
||||
|
@ -58,3 +58,13 @@ class Repo:
|
||||
|
||||
print(outp_toks)
|
||||
# print('\n')
|
||||
|
||||
def output_ast(self) -> None:
|
||||
if len(self.ast) > 0:
|
||||
outp_toks = []
|
||||
for tok in self.ast:
|
||||
outp_toks.append({tok.value: tok.type})
|
||||
# print({tok.value: tok.type})
|
||||
|
||||
print(outp_toks)
|
||||
# print('\n')
|
||||
|
@ -15,9 +15,11 @@ class Main:
|
||||
|
||||
def console(self) -> None:
|
||||
print('sh-edraft.de basic language interpreter:')
|
||||
i = 0
|
||||
cont = True
|
||||
while cont:
|
||||
cont = self.__interpreter.interpret(input('> '))
|
||||
cont = self.__interpreter.interpret(i+1, input('> '))
|
||||
i += 1
|
||||
|
||||
def files(self, file: str) -> None:
|
||||
if os.path.isfile(file):
|
||||
|
Loading…
Reference in New Issue
Block a user