Last active
November 28, 2017 12:35
-
-
Save araraloren/c644ef7d763b8db399b788df1e7e8ae6 to your computer and use it in GitHub Desktop.
grammar exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CTRL { | |
TAB { to right }, | |
PAGEUP { ro left }, | |
PAGEDOWN { to right }, | |
SHIFT { | |
TAB { to left }, | |
PAGEUP { move current tab to left }, | |
PAGEDOWN { move current tab to right }, | |
}, | |
} | |
TOP | |
| item | |
| | name | |
| | * MATCH "CTRL" | |
| | ws | |
| | * MATCH " " | |
| | bracket | |
| | * MATCH "\{" | |
| | ws | |
| | * MATCH "\n" | |
| | item | |
| | | name | |
| | | * MATCH "TAB" | |
| | | ws | |
| | | * MATCH " " | |
| | | bracket | |
| | | * MATCH "\{" | |
| | | ws | |
| | | * MATCH " " | |
| | | content | |
| | | | word | |
| | | | * MATCH "to" | |
| | | | word | |
| | | | * MATCH "right" | |
| | | | word | |
| | | | * FAIL | |
| | | | ws | |
| | | | * MATCH " " | |
| | | * MATCH "to right" | |
| | | ws | |
| | | * MATCH " " | |
| | | bracket | |
| | | * MATCH "}" | |
Too many positionals passed; expected 1 argument but got 2 | |
in regex item at ./example.p6 line 23 | |
in block at /home/sakuya/.perl6/sources/C0DCFF5AEFDF38901A375AE53AF39C4F12B3F6FC (Grammar::Tracer) line 49 | |
in regex item at ./example.p6 line 23 | |
in block at /home/sakuya/.perl6/sources/C0DCFF5AEFDF38901A375AE53AF39C4F12B3F6FC (Grammar::Tracer) line 49 | |
in regex TOP at ./example.p6 line 19 | |
in block at /home/sakuya/.perl6/sources/C0DCFF5AEFDF38901A375AE53AF39C4F12B3F6FC (Grammar::Tracer) line 49 | |
in block <unit> at ./example.p6 line 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CTRL { | |
TAB { to right }, | |
PAGEUP { ro left }, | |
PAGEDOWN { to right }, | |
SHIFT { | |
TAB { to left }, | |
PAGEUP { move current tab to left }, | |
PAGEDOWN { move current tab to right }, | |
}, | |
} | |
Too many positionals passed; expected 1 argument but got 2 | |
in regex item at ./example.p6 line 21 | |
in regex item at ./example.p6 line 21 | |
in regex TOP at ./example.p6 line 17 | |
in block <unit> at ./example.p6 line 58 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
use Grammar::Tracer; | |
my $string = Q :to/EOF/; | |
CTRL { | |
TAB { to right }, | |
PAGEUP { ro left }, | |
PAGEDOWN { to right }, | |
SHIFT { | |
TAB { to left }, | |
PAGEUP { move current tab to left }, | |
PAGEDOWN { move current tab to right }, | |
}, | |
} | |
EOF | |
grammar S { | |
token TOP { | |
^ <item> $ | |
} | |
token item { | |
<name> | |
<ws> | |
<bracket> | |
<ws> [ <content> | <item>+ % <comma> ] <ws> | |
<bracket> | |
} | |
token bracket { | |
\{ | |
| | |
\} | |
} | |
token comma { | |
',' | |
} | |
token name { | |
<[A..Z]>+ | |
} | |
token content { | |
<word>+ % \s <?before <ws>> | |
} | |
token word { | |
<[a..z]>+ | |
} | |
token ws { | |
[\s | \h] | |
} | |
} | |
say $string; | |
say S.parse: $string.chomp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment