Alternative Cross reference not working as expected [message #1005386] |
Fri, 25 January 2013 03:20  |
Eclipse User |
|
|
|
Hi All,
I have a grammar that uses an alternative reference, I have pulled out the parts in question below full source here):
SingleSource:
{SingleSourceTable} tableReference=TableReference ('as' name=ID)? |
{SingleSourceSelectStatement} '(' selectStatement=SelectStatement ')' ('as' name=ID)? |
{SingleSourceJoin} '(' joinSource=JoinSource ')'
;
TableOrSourceReference:
TableReference | =>SingleSourceReference
;
TableReference:
table=[CreateTableStatement|ID]
;
SingleSourceReference:
source=[SingleSource|ID]
;
ResultColumn:
{ResultColumnAll} (reference=TableOrSourceReference '.')? '*' |
{ResultColumnExpression} expression=SqlExpression ('as' name=ID)?
;
The problem is when I use the grammar, it gives me proposals for both TableReference and SingleSourceReference for ResultColumn completion, but when I choose the path SingleSourceReference it gives me an error: Couldn't resolve reference to CreateTableStatement 'j':-
select j.* from table3 as j
But j should not be a CreateTableStatement reference, it should be a SingleSourceTable via the SingleSourceReference.
However its ok if I use the table reference:-
select table3.* from table3 as j
Not sure what I am doing wrong here, any advice would be greatly appreciated!
|
|
|
|
|
Re: Alternative Cross reference not working as expected [message #1005397 is a reply to message #1005386] |
Fri, 25 January 2013 03:56   |
Eclipse User |
|
|
|
HI,
>> TableOrSourceReference:
>> TableReference | =>SingleSourceReference
The parser willways parse this as SingleSourceReference (both are parsed
as ID thus the predicate always succeeds if the first path in the
alternative would succeed) since it does not know anything about cross
references. You'll have to rework your language in order to make a
proper decision.
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 25.01.13 09:20, schrieb Ian Warwick:
> Hi All,
>
> I have a grammar that uses an alternative reference, I have pulled out
> the parts in question below
> https://github.com/robotoworks/mechanoid/blob/master/plugins/com.robotoworks.mechanoid.sqlite/src/com/robotoworks/mechanoid/sqlite/SqliteModel.xtext):
>
>
>
> SingleSource:
> {SingleSourceTable} tableReference=TableReference ('as' name=ID)? |
> {SingleSourceSelectStatement} '(' selectStatement=SelectStatement
> ')' ('as' name=ID)? |
> {SingleSourceJoin} '(' joinSource=JoinSource ')'
> ;
>
> TableOrSourceReference:
> TableReference | =>SingleSourceReference
> ;
>
> TableReference:
> table=[CreateTableStatement|ID]
> ;
>
> SingleSourceReference:
> source=[SingleSource|ID]
> ;
>
>
> ResultColumn:
> {ResultColumnAll} (reference=TableOrSourceReference '.')? '*' |
> {ResultColumnExpression} expression=SqlExpression ('as' name=ID)?
> ;
>
>
> The problem is when I use the grammar, it gives me proposals for both
> TableReference and SingleSourceReference for ResultColumn completion,
> but when I choose the path SingleSourceReference it gives me an error:
> Couldn't resolve reference to CreateTableStatement 'j':-
>
>
> select j.* from table3 as j
>
>
> But j should not be a CreateTableStatement reference, it should be a
> SingleSourceTable via the SingleSourceReference.
>
> However its ok if I use the table reference:-
>
>
> select table3.* from table3 as j
>
>
> Not sure what I am doing wrong here, any advice would be greatly
> appreciated!
|
|
|
Re: Alternative Cross reference not working as expected [message #1005400 is a reply to message #1005397] |
Fri, 25 January 2013 04:15  |
Eclipse User |
|
|
|
Hi Sebastian,
Thanks for pointing that out, is there a standard (or known way) to deal with scenarios with aliases in the grammar such as the "as" clause in SQL?
I will try to rework my grammar I think the mistake I made was modelling it on the SQLite syntax diagrams, now I know the grammar I should probably try to take a fresh approach.
|
|
|
Powered by
FUDForum. Page generated in 0.03577 seconds