Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Grammar solution request(Grammar solution request)
Grammar solution request [message #1856940] Tue, 10 January 2023 08:42 Go to next message
Eclipse UserFriend
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 08:45 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Grammar solution request [message #1856942 is a reply to message #1856941] Tue, 10 January 2023 08:49 Go to previous messageGo to next message
Eclipse UserFriend
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 09:07 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Tue, 10 January 2023 09:08] by Moderator

Re: Grammar solution request [message #1856944 is a reply to message #1856943] Tue, 10 January 2023 09:09 Go to previous messageGo to next message
Eclipse UserFriend
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 09:22 Go to previous message
Eclipse UserFriend
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

[Updated on: Tue, 10 January 2023 09:23] by Moderator

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


Current Time: Sat Jul 12 09:42:56 EDT 2025

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

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

Back to the top