diff --git a/src/compiler/ast.rs b/src/compiler/ast.rs index b23c1603..2337b506 100644 --- a/src/compiler/ast.rs +++ b/src/compiler/ast.rs @@ -1189,7 +1189,7 @@ fn traverse_node(compiler: &mut Compiler, node: &Dict) -> ImlOp { "accept" => Op::LoadAccept.into(), "break" => Op::LoadBreak.into(), "exit" => Op::LoadExit.into(), - "push" => Op::LoadPush.into(), + "push" => Op::LoadPush.into(), // usecase? _ => unreachable!(), } } else { @@ -1197,7 +1197,7 @@ fn traverse_node(compiler: &mut Compiler, node: &Dict) -> ImlOp { "accept" => Op::Accept.into(), "break" => Op::Break.into(), "exit" => Op::Exit.into(), - "push" => Op::Push.into(), + "push" => Op::Push.into(), // usecase? _ => unreachable!(), } } diff --git a/src/vm/capture.rs b/src/vm/capture.rs index 4d7e3361..0db0b656 100644 --- a/src/vm/capture.rs +++ b/src/vm/capture.rs @@ -71,17 +71,6 @@ impl Capture { _ => {} } } - - // Degrades a capture to a severity to a capture with zero severity. - // This is done when a capture is read. - pub fn degrade(&mut self) { - match self { - Capture::Range(_, _, severity) | Capture::Value(_, _, severity) if *severity <= 5 => { - *severity = 0; - } - _ => {} - } - } } impl From for Capture { diff --git a/src/vm/context.rs b/src/vm/context.rs index 666fbe37..9189a986 100644 --- a/src/vm/context.rs +++ b/src/vm/context.rs @@ -189,7 +189,6 @@ impl<'program, 'reader, 'thread, 'parselet> Context<'program, 'reader, 'thread, let capture = &mut self.stack[pos]; - capture.degrade(); // fixme: Can't extract do the degration? Some(capture.extract(&self.thread.reader)) } @@ -202,7 +201,6 @@ impl<'program, 'reader, 'thread, 'parselet> Context<'program, 'reader, 'thread, let capture = &mut self.stack[capture_start + i]; if capture.alias(name) { - capture.degrade(); // fixme: Can't extract do the degration? return Some(capture.extract(&self.thread.reader)); } } diff --git a/tests/builtin_ast_ondemand.tok b/tests/builtin_ast_ondemand.tok new file mode 100644 index 00000000..7821ef5e --- /dev/null +++ b/tests/builtin_ast_ondemand.tok @@ -0,0 +1,15 @@ +Trilli : Int _ ast("int") + +Trollo : @{ + Trilli+ if type($1) == "list" && $1.len > 1 ast("ints") +} + +ast_print(Trollo) +#--- +#1 2 3; 4 +#--- +#ints [start 1:1, end 1:6] +# int [start 1:1, end 1:3] => 1 +# int [start 1:3, end 1:5] => 2 +# int [start 1:5, end 1:6] => 3 +#int [start 1:8, end 1:9] => 4