Skip to content

Instantly share code, notes, and snippets.

@araraloren
Created January 17, 2019 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save araraloren/f4164cd19d16df8a2ecc32163438f072 to your computer and use it in GitHub Desktop.
Save araraloren/f4164cd19d16df8a2ecc32163438f072 to your computer and use it in GitHub Desktop.
grammar PNG {
token TOP {
^ <header> <chunk> $
}
token chunk {
<length>
}
token length {
. ** 4
}
token header {
. ** 8
<?{ say $/.Str.encode("latin1"); say $/.Str.encode("latin1") == Buf.new([137, 80, 78, 71, 13, 10, 26, 10]); }>
}
}
my $str = @*ARGS[0].IO.open(enc => "latin1").read(12);
say "GIVEN =-> ", $str;
say PNG.parse( $str.decode("latin1") );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment