ANTLR generation problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Hendrik_Reitmann
Posted On:   Wednesday, June 1, 2011 06:38 AM

Hello, I have to write a parser for SQL an have some problems with the generated code of ANTLR, because there are errors in the code and I don't understand the problem. Here is is rule with problems: sql_numeric_term_continued [Expression inh] returns [Expression tree] : '*' nf=sql_numeric_factor ntc=sql_numeric_term_continued[new Mult($inh,$nf.tree)] {$tree = $ntc.tree; } | '\\'nf=sql_numeric_factor ntc=sql_numeric_term_continued[new Div($inh,$nf.tree)] {$tree = $ntc.tree; } | {$tree = $inh;} ; The Problem is in the part 'new Mult($inh, $nt.tree)'. At this point ANTLR throws an error during the genera   More>>

Hello,


I have to write a parser for SQL an have some problems with the generated code of ANTLR, because there are errors in the code and I don't understand the problem.


Here is is rule with problems:



sql_numeric_term_continued [Expression inh] returns [Expression tree]

			
: '*' nf=sql_numeric_factor ntc=sql_numeric_term_continued[new Mult($inh,$nf.tree)] {$tree = $ntc.tree; }

| '\\'nf=sql_numeric_factor ntc=sql_numeric_term_continued[new Div($inh,$nf.tree)] {$tree = $ntc.tree; }

| {$tree = $inh;}
;



The Problem is in the part 'new Mult($inh, $nt.tree)'. At this point ANTLR throws an error during the generation of the grammar with the message, that inh attribute is not a token, parameter or return value. If I remove the dollar sign before inh it works, but the generated code has errors.


In another rule similar to this everthing is correct, without an error of ANTLR at generation.



sql_interval_term_continued [Expression inh] returns [Expression tree]

			
: '*' nf=sql_numeric_factor itc=sql_interval_term_continued[new Mult($inh,$nf.tree)] {$tree=$itc.tree;}

| '\\' nf=sql_numeric_factor itc=sql_interval_term_continued[new Div($inh,$nf.tree)] {$tree=$itc.tree;}

| {$tree=$inh;}
;



Can someone help me with this problem?

   <<Less
About | Sitemap | Contact