Fix identifier & literal source locations in parser

This commit is contained in:
Nikita Lisitsa 2026-03-15 16:33:29 +03:00
parent b25400ad65
commit bcdcc9e752

View file

@ -330,7 +330,7 @@ postfix_expression
base_expression base_expression
: literal : literal
| name { $$ = ast::identifier{$1, ctx.location}; } | name { $$ = ast::identifier{$1, @$}; }
| lparen expression rparen { $$ = $2; } | lparen expression rparen { $$ = $2; }
| lbracket nonempty_comma_separated_expression_list rbracket { $$ = ast::array{$2, @$}; } | lbracket nonempty_comma_separated_expression_list rbracket { $$ = ast::array{$2, @$}; }
; ;
@ -346,20 +346,20 @@ nonempty_comma_separated_expression_list
; ;
literal literal
: true { $$ = ast::literal(ast::bool_literal{true, ctx.location}); } : true { $$ = ast::literal(ast::bool_literal{true, @$}); }
| false { $$ = ast::literal(ast::bool_literal{false, ctx.location}); } | false { $$ = ast::literal(ast::bool_literal{false, @$}); }
| lit_i8 { $$ = parse_primitive_literal<std::int8_t>($1, ctx.location); } | lit_i8 { $$ = parse_primitive_literal<std::int8_t>($1, @$); }
| lit_u8 { $$ = parse_primitive_literal<std::uint8_t>($1, ctx.location); } | lit_u8 { $$ = parse_primitive_literal<std::uint8_t>($1, @$); }
| lit_i16 { $$ = parse_primitive_literal<std::int16_t>($1, ctx.location); } | lit_i16 { $$ = parse_primitive_literal<std::int16_t>($1, @$); }
| lit_u16 { $$ = parse_primitive_literal<std::uint16_t>($1, ctx.location); } | lit_u16 { $$ = parse_primitive_literal<std::uint16_t>($1, @$); }
| lit_i32 { $$ = parse_primitive_literal<std::int32_t>($1, ctx.location); } | lit_i32 { $$ = parse_primitive_literal<std::int32_t>($1, @$); }
| lit_u32 { $$ = parse_primitive_literal<std::uint32_t>($1, ctx.location); } | lit_u32 { $$ = parse_primitive_literal<std::uint32_t>($1, @$); }
| lit_i64 { $$ = parse_primitive_literal<std::int64_t>($1, ctx.location); } | lit_i64 { $$ = parse_primitive_literal<std::int64_t>($1, @$); }
| lit_u64 { $$ = parse_primitive_literal<std::uint64_t>($1, ctx.location); } | lit_u64 { $$ = parse_primitive_literal<std::uint64_t>($1, @$); }
| lit_f16 { $$ = parse_primitive_literal<types::half_float>($1, ctx.location); } | lit_f16 { $$ = parse_primitive_literal<types::half_float>($1, @$); }
| lit_f32 { $$ = parse_primitive_literal<float>($1, ctx.location); } | lit_f32 { $$ = parse_primitive_literal<float>($1, @$); }
| lit_f64 { $$ = parse_primitive_literal<double>($1, ctx.location); } | lit_f64 { $$ = parse_primitive_literal<double>($1, @$); }
| lit_char8 { $$ = ast::u8_literal{static_cast<std::uint8_t>($1), ctx.location}; } | lit_char8 { $$ = ast::u8_literal{static_cast<std::uint8_t>($1), @$}; }
; ;
%% %%