mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-03 18:29:04 +00:00
Resolve conflict
This commit is contained in:
commit
d8cfc7e84f
4 changed files with 2445 additions and 144 deletions
|
@ -10,7 +10,8 @@ use crate::{
|
|||
lexer,
|
||||
context::set_context,
|
||||
string::parse_strings,
|
||||
token::StringKind
|
||||
token::StringKind,
|
||||
with::{ExprOrWithitems, TupleOrWithitems},
|
||||
};
|
||||
use num_bigint::BigInt;
|
||||
|
||||
|
@ -159,10 +160,6 @@ TestOrStarExprList: ast::Expr = {
|
|||
TestList
|
||||
};
|
||||
|
||||
TestOrStarNamedExprList: ast::Expr = {
|
||||
GenericList<TestOrStarNamedExpr>
|
||||
};
|
||||
|
||||
TestOrStarExpr: ast::Expr = {
|
||||
Test,
|
||||
StarExpr,
|
||||
|
@ -173,6 +170,12 @@ TestOrStarNamedExpr: ast::Expr = {
|
|||
StarExpr,
|
||||
};
|
||||
|
||||
TestOrStarNamedExprOrWithitem: (ast::Expr, Option<Box<ast::Expr>>) = {
|
||||
<e:NamedExpressionTest> => (e, None),
|
||||
<e:StarExpr> => (e, None),
|
||||
<e:Test> "as" <v:Expression> => (e, Some(Box::new(v))),
|
||||
}
|
||||
|
||||
AugAssign: ast::Operator = {
|
||||
"+=" => ast::Operator::Add,
|
||||
"-=" => ast::Operator::Sub,
|
||||
|
@ -496,7 +499,7 @@ ExceptClause: ast::Excepthandler = {
|
|||
};
|
||||
|
||||
WithStatement: ast::Stmt = {
|
||||
<location:@L> <is_async:"async"?> "with" <items:OneOrMore<WithItem>> ":" <body:Suite> => {
|
||||
<location:@L> <is_async:"async"?> "with" <items:WithItems> ":" <body:Suite> => {
|
||||
let end_location = body.last().unwrap().end_location.unwrap();
|
||||
let type_comment = None;
|
||||
let node = if is_async.is_some() {
|
||||
|
@ -508,6 +511,25 @@ WithStatement: ast::Stmt = {
|
|||
},
|
||||
};
|
||||
|
||||
// These are only used for their types as macro parameters
|
||||
ExprGoal: ast::Expr = {};
|
||||
ExprOrWithitemsGoal: ExprOrWithitems = {};
|
||||
|
||||
WithItems: Vec<ast::Withitem> = {
|
||||
<items:TestAs<ExprOrWithitemsGoal>> =>? items.try_into(),
|
||||
<first:TestAs<ExprOrWithitemsGoal>> "as" <vars:Expression> =>? {
|
||||
let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store)));
|
||||
let context_expr = Box::new(first.try_into()?);
|
||||
Ok(vec![ast::Withitem { context_expr, optional_vars }])
|
||||
},
|
||||
<first:TestAs<ExprOrWithitemsGoal>> <n:("as" Expression)?> "," <mut items:OneOrMore<WithItem>> =>? {
|
||||
let optional_vars = n.map(|val| Box::new(set_context(val.1, ast::ExprContext::Store)));
|
||||
let context_expr = Box::new(first.try_into()?);
|
||||
items.insert(0, ast::Withitem { context_expr, optional_vars });
|
||||
Ok(items)
|
||||
}
|
||||
};
|
||||
|
||||
WithItem: ast::Withitem = {
|
||||
<context_expr:Test> <n:("as" Expression)?> => {
|
||||
let optional_vars = n.map(|val| Box::new(set_context(val.1, ast::ExprContext::Store)));
|
||||
|
@ -715,24 +737,20 @@ YieldExpr: ast::Expr = {
|
|||
},
|
||||
};
|
||||
|
||||
Test: ast::Expr = {
|
||||
<expr:OrTest> <condition: (@L "if" OrTest "else" Test @R)?> => {
|
||||
if let Some(c) = condition {
|
||||
ast::Expr {
|
||||
location: c.0,
|
||||
end_location: Some(c.5),
|
||||
custom: (),
|
||||
node: ast::ExprKind::IfExp {
|
||||
test: Box::new(c.2),
|
||||
body: Box::new(expr),
|
||||
orelse: Box::new(c.4),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
expr
|
||||
Test = TestAs<ExprGoal>;
|
||||
TestAs<Goal>: Goal = {
|
||||
<body:OrTest> <location:@L> "if" <test:OrTest> "else" <orelse:Test> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::IfExp {
|
||||
test: Box::new(test),
|
||||
body: Box::new(body),
|
||||
orelse: Box::new(orelse),
|
||||
}
|
||||
},
|
||||
LambdaDef,
|
||||
}.into(),
|
||||
OrTestAs<Goal>,
|
||||
<e:LambdaDef> => e.into(),
|
||||
};
|
||||
|
||||
NamedExpressionTest: ast::Expr = {
|
||||
|
@ -782,51 +800,49 @@ LambdaDef: ast::Expr = {
|
|||
}
|
||||
}
|
||||
|
||||
OrTest: ast::Expr = {
|
||||
<location:@L> <e1:AndTest> <e2:("or" AndTest)*> <end_location:@R> => {
|
||||
if e2.is_empty() {
|
||||
e1
|
||||
} else {
|
||||
let mut values = vec![e1];
|
||||
values.extend(e2.into_iter().map(|e| e.1));
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BoolOp { op: ast::Boolop::Or, values }
|
||||
}
|
||||
}
|
||||
OrTest = OrTestAs<ExprGoal>;
|
||||
OrTestAs<Goal>: Goal = {
|
||||
<location:@L> <e1:AndTest> <e2:("or" AndTest)+> <end_location:@R> => {
|
||||
let mut values = vec![e1];
|
||||
values.extend(e2.into_iter().map(|e| e.1));
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BoolOp { op: ast::Boolop::Or, values }
|
||||
}.into()
|
||||
},
|
||||
AndTestAs<Goal>,
|
||||
};
|
||||
|
||||
AndTest: ast::Expr = {
|
||||
<location:@L> <e1:NotTest> <e2:("and" NotTest)*> <end_location:@R> => {
|
||||
if e2.is_empty() {
|
||||
e1
|
||||
} else {
|
||||
let mut values = vec![e1];
|
||||
values.extend(e2.into_iter().map(|e| e.1));
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BoolOp { op: ast::Boolop::And, values }
|
||||
}
|
||||
}
|
||||
AndTest = AndTestAs<ExprGoal>;
|
||||
AndTestAs<Goal>: Goal = {
|
||||
<location:@L> <e1:NotTest> <e2:("and" NotTest)+> <end_location:@R> => {
|
||||
let mut values = vec![e1];
|
||||
values.extend(e2.into_iter().map(|e| e.1));
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BoolOp { op: ast::Boolop::And, values }
|
||||
}.into()
|
||||
},
|
||||
NotTestAs<Goal>,
|
||||
};
|
||||
|
||||
NotTest: ast::Expr = {
|
||||
NotTest = NotTestAs<ExprGoal>;
|
||||
NotTestAs<Goal>: Goal = {
|
||||
<location:@L> "not" <e:NotTest> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::UnaryOp { operand: Box::new(e), op: ast::Unaryop::Not }
|
||||
},
|
||||
Comparison,
|
||||
}.into(),
|
||||
ComparisonAs<Goal>,
|
||||
};
|
||||
|
||||
Comparison: ast::Expr = {
|
||||
Comparison = ComparisonAs<ExprGoal>;
|
||||
ComparisonAs<Goal>: Goal = {
|
||||
<location:@L> <left:Expression> <comparisons:(CompOp Expression)+> <end_location:@R> => {
|
||||
let (ops, comparators) = comparisons.into_iter().unzip();
|
||||
ast::Expr {
|
||||
|
@ -834,9 +850,9 @@ Comparison: ast::Expr = {
|
|||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Compare { left: Box::new(left), ops, comparators }
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
Expression,
|
||||
ExpressionAs<Goal>,
|
||||
};
|
||||
|
||||
CompOp: ast::Cmpop = {
|
||||
|
@ -852,44 +868,48 @@ CompOp: ast::Cmpop = {
|
|||
"is" "not" => ast::Cmpop::IsNot,
|
||||
};
|
||||
|
||||
Expression: ast::Expr = {
|
||||
Expression = ExpressionAs<ExprGoal>;
|
||||
ExpressionAs<Goal>: Goal = {
|
||||
<e1:Expression> <location:@L> "|" <e2:XorExpression> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2) }
|
||||
},
|
||||
XorExpression,
|
||||
}.into(),
|
||||
XorExpressionAs<Goal>,
|
||||
};
|
||||
|
||||
XorExpression: ast::Expr = {
|
||||
XorExpression = XorExpressionAs<ExprGoal>;
|
||||
XorExpressionAs<Goal>: Goal = {
|
||||
<e1:XorExpression> <location:@L> "^" <e2:AndExpression> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2) }
|
||||
},
|
||||
AndExpression,
|
||||
}.into(),
|
||||
AndExpressionAs<Goal>,
|
||||
};
|
||||
|
||||
AndExpression: ast::Expr = {
|
||||
AndExpression = AndExpressionAs<ExprGoal>;
|
||||
AndExpressionAs<Goal>: Goal = {
|
||||
<e1:AndExpression> <location:@L> "&" <e2:ShiftExpression> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2) }
|
||||
},
|
||||
ShiftExpression,
|
||||
}.into(),
|
||||
ShiftExpressionAs<Goal>,
|
||||
};
|
||||
|
||||
ShiftExpression: ast::Expr = {
|
||||
ShiftExpression = ShiftExpressionAs<ExprGoal>;
|
||||
ShiftExpressionAs<Goal>: Goal = {
|
||||
<e1:ShiftExpression> <location:@L> <op:ShiftOp> <e2:ArithmeticExpression> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(e1), op, right: Box::new(e2) }
|
||||
},
|
||||
ArithmeticExpression,
|
||||
}.into(),
|
||||
ArithmeticExpressionAs<Goal>,
|
||||
};
|
||||
|
||||
ShiftOp: ast::Operator = {
|
||||
|
@ -897,14 +917,15 @@ ShiftOp: ast::Operator = {
|
|||
">>" => ast::Operator::RShift,
|
||||
};
|
||||
|
||||
ArithmeticExpression: ast::Expr = {
|
||||
ArithmeticExpression = ArithmeticExpressionAs<ExprGoal>;
|
||||
ArithmeticExpressionAs<Goal>: Goal = {
|
||||
<location:@L> <a:ArithmeticExpression> <op:AddOp> <b:Term> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) }
|
||||
},
|
||||
Term,
|
||||
}.into(),
|
||||
TermAs<Goal>,
|
||||
};
|
||||
|
||||
AddOp: ast::Operator = {
|
||||
|
@ -912,14 +933,15 @@ AddOp: ast::Operator = {
|
|||
"-" => ast::Operator::Sub,
|
||||
};
|
||||
|
||||
Term: ast::Expr = {
|
||||
Term = TermAs<ExprGoal>;
|
||||
TermAs<Goal>: Goal = {
|
||||
<a:Term> <location:@L> <op:MulOp> <b:Factor> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(a), op, right: Box::new(b) }
|
||||
},
|
||||
Factor,
|
||||
}.into(),
|
||||
FactorAs<Goal>,
|
||||
};
|
||||
|
||||
MulOp: ast::Operator = {
|
||||
|
@ -930,14 +952,15 @@ MulOp: ast::Operator = {
|
|||
"@" => ast::Operator::MatMult,
|
||||
};
|
||||
|
||||
Factor: ast::Expr = {
|
||||
Factor = FactorAs<ExprGoal>;
|
||||
FactorAs<Goal>: Goal = {
|
||||
<location:@L> <op:UnaryOp> <e:Factor> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::UnaryOp { operand: Box::new(e), op }
|
||||
},
|
||||
Power,
|
||||
}.into(),
|
||||
PowerAs<Goal>,
|
||||
};
|
||||
|
||||
UnaryOp: ast::Unaryop = {
|
||||
|
@ -946,57 +969,53 @@ UnaryOp: ast::Unaryop = {
|
|||
"~" => ast::Unaryop::Invert,
|
||||
};
|
||||
|
||||
Power: ast::Expr = {
|
||||
<e:AtomExpr> <e2:(@L "**" Factor @R)?> => {
|
||||
match e2 {
|
||||
None => e,
|
||||
Some((location, _, b, end_location)) => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) }
|
||||
},
|
||||
}
|
||||
}
|
||||
Power = PowerAs<ExprGoal>;
|
||||
PowerAs<Goal>: Goal = {
|
||||
<e:AtomExpr> <location:@L> "**" <b:Factor> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::BinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b) }
|
||||
}.into(),
|
||||
AtomExprAs<Goal>,
|
||||
};
|
||||
|
||||
AtomExpr: ast::Expr = {
|
||||
<location:@L> <is_await:"await"?> <atom:AtomExpr2> <end_location:@R> => {
|
||||
if is_await.is_some() {
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Await { value: Box::new(atom) }
|
||||
}
|
||||
} else {
|
||||
atom
|
||||
}
|
||||
}
|
||||
AtomExpr = AtomExprAs<ExprGoal>;
|
||||
AtomExprAs<Goal>: Goal = {
|
||||
<location:@L> "await" <atom:AtomExpr2> <end_location:@R> => {
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Await { value: Box::new(atom) }
|
||||
}.into()
|
||||
},
|
||||
AtomExpr2As<Goal>,
|
||||
}
|
||||
|
||||
AtomExpr2: ast::Expr = {
|
||||
Atom,
|
||||
AtomExpr2 = AtomExpr2As<ExprGoal>;
|
||||
AtomExpr2As<Goal>: Goal = {
|
||||
AtomAs<Goal>,
|
||||
<location:@L> <f:AtomExpr2> "(" <a:ArgumentList> ")" <end_location:@R> => {
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Call { func: Box::new(f), args: a.args, keywords: a.keywords }
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
<location:@L> <e:AtomExpr2> "[" <s:SubscriptList> "]" <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Subscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load }
|
||||
},
|
||||
}.into(),
|
||||
<location:@L> <e:AtomExpr2> "." <attr:Identifier> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Attribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load }
|
||||
},
|
||||
}.into(),
|
||||
};
|
||||
|
||||
SubscriptList: ast::Expr = {
|
||||
|
@ -1038,20 +1057,21 @@ SliceOp: Option<ast::Expr> = {
|
|||
<location:@L> ":" <e:Test?> => e,
|
||||
}
|
||||
|
||||
Atom: ast::Expr = {
|
||||
<location:@L> <s:(@L string @R)+> =>? parse_strings(s).map_err(|e| e.into()),
|
||||
Atom = AtomAs<ExprGoal>;
|
||||
AtomAs<Goal>: Goal = {
|
||||
<location:@L> <s:(@L string @R)+> =>? Ok(parse_strings(s)?.into()),
|
||||
<location:@L> <value:Constant> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Constant { value, kind: None }
|
||||
},
|
||||
}.into(),
|
||||
<location:@L> <name:Identifier> <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Name { id: name, ctx: ast::ExprContext::Load }
|
||||
},
|
||||
}.into(),
|
||||
<location:@L> "[" <e:ListLiteralValues?> "]"<end_location:@R> => {
|
||||
let elts = e.unwrap_or_default();
|
||||
ast::Expr {
|
||||
|
@ -1059,7 +1079,7 @@ Atom: ast::Expr = {
|
|||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::List { elts, ctx: ast::ExprContext::Load }
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
<location:@L> "[" <elt:TestOrStarNamedExpr> <generators:CompFor> "]" <end_location:@R> => {
|
||||
ast::Expr {
|
||||
|
@ -1067,40 +1087,38 @@ Atom: ast::Expr = {
|
|||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::ListComp { elt: Box::new(elt), generators }
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
<location:@L> "(" <elements:TestOrStarNamedExprList?> ")" <end_location:@R> =>? {
|
||||
match elements {
|
||||
Some(elt) => {
|
||||
match elt.node {
|
||||
ast::ExprKind::Starred { .. } => {
|
||||
Err(LexicalError{
|
||||
error : LexicalErrorType::OtherError("cannot use starred expression here".to_string()),
|
||||
location: location,
|
||||
}.into())
|
||||
},
|
||||
_ => {
|
||||
Ok(elt)
|
||||
}
|
||||
"(" <location:@L> <items:OneOrMore<TestOrStarNamedExprOrWithitem>> <trailing_comma:","?> <end_location:@R> ")" =>? {
|
||||
if items.len() == 1 && items[0].1.is_none() && trailing_comma.is_none() {
|
||||
match items[0].0.node {
|
||||
ast::ExprKind::Starred { .. } => {
|
||||
Err(LexicalError{
|
||||
error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()),
|
||||
location: items[0].0.location,
|
||||
}.into())
|
||||
}
|
||||
_ => {
|
||||
Ok(items.into_iter().next().unwrap().0.into())
|
||||
}
|
||||
},
|
||||
None => {
|
||||
Ok(ast::Expr::new(
|
||||
location,
|
||||
end_location,
|
||||
ast::ExprKind::Tuple { elts: Vec::new(), ctx: ast::ExprContext::Load }
|
||||
))
|
||||
}
|
||||
} else {
|
||||
TupleOrWithitems { location, end_location, items }.try_into()
|
||||
}
|
||||
},
|
||||
"(" <e:YieldExpr> ")" => e,
|
||||
<location:@L> "(" ")" <end_location:@R> => ast::Expr::new(
|
||||
location,
|
||||
end_location,
|
||||
ast::ExprKind::Tuple { elts: Vec::new(), ctx: ast::ExprContext::Load }
|
||||
).into(),
|
||||
"(" <e:YieldExpr> ")" => e.into(),
|
||||
<location:@L> "(" <elt:NamedExpressionTest> <generators:CompFor> ")" <end_location:@R> => {
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::GeneratorExp { elt: Box::new(elt), generators }
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
"(" <location:@L> "**" <e:Expression> ")" <end_location:@R> =>? {
|
||||
Err(LexicalError{
|
||||
|
@ -1152,7 +1170,7 @@ Atom: ast::Expr = {
|
|||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Dict { keys, values }
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
<location:@L> "{" <e1:DictEntry> <generators:CompFor> "}" <end_location:@R> => {
|
||||
ast::Expr {
|
||||
|
@ -1164,26 +1182,26 @@ Atom: ast::Expr = {
|
|||
value: Box::new(e1.1),
|
||||
generators,
|
||||
}
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
<location:@L> "{" <elts:SetLiteralValues> "}" <end_location:@R> => ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::Set { elts }
|
||||
},
|
||||
}.into(),
|
||||
<location:@L> "{" <elt:Test> <generators:CompFor> "}" <end_location:@R> => {
|
||||
ast::Expr {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
custom: (),
|
||||
node: ast::ExprKind::SetComp { elt: Box::new(elt), generators }
|
||||
}
|
||||
}.into()
|
||||
},
|
||||
<location:@L> "True" <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: true.into(), kind: None }),
|
||||
<location:@L> "False" <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: false.into(), kind: None }),
|
||||
<location:@L> "None" <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::None, kind: None }),
|
||||
<location:@L> "..." <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::Ellipsis, kind: None }),
|
||||
<location:@L> "True" <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: true.into(), kind: None }).into(),
|
||||
<location:@L> "False" <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: false.into(), kind: None }).into(),
|
||||
<location:@L> "None" <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::None, kind: None }).into(),
|
||||
<location:@L> "..." <end_location:@R> => ast::Expr::new(location, end_location, ast::ExprKind::Constant { value: ast::Constant::Ellipsis, kind: None }).into(),
|
||||
};
|
||||
|
||||
ListLiteralValues: Vec<ast::Expr> = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue