Well, autotree is easy in the grammar, but harder later. The key is to use your own actions. You started that with the action for QUOTED_STRING, but you need more. I got this:
$VAR1 = [
{
'trailer' => ' #f',
'str2' => ' *',
'portLists' => undef,
'str1' => ' /opt/mylib/s956M'
}
];
from adding these actions:
my $grammar = <<'_EOGRAMMAR_';
QUOTED_STRING : /"/ <skip:""> quoted_char(s?) /"/ {
" " . join "", @{$item[3]} # leading space flags a str
+ing
}
quoted_char :
/[^\\"]+/ { $item[1] }
| /\\n/ { "\n" } { $item[1] }
| /\\"/ { "\"" } { $item[1] }
portDefinition: "dbSetCellPortTypes"
QUOTED_STRING QUOTED_STRING
portLists
QUOTED_STRING
{ return {
str1 => $item[2],
str2 => $item[3],
portLists => $item[4],
trailer => $item[5]
} }
portLists: "'" "(" list(s?) ")" { $item[2] }
list: "(" QUOTED_STRING(s) ")" { $item[2] }
_EOGRAMMAR_
I'd have better names for the string keys, if I knew what they were for.
Phil
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.