Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammar capture WRT conjunctive '&' operator #3131

Closed
p6rt opened this issue May 10, 2013 · 5 comments
Closed

Grammar capture WRT conjunctive '&' operator #3131

p6rt opened this issue May 10, 2013 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 10, 2013

Migrated from rt.perl.org#117955 (status was 'resolved')

Searchable as RT117955$

@p6rt
Copy link
Author

p6rt commented May 10, 2013

From @dwarring

Hi There,
I'm noticing some unexpected capture results when I introduce the
conjunctive '&' operator as below​:

grammar G {
  rule keyw {\w+}

  rule simple1 { [ <keyw> ] ** 2 }
  rule simple2 { [ <keyw> ] [ <keyw> ] }
  rule conj2 { [ \w+ & <keyw> ] ** 2 }
  rule conj1 { [ <keyw> & \w+ ] [ <keyw> & \w+ ] }
}

for <simple1 simple2 conj1 conj2> -> $rule {
  say "rule​: $rule";
  say G.parse("word1 word2", :rule($rule));
}

Output​:

rule​: simple1
「word1 word2」
keyw => 「word1」
keyw => 「word2」

rule​: simple2
「word1 word2」
keyw => 「word1」
keyw => 「word2」

rule​: conj1
「word1 word2」
keyw => 「word2」

rule​: conj2
「word1 word2」
keyw => 「word2」

Both appear to be fully parse the input. Rules simple1 and simple2 are as I
expected. But conj1 and conj2 appear to be only capturing the last
occurrence of <keyw>.

@p6rt
Copy link
Author

p6rt commented May 2, 2014

From @dwarring

Test has beeen added to S05-captures/caps.t

@p6rt
Copy link
Author

p6rt commented Jul 15, 2015

From @jnthn

On Fri May 02 01​:59​:18 2014, david.warring wrote​:

Test has beeen added to S05-captures/caps.t

Fixed and test unfudged.

@p6rt
Copy link
Author

p6rt commented Jul 15, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 15, 2015

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 15, 2015
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant