15 Feb 04:03
Gwydion Dylan macro parsing error
From: Dustin Voss <d_j_v <at> mac.com>
Subject: Gwydion Dylan macro parsing error
Newsgroups: gmane.comp.lang.dylan.gwydion.devel
Date: 2008-02-15 03:06:20 GMT
Subject: Gwydion Dylan macro parsing error
Newsgroups: gmane.comp.lang.dylan.gwydion.devel
Date: 2008-02-15 03:06:20 GMT
Gwydion Dylan seems to have a bug in its macro processing, which I've logged as #7369. The problem is that final semicolons can't be omitted from a defining macro call. The bug includes a brief sample to demonstrate the problem, and Open Dylan doesn't have a problem. I think I've fixed it, but I wanted to run it past the group before checking it in. The code had special logic for semicolon-separated fragment matching vs. comma-separated fragment matching, and there may have been a reason for that which I'm unaware of. Anyway, since the comma-separated fragment matching code works as I expect from reading the DRM (p. 151-152, http://www.opendylan.org/books/drm/Patterns) , my proposed fix simply applies the same logic to both the semicolon- and comma-separated cases. Here is the diff: Index: d2c/compiler/parser/support.dylan =================================================================== --- d2c/compiler/parser/support.dylan (revision 11673) +++ d2c/compiler/parser/support.dylan (working copy) @@ -425,33 +425,15 @@ define generic remove-optional-semi-and-end (pattern :: <pattern>) => (new-pattern :: <pattern>, found-end? :: <boolean>); -define method remove-optional-semi-and-end (pattern :: <semicolon- pattern>) +define method remove-optional-semi-and-end + (pattern :: type-union(<semicolon-pattern>, <comma-pattern>)) => (new-pattern :: <pattern>, found-end? :: <boolean>); - let right = pattern.pattern-right; - if (instance?(right, <name-pattern>) - & right.pattern-name.token-symbol == #"end") - values(pattern.pattern-left, #t); - else - let (new-right, found-end?) = remove-optional-semi-and-end(right); - if (found-end?) - values(make(<semicolon-pattern>, - left: pattern.pattern-left, - right: new-right, - last: ~instance?(new-right, <semicolon-pattern>)), - #t); - else - values(pattern, #f); - end if; - end if; -end method remove-optional-semi-and-end; - -define method remove-optional-semi-and-end (pattern :: <comma-pattern>) - => (new-pattern :: <pattern>, found-end? :: <boolean>); let (new-right, found-end?) = remove-optional-semi-and-end(pattern.pattern-right); if (found-end?) - values(make(<comma-pattern>, left: pattern.pattern-left, right: new-right, - last: ~instance?(new-right, <comma-pattern>)), + values(make(pattern.object-class, left: pattern.pattern-left, + right: new-right, + last: ~instance?(new-right, pattern.object-class)), #t); else values(pattern, #f); -- -- Gd-hackers mailing list Gd-hackers <at> gwydiondylan.org https://www.opendylan.org/mailman/listinfo/gd-hackers
RSS Feed