Created
January 1, 2024 17:18
-
-
Save librasteve/3fc8e23490702b8c1e12d863b4d260b2 to your computer and use it in GitHub Desktop.
GrammarConsumptionExample1
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
use Grammar::Tracer; | |
grammar Timestamp { | |
token TOP{^<y><m><d>T<hr><mn>$} | |
token y {\d**4} | |
token m {\d**2} | |
token d {\d**2} | |
token hr {\d**2} | |
token mn {\d**2} | |
} | |
#say Timestamp.parse: '20130304T0102'; | |
grammar TimestampExp is Timestamp { | |
token tsx{<y><m><d>T<hr><mn>} | |
} | |
grammar TimestampedFile is TimestampExp { | |
token TOP{^<name> '-' <tsx> '.' <ext>$} | |
token name{<[a..z]>+} | |
token ext{<[a..z]>**3} | |
} | |
say TimestampedFile.parse: 'xxx-20130304T0102.csv'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment