mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
fixed bug in parser on when
This commit is contained in:
@@ -2226,6 +2226,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
|||||||
p.expr_level = -1;
|
p.expr_level = -1;
|
||||||
where_clauses = parse_rhs_expr_list(p);
|
where_clauses = parse_rhs_expr_list(p);
|
||||||
p.expr_level = prev_level;
|
p.expr_level = prev_level;
|
||||||
|
tags = parse_proc_tags(p);
|
||||||
}
|
}
|
||||||
if p.allow_type && p.expr_level < 0 {
|
if p.allow_type && p.expr_level < 0 {
|
||||||
if where_token.kind != .Invalid {
|
if where_token.kind != .Invalid {
|
||||||
@@ -3152,6 +3153,7 @@ parse_simple_stmt :: proc(p: ^Parser, flags: Stmt_Allow_Flags) -> ^ast.Stmt {
|
|||||||
case ast.For_Stmt: n.label = label;
|
case ast.For_Stmt: n.label = label;
|
||||||
case ast.Switch_Stmt: n.label = label;
|
case ast.Switch_Stmt: n.label = label;
|
||||||
case ast.Type_Switch_Stmt: n.label = label;
|
case ast.Type_Switch_Stmt: n.label = label;
|
||||||
|
case ast.Range_Stmt: n.label = label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -256,12 +256,14 @@ align_switch_smt :: proc(p: ^Printer, index: int) {
|
|||||||
length += len(format_token.text) + format_token.spaces_before;
|
length += len(format_token.text) + format_token.spaces_before;
|
||||||
}
|
}
|
||||||
|
|
||||||
if case_count > brace_token.parameter_count {
|
if case_count >= brace_token.parameter_count {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.println(case_count, brace_token);
|
||||||
|
|
||||||
case_count = 0;
|
case_count = 0;
|
||||||
|
|
||||||
for line, line_index in p.lines[brace_line+1:] {
|
for line, line_index in p.lines[brace_line+1:] {
|
||||||
@@ -291,10 +293,10 @@ align_switch_smt :: proc(p: ^Printer, index: int) {
|
|||||||
|
|
||||||
length += len(format_token.text) + format_token.spaces_before;
|
length += len(format_token.text) + format_token.spaces_before;
|
||||||
|
|
||||||
if case_count > brace_token.parameter_count {
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if case_count >= brace_token.parameter_count {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,8 +333,6 @@ align_struct :: proc(p: ^Printer, index: int) {
|
|||||||
largest := 0;
|
largest := 0;
|
||||||
colon_count := 0;
|
colon_count := 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for line, line_index in p.lines[brace_line+1:] {
|
for line, line_index in p.lines[brace_line+1:] {
|
||||||
|
|
||||||
length := 0;
|
length := 0;
|
||||||
@@ -352,7 +352,7 @@ align_struct :: proc(p: ^Printer, index: int) {
|
|||||||
length += len(format_token.text) + format_token.spaces_before;
|
length += len(format_token.text) + format_token.spaces_before;
|
||||||
}
|
}
|
||||||
|
|
||||||
if colon_count > brace_token.parameter_count {
|
if colon_count >= brace_token.parameter_count {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,19 +371,18 @@ align_struct :: proc(p: ^Printer, index: int) {
|
|||||||
|
|
||||||
if format_token.kind == .Colon {
|
if format_token.kind == .Colon {
|
||||||
colon_count += 1;
|
colon_count += 1;
|
||||||
line.format_tokens[i+1].spaces_before += (largest - length) - 1;
|
line.format_tokens[i+1].spaces_before = largest - length + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
length += len(format_token.text) + format_token.spaces_before;
|
length += len(format_token.text) + format_token.spaces_before;
|
||||||
}
|
}
|
||||||
|
|
||||||
if colon_count > brace_token.parameter_count {
|
if colon_count >= brace_token.parameter_count {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
align_blocks :: proc(p: ^Printer) {
|
align_blocks :: proc(p: ^Printer) {
|
||||||
|
|||||||
@@ -1259,14 +1259,13 @@ visit_field_list :: proc(p: ^Printer, list: ^ast.Field_List, add_comma := false,
|
|||||||
|
|
||||||
visit_exprs(p, field.names, true);
|
visit_exprs(p, field.names, true);
|
||||||
|
|
||||||
if len(field.names) != 0 {
|
|
||||||
push_generic_token(p, .Colon, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if field.type != nil {
|
if field.type != nil {
|
||||||
|
if len(field.names) != 0 {
|
||||||
|
push_generic_token(p, .Colon, 0);
|
||||||
|
}
|
||||||
visit_expr(p, field.type);
|
visit_expr(p, field.type);
|
||||||
} else {
|
} else {
|
||||||
push_generic_token(p, .Colon, 0);
|
push_generic_token(p, .Colon, 1);
|
||||||
push_generic_token(p, .Eq, 0);
|
push_generic_token(p, .Eq, 0);
|
||||||
visit_expr(p, field.default_value);
|
visit_expr(p, field.default_value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user