mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-14 13:31:25 -07:00
fix parse error visualization; fix invalid cases in eval expression parser
This commit is contained in:
+2
-2
@@ -84,8 +84,8 @@ E_ExprKindTable:
|
||||
{ Deref UnaryPrefix 2 "*" "*" "" "" }
|
||||
{ Address UnaryPrefix 2 "&" "&" "" "" }
|
||||
|
||||
{ Cast Null 0 "cast" "" "" "" }
|
||||
{ Sizeof UnaryPrefix 0 "sizeof" "sizeof" "" "" }
|
||||
{ Cast Null 1 "cast" "" "" "" }
|
||||
{ Sizeof UnaryPrefix 1 "sizeof" "sizeof" "" "" }
|
||||
|
||||
{ Neg UnaryPrefix 2 "-" "-" "" "" }
|
||||
{ LogNot UnaryPrefix 2 "!" "!" "" "" }
|
||||
|
||||
+17
-10
@@ -1191,14 +1191,21 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
it = nested_parse.last_token;
|
||||
|
||||
// rjf: build cast-to-U64*, and dereference operators
|
||||
E_Expr *type = e_push_expr(arena, E_ExprKind_TypeIdent, token_string.str);
|
||||
type->type_key = e_type_key_cons_ptr(e_type_key_basic(E_TypeKind_U64));
|
||||
E_Expr *casted = atom;
|
||||
E_Expr *cast = e_push_expr(arena, E_ExprKind_Cast, token_string.str);
|
||||
e_expr_push_child(cast, type);
|
||||
e_expr_push_child(cast, casted);
|
||||
atom = e_push_expr(arena, E_ExprKind_Deref, token_string.str);
|
||||
e_expr_push_child(atom, cast);
|
||||
if(nested_parse.expr == &e_expr_nil)
|
||||
{
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, token_string.str, "Expected expression following `[`.");
|
||||
}
|
||||
else
|
||||
{
|
||||
E_Expr *type = e_push_expr(arena, E_ExprKind_TypeIdent, token_string.str);
|
||||
type->type_key = e_type_key_cons_ptr(e_type_key_basic(E_TypeKind_U64));
|
||||
E_Expr *casted = atom;
|
||||
E_Expr *cast = e_push_expr(arena, E_ExprKind_Cast, token_string.str);
|
||||
e_expr_push_child(cast, type);
|
||||
e_expr_push_child(cast, casted);
|
||||
atom = e_push_expr(arena, E_ExprKind_Deref, token_string.str);
|
||||
e_expr_push_child(atom, cast);
|
||||
}
|
||||
|
||||
// rjf: expect ]
|
||||
E_Token close_paren_maybe = e_token_at_it(it, tokens);
|
||||
@@ -1814,7 +1821,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
}
|
||||
|
||||
//- rjf: upgrade atom w/ previously parsed prefix unaries
|
||||
if(atom == &e_expr_nil && first_prefix_unary != 0 && first_prefix_unary->cast_expr != 0)
|
||||
if(atom == &e_expr_nil && first_prefix_unary != 0 && first_prefix_unary->cast_expr != &e_expr_nil)
|
||||
{
|
||||
atom = first_prefix_unary->cast_expr;
|
||||
for(PrefixUnaryNode *prefix_unary = first_prefix_unary->next;
|
||||
@@ -1830,7 +1837,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
e_expr_push_child(atom, rhs);
|
||||
}
|
||||
}
|
||||
else if(atom == 0 && first_prefix_unary != 0)
|
||||
else if(atom == &e_expr_nil && first_prefix_unary != 0)
|
||||
{
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, last_prefix_unary->location, "Missing expression.");
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ E_OpInfo e_expr_kind_op_info_table[43] =
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp("."), str8_lit_comp("MemberAccess") },
|
||||
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("*"), str8_lit_comp(""), str8_lit_comp("Deref") },
|
||||
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("&"), str8_lit_comp(""), str8_lit_comp("Address") },
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("Cast") },
|
||||
{ E_OpKind_UnaryPrefix, 0, str8_lit_comp("sizeof"), str8_lit_comp(""), str8_lit_comp("Sizeof") },
|
||||
{ E_OpKind_Null, 1, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("Cast") },
|
||||
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("sizeof"), str8_lit_comp(""), str8_lit_comp("Sizeof") },
|
||||
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("-"), str8_lit_comp(""), str8_lit_comp("Neg") },
|
||||
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("!"), str8_lit_comp(""), str8_lit_comp("LogNot") },
|
||||
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("~"), str8_lit_comp(""), str8_lit_comp("BitNot") },
|
||||
|
||||
Reference in New Issue
Block a user