I want to use the built-in methods for tracking column and line numbers of tokens
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Tim_McKenzie
Posted On:   Monday, January 28, 2002 08:00 PM

There are several examples on the FAQ's detailing how to over-ride the column/line counting mechanisms of antlr. Presumably, there were written for previous versions of the program, as it appears to have been completely implemented in the current one. However, when I attempt to call upon these methods, I get only error messages. For example, the line: (inserted in the lexer) System.out.println(antlr.CharScanner.getColumn()); gives the following error when the generated file is compiled (javac) myLexer.java:44: non-static method getColumn() cannot be referenced from a static context System.out.println(antlr.CharScanner.getColumn());    More>>

There are several examples on the FAQ's detailing how to over-ride the column/line counting mechanisms of antlr. Presumably, there were written for previous versions of the program, as it appears to have been completely implemented in the current one.
However, when I attempt to call upon these methods, I get only error messages.
For example, the line: (inserted in the lexer)


System.out.println(antlr.CharScanner.getColumn());

gives the following error when the generated file is compiled (javac)


myLexer.java:44: non-static method getColumn() cannot be referenced from a static context

System.out.println(antlr.CharScanner.getColumn());

^

1 error



Are these methods actually implemented in a way which they can be publically accessed, or am I attempting to access them incorrectly?


Any help would be appreciated, thanks.

   <<Less

Re: I want to use the built-in methods for tracking column and line numbers of tokens

Posted By:   joe_kraska  
Posted On:   Tuesday, January 29, 2002 11:50 AM



The answer is in front of your face; you
are attempting to access a non-static
method from a static context. Don't do
that. :)

Anyway, you can only access the getColumn()
method from an _instance_ of a CharScanner
class. The CharScanner instance is most
likely the instance of your lexer.

C//
About | Sitemap | Contact