fix syntax errors with -O3
This commit is contained in:
@@ -25,7 +25,8 @@ static void astTokenListEnsureCapacity(
|
||||
list->cap = new_cap;
|
||||
}
|
||||
|
||||
Ast astParse(const char* source, const uint32_t len) {
|
||||
static __attribute__((noinline)) AstTokenList tokenize(
|
||||
const char* source, uint32_t len) {
|
||||
uint32_t estimated_token_count = len / 8;
|
||||
|
||||
AstTokenList tokens = {
|
||||
@@ -45,6 +46,12 @@ Ast astParse(const char* source, const uint32_t len) {
|
||||
break;
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
Ast astParse(const char* source, const uint32_t len) {
|
||||
AstTokenList tokens = tokenize(source, len);
|
||||
|
||||
uint32_t estimated_node_count = (tokens.len + 2) / 2;
|
||||
|
||||
char err_buf[PARSE_ERR_BUF_SIZE];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// //
|
||||
// astgen.c -- AST to ZIR conversion, ported from lib/std/zig/AstGen.zig.
|
||||
//
|
||||
// Structural translation of AstGen.zig into C.
|
||||
@@ -13699,21 +13700,17 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
|
||||
// block (Ast.zig:1085): end_offset += 1 (rbrace), recurse into last.
|
||||
case AST_NODE_BLOCK: {
|
||||
uint32_t start = nd.lhs;
|
||||
uint32_t end = nd.rhs;
|
||||
assert(start != end);
|
||||
assert(nd.lhs != nd.rhs);
|
||||
end_offset += 1;
|
||||
n = tree->extra_data.arr[end - 1];
|
||||
n = tree->extra_data.arr[nd.rhs - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
// block_semicolon (Ast.zig:1097): += 2 (semicolon + rbrace).
|
||||
case AST_NODE_BLOCK_SEMICOLON: {
|
||||
uint32_t start = nd.lhs;
|
||||
uint32_t end = nd.rhs;
|
||||
assert(start != end);
|
||||
assert(nd.lhs != nd.rhs);
|
||||
end_offset += 2;
|
||||
n = tree->extra_data.arr[end - 1];
|
||||
n = tree->extra_data.arr[nd.rhs - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -13970,9 +13967,8 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
}
|
||||
case AST_NODE_SWITCH_COMMA: {
|
||||
uint32_t ei = nd.rhs;
|
||||
uint32_t cs = tree->extra_data.arr[ei];
|
||||
uint32_t ce = tree->extra_data.arr[ei + 1];
|
||||
assert(cs != ce);
|
||||
assert(tree->extra_data.arr[ei] != ce);
|
||||
end_offset += 2; // comma + rbrace
|
||||
n = tree->extra_data.arr[ce - 1];
|
||||
continue;
|
||||
@@ -14036,9 +14032,8 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
|
||||
// struct_init: node_and_extra SubRange pattern.
|
||||
case AST_NODE_STRUCT_INIT: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 1;
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
@@ -14046,17 +14041,15 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
|
||||
// call: SubRange pattern.
|
||||
case AST_NODE_CALL: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 1;
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
}
|
||||
case AST_NODE_CALL_COMMA: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 2;
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
@@ -14147,9 +14140,8 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
continue;
|
||||
}
|
||||
case AST_NODE_CONTAINER_DECL_ARG_TRAILING: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 2;
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
@@ -14214,9 +14206,8 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
|
||||
// struct_init_comma: node_and_extra SubRange.
|
||||
case AST_NODE_STRUCT_INIT_COMMA: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 2;
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
@@ -14224,17 +14215,15 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
|
||||
// array_init variants.
|
||||
case AST_NODE_ARRAY_INIT: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 1;
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
}
|
||||
case AST_NODE_ARRAY_INIT_COMMA: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 2;
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
@@ -14375,9 +14364,8 @@ static uint32_t lastToken(const Ast* tree, uint32_t node) {
|
||||
}
|
||||
// tagged_union_enum_tag_trailing (Ast.zig:1022-1030).
|
||||
case AST_NODE_TAGGED_UNION_ENUM_TAG_TRAILING: {
|
||||
uint32_t si = tree->extra_data.arr[nd.rhs];
|
||||
uint32_t se = tree->extra_data.arr[nd.rhs + 1];
|
||||
assert(si != se);
|
||||
assert(tree->extra_data.arr[nd.rhs] != se);
|
||||
end_offset += 2; // comma/semicolon + rbrace
|
||||
n = tree->extra_data.arr[se - 1];
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user