Skip to content

Instantly share code, notes, and snippets.

@masak

masak/weird.txt Secret

Created December 17, 2014 17:46
Show Gist options
  • Save masak/d10db42d5c6fd6d8d906 to your computer and use it in GitHub Desktop.
Save masak/d10db42d5c6fd6d8d906 to your computer and use it in GitHub Desktop.
Grammar succeeds once Grammar::Tracer is imported
$ perl6 -e 'grammar G { regex TOP { [<x> ['\'';'\'' | $$] \s*]* }; token x { B | \s* <y> \s* '\''()'\''* }; regex y { A | B } }; my $s = "B\nA();"; say ?G.parse($s)'
False
$ perl6 -e 'use Grammar::Tracer; grammar G { regex TOP { [<x> ['\'';'\'' | $$] \s*]* }; token x { B | \s* <y> \s* '\''()'\''* }; regex y { A | B } }; my $s = "B\nA();"; say ?G.parse($s)'
TOP
| x
| * MATCH "B"
| x
| | y
| | * MATCH "A"
| * MATCH "A()"
| x
| | y
| | * FAIL
| * FAIL
* MATCH "B\nA();"
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment