Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env raku
- use v6.d;
- grammar Timestamp {
- rule TOP { <year><month><day>T<hours><minutes> }
- token year { \d**4 }
- token month { \d**2 }
- token day { \d**2 }
- token hours { \d**2 }
- token minutes { \d**2 }
- }
- grammar Filename {
- # This line fails with:
- # Cannot look up attributes in a Nil type object. Did you forget a '.new'?
- # in regex TOP at ./test-nesting-grammar.raku line 16
- # in block <unit> at ./test-nesting-grammar.raku line 23
- rule TOP { <name>'-'<timestamp>'.'<extension> }
- token name { <[a..z]>+ }
- token extension { <[a..z]>**3 }
- }
- Filename.^add_method("timestamp", -> *@_, *%_ { Timestamp.parse(@_[*-1].orig) });
- Filename.parse('foo-20240102T1234.bar').say;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement