I've read the section on error reporting and recovery from "the book" but still can't figure out what may be a simple problem.
I want to parse a file that consists of bibliographic entries. Each entry is on one line (so each record ends with \n). If a record does not match, I just want to print an error message, and skip to the end of line and start again with the next record. If I understand chapter 10 correctly, then '\n' should be in the resynchronization set, and the parser will consume tokens until it finds one. This isn't happening. Once I get an error, the parser never recovers. I get a bunch of NoViableAlt exceptions. I'm hoping someone can explain what I'm doing wrong. Here is a sample input file. The 1st and 3rd lines are ok, the 2nd line is an error. Name. "Title," Periodical, 2005, v41(3,Oct), 217-240. Name. "Title," Periodical, 2005, v41(3,Oct), Article 2. Name. "Title," Periodical, 2005, v41(3,Oct), 217-240. Here is the grammar: grammar Periodical; article_list : (article NL)* article NL? ; article : a=authors PERIOD SPACE QUOTE t=title COMMA QUOTE SPACE j=journal COMMA SPACE y=year COMMA SPACE v=volume COMMA SPACE p=pages PERIOD SPACE* ; authors : (~QUOTE)+; title : (~QUOTE)+; journal : (LETTER|SPACE|COMMA|DASH)+; volume : (LETTER|DIGIT)+ | (LETTER|DIGIT)+ '(' (LETTER|DIGIT|SLASH|COMMA)+ ')' ; year : DIGIT DIGIT DIGIT DIGIT; pages : DIGIT+ DASH DIGIT+; PERIOD : '.'; QUOTE : '"'; COMMA : ','; SPACE : ' '; DIGIT : '0'..'9'; LETTER : ('a'..'z')|('A'..'Z'); DASH : '-'; SLASH : '/'; NL : '\r'? '\n'; -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address