improve col_offset in new line and lalr

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

View file

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

View file

@ -871,7 +871,7 @@ ShiftOp: ast::Operator = {
};
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,
end_location: Some(end_location),
custom: (),

View file

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

View file

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

View file

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

View file

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