I have a probably easy to answer Raku grammar question. I wont to parse a log file and get back the entries log entry by log entry. A log entry can be just a line or a multi line string.
My draft code looks like this:
grammar Grammar::Entries {
rule TOP { <logentries>+ }
token logentries { <loglevel> <logentry> }
token loglevel { 'DEBUG' | 'WARN' | 'INFO ' | 'ERROR' }
token logentry { .*? <.finish> }
token finish { <.loglevel> || $ }
}
That works for just the first line because in the second line the loglevel is consumed by the first line match although I used '.' in the regex <> that as far as I know means non-capturing.
Following are a log example:
INFO 2020-01-22T11:07:38Z PID[8528] TID[6736]: Current process-name: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
INFO 2020-01-22T11:07:38Z PID[8528] TID[6736]: Session data:
PID: 1234
TID: 1234
Session: 1
INFO 2020-01-22T11:07:38Z PID[8528] TID[6736]: Clean up.
What would be the right approach to get back the log entries even for multi line ones? Thanks!