Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ebnf2 is not supported for CrossReference
ebnf2 is not supported for CrossReference [message #655193] Fri, 18 February 2011 15:41 Go to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hello everybody, I am getting this error when I run the workflow for my languages:

ebnf2 is not supported for CrossReference
ebnf2 is not supported for CrossReference
warning(200): ../org.xtext.example.test.ui/src-gen/org/xtext/example/test/ui/contentassist/antlr/internal/InternalMyDslB.g:121:1: Decision can match input such as "EOF" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(201): ../org.xtext.example.test.ui/src-gen/org/xtext/example/test/ui/contentassist/antlr/internal/InternalMyDslB.g:121:1: The following alternatives are unreachable: 2


This is my example grammar:

grammar org.xtext.example.test.MyDslA with org.eclipse.xtext.common.Terminals

generate myDslA "http://www.xtext.org/example/test/MyDslA"


Domain:
	'Name' ':' name=ID
;


grammar org.xtext.example.test.MyDslC with org.eclipse.xtext.common.Terminals

generate myDslC "http://www.xtext.org/example/test/MyDslC"


CObject:
	'Name' ':' name=ID
;



and,

grammar org.xtext.example.test.MyDslB with org.eclipse.xtext.common.Terminals
import "platform:/resource/org.xtext.example.test/src-gen/org/xtext/example/test/MyDslA.ecore" as mydsla
import "platform:/resource/org.xtext.example.test/src-gen/org/xtext/example/test/MyDslC.ecore" as mydslc
generate myDslB "http://www.xtext.org/example/test/MyDslB"


Attribute:
	'Name :' name=ID
	'AorC : ' aorc=AorC
;

AorC:
	name=([mydsla::Domain]|[mydslc::CObject])
;


As you can see, I must have a property which can be one of the two types: MyDslA or MyDslC, but I am getting the error showed before.

However, even if I fix this, there is going to be another problem: I should let the user name MyDslA and MyDslC objects however he wants, so there is the possibility of two of this objects having the same name. So I think the grammar would not know which object should choose if there is a MyDslA object with the same name of a MyDslC object.

I would appreciate any help or advise for helping me to solve this case.

Thank you very much!!!





Re: ebnf2 is not supported for CrossReference [message #655324 is a reply to message #655193] Sat, 19 February 2011 13:11 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

I think you will have to use a common super type for Domain and CObject. A cross reference can point to elements of one type only. You could reference EObject and adapt scoping by making visible only elements of the two desired types.

The default cross referencing implementation is that if two elements have the same name, they are not referrable at all (as they hide each other in that context). This is why often, you would not use simple names for referencing but rather fully qualified names (possibly with importing name spaces).

Alex
Re: ebnf2 is not supported for CrossReference [message #655327 is a reply to message #655193] Sat, 19 February 2011 12:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Rafael,

your grammar could be rewritten as

AorC: name=[mydsla::Domain] | name=[mydslc:CObject]

However, it is ambiguous in either case since the cross refernce will be
represented as an ID in the actual syntax which leads to AorC: ID | ID;
which cannot be resolved. You'll have to introduce a common super type
for Domain and CObject or use EObject and customized scoping rules
instead. Please note that a property "name" should probably be a string
and not a Domain or CObject.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 18.02.11 16:41, schrieb Rafael Angarita:
> Hello everybody, I am getting this error when I run the workflow for my
> languages:
>
>
> ebnf2 is not supported for CrossReference
> ebnf2 is not supported for CrossReference
> warning(200):
> ../org.xtext.example.test.ui/src-gen/org/xtext/example/test/ ui/contentassist/antlr/internal/InternalMyDslB.g:121:1:
> Decision can match input such as "EOF" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
> warning(201):
> ../org.xtext.example.test.ui/src-gen/org/xtext/example/test/ ui/contentassist/antlr/internal/InternalMyDslB.g:121:1:
> The following alternatives are unreachable: 2
>
>
> This is my example grammar:
>
>
> grammar org.xtext.example.test.MyDslA with
> org.eclipse.xtext.common.Terminals
>
> generate myDslA "http://www.xtext.org/example/test/MyDslA"
>
>
> Domain:
> 'Name' ':' name=ID
> ;
>
>
>
> grammar org.xtext.example.test.MyDslC with
> org.eclipse.xtext.common.Terminals
>
> generate myDslC "http://www.xtext.org/example/test/MyDslC"
>
>
> CObject:
> 'Name' ':' name=ID
> ;
>
>
>
> and,
>
>
> grammar org.xtext.example.test.MyDslB with
> org.eclipse.xtext.common.Terminals
> import
> " platform:/resource/org.xtext.example.test/src-gen/org/xtext/ example/test/MyDslA.ecore "
> as mydsla
> import
> " platform:/resource/org.xtext.example.test/src-gen/org/xtext/ example/test/MyDslC.ecore "
> as mydslc
> generate myDslB "http://www.xtext.org/example/test/MyDslB"
>
>
> Attribute:
> 'Name :' name=ID
> 'AorC : ' aorc=AorC
> ;
>
> AorC:
> name=([mydsla::Domain]|[mydslc::CObject])
> ;
>
>
> As you can see, I must have a property which can be one of the two
> types: MyDslA or MyDslC, but I am getting the error showed before.
>
> However, even if I fix this, there is going to be another problem: I
> should let the user name MyDslA and MyDslC objects however he wants, so
> there is the possibility of two of this objects having the same name. So
> I think the grammar would not know which object should choose if there
> is a MyDslA object with the same name of a MyDslC object.
>
> I would appreciate any help or advise for helping me to solve this case.
>
> Thank you very much!!!
>
>
>
>
>
>
Re: ebnf2 is not supported for CrossReference [message #655747 is a reply to message #655327] Tue, 22 February 2011 14:43 Go to previous messageGo to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Thank you guys for your answers. I'm going for the EObject reference approach:

Register: {Register}
	name=ID ':' (datatype=DataType|objectag=[ecore::EObject])
;


Before, I used scoping to limit the objects to the already used in the current object. For example:

public IScope scope_IndexColumn_indexColumn(IndexColumn i, EReference r) {
		EList<Column> list = ((Table) i.eContainer().eContainer())
				.getColumns();
		return Scopes.scopeFor(list, nameProvider, IScope.NULLSCOPE);
}


limited the objects available to be chosen as indexes of my tables to the objects already used as a column of the current table.


In this case I am using a similir approach since I would like to return only objects of type MyDslA or MyDslB:

public class MyDslBScopeProvider extends AbstractDeclarativeScopeProvider {
	
	public IScope scope_AorC_a(EObject o, EReference r) {
		//appropiate code here
		return null;
	}

}



, but when I check the content of the o and r objects, it seems there are only the objects already defined in the current MyDslB. So I can't find there all the global objects of typa MyDslA and MyDslC to filter them.

Am I going in the wrong direction?

Again, thank you very much!



Re: ebnf2 is not supported for CrossReference [message #655874 is a reply to message #655747] Wed, 23 February 2011 00:17 Go to previous message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Ok, I think I will solve it with the scoping and filtering of the Arithmetics example.

Thank you!
Previous Topic:Two file extension for one Xtext project
Next Topic:Simple RunTime Library of Functions
Goto Forum:
  


Current Time: Fri Apr 19 22:35:55 GMT 2024

Powered by FUDForum. Page generated in 0.03350 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top