Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Grammar solution request(Grammar solution request)
Grammar solution request [message #1856940] Tue, 10 January 2023 13:42 Go to next message
Thomas Landuyt is currently offline Thomas LanduytFriend
Messages: 11
Registered: May 2021
Junior Member
Hi,

I'm requesting some help in the creation of our grammar

currently we have some base grammar with one object

Expression1 returns QueryExpression:
{Expression1 } fct=ID '(' args+=QueryExpression (',' args+=QueryExpression)* ')'
;

this should be able to retrieve functions like to_string(1) or to_integer("0");

Now on our top level we should have something to be able to retrieve
ID(args*)?.(ID (args*))*

as example we can have

field
fieldWithoutArg.id
fieldWithArg(1).id
fieldWithArg(1)..fieldWithArg(2).id

fieldWithArg(1)..fieldWithArg(2)....id
but at grammar level we encounter issues that we can't make the difference between expression1 and expression2

Reference:
ref=[ecore::EObject|ID];

Expression2 returns query::QueryExpression:
=> Reference -> ( {Expression2 .root=current} ('('args+=QueryExpression (',' args+=QueryExpression)*')')? => '.' path=[ecore::EObject|ID] )*
;

Baseexpression:
Expression1 | Expression2

Can somebody help me on this?
Re: Grammar solution request [message #1856941 is a reply to message #1856940] Tue, 10 January 2023 13:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
if they are synactially exactly the same and can be used at the same place i dont see how this should be solvable,
native question: what stops you from unifying them?

e.g. using
Reference:
ref=[ecore::EObject|ID];
everywthere.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Grammar solution request [message #1856942 is a reply to message #1856941] Tue, 10 January 2023 13:49 Go to previous messageGo to next message
Thomas Landuyt is currently offline Thomas LanduytFriend
Messages: 11
Registered: May 2021
Junior Member
Problem is that we don't want to touch expression1 as this is a base for every other grammar but in this case we want to extend this one with extra levels

Expression1 will only have 1 level
Expression2 can have * levels and doesn't need ot have always args, can also be without
Re: Grammar solution request [message #1856943 is a reply to message #1856942] Tue, 10 January 2023 14:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
if you have


xxxx(yyyy)

it can be both, right?

=> what about checking the restrictions using variables.
maybe you can also use IDerivedStateComputer and SyntheticLinkingSupport
to create references for the id


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 10 January 2023 14:08]

Report message to a moderator

Re: Grammar solution request [message #1856944 is a reply to message #1856943] Tue, 10 January 2023 14:09 Go to previous messageGo to next message
Thomas Landuyt is currently offline Thomas LanduytFriend
Messages: 11
Registered: May 2021
Junior Member
Hi, we would expect this is expression1 and should not be Expression2

For expression2 we should be able to have
field
fieldWithoutArg.id
fieldWithArg(1).id
fieldWithArg(1)..fieldWithArg(2).id

fieldWithArg(1)..fieldWithArg(2)....id

but we don't want to accept
fieldWithArg(1)
Re: Grammar solution request [message #1856945 is a reply to message #1856944] Tue, 10 January 2023 14:22 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
then maybe you should have different cases for just one element or at least 2 elements (maybe also using the => operator)

but i still would try to unify


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 10 January 2023 14:23]

Report message to a moderator

Previous Topic:Xtext 2.30.0.M1 is out
Next Topic:exec-maven-plugin with Xtext
Goto Forum:
  


Current Time: Tue Apr 16 17:52:26 GMT 2024

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

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

Back to the top