Paebbels
Paebbels

Reputation: 16239

How to change the comment sign for m4's --synclines option?

I'm using m4 preprocessor with the command line option --synclines. This option emits #line <nn> lines after each expanded multi line.

Example:

; sr0(<register>, <count>) unrolls the sr0 statement for <register> <count> times.
sr0(reg_0, 3)
sr1 reg_1

Result:

#line 1 "test.psm"
; sr0(<register>, <count>) unrolls the sr0 statement for <register> <count> times.
sr0 reg_0
#line 2
sr0 reg_0
#line 2
sr0 reg_0
#line 2
sr1 reg_1

Because sr0(reg_0, 3) was originated in line 2, m4 adds #line 2 after each expansion.

How can I change the comment sign # to ;?, because the assembler does not support # as a comment sign.

Upvotes: 0

Views: 165

Answers (1)

Simon
Simon

Reputation: 10841

If you don't mind using sed, assuming the code produced by m4 is in test.psm:

$ sed 's/^#/;/' <test.psm
;line 1 "test.psm"
; sr0(<register>, <count>) unrolls the sr0 statement for <register> <count> times.
sr0 reg_0
;line 2
sr0 reg_0
;line 2
sr0 reg_0
;line 2
sr1 reg_1

Upvotes: 0

Related Questions