marpa

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

Case-insensitive matching in Marpa

淺唱寂寞╮ 提交于 2019-12-08 20:29:07
问题 Related to my earlier question about case-insensitive keyword matching using regular expressions. Is it possible to match strings case-insensitively in Marpa? If so, how? Suppose I have the grammar :start ::= script identifier ~ [\w]+ script ::= 'script' identifier code code ::= command* command ::= 'run' | 'walk' | 'stop' How can I make it match any of script , Script , SCRIPT or any other combination of lower and uppercase letters? 回答1: There isn't a straightforward way to specify case