Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Patch for nested macro support

0 views
Skip to first unread message

Joshua Isom

unread,
Mar 6, 2006, 4:04:12 AM3/6/06
to Internals List
I finally got around to writing up a patch to parrot that would allow
the features I mentioned a while back. There aren't any heuristics,
just braces. The first file is a patch to imcc.l and imclexer.c(may as
well). The second file is a set of macro's I've already written up(not
documented presently). The third file is a broken health shootout. It
compiles and runs, and demonstrates many of the macros. Thoughts?

nested_macros.patch
hllmacros.pir
health.pir

Chip Salzenberg

unread,
Mar 7, 2006, 12:22:49 PM3/7/06
to Joshua Isom, Internals List
Neat: It's backward-compatible and makes macros more useful, so file it
under "improvement" and commit it. Two and a half Qs:

It looks to me like this implementation is safe against "{" and "}" in
strings, right?

(Not a new issue, but since we're on the subject of macros:) If I define a
macro named eg. ".local", does it expand as a macro, i.e. is it recognized
before or after core Parrot keywords? I think the example of Perl keywords
vs. user-defined functions teaches us it's a good idea for macros to win in
case of conflict, for backward compatibility when we introduce new keywords.
--
Chip Salzenberg <ch...@pobox.com>

Joshua Isom

unread,
Mar 7, 2006, 8:44:10 PM3/7/06
to Chip Salzenberg, Internals List
I've committed it as of r11820. Since it parses by tokens, braces
inside of strings are allowed.

With regard to clashing, pir specials take precedent over macros. The
complications that could arise from accidental recursion, etc, seems
complex. As for your .local example, you can always use .my or .our
instead.

.macro my(var, type)
.sym pmc .var
.var = new .type
.endm
.sub main
.my(foo, .String)
foo = "hello\n"
print foo
.end

0 new messages