[antlr-interest] passing an argument to a lexer

Johannes Luber jaluber at gmx.de
Sat Apr 26 03:26:51 PDT 2008


siemsen at ucar.edu schrieb:
> I want the translator to look for include files relative to the current 
> input file.  It's easy to get the base path of the current input file, 
> but I don't know how to get the path into the lexer.  The relevant 
> fragment of my "rig" looks like this

It is pretty simple. Add in the lexer grammar

@members {

private String path;

public void setPath(String path) {
	this.path = path;
}
}

Then you have to change your driver to use this setter and you lexer to 
use the path member field.

Johannes


More information about the antlr-interest mailing list