in reply to Re^2: Help with Parse::RecDescent grammar
in thread Help with Parse::RecDescent grammar
from adding these actions:$VAR1 = [ { 'trailer' => ' #f', 'str2' => ' *', 'portLists' => undef, 'str1' => ' /opt/mylib/s956M' } ];
I'd have better names for the string keys, if I knew what they were for.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_
Phil
|
|---|