From e4aaa8080d67f0fcdc1a5479dce92ed37c2e8fa3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 7 Apr 2019 00:36:56 -0700 Subject: doc: update debug session. * txr.1: Repeated debug session with new version of the navytime.txr script, and the latest TXR. --- txr.1 | 206 +++++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 147 insertions(+), 59 deletions(-) diff --git a/txr.1 b/txr.1 index 8ea6bad7..6d73053e 100644 --- a/txr.1 +++ b/txr.1 @@ -67197,18 +67197,19 @@ containing HTML. This is the code, saved in a file called navytime.txr: .verb - @(next `!wget -c http://tycho.usno.navy.mil/cgi-bin/timer.pl -O - 2> /dev/null`) + @(bind url "http://tycho.usno.navy.mil/cgi-bin/timer.pl") + @(next (open-command `wget -c @url -O - 2> /dev/null`)) What time is it?

US Naval Observatory Master Clock Time

   @(collect :vars (MO DD HH MM SS (PM "  ") TZ TZNAME))
-  
@MO. @DD, @HH:@MM:@SS @(maybe)@{PM /PM/} @(end)@TZ@/\et+/@TZNAME +
@MO. @DD, @HH:@MM:@SS @(maybe)@{PM /PM/} @(end)@TZ@/\t+/@TZNAME @ (until)
@/.*/ @(end) -

US Naval Observatory +

