From bcdcc9e752149a2b1c3596a6089f284d8dcd5fd3 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 15 Mar 2026 16:33:29 +0300 Subject: [PATCH] Fix identifier & literal source locations in parser --- libs/parser/rules/pslang.y | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libs/parser/rules/pslang.y b/libs/parser/rules/pslang.y index 1e33cd5..cb869c2 100644 --- a/libs/parser/rules/pslang.y +++ b/libs/parser/rules/pslang.y @@ -330,7 +330,7 @@ postfix_expression base_expression : literal -| name { $$ = ast::identifier{$1, ctx.location}; } +| name { $$ = ast::identifier{$1, @$}; } | lparen expression rparen { $$ = $2; } | lbracket nonempty_comma_separated_expression_list rbracket { $$ = ast::array{$2, @$}; } ; @@ -346,20 +346,20 @@ nonempty_comma_separated_expression_list ; literal -: true { $$ = ast::literal(ast::bool_literal{true, ctx.location}); } -| false { $$ = ast::literal(ast::bool_literal{false, ctx.location}); } -| lit_i8 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_u8 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_i16 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_u16 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_i32 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_u32 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_i64 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_u64 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_f16 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_f32 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_f64 { $$ = parse_primitive_literal($1, ctx.location); } -| lit_char8 { $$ = ast::u8_literal{static_cast($1), ctx.location}; } +: true { $$ = ast::literal(ast::bool_literal{true, @$}); } +| false { $$ = ast::literal(ast::bool_literal{false, @$}); } +| lit_i8 { $$ = parse_primitive_literal($1, @$); } +| lit_u8 { $$ = parse_primitive_literal($1, @$); } +| lit_i16 { $$ = parse_primitive_literal($1, @$); } +| lit_u16 { $$ = parse_primitive_literal($1, @$); } +| lit_i32 { $$ = parse_primitive_literal($1, @$); } +| lit_u32 { $$ = parse_primitive_literal($1, @$); } +| lit_i64 { $$ = parse_primitive_literal($1, @$); } +| lit_u64 { $$ = parse_primitive_literal($1, @$); } +| lit_f16 { $$ = parse_primitive_literal($1, @$); } +| lit_f32 { $$ = parse_primitive_literal($1, @$); } +| lit_f64 { $$ = parse_primitive_literal($1, @$); } +| lit_char8 { $$ = ast::u8_literal{static_cast($1), @$}; } ; %%