Let's suppose you have a rule like the one below from the Rebol docs on parsing.
If you wanted to check some input against a rule just to validate it, but without having the contents of the parentheses evaluated, how can you do it?
Is there a way that easily lets you just validate inputs against a rule without having the content of the parentheses being evaluated?
rule: [
set action ['buy | 'sell]
set number integer!
'shares 'at
set price money!
(either action = 'sell [
print ["income" price * number]
total: total + (price * number)
] [
print ["cost" price * number]
total: total - (price * number)
]
)
]
Depends if you mean parse input or parse rules.
For parse rules you need some special flag and function that will take care of it:
do?: true
parse-do: function [code] [if do? [do code]]
rule: ['a (parse-do [print "got it"])]
parse [a] rule
do?: false
parse [a] rule
For parse input use INTO
:
>> parse [paren (1 + 1)]['paren into [integer! '+ integer!]]
== true