This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
new flag --debug-syntax-pattern-match
- From: Per Bothner <per at bothner dot com>
- To: kawa mailing list <kawa at sourceware dot org>
- Date: Mon, 15 Sep 2014 23:27:44 -0700
- Subject: new flag --debug-syntax-pattern-match
- Authentication-results: sourceware.org; auth=none
You might find the new Kawa flag --debug-syntax-pattern-match useful.
It prints out logging information to standard error when a syntax-rules
or syntax-case pattern matches. For example:
$ kawa --debug-syntax-pattern-match
#|kawa:1|# (if (and 3 4) 6 9)
{syntax-pattern prim_syntax.scm:87
match (if (and 3 4) 6 9) -> vars:
0: ((and 3 4) 6 9)
1: (6 9)
2: (9)
3: #!null}
{syntax-pattern std_syntax.scm:62 match (and 3 4) -> vars: 0: (3 4) 1: (4)}
{syntax-pattern prim_syntax.scm:87
match (#<syntax#3 if in #5> #<syntax#4 x in #5> (#<syntax#5 and in #5> 4)
#<syntax#7 x in #5>) -> vars:
0: (#<syntax#4 x in #5> (#<syntax#5 and in #5> 4) #<syntax#7 x in #5>)
1: ((#<syntax#5 and in #5> 4) #<syntax#7 x in #5>)
2: (#<syntax#6 x in #5>)
3: #!null}
{syntax-pattern std_syntax.scm:61
match (#<syntax#5 and in #5> 4) -> vars:
0: (4)
1: #!null}
6
For example the second log reports that the 3rd rule (on
line 62 of kawa/lib/std_syntax.scm) of the 'and' macro
matches the input (and 3 4).
The variable binding mapping uses internal numbering, but is as follows:
The test2 variable is variable #1 - i.e. (4).
The test1 variable is *the car of* variable #0 - i.e. (car '(3 4)).
The reason for storing a reference to the pair (rather than just the car)
is to preserve line number information, which is in the pairs.
Of course this is extremely crude. It should be tied into a more
logging facility, and there should be a way to control and filter
the logging. That's a project for later.
--
--Per Bothner
per@bothner.com http://per.bothner.com/