How to solve QualifiedName ambiguity [message #1151332] |
Wed, 23 October 2013 05:20  |
Eclipse User |
|
|
|
Hi all,
I have following grammar (simplified):
Type:
name = ID
;
Member:
type = [Type | QualifiedName] name = ID
;
Reference:
type = [Type | QualifiedName] '.' member = [Member | QualifiedName]
;
This grammar is ambigous, since Type and Member are both defined through QualifiedNames. I think, this example is comparable to Java static members access. The Types are nested in my DSL, so I could have references like this: com.example.A.B.c.d, where com.example is a namespace, A.B are nested Types and c.b are Members.
How can I solve this? Changing the language is not an option, because I'm writing editor/generator for existing one.
|
|
|
|
Re: How to solve QualifiedName ambiguity [message #1152799 is a reply to message #1151332] |
Thu, 24 October 2013 03:17   |
Eclipse User |
|
|
|
Hi,
I don't understand what you mean. I have reference paths, which contain Type and Member as its parts. The real grammar I have is following:
Reference:
type = [Type | QualifiedName] tail = ReferenceTail
;
ReferenceTail:
'.' member = [Member | ID] tail = ReferenceTail?
;
This way I can implement a IScopeProvider for available Members, since I have to detect a Type of one member to calculate scope for the next one. The problem here is, that I'm using QualifiedName for Type reference, that way ANTLR can't decide where the QualifiedName is finished and where my the ReferenceTail rule starts, since this one has the same signature as QualifiedName. If I use ID (instead of QualifiedName) for Type reference, I can't reference my Types by using namespaces.
I want two following examples working:
com.example.MyTypeA.memberA.memberB - This one needs QualifiedName for Type reference, but is ambigous grammar
MyTypeA.memberA.memberB - Works fine with ID for Type reference, but ignores namespaces. What if I have MyTypeA in multiple namespaces and I want to mix them?
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06173 seconds