[antlr-interest] Re: Request enhancement ANTLR

Brian Smith brian-l-smith at uiowa.edu
Sat Sep 14 22:32:42 PDT 2002


Terence,

It isn't a big deal to me. I was actually thinking that people would use 
the "file://" form instead (actually, I use java.net.URL objects), but 
then they'd have to have URL->"friendly filename" mapper. I already have 
to have a URL->"friendly filename" mapper but my requirements are not as 
common, probably.

Actually, I would be more interested in adding a "tokenClass" option for 
the lexer. That way, things like this extension would be quite easy to 
individual users to do and wouldn't require the ugly downcasting that is 
currently required. I was thinking that it would work something as follows:

options { tokenClass=org.brianlsmith.smn.reader.ValuedToken; }

* When set at the lexer grammar level, it defines the type of the token 
class.

* When set at the parser grammar level, it defines the type of the token 
class that the parser assumes that the lexer returns.

* When set at the rule level, it defines the type of the token that will 
be returned by the rule (to support the heterogenous token feature as 
explained in the documentation).

* Rules that reference tokens in the lexer would no longer have to 
downcast from antlr.Token (e.g. no need to cast from antlr.Token to 
o.b.s.r.ValuedToken).

* Rules that reference tokens in the parser would no longer have to 
downcast from antlr.Token either.

* When creating tokens, the makeToken() method would automatically 
instantiate the correct class and set the type, column, line as 
necessary. Lexer creators could then override makeToken() and set custom 
properties (like filename, url, etc.) as necessary. Then these custom 
properties would automatically be available in the lexer grammar.

- Brian

Terence Parr wrote:
> On Saturday, September 14, 2002, at 09:57  PM, Brian Smith wrote:
> 
> 
>>Terence,
>>
>>May I recommend that instead of getFilename/setFilename, you have 
>>getURL
>>and setURL()? I am using ANTLR inside of NetBeans and I've added an
>>extension just as you described. With NetBeans they have a filesystem
>>abstraction that uses URL's of the form nbfs://XXXX to identify files,
>>so I can't use a "filename" per se. Also, get/setFilename wouldn't be
>>very useful for parsing from a HTTP stream.
> 
> 
> Hi,
> 
> Hmm...well, getInputName or some such would work.  i'm worried that URL 
> would make people think you needed file:// on the front or something.  
> Can you just use the method knowing it's a bit of a misnomer?
> 
> What are you doing with NetBeans?  A cool secret project?
> 
> Ter
> --
> Co-founder, http://www.jguru.com
> Creator, ANTLR Parser Generator: http://www.antlr.org
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list