parse-recdescent

Parse::RecDescent grammar not working as expected

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-24 08:59:00
问题 All I managed to get working is STRING, PARAMS, VARIABLE and FUNCNAME There seems to be a problem with FUNCTION, but I just can't see it. use strict; use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammar = <<'_GRAMMAR_'; SCRIPT : INSTRUCTION(s /;/) INSTRUCTION: FUNCTION | VARIABLE "=" FUNCTION FUNCTION : FUNCNAME "[

Parse::RecDescent grammar not working as expected

◇◆丶佛笑我妖孽 提交于 2020-02-24 08:56:12
问题 All I managed to get working is STRING, PARAMS, VARIABLE and FUNCNAME There seems to be a problem with FUNCTION, but I just can't see it. use strict; use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammar = <<'_GRAMMAR_'; SCRIPT : INSTRUCTION(s /;/) INSTRUCTION: FUNCTION | VARIABLE "=" FUNCTION FUNCTION : FUNCNAME "[

Parse::RecDescent grammar not working as expected

拈花ヽ惹草 提交于 2020-02-24 08:56:07
问题 All I managed to get working is STRING, PARAMS, VARIABLE and FUNCNAME There seems to be a problem with FUNCTION, but I just can't see it. use strict; use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammar = <<'_GRAMMAR_'; SCRIPT : INSTRUCTION(s /;/) INSTRUCTION: FUNCTION | VARIABLE "=" FUNCTION FUNCTION : FUNCNAME "[

Parsing string with nested parentheses using Parse::RecDescent

跟風遠走 提交于 2019-12-23 20:07:40
问题 I'm trying to use Parse::RecDescent make a parser which can parse parenthetical expressions and the unary operator ? . What I have so far is failing when I create the parser because the rule expression is left-recursive: use strict; use warnings; use Parse::RecDescent; my $test = <<END; ((foo)? bar) END my $grammar = q( parse: expression(s) expression: string | parend | expression(s) parend : "(" (string | expression) ")" /\??/ string : /\w+/ /\??/ ); my $parser = Parse::RecDescent->new(