improve col_offset in new line and lalr

This commit is contained in:
dvermd 2022-10-19 23:45:24 +02:00
parent d5a208ca9d
commit a5b59f3c9d
6 changed files with 34 additions and 34 deletions

View file

@ -56,7 +56,7 @@ impl Location {
pub fn newline(&mut self) { pub fn newline(&mut self) {
self.row += 1; self.row += 1;
self.column = 1; self.column = 0;
} }
} }

View file

@ -871,7 +871,7 @@ ShiftOp: ast::Operator = {
}; };
ArithmeticExpression: ast::Expr = { ArithmeticExpression: ast::Expr = {
<a:ArithmeticExpression> <location:@L> <op:AddOp> <b:Term> <end_location:@R> => ast::Expr { <location:@L> <a:ArithmeticExpression> <op:AddOp> <b:Term> <end_location:@R> => ast::Expr {
location, location,
end_location: Some(end_location), end_location: Some(end_location),
custom: (), custom: (),

View file

@ -35,7 +35,7 @@ pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, Pars
/// assert_eq!( /// assert_eq!(
/// expr, /// expr,
/// ast::Expr { /// ast::Expr {
/// location: ast::Location::new(1, 2), /// location: ast::Location::new(1, 0),
/// end_location: Some(ast::Location::new(1, 5)), /// end_location: Some(ast::Location::new(1, 5)),
/// custom: (), /// custom: (),
/// node: ast::ExprKind::BinOp { /// node: ast::ExprKind::BinOp {

View file

@ -11,7 +11,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
end_location: Some( end_location: Some(
Location { Location {
row: 5, row: 5,
column: 7, column: 6,
}, },
), ),
custom: (), custom: (),
@ -58,12 +58,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 2, row: 2,
column: 2, column: 1,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 4, row: 4,
column: 2, column: 1,
}, },
), ),
custom: (), custom: (),
@ -75,12 +75,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 2, row: 2,
column: 15, column: 14,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 2, row: 2,
column: 19, column: 18,
}, },
), ),
custom: (), custom: (),
@ -101,12 +101,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 3, row: 3,
column: 3, column: 2,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 3, row: 3,
column: 7, column: 6,
}, },
), ),
custom: (), custom: (),
@ -121,12 +121,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 4, row: 4,
column: 2, column: 1,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 5, row: 5,
column: 7, column: 6,
}, },
), ),
custom: (), custom: (),
@ -138,12 +138,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 4, row: 4,
column: 26, column: 25,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 4, row: 4,
column: 30, column: 29,
}, },
), ),
custom: (), custom: (),
@ -156,12 +156,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 4, row: 4,
column: 32, column: 31,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 4, row: 4,
column: 35, column: 34,
}, },
), ),
custom: (), custom: (),
@ -180,12 +180,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 4, row: 4,
column: 36, column: 35,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 4, row: 4,
column: 45, column: 44,
}, },
), ),
custom: (), custom: (),
@ -202,12 +202,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
Located { Located {
location: Location { location: Location {
row: 5, row: 5,
column: 3, column: 2,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 5, row: 5,
column: 7, column: 6,
}, },
), ),
custom: (), custom: (),

View file

@ -11,7 +11,7 @@ expression: parse_ast
end_location: Some( end_location: Some(
Location { Location {
row: 3, row: 3,
column: 9, column: 8,
}, },
), ),
custom: (), custom: (),
@ -75,12 +75,12 @@ expression: parse_ast
Located { Located {
location: Location { location: Location {
row: 2, row: 2,
column: 1, column: 0,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 3, row: 3,
column: 1, column: 0,
}, },
), ),
custom: (), custom: (),
@ -88,12 +88,12 @@ expression: parse_ast
test: Located { test: Located {
location: Location { location: Location {
row: 2, row: 2,
column: 6, column: 5,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 2, row: 2,
column: 7, column: 6,
}, },
), ),
custom: (), custom: (),
@ -108,12 +108,12 @@ expression: parse_ast
Located { Located {
location: Location { location: Location {
row: 2, row: 2,
column: 9, column: 8,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 2, row: 2,
column: 11, column: 10,
}, },
), ),
custom: (), custom: (),
@ -121,12 +121,12 @@ expression: parse_ast
value: Located { value: Located {
location: Location { location: Location {
row: 2, row: 2,
column: 9, column: 8,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 2, row: 2,
column: 11, column: 10,
}, },
), ),
custom: (), custom: (),
@ -144,12 +144,12 @@ expression: parse_ast
Located { Located {
location: Location { location: Location {
row: 3, row: 3,
column: 7, column: 6,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 3, row: 3,
column: 9, column: 8,
}, },
), ),
custom: (), custom: (),
@ -157,12 +157,12 @@ expression: parse_ast
value: Located { value: Located {
location: Location { location: Location {
row: 3, row: 3,
column: 7, column: 6,
}, },
end_location: Some( end_location: Some(
Location { Location {
row: 3, row: 3,
column: 9, column: 8,
}, },
), ),
custom: (), custom: (),

View file

@ -48,7 +48,7 @@ Located {
value: Located { value: Located {
location: Location { location: Location {
row: 1, row: 1,
column: 8, column: 6,
}, },
end_location: Some( end_location: Some(
Location { Location {