regexp-grammars

Parse single quoted string using Marpa:r2 perl

跟風遠走 提交于 2020-01-04 06:03:21
问题 How to parse single quoted string using Marpa:r2? In my below code, the single quoted strings appends '\' on parsing. Code: use strict; use Marpa::R2; use Data::Dumper; my $grammar = Marpa::R2::Scanless::G->new( { default_action => '[values]', source => \(<<'END_OF_SOURCE'), lexeme default = latm => 1 :start ::= Expression # include begin Expression ::= Param Param ::= Unquoted | ('"') Quoted ('"') | (') Quoted (') :discard ~ whitespace whitespace ~ [\s]+ Unquoted ~ [^\s\/\(\),&:\"~]+ Quoted

Parse single quoted string using Marpa:r2 perl

安稳与你 提交于 2020-01-04 06:03:10
问题 How to parse single quoted string using Marpa:r2? In my below code, the single quoted strings appends '\' on parsing. Code: use strict; use Marpa::R2; use Data::Dumper; my $grammar = Marpa::R2::Scanless::G->new( { default_action => '[values]', source => \(<<'END_OF_SOURCE'), lexeme default = latm => 1 :start ::= Expression # include begin Expression ::= Param Param ::= Unquoted | ('"') Quoted ('"') | (') Quoted (') :discard ~ whitespace whitespace ~ [\s]+ Unquoted ~ [^\s\/\(\),&:\"~]+ Quoted

How do I best do balanced quoting with Perl's Regexp::Grammars?

戏子无情 提交于 2019-12-10 11:11:42
问题 Using Damian Conway's Regexp::Grammars, I'm trying to match different balanced quoting ( 'foo' , "foo" , but not 'foo" ) mechanisms -- such as parens, quotes, double quotes, and double dollars. This is the code I'm currently using. <token: pair> \'<literal>\'|\"<literal>\"|\$\$<literal>\$\$ <token: literal> [\S]+ This generally works fine and allows me to say something like: <rule: quote> QUOTE <.as>? <pair> My question is how do I reform the output, to exclude the needles notation for the

How do I best do balanced quoting with Perl's Regexp::Grammars?

℡╲_俬逩灬. 提交于 2019-12-06 09:51:58
Using Damian Conway's Regexp::Grammars , I'm trying to match different balanced quoting ( 'foo' , "foo" , but not 'foo" ) mechanisms -- such as parens, quotes, double quotes, and double dollars. This is the code I'm currently using. <token: pair> \'<literal>\'|\"<literal>\"|\$\$<literal>\$\$ <token: literal> [\S]+ This generally works fine and allows me to say something like: <rule: quote> QUOTE <.as>? <pair> My question is how do I reform the output, to exclude the needles notation for the pair token? { '' => 'QUOTE AS \',\'', 'quote' => { '' => 'QUOTE AS \',\'', 'pair' => { 'literal' => ',',