mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Reimplement -collection; remove static from Odin tokenizer/parser in core library
This commit is contained in:
@@ -42,8 +42,8 @@ del *.ilk > NUL 2> NUL
|
|||||||
|
|
||||||
cl %compiler_settings% "src\main.cpp" ^
|
cl %compiler_settings% "src\main.cpp" ^
|
||||||
/link %linker_settings% -OUT:%exe_name% ^
|
/link %linker_settings% -OUT:%exe_name% ^
|
||||||
&& odin run examples/demo/demo.odin
|
&& odin run examples/demo/demo.odin -keep-temp-files
|
||||||
|
|
||||||
del *.obj > NUL 2> NUL
|
del *.obj > NUL 2> NUL
|
||||||
|
|
||||||
:end_of_build
|
:end_of_build
|
||||||
|
|||||||
@@ -365,7 +365,6 @@ Value_Decl :: struct {
|
|||||||
type: ^Expr,
|
type: ^Expr,
|
||||||
values: []^Expr,
|
values: []^Expr,
|
||||||
comment: ^Comment_Group,
|
comment: ^Comment_Group,
|
||||||
is_static: bool,
|
|
||||||
is_using: bool,
|
is_using: bool,
|
||||||
is_mutable: bool,
|
is_mutable: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1033,37 +1033,6 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
|||||||
expect_semicolon(p, s);
|
expect_semicolon(p, s);
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
case token.Static:
|
|
||||||
docs := p.lead_comment;
|
|
||||||
tok := expect_token(p, token.Static);
|
|
||||||
|
|
||||||
list := parse_lhs_expr_list(p);
|
|
||||||
if len(list) == 0 {
|
|
||||||
error(p, tok.pos, "illegal use of 'static' statement");
|
|
||||||
expect_semicolon(p, nil);
|
|
||||||
return ast.new(ast.Bad_Stmt, tok.pos, end_pos(p.prev_tok));
|
|
||||||
}
|
|
||||||
|
|
||||||
expect_token_after(p, token.Colon, "identifier list");
|
|
||||||
decl := parse_value_decl(p, list, docs);
|
|
||||||
if decl != nil do switch d in &decl.derived {
|
|
||||||
case ast.Value_Decl:
|
|
||||||
if d.is_mutable {
|
|
||||||
d.is_static = true;
|
|
||||||
} else {
|
|
||||||
error(p, tok.pos, "'static' may only be currently used with variable declarations");
|
|
||||||
}
|
|
||||||
case:
|
|
||||||
error(p, tok.pos, "illegal use of 'static' statement");
|
|
||||||
}
|
|
||||||
|
|
||||||
error(p, tok.pos, "illegal use of 'static' statement");
|
|
||||||
if decl != nil {
|
|
||||||
return decl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ast.new(ast.Bad_Stmt, tok.pos, end_pos(p.prev_tok));
|
|
||||||
|
|
||||||
case token.Using:
|
case token.Using:
|
||||||
docs := p.lead_comment;
|
docs := p.lead_comment;
|
||||||
tok := expect_token(p, token.Using);
|
tok := expect_token(p, token.Using);
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ using Kind :: enum u16 {
|
|||||||
Bit_Field,
|
Bit_Field,
|
||||||
Bit_Set,
|
Bit_Set,
|
||||||
Map,
|
Map,
|
||||||
Static,
|
|
||||||
Dynamic,
|
Dynamic,
|
||||||
Auto_Cast,
|
Auto_Cast,
|
||||||
Cast,
|
Cast,
|
||||||
@@ -274,7 +273,6 @@ tokens := [Kind.COUNT]string {
|
|||||||
"bit_field",
|
"bit_field",
|
||||||
"bit_set",
|
"bit_set",
|
||||||
"map",
|
"map",
|
||||||
"static",
|
|
||||||
"dynamic",
|
"dynamic",
|
||||||
"auto_cast",
|
"auto_cast",
|
||||||
"cast",
|
"cast",
|
||||||
|
|||||||
@@ -505,6 +505,71 @@ bool parse_build_flags(Array<String> args) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case BuildFlag_Collection: {
|
||||||
|
GB_ASSERT(value.kind == ExactValue_String);
|
||||||
|
String str = value.value_string;
|
||||||
|
isize eq_pos = -1;
|
||||||
|
for (isize i = 0; i < str.len; i++) {
|
||||||
|
if (str[i] == '=') {
|
||||||
|
eq_pos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eq_pos < 0) {
|
||||||
|
gb_printf_err("Expected 'name=path', got '%.*s'\n", LIT(param));
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String name = substring(str, 0, eq_pos);
|
||||||
|
String path = substring(str, eq_pos+1, str.len);
|
||||||
|
if (name.len == 0 || path.len == 0) {
|
||||||
|
gb_printf_err("Expected 'name=path', got '%.*s'\n", LIT(param));
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string_is_valid_identifier(name)) {
|
||||||
|
gb_printf_err("Library collection name '%.*s' must be a valid identifier\n", LIT(name));
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == "_") {
|
||||||
|
gb_printf_err("Library collection name cannot be an underscore\n");
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == "system") {
|
||||||
|
gb_printf_err("Library collection name 'system' is reserved\n");
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String prev_path = {};
|
||||||
|
bool found = find_library_collection_path(name, &prev_path);
|
||||||
|
if (found) {
|
||||||
|
gb_printf_err("Library collection '%.*s' already exists with path '%.*s'\n", LIT(name), LIT(prev_path));
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gbAllocator a = heap_allocator();
|
||||||
|
String fullpath = path_to_fullpath(a, path);
|
||||||
|
if (!path_is_directory(fullpath)) {
|
||||||
|
gb_printf_err("Library collection '%.*s' path must be a directory, got '%.*s'\n", LIT(name), LIT(fullpath));
|
||||||
|
gb_free(a, fullpath.text);
|
||||||
|
bad_flags = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_library_collection(name, path);
|
||||||
|
|
||||||
|
// NOTE(bill): Allow for multiple library collections
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
case BuildFlag_Define: {
|
case BuildFlag_Define: {
|
||||||
GB_ASSERT(value.kind == ExactValue_String);
|
GB_ASSERT(value.kind == ExactValue_String);
|
||||||
String str = value.value_string;
|
String str = value.value_string;
|
||||||
|
|||||||
Reference in New Issue
Block a user