diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-04-07 00:36:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-04-07 00:36:56 -0700 |
commit | 52ef6223a9c84076bf19728028a77d9850d2c088 (patch) | |
tree | 1aa86aa82270ee3d8e02c20fd20cb82f8d7a06ff | |
parent | 4e852195e3d699f874702bfc0b473bcb021d3801 (diff) | |
download | txr-52ef6223a9c84076bf19728028a77d9850d2c088.tar.gz txr-52ef6223a9c84076bf19728028a77d9850d2c088.tar.bz2 txr-52ef6223a9c84076bf19728028a77d9850d2c088.zip |
doc: update debug session.
* txr.1: Repeated debug session with new version of the
navytime.txr script, and the latest TXR.
-rw-r--r-- | txr.1 | 206 |
1 files changed, 147 insertions, 59 deletions
@@ -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`)) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final"//EN> <html> <body> <TITLE>What time is it?</TITLE> <H2> US Naval Observatory Master Clock Time</H2> <H3><PRE> @(collect :vars (MO DD HH MM SS (PM " ") TZ TZNAME)) - <BR>@MO. @DD, @HH:@MM:@SS @(maybe)@{PM /PM/} @(end)@TZ@/\et+/@TZNAME + <BR>@MO. @DD, @HH:@MM:@SS @(maybe)@{PM /PM/} @(end)@TZ@/\t+/@TZNAME @ (until) </PRE>@/.*/ @(end) - </PRE></H3><P><A HREF="http://www.usno.navy.mil"> US Naval Observatory</A> + </PRE></H3><P><A HREF="http://@(skip)"> US Naval Observatory</A> </body></html> @(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 "<!DOCTYPE" (#<sys:regex: 95e4590> 1+ #\espace) "HTML" (#<sys:regex: 95e4618> 1+ #\espace) "PUBLIC" (#<sys:regex: 95e46a8> 1+ #\espace) "\e"-//W3C//DTD" (#<sys:regex: 95e4750> 1+ #\espace) "HTML" (#<sys:regex: 95e47d8> 1+ #\espace) "3.2" (#<sys:regex: 95e4860> 1+ #\espace) "Final\e"//EN>") + form: (open-command `wget -c @url -O - 2> /dev/null`) depth: 2 - data (1): - "<!DOCTYPE HTML PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" - 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 "<!DOCTYPE" (#<sys:regex: 95e4590> 1+ #\espace) "HTML" (#<sys:regex: 95e4618> 1+ #\espace) "PUBLIC" (#<sys:regex: 95e46a8> 1+ #\espace) "\e"-//W3C//DTD" (#<sys:regex: 95e4750> 1+ #\espace) "HTML" (#<sys:regex: 95e47d8> 1+ #\espace) "3.2" (#<sys:regex: 95e4860> 1+ #\espace) "Final\e"//EN>") + form: `wget -c @url -O - 2> /dev/null` depth: 3 - data (1:0): - "" . "<!DOCTYPE HTML PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" + 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: "<!DOCTYPE" - depth: 4 + stopped at line 3 of navytime.txr + form: ((sys:text "<!DOCTYPE" #/ +/ "HTML" #/ +/ "PUBLIC" + #/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ "3.2" + #/ +/ "Final\e"//EN>")) + depth: 2 + data (1): + "<!DOCTYPE HTML PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" +.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 "<!DOCTYPE" #/ +/ "HTML" #/ +/ "PUBLIC" + #/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ "3.2" + #/ +/ "Final\e"//EN>")) + depth: 3 data (1:0): "" . "<!DOCTYPE HTML PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" .brev @@ -67283,27 +67321,44 @@ 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: ("<!DOCTYPE" #/ +/ "HTML" #/ +/ "PUBLIC" #/ +/ "\e"-//W3C//DTD" + #/ +/ "HTML" #/ +/ "3.2" #/ +/ "Final\e"//EN>") + depth: 4 + data (1:0): + "" . "<!DOCTYPE HTML PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" +.brev + +The literal text +.str "<!DOCTYPE" +is about to be matched. + +.verb txr> s - stopped at line 2 of navytime.txr - form: (#<sys:regex: 95e4590> 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): "<!DOCTYPE" . " HTML PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" .brev +The +.str "<!DOCTYPE" +text matches and so the current position advances in the input. Control has now passed to the second element of the .codn "(sys:text ...)" , -a regular expression which matches one or more spaces, generated by -a single space in the source code according to the language rules. - -The input context shows that -.str <!DOCTYPE -was matched in the input, and the position moved past it. +the regular expression +.code "#/ +/" +which matches one or more spaces. This regular expression is +produced by a single space in the source code, according to the language rules. .verb txr> 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): "<!DOCTYPE " . "HTML PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" @@ -67319,32 +67374,35 @@ command by hitting Enter. .verb txr> - stopped at line 2 of navytime.txr - form: (#<sys:regex: 95e4618> 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): "<!DOCTYPE HTML" . " PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" 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): "<!DOCTYPE HTML " . "PUBLIC \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" txr> - stopped at line 2 of navytime.txr - form: (#<sys:regex: 95e46a8> 1+ #\espace) + stopped at line 3 of navytime.txr + form: (#/ +/ "\e"-//W3C//DTD" #/ +/ "HTML" #/ +/ "3.2" #/ +/ + "Final\e"//EN>") depth: 4 data (1:21): "<!DOCTYPE HTML PUBLIC" . " \e"-//W3C//DTD HTML 3.2 Final\e"//EN>" 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): "<!DOCTYPE HTML PUBLIC " . "\e"-//W3C//DTD HTML 3.2 Final\e"//EN>" txr> - stopped at line 2 of navytime.txr - form: (#<sys:regex: 95e4750> 1+ #\espace) + stopped at line 3 of navytime.txr + form: (#/ +/ "HTML" #/ +/ "3.2" #/ +/ "Final\e"//EN>") depth: 4 data (1:34): "<!DOCTYPE HTML PUBLIC \e"-//W3C//DTD" . " HTML 3.2 Final\e"//EN>" @@ -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 |