[antlr-interest] need ANTLRHashString.toString() conversion!

Alexey Demakov allex at all-x.net
Wed Feb 15 05:53:09 PST 2006


I'm trying to use lexer's literalsTable as source for set of keywords.
But the current ANTLRHashString interface have not method to convert it to String,
so only "query" interface is possible. 
To implement "enumeration" interface I need to get string value of ANTLRHashString.
"enumeration" interface required, for example, to implement syntax highliting in Eclipse.

There is my "query" interface:

private static TDL_Lexer literalsTableProvider 
    = new TDL_Lexer( (antlr.LexerSharedInputState)null ); 
private static Hashtable literalsTable = literalsTableProvider.getLiteralsTable();
private static ANTLRHashString hashString = new ANTLRHashString( literalsTableProvider );
    
    /**
     * Returns true if given string is one of TreeDL keywords.
     *  
     * @param s        String to be checked.
     * @return         true if string is one of TreeDL keywords.
     */
    public static synchronized boolean isKeyword( String s )
    {
        hashString.setString( s );
        return literalsTable.containsKey( hashString );
    }


Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com




More information about the antlr-interest mailing list