Debugging parse

Sometimes, you need some help to see how the parse process is working. A simple measure is to include a print or probe statement with certain matches, such as when parsing the rate string in the Searching, extracting, and changing section:

rate: "<title>1 USD = 0.81191502 EUR</title>"parse rate [thru "<title>" copy data to "</title>" (probe data) thru ">"];"1 USD = 0.81191502 EUR";== true

Or you could simply print out:

  (print "found a </title>"), to indicate that a match was found.

Let's apply this to the last example from the previous section:

rule: [start: word! string! finish:    (         print ["-->" start]        print ["<--" finish]        append result copy/part start finish     )]

This prints out the following:

--> print x is smaller ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.