[antlr-interest] NoViableAlException

Fabian Haupt fabian at fabianhaupt.de
Wed Nov 10 09:23:42 PST 2010


Hi all,

I have a fairly simple grammar with which i'm trying to extract some 
values from the diagnostic output of an analyzer program.

This is a minimal grammar (see down below) to demonstrate the error I'm 
experiencing.

I'm getting a NoViableAltException: line 1:55 no viable alternative at 
input '.[CheckIntegrity'

with the input of
'The lower level block specifies a right link block of 0. 
[CheckIntegrity+343^%SYS.DATABASE:%SYS]'
starting with the 'test' rule.


 From my (limited) understanding the decision at this point is clear. 
There is only the possibility to match a whitespace and then the 
debugnote ([Che...)
I see that the second part of firstNodePtrWrong starts with '. We' which 
starts with the . as well.

I've read up on the posts of the other occurences of 
NoViableAltException, but found no case matching this (or maybe just 
didn't recognize).

The problem goes away if I remove the fist space in '. We were...' but 
unfortunately I can't change the output of the program, so that's not an 
option.

What do I have to change in my grammar to make it work?
Or is this even a reasonible approach to extract some numbers and error 
types from an ouput? If you think I should do it completely different, 
please feel free to tell me.

The output I'm trying to parse looks like this:
**********Global A is Not OK**********
[CheckIntegrity+186^%SYS.DATABASE:%SYS]
  Error of type 26 while processing pointer block 39
[CheckIntegrity+190^%SYS.DATABASE:%SYS]
  The error occurred while processing node 213
[CheckIntegrity+206^%SYS.DATABASE:%SYS]
   which is ^A(97096) pointing to the lower level block 285
[CheckIntegrity+207^%SYS.DATABASE:%SYS]
  The lower level block specifies a right link block of 0.
[CheckIntegrity+343^%SYS.DATABASE:%SYS]
  That doesn't match the next pointer node in the pointer block, which 
is 286. [CheckIntegrity+344^%SYS.DATABASE:%SYS]
  Data Level:           # of blocks=1      8kb (0% full)
[CheckIntegrity+479^%SYS.DATABASE:%SYS]
  Total:                # of blocks=2      16kb (10% full)
[CheckIntegrity+66^%SYS.DATABASE:%SYS]



Thanks for your ideas and time,

Kind regards,
Fabian


this is the grammar:
----------------------------
grammar integrit;

options {
   language= Java;
}


test:'The lower level block specifies a right link block of '+INT+'.' WS 
debugnote NEWLINE;

firstNodePtrWrong: INT+'. We were expecting it to point to ';


debugnote:'['+ID+'+'+INT+'^%SYS.DATABASE:%SYS'+']';

ID  :   ('a'..'z'|'A'..'Z')+ ;
INT :   '0'..'9'+ ;
NEWLINE:('\r'? '\n');
WS  :   (' '|'\t')+ {skip();} ;


More information about the antlr-interest mailing list