New syntax that's easier to parse, parsing doesn't need variable lookup

This commit is contained in:
Krzosa Karol
2022-05-03 11:31:21 +02:00
parent 3c376bbe30
commit 8c04044ea2
12 changed files with 1216 additions and 244 deletions

66
test.cc
View File

@@ -1,26 +1,26 @@
#if 0
OS_Memory:struct{
OS_Memory::struct{
data: void*;
commit: SizeU;
reserve: SizeU;
}
Arena:struct{
Arena::struct{
@using memory: OS_Memory;
len: U64;
alignment: U64;
}
String:struct{
String::struct{
str: U8*;
len: S64;
}
Intern_String:typedef String;
Intern_String::typedef String;
@stringify
@prefix="TK_"
Token_Kind:enum{
Token_Kind::enum{
@str="End of stream" End,
@str="*" Mul,
@str="/" Div,
@@ -86,25 +86,25 @@ Token_Kind:enum{
Keyword,
}
Token:struct{
Token::struct{
kind:Token_Kind;
@using string:String;
union:{
int_val:S64;
error_val:String;
intern_val:Intern_String;
}
val: union{
integer:S64;
error:String;
intern:Intern_String;
};
file:String;
line:S64;
line_begin:U8*;
}
Tokens:struct{
Tokens::struct{
@array tokens: Token*;
iter : S64;
}
Lex_Stream:struct{
Lex_Stream::struct{
stream: U8*;
line_begin: U8*;
filename: String;
@@ -112,7 +112,7 @@ Lex_Stream:struct{
}
@prefix="EK_"
Expr_Kind: enum{
Expr_Kind::enum{
None,
Atom,
Unary,
@@ -124,46 +124,44 @@ Expr_Kind: enum{
Index,
}
/*
Expr: struct{
Expr:: struct{
kind: Expr_Kind;
token: Token*;
next : Expr*;
union:{
cast: struct{
_: union{
cast_val: struct{
type: AST_Node*;
expr: Expr*;
}
};
list: struct{
first: Expr *;
last: Expr *;
}
};
call: struct{
atom: Expr *;
list: Expr *;
}
};
index: struct{
atom: Expr *;
index: Expr *;
}
};
unary: struct{
expr: Expr* ;
}
};
binary: struct{
left: Expr* ;
right: Expr* ;
}
};
ternary: struct{
cond: Expr* ;
on_true: Expr*;
on_false: Expr*;
}
}
};
};
}
*/
@prefix="AK_"
AST_Kind:enum{
AST_Kind::enum{
None,
BaseType,
Typedef,
@@ -179,7 +177,7 @@ AST_Kind:enum{
EnumChild,
}
AST_Node:struct{
AST_Node::struct{
kind: AST_Kind;
pos : Token*;
name: Intern_String;
@@ -192,28 +190,28 @@ AST_Node:struct{
first_child: AST_Node*;
last_child: AST_Node*;
union:{
_:union{
base_type_size: SizeU;
pointer: AST_Node*;
typedef_type: AST_Node*;
variable_type: AST_Node*;
func_return_type: AST_Node*;
}
};
}
Parser_Error: struct{
Parser_Error :: struct{
next: Parser_Error*;
message: String;
token : Token *;
}
Scope: struct{
Scope :: struct{
next : Scope*;
first: AST_Node*;
last : AST_Node*;
}
Parser: struct{
Parser :: struct{
main_arena: Arena;
intern_table_arena: Arena;
symbol_table_arena: Arena;