mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-30 23:27:39 +00:00
Add variable annotation syntax. Simplify grammar for comprehensions. Add capital J suffix for complex numbers.
This commit is contained in:
parent
7e9b3ddc1f
commit
b22698a6f1
2 changed files with 25 additions and 0 deletions
|
@ -553,6 +553,20 @@ impl Compiler {
|
||||||
self.compile_op(op, true);
|
self.compile_op(op, true);
|
||||||
self.compile_store(target)?;
|
self.compile_store(target)?;
|
||||||
}
|
}
|
||||||
|
AnnAssign {
|
||||||
|
target,
|
||||||
|
annotation,
|
||||||
|
value,
|
||||||
|
} => {
|
||||||
|
// Throw away annotation:
|
||||||
|
self.compile_expression(annotation)?;
|
||||||
|
self.emit(Instruction::Pop);
|
||||||
|
|
||||||
|
if let Some(value) = value {
|
||||||
|
self.compile_expression(value)?;
|
||||||
|
self.compile_store(target)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
Delete { targets } => {
|
Delete { targets } => {
|
||||||
for target in targets {
|
for target in targets {
|
||||||
self.compile_delete(target)?;
|
self.compile_delete(target)?;
|
||||||
|
|
|
@ -335,6 +335,17 @@ impl SymbolTableBuilder {
|
||||||
self.scan_expression(target)?;
|
self.scan_expression(target)?;
|
||||||
self.scan_expression(value)?;
|
self.scan_expression(value)?;
|
||||||
}
|
}
|
||||||
|
AnnAssign {
|
||||||
|
target,
|
||||||
|
annotation,
|
||||||
|
value,
|
||||||
|
} => {
|
||||||
|
self.scan_expression(target)?;
|
||||||
|
self.scan_expression(annotation)?;
|
||||||
|
if let Some(value) = value {
|
||||||
|
self.scan_expression(value)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
With { items, body, .. } => {
|
With { items, body, .. } => {
|
||||||
for item in items {
|
for item in items {
|
||||||
self.scan_expression(&item.context_expr)?;
|
self.scan_expression(&item.context_expr)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue