[antlr-interest] problem with literal match
Ruslan Zasukhin
sunshine at public.kherson.ua
Wed Oct 3 14:41:52 PDT 2001
on 10/3/01 23:34, John Lambert at johnl at jbase.com wrote:
Well, it seems I have found at least one way when it works.
I did have Lexer and Parser in separate files. In Lexer I did have
exportVocab=OBL_SQL
in Parser I have
importVocab=OBL_SQL
In this configuration ANTLR produce EMPTY initLiterals()...
When I have put Lexer into the same file as Parser It start work.
I also remove export/import options after merge...
So may be bug in ANTLR...may be I have made something wrong, but what ?
> Ruslan,
>
> What options do you have in the lexer header?
>
> I have
>
> options {
> defaultErrorHandler=false;
> testLiterals=true;
> caseSensitive=false;
> caseSensitiveLiterals=false;
> charVocabulary = '\3'..'\377';
> }
>
>
> and it generates
>
> void SQLLexer::initLiterals()
> {
> literals["option"] = 51;
> literals["index"] = 43;
> literals["public"] = 30;
> literals["selectany"] = 63;
> literals["link"] = 15;
>
> ... etc ....
> John
>
>
> -----Original Message-----
> From: Ruslan Zasukhin [mailto:sunshine at public.kherson.ua]
> Sent: Wednesday, October 03, 2001 1:22 PM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] problem with literal match
>
>
> on 10/3/01 22:35, Ruslan Zasukhin at sunshine at public.kherson.ua wrote:
>
> I wonder that may be problem is hidden that the next function is EMPTY in
> generated code?
>
> void OBL_SQL_Lexer::initLiterals()
> {
> }
>
> But then I wonder why I must init table of Literals by hands ???
> And how to do this ?
> I don't see nothing helpful in examples and docs.
>
>
>> Hi All,
>>
>> I have in grammar rule as:
>>
>> -------------------------------------------------
>> drop_table_statement
>> : "drop"! "table"! table_name drop_behavior
>> ;
>>
>>
>> in generated parser I see that in table ANTLR put literals with ""
>> -------------------------------------------------
>> const char* OBL_SQL_Parser::tokenNames[] = {
>> "<0>",
>> "EOF",
>> ........
>> "\"drop\"",
>> "\"table\"",
>> "\"cascade\"",
>> "\"restrict\"",
>> 0
>> };
>>
>>
>> Now I try to pass to Parser test string "DROP TABLE errors"
>> I see in debugger that function
>>
>> int CharScanner::testLiteralsTable(int ttype) const
>> {
>> STD::map<STD::string,int,CharScannerLiteralsLess>::const_iterator i =
>> literals.find(text);
>> if (i != literals.end())
>> ttype = (*i).second;
>> return ttype;
>> }
>>
>> DO NOT FIND first word 'DROP' in my test string.
>>
>> NOTES:
>> ** CASE is not sensitive.
>> ** I did try testLiterals as true so false.
>>
>> WHERE IS PROBLEM ???
--
Best regards,
Ruslan Zasukhin
-------------------------
Paradigma.
e-mail: ruslan at paradigmasoft.com
web : http://www.paradigmasoft.com
To subscribe to the Valentina mail list
send a letter to valentina-on at lists.macserve.net
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list