Skip to content

Commit dcd2fd5

Browse files
committed
Parse DEBUG to OP_RESERVED
1 parent 1ff09f3 commit dcd2fd5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/parse.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bitcoin::blockdata::opcodes::Opcode;
1+
use bitcoin::{blockdata::opcodes::Opcode, opcodes::OP_RESERVED};
22
use proc_macro2::{
33
Delimiter, Span, TokenStream,
44
TokenTree::{self, *},
@@ -49,7 +49,12 @@ pub fn parse(tokens: TokenStream) -> Vec<(Syntax, Span)> {
4949
syntax.push(match (&token, token_str.as_ref()) {
5050
// Wrap for loops such that they return a Vec<ScriptBuf>
5151
(Ident(_), ident_str) if ident_str == "for" => parse_for_loop(token, &mut tokens),
52+
// Wrap if-else statements such that they return a Vec<ScriptBuf>
5253
(Ident(_), ident_str) if ident_str == "if" => parse_if(token, &mut tokens),
54+
// Replace DEBUG with OP_RESERVED
55+
(Ident(_), ident_str) if ident_str == "DEBUG" => {
56+
(Syntax::Opcode(OP_RESERVED), token.span())
57+
}
5358

5459
// identifier, look up opcode
5560
(Ident(_), _) => {
@@ -112,8 +117,7 @@ where
112117
});
113118

114119
match tokens.peek() {
115-
Some(else_token) if else_token.to_string().as_str() == "else" =>
116-
continue,
120+
Some(else_token) if else_token.to_string().as_str() == "else" => continue,
117121
_ => break,
118122
}
119123
}

0 commit comments

Comments
 (0)