Replies: 1 comment
-
Does this work?
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to write a parser for cron expressions that collects invalid inputs instead of failing to parse the expression altogether. For example, when parsing
1,5- 4 * * *
, I want to record the valid1
and invalid5-
entries for the minutes field, the valid4
entry for the hours and the valid*
for the remaining fields.This is the grammar I put together:
The problem is that the
5
gets eagerly parsed bynumber
and the-
is left for the next rule which then fails. Similarly, when parsing-1 4 * * *
, theinvalid
rule captures the full input and the parser fails because there's nothing left to parse. Is there some way to look head in theentry
rule to make sure the wrong rule doesn't capture part of the input? I feel like using the stack could be useful here but I have a hard time wrapping my head around how to actually use it.Beta Was this translation helpful? Give feedback.
All reactions