[antlr-interest] Multiple inheritance problem
Fazlur Rahaman Naik
fazlur.bluelane at gmail.com
Wed Sep 17 00:22:08 PDT 2008
Hi All,
This is Falzur. I am using Antlr 2.7.6 to parse MySQL queries. I am
facing a problem with the multiple inheritance. I wrote a seperate grammar
file for each MySQL statement. and a base file for the comman grammar. In
MySQL we have a begin end block statement, in which any statement can come.
Here the problem raised. The grammar for the begin end block is as follows:
compound_stmt {SaToken t;}: t = begin_end_block
{
cout<<"Pushing for element compound_stmt at depth "<<currentDepth<<endl;
ElemToken elem_token = createElementToken(currentDepth,
ELEMENT_TYPE_compound_stmt, t);
add_elem_token_to_list(elem_token);
currentDepth --;
};
begin_end_block : (begin_label COLON)? begin_clause (statement_list)?
end_clause;
begin_clause returns [SaToken t] : e: "begin" {
t = createSaToken (e);
};
end_clause: "end" (end_label)?;
statement_list: (stmt)* ;
stmt: (subquery | create_stmt | replace_stmt | update_stmt | alter_stmt |
truncate_stmt | compound_stmt);
begin_label: identifier;
end_label: begin_label;
Where all the, subquery, create_stmt, replace_stmt, update_stmt,
alter_stmt, truncate_stmt, compound_stmt are in different parser files.
and i choosed the following options:
options {
importVocab = BaseLexer;
k = 3;
defaultErrorHandler = false;
buildAST = true;
classHeaderSuffix = UpdateParser, ReplaceParser, TruncateParser,
AlterPaser, SelectParser;
}
When i compile, it raises an error
rule classDef trapped
expecting SEMI, found ','
ane when i compile with the option classHeaderSuffix = UpdateParser; then,
the compilation throws errors saying that the following statements doesn't
have the rule define, which is right.
create_stmt,
replace_stmt,
update_stmt,
alter_stmt,
truncate_stmt
I would like to inherit each grammar file in the current file. So that all
the Tokens should resolve.
Can anybody help me out how to resolve this problem. Thanks in advance.
--
Thanks & Regards,
Fazlur Rahaman Naik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080917/99c0e934/attachment.html
More information about the antlr-interest
mailing list