I found this issue interesting so I set up a little repo to work on it, to reproduce the problem outside of the somewhat ‘heavy’ environment of the full jenkins source code. I basically copied the smallest amount of code (including the grammar) to observe the issue. It’s available there.
Here’s what I can tell from the issue, complementing what’s already been found by Daniel.
In labelExpr.g, 7 ‘operators’ (or 'special tokens') are defined: AND, OR, NOT, IMPLIES, IFF, LPAREN, RPAREN. They’re made of a combination of the following characters: &|!->(). These characters are all excluded from what’s allowed in a “LabelAtom” token, except -, which is the issue.
When the lexer starts parsing a full label and starts a new token (for instance after a white space) with character ‘-‘, the token is either IMPLIES or ATOM. If the following character is >, the token is IMPLIES and should be complete (= a white space should follow). If it’s another character, the token must be an ATOM. Now if the lexer has already determined that it’s in an ATOM and finds a - followed by a >, it doesn’t understand that it should keep - and > together as an IMPLIES and backtrack before the - to close the ATOM it was reading. Instead it considers it’s an ATOM, and since > is not allowed in an ATOM the whole parsing fails.
Even though I (believe I) understand the issue I don’t see yet how to solve it by modifying the grammar.
One naive way to solve the problem is by forcefully looking for -> not preceded by space in the label, and add an extra space before feeding the parser/lexer. See function prepareLabelForParsing in TestGrammar.java.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to