|
If I add it to the ValidWhen unit test, I get an error:
Feb 1, 2007 3:31:18 PM org.apache.struts.validator.TestValidWhen doParse SEVERE: Parsing (*this* == "foo:bar") for property 'stringValue1' line 1:16: expecting '"', found ':' at org.apache.struts.validator.validwhen.ValidWhenLexer.nextToken(ValidWhenLexer.java:245) Digging into this more, it appears to be because the charVocabulary is not being set. Every char referenced in the antlr grammer is implicitly added to the charVocabulary, and when you say "~f", it means every char other than f __in the charVocabulary__. So the reason you don't see the other characters is that they've not been added to the charVocabulary yet.
I'll post in a bit with a recommended fix, once I figure out the correct way to generate the .g file into the .java file. I don't think the Struts trunk build is doing it automatically yet. Fix for this issue. I've chosen to make all chars from the space char up to the ~ legal. The rest of the grammar then adds the necessary ctrl characters (9,10,13). It's a bit wasteful as the uppercase chars are never checked as things are caseSensitive = false, but I don't think that's a big deal.
It does mean that Extended ISO and Unicode are not permitted. The Antlr site points out that a ~ on a Unicode charVocabulary takes up 8k, so that seems like something to think carefully about getting into. svn ci -m "Applying unit test and fix from
Sending core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenLexer.java Sending core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.g Sending core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.java Sending core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParserTokenTypes.java Sending core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParserTokenTypes.txt Sending core/src/test/java/org/apache/struts/validator/TestValidWhen.java Transmitting file data ...... Committed revision 504715. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
So I'm guessing the problem is that the STRING_LITERAL is not being applied to the part inside the quotes; instead it is treating it as source. Looking at ValidWhenParser.g, I can't see any obvious reasons why that'd be so.