Expand description
§Grammar rules
Here pest grammar rules are described.
§time
This rule matches a time in the format HH:MM:SS
.
Structure: hour
:minsec
:minsec
time = { hour ~ ":" ~ minsec ~ ":" ~ minsec }
Components:
- hour: Matches an hour value from 00 to 23.
hour = { "0" ~ ASCII_DIGIT | "1" ~ ASCII_DIGIT | "2" ~ '0'..'3' }
- minsec: Matches minutes or seconds from 00 to 59.
minsec = { '0'..'5' ~ ASCII_DIGIT }
§date
This rule matches a date in the format YYYY-MM-DD
.
Structure: YYYY-month-day
date = { ASCII_DIGIT{4} ~ "-" ~ month ~ "-" ~ day }
Components:
-
ASCII_DIGIT{4}: Matches a four-digit year (e.g., 2023).
-
month: Matches month values from 01 to 12.
month = { "0" ~ ASCII_NONZERO_DIGIT | "1" ~ '0'..'2' }
- day: Matches a two-digit day.
day = { "0" ~ ASCII_NONZERO_DIGIT | '1'..'2' ~ ASCII_DIGIT | "3" ~ '0'..'1' }
§datetime
Combines a date
and a time
to represent a full timestamp.
datetime = { date ~ " " ~ time }
§loglevel
Matches specific log levels in log entries. 3 different values are supported: INFO, WARNING, ERROR.
loglevel = { "INFO" | "WARNING" | "ERROR" }
§message
Captures message part of the log line. Matches any sequence of characters until a newline, ensuring the content is part of a single line.
message = { (!NEWLINE ~ ANY)+ }
§logline
Represents a full log entry, combining all previous rules. Matches a complete log line that starts with a timestamp, followed by a log level, and ends with a log message.
Structure: datetime
loglevel
message
logline = { datetime ~ " " ~ loglevel ~ " " ~ message }
§Example log line:
2024-11-06 18:46:37 WARNING A warning log line example
Structs§
Enums§
Traits§
- Parser
- A trait with a single method that parses strings.