-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex parser improvements and bug fixes #4087
Conversation
Signed-off-by: Andy Grove <[email protected]>
RegexRepetition(RegexCharacterClass(negated = false, | ||
ListBuffer(RegexCharacterRange('0', '9'))),SimpleQuantifier('+'))))), | ||
RegexChar('|'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we were detecting |
as a character and not as a choice delimiter
private def parseInternal(): RegexAST = { | ||
val term = parseTerm(() => peek().contains('|')) | ||
private def parseUntil(until: () => Boolean): RegexAST = { | ||
val term = parseTerm(() => until() || peek().contains('|')) | ||
if (!eof() && peek().contains('|')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Not needed as part of this PR, but I think peek()
will return None
at EOF, so this can be simplified to:
if (!eof() && peek().contains('|')) { | |
if (peek().contains('|')) { |
Applies to a few other places where eof
and peek
are combined.
while (!eof() && !until() | ||
&& (peek().exists(ch => ch == '*' || ch == '+' || ch == '?') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per previous nit, should be able to simplify this to something like:
while (!eof() && !until() | |
&& (peek().exists(ch => ch == '*' || ch == '+' || ch == '?') | |
while (!until() && (peek().exists(ch => ch == '*' || ch == '+' || ch == '?') |
build |
Signed-off-by: Andy Grove [email protected]
This PR fixes some issues I found during more extensive testing with random inputs.
]
as the first character