Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scope provider stops working with UPPER_CASE_ID terminal rule
Scope provider stops working with UPPER_CASE_ID terminal rule [message #1016159] Tue, 05 March 2013 10:01 Go to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
Hi,
I have two DSL's below. In the Entity DSL, if I change the Attribute rule to [0], the scope provider in the Function DSL stops returning me the list of Entity attributes. Is there a way I could fix this ? I am going through the implementation of the Scopes class, but so far I haven't found a solution. Any thoughts ?

[0]
Attribute:
name=UPPER_CASE_ID ':' type=DataType

-------------------Function DSL------------------------------------------------------
....
....
Function:
'func' name=ID '('parameters+=Parameter (',' parameters+=Parameter)* ')' '{'
body += Body (';' body += Body)*
'}'
;

Body:
object=[Parameter] tail=AttributeReference?
;

Parameter:
name=ID ':' type=[entity::Entity]
;

AttributeReference:
'.' attribute=[entity::Attribute]
;

---------------------------Entity DSL------------------------------------------------
....
....
Attribute:
name=ID ':' type=DataType

terminal UPPER_CASE_ID : '^'?('A'..'Z'|'_') ('A'..'Z'|'_'|'0'..'9')*;

-------------------------------------------------------------------------------------

Thanks in advance,


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj

[Updated on: Tue, 05 March 2013 10:03]

Report message to a moderator

Re: Scope provider stops working with UPPER_CASE_ID terminal rule [message #1016264 is a reply to message #1016159] Tue, 05 March 2013 17:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

cannot reproduce that. maybe cause some parts of the grammar are missing
never the less there are 2 potential pitfalls.

(1) your UPPER_CASE_ID may collide with ID - dont know if this i a problem in your case - and do you use it in both grammars?
(2) xxx=[Type] is short for xx=[Type|ID] which tells the parser to parse an ID
depending on your solution to (1) you may have to write xx=[Type|UPPER_CASE_ID] instead


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scope provider stops working with UPPER_CASE_ID terminal rule [message #1016845 is a reply to message #1016159] Thu, 07 March 2013 21:15 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
Hi Christian,
Thanks for the reply. Yes, the grammar is incomplete. I had posted only the relevant parts of it.

1) I am aware that the UPPER_CASE_ID rule shadows/collides with the ID rule in some cases. For example, in the above dsl, if I was to define function name with all upper case, I would see the error - mismatched input 'FUNTIONFOO' expecting RULE_ID. Out of curiosity, is there a way we could fix this issue ?

2) xx=[Type|UPPER_CASE_ID] worked.

Thanks for the help.


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj

[Updated on: Thu, 07 March 2013 21:16]

Report message to a moderator

Re: Scope provider stops working with UPPER_CASE_ID terminal rule [message #1016851 is a reply to message #1016845] Thu, 07 March 2013 21:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what about to put the upper case thing not into the grammar but into semantic validation?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:dot as separator in rule with hidden white spaces
Next Topic:Couldn't resolve reference to Type
Goto Forum:
  


Current Time: Thu Apr 25 19:22:53 GMT 2024

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

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

Back to the top