Skip to content

Commit

Permalink
Fix ast types' _fields and use 0-based column
Browse files Browse the repository at this point in the history
  • Loading branch information
dvermd authored and youknowone committed Oct 26, 2022
1 parent 952d70b commit fa41a1e
Show file tree
Hide file tree
Showing 56 changed files with 480 additions and 480 deletions.
2 changes: 1 addition & 1 deletion ast/asdl_rs.py
Expand Up @@ -449,7 +449,7 @@ def gen_classdef(self, name, fields, attrs, depth, base="AstNode"):
f"ctx.new_str(ascii!({json.dumps(f.name)})).into()" for f in fields
)
self.emit(
f"class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![{fields}]).into());",
f"class.set_attr(identifier!(ctx, _fields), ctx.new_tuple(vec![{fields}]).into());",
depth + 2,
)
attrs = ",".join(
Expand Down
2 changes: 1 addition & 1 deletion core/src/location.rs
Expand Up @@ -43,7 +43,7 @@ impl Location {

pub fn reset(&mut self) {
self.row = 1;
self.column = 1;
self.column = 0;
}

pub fn go_right(&mut self) {
Expand Down
12 changes: 6 additions & 6 deletions parser/src/parser.rs
Expand Up @@ -35,13 +35,13 @@ pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, Pars
/// assert_eq!(
/// expr,
/// ast::Expr {
/// location: ast::Location::new(1, 3),
/// end_location: Some(ast::Location::new(1, 6)),
/// location: ast::Location::new(1, 2),
/// end_location: Some(ast::Location::new(1, 5)),
/// custom: (),
/// node: ast::ExprKind::BinOp {
/// left: Box::new(ast::Expr {
/// location: ast::Location::new(1, 1),
/// end_location: Some(ast::Location::new(1, 2)),
/// location: ast::Location::new(1, 0),
/// end_location: Some(ast::Location::new(1, 1)),
/// custom: (),
/// node: ast::ExprKind::Constant {
/// value: ast::Constant::Int(1.into()),
Expand All @@ -50,8 +50,8 @@ pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, Pars
/// }),
/// op: ast::Operator::Add,
/// right: Box::new(ast::Expr {
/// location: ast::Location::new(1, 5),
/// end_location: Some(ast::Location::new(1, 6)),
/// location: ast::Location::new(1, 4),
/// end_location: Some(ast::Location::new(1, 5)),
/// custom: (),
/// node: ast::ExprKind::Constant {
/// value: ast::Constant::Int(2.into()),
Expand Down
Expand Up @@ -6,25 +6,25 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 1,
column: 0,
},
end_location: Some(
Location {
row: 1,
column: 11,
column: 10,
},
),
custom: (),
node: AnnAssign {
target: Located {
location: Location {
row: 1,
column: 1,
column: 0,
},
end_location: Some(
Location {
row: 1,
column: 2,
column: 1,
},
),
custom: (),
Expand All @@ -36,12 +36,12 @@ expression: parse_ast
annotation: Located {
location: Location {
row: 1,
column: 4,
column: 3,
},
end_location: Some(
Location {
row: 1,
column: 7,
column: 6,
},
),
custom: (),
Expand All @@ -54,12 +54,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 10,
column: 9,
},
end_location: Some(
Location {
row: 1,
column: 11,
column: 10,
},
),
custom: (),
Expand Down
Expand Up @@ -6,12 +6,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 1,
column: 0,
},
end_location: Some(
Location {
row: 1,
column: 16,
column: 15,
},
),
custom: (),
Expand All @@ -20,25 +20,25 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 1,
column: 0,
},
end_location: Some(
Location {
row: 1,
column: 4,
column: 3,
},
),
custom: (),
node: Attribute {
value: Located {
location: Location {
row: 1,
column: 1,
column: 0,
},
end_location: Some(
Location {
row: 1,
column: 2,
column: 1,
},
),
custom: (),
Expand All @@ -55,12 +55,12 @@ expression: parse_ast
value: Located {
location: Location {
row: 1,
column: 8,
column: 7,
},
end_location: Some(
Location {
row: 1,
column: 15,
column: 14,
},
),
custom: (),
Expand All @@ -69,12 +69,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 8,
column: 7,
},
end_location: Some(
Location {
row: 1,
column: 9,
column: 8,
},
),
custom: (),
Expand All @@ -88,12 +88,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 11,
column: 10,
},
end_location: Some(
Location {
row: 1,
column: 12,
column: 11,
},
),
custom: (),
Expand All @@ -107,12 +107,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 14,
column: 13,
},
end_location: Some(
Location {
row: 1,
column: 15,
column: 14,
},
),
custom: (),
Expand Down
Expand Up @@ -6,25 +6,25 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 1,
column: 0,
},
end_location: Some(
Location {
row: 1,
column: 25,
column: 24,
},
),
custom: (),
node: For {
target: Located {
location: Location {
row: 1,
column: 5,
column: 4,
},
end_location: Some(
Location {
row: 1,
column: 6,
column: 5,
},
),
custom: (),
Expand All @@ -36,12 +36,12 @@ expression: parse_ast
iter: Located {
location: Location {
row: 1,
column: 11,
column: 10,
},
end_location: Some(
Location {
row: 1,
column: 18,
column: 17,
},
),
custom: (),
Expand All @@ -50,12 +50,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 11,
column: 10,
},
end_location: Some(
Location {
row: 1,
column: 12,
column: 11,
},
),
custom: (),
Expand All @@ -69,12 +69,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 14,
column: 13,
},
end_location: Some(
Location {
row: 1,
column: 15,
column: 14,
},
),
custom: (),
Expand All @@ -88,12 +88,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 17,
column: 16,
},
end_location: Some(
Location {
row: 1,
column: 18,
column: 17,
},
),
custom: (),
Expand All @@ -112,12 +112,12 @@ expression: parse_ast
Located {
location: Location {
row: 1,
column: 21,
column: 20,
},
end_location: Some(
Location {
row: 1,
column: 25,
column: 24,
},
),
custom: (),
Expand Down

0 comments on commit fa41a1e

Please sign in to comment.