Closed youknowone closed 1 year ago
Currently the rust AST nodes layout is almost same as Python ast defined in Python side.
pub struct Arguments<R = TextRange> { pub range: OptionalRange<R>, pub posonlyargs: Vec<Arg<R>>, pub args: Vec<Arg<R>>, pub vararg: Option<Box<Arg<R>>>, pub kwonlyargs: Vec<Arg<R>>, pub kw_defaults: Vec<Expr<R>>, pub kwarg: Option<Box<Arg<R>>>, pub defaults: Vec<Expr<R>>, }
Which is less parser-friendly than:
pub struct Arguments<R = TextRange> { range: ..., posonlyargs: Vec<Argument>, args: Vec<Argument>, vararg: Option<Box<Argument>>, kwonlyargs: Vec<Argument>, kwarg: Option<Box<Argument>>, type_comment: Option<String>, // unparsed type_comment // no defaults and kw_defaults here } struct Argument { arg: Identifier, annotation: Option<Expr>, default: Option<Expr>, // default is placed here unlike Arg }
cc @MichaReiser
I like that. It should also make it less error prone to inspect the AST
Currently the rust AST nodes layout is almost same as Python ast defined in Python side.
Which is less parser-friendly than:
cc @MichaReiser