dcsimg
When reaching an end of file, I keep getting nulls
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mustafa_Iqbal
Posted On:   Wednesday, January 30, 2002 01:24 PM

I have just started using ANTLR. When I ANTLRISE the grammer, it is fine, but when I try and parse some text i.e. 'This is just a test to see what happens ', it seems to go past the EOF and keep getting nulls, I end up getting a 'java.lang.NullPointerException'. The grammer is as follows:- // THE PARSER class MuckParser extends Parser; stuff : a:INT lala | b:ID lala | c:IE lala | d:HM lala { System.out.println(a.getText()); } ; lala : stuff EOF_TYP   More>>

I have just started using ANTLR.

When I ANTLRISE the grammer, it is fine,

but when I try and parse some text

i.e. 'This is just a test to see what

happens ', it seems to go past the EOF

and keep getting nulls, I end up getting

a 'java.lang.NullPointerException'. The grammer is as follows:-



			

// THE PARSER


class MuckParser extends Parser;


stuff : a:INT lala | b:ID lala | c:IE lala | d:HM lala

{

System.out.println(a.getText());

}

;


lala : stuff EOF_TYPE

;



//--------------------------------



// THE LEXER


class MuckLexer extends Lexer;


{

/* public void uponEOF() throws TokenStreamException, CharStreamException

{

System.out.println("Shit happens");

}

*/


}



//THINGS : (INT|ID|IE|HM)

// ;


INT : ('0'..'9')

;


ID : ('a'..'z')

;


IE : ('A'..'Z')

;


HM : (' '

|' '

|'
'

|'
')

;





please help me man ! ! !

   <<Less

Re: When reaching an end of file, I keep getting nulls

Posted By:   Terence_Parr  
Posted On:   Thursday, January 31, 2002 06:27 PM

a.getText() is in an action that is associated with the last alternative, not the one with a: label in it. That will always generate a nullptr exc.
About | Sitemap | Contact