| 1 | # This file was automatically generated from src/xsh_grammar.xml on | ||
| 2 | # Sun Jun 12 16:34:31 2022 | ||
| 3 | |||
| 4 | |||
| 5 | package XML::XSH2::Grammar; | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use Parse::RecDescent; | ||
| 9 | use vars qw/$grammar/; | ||
| 10 | |||
| 11 | $Parse::RecDescent::skip = '(\s|\n|#[^\n]*)*'; | ||
| 12 | $grammar=<<'_EO_GRAMMAR_'; | ||
| 13 | |||
| 14 | |||
| 15 | command: | ||
| 16 | /(?=\s*[}{;]|\s*\Z)/ <commit> <reject> | ||
| 17 | | /assign\b|(?:local\b|my\b)?(?=\s*\$[a-zA-Z_][a-zA-Z0-9_]*\s*\s*(?:[\-\+\*\/%x.]|\|\||\&\&)?:?=)/ <commit> variable | ||
| 18 | ( /(?:[\-\+\*\/%x.]|\|\||\&\&)?=/ <commit> loose_exp | ||
| 19 | { ['xpath_assign',$item[3],$item[1]] } | ||
| 20 | |||
| 21 | | /\s*(?:[\-\+\*\/%x.]|\|\||\&\&)?:=/ command | ||
| 22 | { ['command_assign',$item[2],$item[1]] } | ||
| 23 | |||
| 24 | ) | ||
| 25 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,@{$item[4]},$item[1],$item[3]] } | ||
| 26 | |||
| 27 | | /(my)\b/ variable(s) | ||
| 28 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'store_lex_variables',0,@{$item[2]}] } | ||
| 29 | |||
| 30 | | /(local)\b/ variable(s) | ||
| 31 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'make_local',@{$item[2]}] } | ||
| 32 | |||
| 33 | | /(do)\b/ <commit> block | ||
| 34 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'run_commands',$item[3],0] } | ||
| 35 | |||
| 36 | | /(if)\b/ <commit> exp command | ||
| 37 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'if_statement',[$item[3],[$item[4]]]] } | ||
| 38 | |||
| 39 | | /(unless)\b/ <commit> exp command | ||
| 40 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'unless_statement',$item[3],[$item[4]]] } | ||
| 41 | |||
| 42 | | /(while)\b/ <commit> exp command | ||
| 43 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'while_statement',$item[3],[$item[4]]] } | ||
| 44 | |||
| 45 | | /(foreach|for)\b/ <commit> local_var_in(?) exp command | ||
| 46 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'foreach_statement',$item[4],[$item[5]],@{$item[3]}] } | ||
| 47 | |||
| 48 | | /(stream)\b/ <commit> | ||
| 49 | (( /--input-file|:f/ filename { [ 'string/input-file' => $item[2] ] } | ||
| 50 | | /--input-pipe|:p/ filename { [ 'string/input-pipe' => $item[2] ] } | ||
| 51 | | /--input-string|:s/ exp { [ 'exp/input-string' => $item[2] ] } | ||
| 52 | | /--output-file|:F/ filename { [ 'string/output-file' => $item[2] ] } | ||
| 53 | | /--output-encoding|:E/ enc_string { [ 'string/output-encoding' => $item[2] ] } | ||
| 54 | | /--output-pipe|:P/ filename { [ 'string/output-pipe' => $item[2] ] } | ||
| 55 | | /--output-string|:S/ exp { [ 'varname/output-string' => $item[2] ] } | ||
| 56 | | /--no-output|:N/ { [ '/no-output' => 1 ] } | ||
| 57 | )(s?) { [ map { @$_ } @{$item[1]} ] } | ||
| 58 | ) | ||
| 59 | stream_select(s) | ||
| 60 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'stream_process',$item[3],$item[4]] } | ||
| 61 | |||
| 62 | | /(undef|undefine)\b/ <commit> /\$?[a-zA-Z_][a-zA-Z0-9_]*/ | ||
| 63 | { | ||
| 64 | [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'undefine',$item[3]]; | ||
| 65 | } | ||
| 66 | |||
| 67 | | /(use)\b/ <commit> /XML::XSH2::(?:Inline|Compile)/ | ||
| 68 | { 1 } | ||
| 69 | |||
| 70 | | /(test-mode|test_mode)/ | ||
| 71 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,"test-mode"] } | ||
| 72 | |||
| 73 | | /(run-mode|run_mode)/ | ||
| 74 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,"run-mode"] } | ||
| 75 | |||
| 76 | | /(?!(?:iterate|try|def|define)\b)/ /\.|[a-zA-Z_][-a-zA-Z0-9_]*/ exp_or_opt(s?) | ||
| 77 | { | ||
| 78 | bless | ||
| 79 | [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,$item[2],@{$item[3]}], | ||
| 80 | 'XML::XSH2::Command' | ||
| 81 | } | ||
| 82 | |||
| 83 | |||
| 84 | statement: | ||
| 85 | /(?=\s*[}{;])/ <commit> <reject> | ||
| 86 | | /(if)\b/ <commit> exp block elsif_block else_block | ||
| 87 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'if_statement',[$item[3],$item[4]],@{$item[5]},@{$item[6]}] } | ||
| 88 | |||
| 89 | | /(unless)\b/ <commit> exp block else_block(?) | ||
| 90 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'unless_statement',$item[3],$item[4],@{$item[5]}] } | ||
| 91 | |||
| 92 | | /(while)\b/ <commit> exp block | ||
| 93 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'while_statement',$item[3],$item[4]] } | ||
| 94 | |||
| 95 | | /(foreach|for)\b/ <commit> local_var_in(?) exp block | ||
| 96 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'foreach_statement',@item[4,5],@{$item[3]}] } | ||
| 97 | |||
| 98 | | /(try)\b/ <commit> block 'catch' local_var(?) block | ||
| 99 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'try_catch',$item[3],$item[6],@{$item[5]}] } | ||
| 100 | |||
| 101 | | /(iterate)\b/ <commit> xpstep block | ||
| 102 | { [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'iterate',$item[4],@{$item[3]}] } | ||
| 103 | |||
| 104 | | /(def|define)\b/ <commit> ID | ||
| 105 | { XML::XSH2::Functions::is_command($item[3])?undef:1 } | ||
| 106 | variable(s?) block | ||
| 107 | { | ||
| 108 | [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'def',$item[3],$item[6],$item[5]] | ||
| 109 | } | ||
| 110 | |||
| 111 | |||
| 112 | complex_command: | ||
| 113 | /(?=\s*[{}]|\s*\Z)/ <commit> <reject> | ||
| 114 | | /\s*;/ <commit> | ||
| 115 | | /(?=(?:foreach|for|if|unless|iterate|while|try|def|define)\b)/ statement <commit> trail(?) | ||
| 116 | { | ||
| 117 | if (scalar(@{$item[4]})) { | ||
| 118 | if ($item[4][0][0] eq 'pipe') { | ||
| 119 | $return=[$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'pipe_command',[$item[2]],$item[4][0][1]] | ||
| 120 | } else { | ||
| 121 | $return=[$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'string_pipe_command',[$item[2]],$item[4][0][1]] | ||
| 122 | } | ||
| 123 | } else { | ||
| 124 | $return=$item[2] | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | | command <commit> trail(?) /\s*;|(?=\s*}|\s*\Z)/ | ||
| 129 | { | ||
| 130 | if (scalar(@{$item[3]})) { | ||
| 131 | if ($item[3][0][0] eq 'pipe') { | ||
| 132 | $return=[$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'pipe_command',[$item[1]],$item[3][0][1]] | ||
| 133 | } else { | ||
| 134 | $return=[$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'string_pipe_command',[$item[1]],$item[3][0][1]] | ||
| 135 | } | ||
| 136 | } else { | ||
| 137 | $return=$item[1] | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | | <error:Parse error near: "}.substr($text,0,40).qq{ ..."> | ||
| 142 | |||
| 143 | block: | ||
| 144 | '{' <commit> complex_command(s) '}' | ||
| 145 | { [grep ref,@{$item[3]}] } | ||
| 146 | |||
| 147 | |||
| 148 | exp_or_opt: | ||
| 149 | /(?=\s*[};]|\s*\Z)/ <commit> <reject> | ||
| 150 | | option | ||
| 151 | | exp | ||
| 152 | |||
| 153 | option: | ||
| 154 | /:[[:alnum:]]|--[-_[:alnum:]]+/ | ||
| 155 | |||
| 156 | inline_doc_string: | ||
| 157 | /'[a-zA-Z_][a-zA-Z0-9_]*'|"[a-zA-Z_][a-zA-Z0-9_]*"|\([a-zA-Z_][a-zA-Z0-9_]*\)|\{[a-zA-Z_][a-zA-Z0-9_]*\}|[a-zA-Z_][a-zA-Z0-9_]*/ | ||
| 158 | { [($item[1]=~/^(['"({])?(.*?)(['")}])?$/)] } | ||
| 159 | |||
| 160 | |||
| 161 | inline_doc: | ||
| 162 | /<</ inline_doc_string <skip:""> /.*\n/ /(.|\n)*?\n$item[2][1]\s*(\n|$)/ | ||
| 163 | { | ||
| 164 | $text=$item[4].$text; | ||
| 165 | local $_=$item[5]; s/\n$item[2][1]\s*$//; | ||
| 166 | my $paren = $item[2][0]; | ||
| 167 | $paren = '"' if $paren eq ""; | ||
| 168 | if ($paren eq "'") { | ||
| 169 | $paren = '"'; | ||
| 170 | s{(\\)(.|\n)|(\$)}{ (defined($3) and $3 eq '$') ? "\\\$" | ||
| 171 | : ((defined($2) and $2 eq "\\") | ||
| 172 | ? "\\\\" : ((defined($2) and $2 eq "'") ? "'" : ( | ||
| 173 | (defined($2) and $2 eq '$') ? "\\\\\\$2" : | ||
| 174 | "\\\\$2"))) }eg; | ||
| 175 | } "<<".$paren.$_; | ||
| 176 | } | ||
| 177 | |||
| 178 | |||
| 179 | enc_string: | ||
| 180 | exp | ||
| 181 | |||
| 182 | ID: | ||
| 183 | /[a-zA-Z_][a-zA-Z0-9_]*/ | ||
| 184 | |||
| 185 | filename: | ||
| 186 | exp | ||
| 187 | |||
| 188 | nodename: | ||
| 189 | exp | ||
| 190 | |||
| 191 | xpath: | ||
| 192 | /(?=['"])/ <commit> xpstring | ||
| 193 | { $item[3] } | ||
| 194 | |||
| 195 | | xpsimple <skip:""> xpcont(?) | ||
| 196 | { $item[1].join("",@{$item[3]}) } | ||
| 197 | |||
| 198 | | <error:expected XPath, but got "}.substr($text,0,40).qq{ ..."> | ||
| 199 | |||
| 200 | xpsimple: | ||
| 201 | /(?: | ||
| 202 | \$\{ (?: \$?[a-zA-Z_][a-zA-Z0-9_]* | \{.*?\} | \(.+?\) ) \} | | ||
| 203 | \$(?!\{) | | ||
| 204 | [^-:\$\[\]{}|"'\ \s();] | | ||
| 205 | -[^-\[\]{}|"'\ \s();] | ||
| 206 | ) | ||
| 207 | (?: | ||
| 208 | \$\{ (?: \$?[a-zA-Z_][a-zA-Z0-9_]* | \{.*?\} | \(.+?\) ) \} | | ||
| 209 | \$(?!\{) | | ||
| 210 | [^\[\]\${}|"'\ \s();] | ||
| 211 | )*/x | ||
| 212 | | xpbrackets | ||
| 213 | |||
| 214 | xpcont: | ||
| 215 | ( xpfilters | ||
| 216 | | xpbrackets | ||
| 217 | ) <skip:""> xpath(?) | ||
| 218 | { $item[1].join("",@{$item[3]}) } | ||
| 219 | |||
| 220 | | xpath | ||
| 221 | { $item[1] } | ||
| 222 | |||
| 223 | |||
| 224 | xpfilters: | ||
| 225 | /(?=\[)/ xpfilter(s) | ||
| 226 | { join("",@{$item[2]}) } | ||
| 227 | |||
| 228 | |||
| 229 | xpfilter: | ||
| 230 | '[' xpinter ']' | ||
| 231 | { "[$item[2]]" } | ||
| 232 | |||
| 233 | |||
| 234 | xpbracket: | ||
| 235 | '(' <skip:""> xpinter ')' | ||
| 236 | { "($item[3])" } | ||
| 237 | |||
| 238 | |||
| 239 | xpbrackets: | ||
| 240 | /(?=\()/ xpbracket <skip:""> xpfilters(?) | ||
| 241 | { join "",$item[2],@{$item[4]} } | ||
| 242 | |||
| 243 | |||
| 244 | xpinter: | ||
| 245 | xps <skip:""> xpintercont(?) | ||
| 246 | { join("",$item[1],@{$item[3]}) } | ||
| 247 | |||
| 248 | |||
| 249 | xpintercont: | ||
| 250 | ( xpfilters | ||
| 251 | | xpbrackets | ||
| 252 | ) <skip:""> xpinter(?) | ||
| 253 | { join("",$item[1],@{$item[3]}) } | ||
| 254 | |||
| 255 | |||
| 256 | xps: | ||
| 257 | /(?: [^\$\[\]()'"};]+ | | ||
| 258 | \$(?!\{) | | ||
| 259 | \$\{ (?:\$?[a-zA-Z_][a-zA-Z0-9_]* | | ||
| 260 | \{.*?\} | | ||
| 261 | \(.+?\) | ||
| 262 | ) | ||
| 263 | \} | | ||
| 264 | '(?:\$\{ (?: \$?[a-zA-Z_][a-zA-Z0-9_]* | \{.*?\} | \(.+?\)) \} | | ||
| 265 | \$(?!\{) | [^\$'] | \\\$ | ||
| 266 | )*' | | ||
| 267 | "(?:\$\{ (?: \$?[a-zA-Z_][a-zA-Z0-9_]* | \{.*?\} | \(.+?\)) \} | | ||
| 268 | \$(?!\{) | [^\$"] | \\\$ | ||
| 269 | )*" | ||
| 270 | )*/x | ||
| 271 | |||
| 272 | xpstring: | ||
| 273 | /'(?:\$\{(?:\$?[a-zA-Z_][a-zA-Z0-9_]*|\{.*?\}|\(.+?\))\}|\$(?!\{)|[^\$']|\\\$)*' | | ||
| 274 | "(?:\$\{(?:\$?[a-zA-Z_][a-zA-Z0-9_]*|\{.*?\}|\(.+?\))\}|\$(?!\{)|[^\$"]|\\\$)*"/x | ||
| 275 | |||
| 276 | perl_expression: | ||
| 277 | |||
| 278 | { $main::myline = $thisline; } | ||
| 279 | <reject> | ||
| 280 | | exp | ||
| 281 | { {local $^W=0; "\n# line $main::myline \"$XML::XSH2::Functions::SCRIPT\"\n".$item[1]} } | ||
| 282 | |||
| 283 | |||
| 284 | perl_block: | ||
| 285 | |||
| 286 | { $main::myline = $thisline; } | ||
| 287 | <reject> | ||
| 288 | | | ||
| 289 | { $main::myline = $thisline; } | ||
| 290 | <reject> | ||
| 291 | | <perl_codeblock> | ||
| 292 | { { | ||
| 293 | $return=$item[1]; | ||
| 294 | { | ||
| 295 | local $^W = 0; # don't warn about undefined contants | ||
| 296 | my $pos="# line $main::myline \"$XML::XSH2::Functions::SCRIPT\"\n"; | ||
| 297 | $return=~s/^\{/\{\n$pos/; | ||
| 298 | } | ||
| 299 | } } | ||
| 300 | |||
| 301 | |||
| 302 | loose_exp: | ||
| 303 | /^(?={)/ perl_block | ||
| 304 | { $item[2] } | ||
| 305 | |||
| 306 | | '&' block | ||
| 307 | { $item[2] } | ||
| 308 | |||
| 309 | | /^(?=<<)/ inline_doc | ||
| 310 | { $item[2] } | ||
| 311 | |||
| 312 | | xpinter | ||
| 313 | |||
| 314 | exp: | ||
| 315 | /^(?={)/ perl_block | ||
| 316 | { $item[2] } | ||
| 317 | |||
| 318 | | '&' block | ||
| 319 | { $item[2] } | ||
| 320 | |||
| 321 | | /^(?=<<)/ inline_doc | ||
| 322 | { $item[2] } | ||
| 323 | |||
| 324 | | xpath | ||
| 325 | |||
| 326 | variable: | ||
| 327 | /\$[a-zA-Z_][a-zA-Z0-9_]*/ | ||
| 328 | |||
| 329 | eof: | ||
| 330 | /\Z/ | ||
| 331 | { 1; } | ||
| 332 | |||
| 333 | |||
| 334 | startrule: | ||
| 335 | shell <commit> eof | ||
| 336 | { $item[1] } | ||
| 337 | |||
| 338 | | complex_command(s) <commit> eof | ||
| 339 | { $item[1] } | ||
| 340 | |||
| 341 | |||
| 342 | trail: | ||
| 343 | /(?=\s*[};]|\s*\Z)/ <commit> <reject> | ||
| 344 | | '|>' <commit> variable | ||
| 345 | { ['var',$item[3]] } | ||
| 346 | |||
| 347 | | '|' <commit> shline | ||
| 348 | { ['pipe',$item[3]] } | ||
| 349 | |||
| 350 | |||
| 351 | shline_nosc: | ||
| 352 | /([^;()\\"'\|]|\|[^>]|\\.|\"([^\"\\]|\\.)*\"|\'([^\'\\]|\\\'|\\\\|\\[^\'\\])*\')*/ | ||
| 353 | |||
| 354 | shline_inter: | ||
| 355 | /([^()\\"']|\\.|\"([^\"\\]|\\.)*\"|\'([^\'\\]|\\\'|\\\\|\\[^\'\\])*\')*/ | ||
| 356 | |||
| 357 | shline_bracket: | ||
| 358 | '(' shline_inter shline_bracket(?) shline_inter ')' | ||
| 359 | { join("",'(',$item[2],@{$item[3]},$item[4],')') } | ||
| 360 | |||
| 361 | |||
| 362 | shline: | ||
| 363 | shline_nosc shline_bracket(?) shline_nosc | ||
| 364 | { join("",$item[1],@{$item[2]},$item[3]) } | ||
| 365 | |||
| 366 | |||
| 367 | shell: | ||
| 368 | /!\s*/ <commit> /.*/ | ||
| 369 | { [[$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'sh_noev',$item[3]]] } | ||
| 370 | |||
| 371 | | <error?:Parse error near: "! }.substr($text,0,40).qq{ ..."> <reject> | ||
| 372 | |||
| 373 | elsif_block: | ||
| 374 | /(elsif)\b/ <commit> exp block elsif_block | ||
| 375 | { [[$item[3],$item[4]],@{$item[5]}] } | ||
| 376 | |||
| 377 | | /(?!elsif)/ | ||
| 378 | { [] } | ||
| 379 | |||
| 380 | | <uncommit> <error:Parse error near keyword elsif: "}.substr($text,0,40).qq{ ..."> | ||
| 381 | |||
| 382 | else_block: | ||
| 383 | /(else)\b/ <commit> block | ||
| 384 | { [[undef,$item[3]]] } | ||
| 385 | |||
| 386 | | /(?!else)/ | ||
| 387 | { [] } | ||
| 388 | |||
| 389 | | <uncommit> <error:Parse error near keyword else: "}.substr($text,0,40).qq{ ..."> | ||
| 390 | |||
| 391 | local_var: | ||
| 392 | ( /(local|my)\s/ | ||
| 393 | )(?) variable | ||
| 394 | { [$item[2],@{$item[1]}] } | ||
| 395 | |||
| 396 | |||
| 397 | local_var_in: | ||
| 398 | local_var 'in' | ||
| 399 | { $item[1] } | ||
| 400 | |||
| 401 | |||
| 402 | undef: | ||
| 403 | /(undef|undefine)\b/ <commit> /\$?[a-zA-Z_][a-zA-Z0-9_]*/ | ||
| 404 | { | ||
| 405 | [$thisline,$thiscolumn,$thisoffset,$XML::XSH2::Functions::SCRIPT,'undefine',$item[3]]; | ||
| 406 | } | ||
| 407 | |||
| 408 | |||
| 409 | param: | ||
| 410 | /[^=\s]+/ '=' exp | ||
| 411 | { [$item[1],$item[3]] } | ||
| 412 | |||
| 413 | |||
| 414 | nodetype: | ||
| 415 | /element|attribute|attributes|text|cdata|pi|comment|chunk|entity_reference/ | ||
| 416 | |||
| 417 | loc: | ||
| 418 | /after\s/ | ||
| 419 | { "after" } | ||
| 420 | |||
| 421 | | /before\s/ | ||
| 422 | { "before" } | ||
| 423 | |||
| 424 | | /(in)?to\s/ | ||
| 425 | { "into" } | ||
| 426 | |||
| 427 | | /(append(ing)?|as\s+(a\s+)child(\s+of)?)\s/ | ||
| 428 | { "append" } | ||
| 429 | |||
| 430 | | /(prepend(ing)?|(as\s+)(the\s+)first(\s+child(\s+of)?)?)\s/ | ||
| 431 | { "prepend" } | ||
| 432 | |||
| 433 | | /(replace|instead( of)?)\s/ | ||
| 434 | { "replace" } | ||
| 435 | |||
| 436 | |||
| 437 | xpaxis: | ||
| 438 | /[-a-z]+::/ | ||
| 439 | |||
| 440 | xpnodetest: | ||
| 441 | /node\(\)|text\(\)|comment\(\)|processing-instruction\(\s*(?:"[^"]*"\s*|'[^'*]'\s*)?\)|[^\(\[\/\"\'\&\;\s]+/ | ||
| 442 | |||
| 443 | xplocationstep: | ||
| 444 | xpaxis(?) xpnodetest | ||
| 445 | { [ (@{$item[1]} ? $item[1][0] : 'child::'),$item[3] ] } | ||
| 446 | |||
| 447 | |||
| 448 | xpstep: | ||
| 449 | xplocationstep <skip:""> xpfilter(?) | ||
| 450 | { [ @{$item[1]}, @{$item[3]}] } | ||
| 451 | |||
| 452 | |||
| 453 | stream_select: | ||
| 454 | /select\s/ xpath block | ||
| 455 | { [$item[2],$item[3]] } | ||
| 456 | |||
| 457 | |||
| 458 | |||
| 459 | |||
| 460 | _EO_GRAMMAR_ | ||
| 461 | |||
| 462 | sub compile { | ||
| 463 | my @opts = ( { -standalone => 1 }, | ||
| 464 | $grammar, | ||
| 465 | "XML::XSH2::Parser", | ||
| 466 | ); | ||
| 467 | shift @opts | ||
| 468 | if $Parse::RecDescent::VERSION < 1.967_005; # Standalone not supported. | ||
| 469 | Parse::RecDescent->Precompile(@opts); | ||
| 470 | } | ||
| 471 | |||
| 472 | sub new { | ||
| 473 | return new Parse::RecDescent ($grammar); | ||
| 474 | } | ||
| 475 | |||
| 476 | 1; | ||
| 477 | |||
| 478 |