US Naval Observatory @(output) @@ -67223,9 +67224,25 @@ This is the debug session: .verb $ txr -d navytime.txr stopped at line 1 of navytime.txr - form: (next (sys:quasi "!wget -c http://tycho.usno.navy.mil/cgi-bin/timer.pl -O - 2> /dev/null")) + form: ((bind url "http://tycho.usno.navy.mil/cgi-bin/timer.pl")) depth: 1 - data (nil): + data (1): + nil + txr> s +.brev + +Control stops on the first line of the script. The +.code form: +line output by the debugger shows the internal syntax. +The user issues the +.code s +command to step: + +.verb + stopped at line 2 of navytime.txr + form: ((next (open-command `wget -c @url -O - 2> /dev/null`))) + depth: 1 + data (1): nil .brev @@ -67238,37 +67255,58 @@ form. .verb txr> s stopped at line 2 of navytime.txr - form: (sys:text " 1+ #\espace) "HTML" (# 1+ #\espace) "PUBLIC" (# 1+ #\espace) "\e"-//W3C//DTD" (# 1+ #\espace) "HTML" (# 1+ #\espace) "3.2" (# 1+ #\espace) "Final\e"//EN>") + form: (open-command `wget -c @url -O - 2> /dev/null`) depth: 2 - data (1): - "" - txr> s + data (nil): + nil .brev -The current form now is a -.code sys:text -form which is an internal representation of -a block of horizontal material. The pattern matching is in vertical mode at -this point, and so the line of data is printed without an indication of -character position. +The current form now is the \*(TL +.code open-command +form which will create an input stream from the given +.code wget +command. The user types +.code s +again to step in: .verb + txr> s stopped at line 2 of navytime.txr - form: (sys:text " 1+ #\espace) "HTML" (# 1+ #\espace) "PUBLIC" (# 1+ #\espace) "\e"-//W3C//DTD" (# 1+ #\espace) "HTML" (# 1+ #\espace) "3.2" (# 1+ #\espace) "Final\e"//EN>") + form: `wget -c @url -O - 2> /dev/null` depth: 3 - data (1:0): - "" . "" + data (nil): + nil .brev -The user types -.code s -to step in. +Now, the argument expression of the +.code open-command +form is about to be evaluated. .verb txr> s - stopped at line 2 of navytime.txr - form: "")) + depth: 2 + data (1): + "" +.brev + +Now, the input stream has been opened, and control has stopped at line 3 +of the query. The +.code "((sys:text ...) ...)" +syntax is the internal representation of this line. The pattern matching +is in vertical mode, and so the current line of input is shown without +an indication of the character position. + +.verb + txr> s + stopped at line 3 of navytime.txr + form: ((sys:text "")) + depth: 3 data (1:0): "" . "" .brev @@ -67282,28 +67320,45 @@ The input is shown broken into two quoted strings with a dot in between. The dot indicates the current position. The left string is empty, meaning that this is the leftmost position. The programmer steps: +.verb +txr> s + stopped at line 3 of navytime.txr + form: ("") + depth: 4 + data (1:0): + "" . "" +.brev + +The literal text +.str " s - stopped at line 2 of navytime.txr - form: (# 1+ #\espace) + stopped at line 3 of navytime.txr + form: (#/ +/ "HTML" #/ +/ "PUBLIC" #/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" + #/ +/ "3.2" #/ +/ "Final\e"//EN>") depth: 4 data (1:9): "" .brev +The +.str " s - stopped at line 2 of navytime.txr - form: "HTML" + stopped at line 3 of navytime.txr + form: ("HTML" #/ +/ "PUBLIC" #/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ + "3.2" #/ +/ "Final\e"//EN>") depth: 4 data (1:10): "" @@ -67319,32 +67374,35 @@ command by hitting Enter. .verb txr> - stopped at line 2 of navytime.txr - form: (# 1+ #\espace) + stopped at line 3 of navytime.txr + form: (#/ +/ "PUBLIC" #/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ "3.2" + #/ +/ "Final\e"//EN>") depth: 4 data (1:14): "" txr> - stopped at line 2 of navytime.txr - form: "PUBLIC" + stopped at line 3 of navytime.txr + form: ("PUBLIC" #/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ "3.2" #/ +/ + "Final\e"//EN>") depth: 4 data (1:15): "" txr> - stopped at line 2 of navytime.txr - form: (# 1+ #\espace) + stopped at line 3 of navytime.txr + form: (#/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ "3.2" #/ +/ + "Final\e"//EN>") depth: 4 data (1:21): "" txr> - stopped at line 2 of navytime.txr - form: "\e"-//W3C//DTD" + stopped at line 3 of navytime.txr + form: ("\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ "3.2" #/ +/ "Final\e"//EN>") depth: 4 data (1:22): "" txr> - stopped at line 2 of navytime.txr - form: (# 1+ #\espace) + stopped at line 3 of navytime.txr + form: (#/ +/ "HTML" #/ +/ "3.2" #/ +/ "Final\e"//EN>") depth: 4 data (1:34): "" @@ -67354,7 +67412,7 @@ It is not evident from the session transcript, but during interactive use, the input context appears to be animated. Whenever the programmer hits Enter, the new context is printed and the dot appears to advance. -Eventually the programmer becomes bored and place a breakpoint on line 15, +Eventually the programmer becomes bored and place a breakpoint on line 16, where the .code @(output) block begins, and invokes the @@ -67362,10 +67420,16 @@ block begins, and invokes the command to continue the execution: .verb - txr> b 15 + txr> b 16 txr> c - stopped at line 15 of navytime.txr - form: (output (((repeat nil (((sys:var MO nil nil) "-" (sys:var DD nil nil) " " (sys:var HH nil nil) ":" (sys:var MM nil nil) ":" (sys:var SS nil nil) " " (sys:var PM nil nil) " " (sys:var TZ nil nil))) nil nil nil nil nil nil)))) + stopped at line 16 of navytime.txr + form: ((output (((repeat () ((@MO "-" @DD + " " @HH ":" + @MM ":" @SS + " " @PM " " + @TZ)) + () () () () + () ()))))) depth: 2 data (16): "" @@ -67381,20 +67445,44 @@ has produced some lists: .verb txr> v bindings: - 0: ((PM " " "PM" "PM" "PM" "PM" "PM" "PM") (TZNAME "Universal Time" "Eastern Time" "Central Time" "Mountain Time" "Pacific Time" "Alaska Time" "Hawaii-Aleutian Time") (TZ "UTC" "EDT" "CDT" "MDT" "PDT" "AKDT" "HAST") (SS "35" "35" "35" "35" "35" "35" "35") (MM "32" "32" "32" "32" "32" "32" "32") (HH "23" "07" "06" "05" "04" "03" "01") (DD "30" "30" "30" "30" "30" "30" "30") (MO "Mar" "Mar" "Mar" "Mar" "Mar" "Mar" "Mar")) -.brev - -Then a continue command, which finishes the program, whose output appears: + 0: ((PM " " " " " " " " " " "PM" "PM") + (TZNAME "Universal Time" "Eastern Time" + "Central Time" "Mountain Time" "Pacific Time" + "Alaska Time" "Hawaii-Aleutian Time") + (TZ "UTC" "AM EDT" "AM CDT" + "AM MDT" "AM PDT" "AKDT" "HAST") + (SS "03" "03" "03" "03" "03" "03" "03") + (MM "09" "09" "09" "09" "09" "09" "09") + (HH "07" "03" "02" "01" "12" "11" "09") + (DD "07" "07" "07" "07" "07" "06" "06") + (MO "Apr" "Apr" "Apr" "Apr" "Apr" "Apr" "Apr")) +.brev + +Then the continue command +.code c +is isued twice, which finishes the program, whose output appears: .verb txr> c - Mar-30 23:22:52 UTC - Mar-30 07:22:52 PM EDT - Mar-30 06:22:52 PM CDT - Mar-30 05:22:52 PM MDT - Mar-30 04:22:52 PM PDT - Mar-30 03:22:52 PM AKDT - Mar-30 01:22:52 PM HAST + stopped at line 16 of navytime.txr + form: ((output (((repeat () ((@MO "-" @DD + " " @HH ":" + @MM ":" @SS + " " @PM " " + @TZ)) + () () () () + () ()))))) + depth: 3 + data (nil): + nil + txr> c + Apr-07 07:09:03 UTC + Apr-07 03:09:03 AM EDT + Apr-07 02:09:03 AM CDT + Apr-07 01:09:03 AM MDT + Apr-07 12:09:03 AM PDT + Apr-06 11:09:03 PM AKDT + Apr-06 09:09:03 PM HAST .brev .SH* COMPATIBILITY -- cgit v1.2.3