Created
May 12, 2018 18:12
-
-
Save kybr/ad17c2246f693c08ea817be7ab3aa089 to your computer and use it in GitHub Desktop.
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 | |
# i'm trying to make a grammar for this file format: | |
# https://puredata.info/docs/developer/PdFileFormat | |
my regex statement { '#' <( [ A | N | X ] .*? )> ';' \n } | |
#$_ = slurp("a-pd-patch.pd"); | |
$_ = Q { | |
#N canvas 166 0 1426 857 10; | |
#X obj 254 310 phasor~; | |
#X connect 20 0 0 0; | |
#X connect 20 0 5 0; | |
}; | |
my @match = m:g/ <statement> /; | |
.say for @match; | |
# i get that $_ in the for loop is a match object; i looked at | |
# https://docs.perl6.org/type/Match | |
# but i haven't figured out how to refer to the capture. | |
# i see this: | |
# | |
# 「#N canvas 166 0 1426 857 10; | |
# 」 | |
# statement => 「N canvas 166 0 1426 857 10」 | |
# 「#X obj 254 310 phasor~; | |
# 」 | |
# statement => 「X obj 254 310 phasor~」 | |
# 「#X connect 20 0 0 0; | |
# 」 | |
# statement => 「X connect 20 0 0 0」 | |
# 「#X connect 20 0 5 0; | |
# 」 | |
# statement => 「X connect 20 0 5 0」 | |
# but i want this: | |
# | |
# N canvas 166 0 1426 857 10 | |
# X obj 254 310 phasor~ | |
# X connect 20 0 0 0 | |
# X connect 20 0 5 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment