Jürgen Bömmels (via RT) wrote:

# New Ticket Created by Jürgen Bömmels # Please include the string: [perl #21033]
# in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21033 >


Hello,

I just implemented macro expansion in imcc.

Fine, fine, fine.


This brings us one step closer to substitude assemble.pl

The following things are working:
macro definition with parameters
macro expansion with parameters
parameter expansion
local labels
including of files

Following bugs still exist:
.constant not yet implemented

This should work like imcc's .const syntax:
t/syn/const_1.imc:      .const int N = 5


string constants with embedded NUL characters segfault

We disallow them :)


Compound keys are not working, but thats also in an unpatched imcc

Should work - or they have worked. Maybe I have broken them somewhen.



The macroexpansion is done by storing the neccessary information of the state of the current buffer in a linked list and continue the lexing
with the expansion of macro. After finishing the lexing of the macro
expansion the old buffer is restored (in the yywrap function) and the
lexing is continued.

Here something fishy must happen:

$ cat t/op/arithmetics_22.pasm | imcc -
error:imcc: file - line 1: unknown macro '.macro'

$ imcc t/op/arithmetics_22.pasm
ok 1

I tried to run tests and skipped writing the $assembly to a file:

 if (($imcc = $ENV{IMCC})) {
  system("echo '$assembly' | $imcc $TEST_PROG_ARGS -- - > $out_f 2>&1");
 }

The $out_f could be skipped to by just catching STDIN and STDERR.


bye
boe

One minor note: Could you replace these "yyerror"


+	if (!expand_macro(valp, interp, yytext+1)) yyerror("unknown macro");

with a little more informative message:

            fataly(1, "", line, "unknown macro '%s'\n", yytext);

fataly could also take a function name (.sub argument or bsr label?)

Thanks,
leo

Reply via email to