Skip to Content
Learn Red ? Fundamentals of Red
book

Learn Red ? Fundamentals of Red

by Ivo Balbaert
May 2018
Beginner content levelBeginner
252 pages
6h 19m
English
Packt Publishing
Content preview from Learn Red ? Fundamentals of Red

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How I Built a Personal Board of Directors With GenAI

How I Built a Personal Board of Directors With GenAI

Vipin Gupta
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally
Why AI Demands a New Breed of Leaders

Why AI Demands a New Breed of Leaders

Faisal Hoque, Thomas Davenport, Erik Nelson

Publisher Resources

ISBN: 9781789130706Supplemental Content