spurperl has asked for the wisdom of the Perl Monks concerning the following question:
I want to use Parse::RecDescent to parse a certain assembly language. In assembly, data is "line oriented", that is newline is the statement separator. Simplified demonstration:
command1 arg1 \n command2 arg2 \nDefines two statements. More than one statement on a line is illegal, a statement broken to two lines is also illegal.
Now, P::RD has an issue with newlines. It swallows them by default. There is a workaround using the "skip" directive, but it became tedious and my grammar code is full of <skip: qr/ \t*/> directives.
Is there an easier way ?
What I want, for starters, is a trivial "command arg" pairs for statements:
line -> command arg "\n"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Handling newlines in P::RD
by merlyn (Sage) on Nov 15, 2004 at 17:34 UTC | |
by ikegami (Patriarch) on Nov 15, 2004 at 18:23 UTC | |
by spurperl (Priest) on Nov 16, 2004 at 10:50 UTC | |
|
Re: Handling newlines in P::RD
by Boots111 (Hermit) on Nov 16, 2004 at 04:25 UTC | |
|
Re: Handling newlines in P::RD
by metaperl (Curate) on Dec 03, 2004 at 02:13 UTC |