Hi, as I am progressing in the definition of my powerscript grammar, I began to build a consistent base of test cases to point the portions of the grammar that still need some work.
I first used to put the test cases in a String array processed in the main method of the parser class. Not very practical. I used also to parse a set of debug_* files where I put the test cases grouped by theme, with a pause between each test file to look for error messages. Better, but it lacks the ability to display a resume of the passed vs. failed tests (though I still use that to produce automated graphviz diagrams of syntax). Then I discovered gunit, which looks to be what I am looking for, with some problems : 1) gunit seems to be annoyed by some debug output messages (System.ot.print...) that I put in Lexer and Parser actions. I get a the following in the gunit results (partial output) : executing testsuite for grammar:PowerScript with 39 tests ----------------------------------------------------------------------- 8 failures found: test1 (Ident, line7) - expected: OK actual: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 test2 (Ident, line9) - expected: OK actual: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 [...] If I comment out a System.out.print in the Ident rule, the tests are passed OK. 2) following Jim Idle advice, I am using a custom ANTLRNoCaseFileStream to perform a case insensitive matching of the language keywords, and I am about to implement a such StringStream. Would it be possible to use that case insensitive stream with gunit ? For the moment I need to type each keyword in uppercase as they are defined in the grammar. 3) I have some tests that fails. Sometimes the cause is obvious (in the test case), sometimes it is not and I cannot get a verbose reason with gunit. E.g , I get a expected: OK / actual: FAIL. I need to specifically invoke the rule with the same input to get a clear error message from the parser. I have made a dynamic rule invoker to help, but would it be possible to get the error message directly with gunit ? For those that could help, I join my "dynamic invoker", you just need to pass the rule name and an input string to invoke the rule from the parser. Start it by giving the rule name and a test string in the command line arguments. Regards, -- Sébastien Kirche
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
RunExpression.java
Description: Binary data
-- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
