Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [TCS] Grammar file ".g"
[TCS] Grammar file ".g" [message #32193] Wed, 18 March 2009 10:44 Go to next message
Eclipse UserFriend
Hello,

I have a question regarding the grammar file generated in a TCS project.

By default, whene I create a new TCS project an empty grammar file is
generated. Should we specify the grammar ourselves?? or is there something
wrong with that?

Thank you for your reply

Best regards,

Hayfa.
Re: [TCS] Grammar file ".g" [message #32437 is a reply to message #32193] Wed, 18 March 2009 16:10 Go to previous messageGo to next message
Eclipse UserFriend
> I have a question regarding the grammar file generated in a TCS project.
>
> By default, whene I create a new TCS project an empty grammar file is
> generated. Should we specify the grammar ourselves?? or is there something
> wrong with that?

The .g file is automatically generated by the TCSBuilder from the
..km3 and .tcs files. You should modify these files.

Andy.
Re: [TCS] Grammar file ".g" [message #32606 is a reply to message #32437] Thu, 19 March 2009 07:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi Andy,

Thank you for your reply

The problem is that even when I modify the km3 and .tcs files, the grammar
file is still empty. IS it a problem with my TCSBuilder??
PS: I have installed this version of TCS:
http://www.sciences.univ-nantes.fr/lina/atl/www/tcsdemo/2008 1103/ and I am
using eclipse 3.4.1

Best regard,

Hayfa.
Re: [TCS] Grammar file ".g" [message #32858 is a reply to message #32606] Fri, 20 March 2009 15:22 Go to previous messageGo to next message
Eclipse UserFriend
> Thank you for your reply
>
> The problem is that even when I modify the km3 and .tcs files, the grammar
> file is still empty. IS it a problem with my TCSBuilder??
> PS: I have installed this version of TCS:
> http://www.sciences.univ-nantes.fr/lina/atl/www/tcsdemo/2008 1103/ and I am
> using eclipse 3.4.1

It sounds like you've not completed the stages set out on the
http://wiki.eclipse.org/TCS/Language_Project wiki page. You need
to add
http://www.sciences.univ-nantes.fr/lina/atl/www/download/upd ates/tcs/
as an update site fro your eclipse installation and add the elements
available from this site.

Andy.
Re: [TCS] Grammar file ".g" [message #36706 is a reply to message #32858] Thu, 02 April 2009 15:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi Andy,

I added that update site to my eclipse and I have the plugin now but
nothing happened. The grammar file is still empty!!!
Re: [TCS] Grammar file ".g" [message #36809 is a reply to message #36706] Fri, 03 April 2009 05:04 Go to previous messageGo to next message
Eclipse UserFriend
Hayfa,

I would have expected the install of TCS to just work and
I don't know why it is not.

For a new project you need to consider the state of TCS. It's
not clear that there has been any development of it for a about
a year and the developers never answer questions in the newsgroup.
It has all of the characteristics of a dead project, and I would not
advise using it for a new project.

Although I find TMF Xtext definitions much more verbose than
TCS ones, TMF Xtext will have the capabilities that you need and
my advise would be to use it for your project.

Andy.

"Hayfa " <hayfa.nakouri@gmail.com> wrote in message
news:cc9cc815ebf5102c1b651969dc7dfcba$1@www.eclipse.org...
> Hi Andy,
>
> I added that update site to my eclipse and I have the plugin now but
> nothing happened. The grammar file is still empty!!!
Re: [TCS] Grammar file ".g" [message #37388 is a reply to message #36809] Mon, 06 April 2009 08:01 Go to previous messageGo to next message
Eclipse UserFriend
Hello Andy,

Actually, in my case I already have my metamodel (I don't need to generate
it) then I have a textual file (with a certain structure) and I want to
inject its content in its corresponding model. So its is exactly the way
TCS works. Is it possible to di this kind of injection with TMF Xtext?
According to what I have seen in the documentation, it generates a
metamodel too, and that is not my point.

Thank you again.

Best regards,

Hayfa.
Re: [TCS] Grammar file ".g" [message #37456 is a reply to message #36809] Mon, 06 April 2009 08:20 Go to previous messageGo to next message
Eclipse UserFriend
Andy Carpenter schrieb:
> Although I find TMF Xtext definitions much more verbose than
> TCS ones, TMF Xtext will have the capabilities that you need and
> my advise would be to use it for your project.

What specifically do you find more verbose in TMF Xtext?
Or did you mean less verbose?

Cheers,
Sven
Re: [TCS] Grammar file ".g" [message #37490 is a reply to message #37388] Mon, 06 April 2009 08:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi Hayfa,

You can use any number of existing ecore models in TMF Xtext.
See
http://wiki.eclipse.org/Xtext/Documentation#Importing_existi ng_Meta_Models

Regards,
Sven

Hayfa schrieb:
> Hello Andy,
>
> Actually, in my case I already have my metamodel (I don't need to
> generate it) then I have a textual file (with a certain structure) and
> I want to inject its content in its corresponding model. So its is
> exactly the way TCS works. Is it possible to di this kind of injection
> with TMF Xtext? According to what I have seen in the documentation, it
> generates a metamodel too, and that is not my point.
> Thank you again.
>
> Best regards,
>
> Hayfa.
>
Re: [TCS] Grammar file ".g" [message #37557 is a reply to message #37456] Mon, 06 April 2009 09:06 Go to previous messageGo to next message
Eclipse UserFriend
"Sven Efftinge" <sven.efftinge@itemis.de> wrote in message
news:grcs34$ktr$1@build.eclipse.org...
> Andy Carpenter schrieb:
>> Although I find TMF Xtext definitions much more verbose than
>> TCS ones, TMF Xtext will have the capabilities that you need and
>> my advise would be to use it for your project.
>
> What specifically do you find more verbose in TMF Xtext?
> Or did you mean less verbose?

I did mean that Xtext was more verbose. Consider a comma
separated parameter list, associated with a feature called
parameters. In TCS I can write

parameters{separator=","}

I just started with Xtext, so there might be an alternative, but at
the moment to express the same in Xtext I'm writing

parameters+=Parameter (',' parameters+=Parameter)*


Since, my original post I've been using Xtext more and have
discovered that it appears to assume that a resource is a flat
namespace. Thus, to resolve references in my DSL which is
scoped, I've had to write an implementation of both IScopeProvider
and IScope that allow nested namespaces within a resource.
In TCS I had to just indicate which syntactic elements gave a
scope and which elements were added to the current scope.


The biggest issue I've faced with Xtext is parsing a multiplicity
statement that supports specified (0..n), unspecified (?) and
unbounded (*) values. The TCS function to parse this was
not simple, but it did allow me to have simple numeric
lowerBound and upperBound features.

function multiplicity(ETypedElement) :
(lowerBound = 0 and upperBound = -2
? "[" "?" "]"
: (lowerBound = 0 and upperBound = 1
?
: (lowerBound = 0 and upperBound = -1
? "[" "*" "]"
: (lowerBound = 0 and upperBound = -1
? "[" "]"
: (lowerBound = 1 and upperBound = -1
? "[" "+" "]"
: (upperBound = -3 -- TODO equals lowerBound
? "[" lowerBound "]"
: (upperBound = -1
? "[" lowerBound ".." "*" "]"
: (upperBound = -2
? "[" lowerBound ".." "?" "]"
: "[" lowerBound ".." upperBound"]"
)
)
)
)
)
)
)
);

To do this in Xtext I've currently introduced the elements shown
below into the meta-model and am about to write the m2m
transformation that removes them from the meta-model that
my application uses.

ElementBound : SpecifiedBound | UnspecifiedBound | UnlimitedBound;
SpecifiedBound : bound=INT;
UnspecifiedBound : '?';
UnlimitedBound : '*';

( '[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']' )?


Please don't take my view of Xtext as just negative, these are
the issues that I've found while using it. I have found that it
does much of what I want and I'm building on it.

Andy.
[Xtext] Feedback (was Re: [TCS] Grammar file ".g") [message #37640 is a reply to message #37557] Mon, 06 April 2009 10:33 Go to previous messageGo to next message
Eclipse UserFriend
Hi Andy,

thanks for the feedback.
Please find my comments inlined.

Andy Carpenter schrieb:
> In TCS I can write
>
> parameters{separator=","}
>
> I just started with Xtext, so there might be an alternative, but at
> the moment to express the same in Xtext I'm writing
>
> parameters+=Parameter (',' parameters+=Parameter)*

Yes, we've been thinking about this, since this is a common recurring thing.
However, we wanted to make sure that we find a good generalized solution
and also wanted to spend our time on other things, since this can be
solved even if in a little more verbose manner.

> Since, my original post I've been using Xtext more and have
> discovered that it appears to assume that a resource is a flat
> namespace. Thus, to resolve references in my DSL which is
> scoped, I've had to write an implementation of both IScopeProvider
> and IScope that allow nested namespaces within a resource.
> In TCS I had to just indicate which syntactic elements gave a
> scope and which elements were added to the current scope.

Yes, the flat scoping is the default.
The difference to the approach in TCS is, that we don't have any special
scoping syntax in the grammar DSL, but provide an orthogonal API
(IScopeProvider) to do it.

> The biggest issue I've faced with Xtext is parsing a multiplicity
> statement that supports specified (0..n), unspecified (?) and
> unbounded (*) values. The TCS function to parse this was
> not simple, but it did allow me to have simple numeric
> lowerBound and upperBound features.
>
> function multiplicity(ETypedElement) :
> (lowerBound = 0 and upperBound = -2
> ? "[" "?" "]"
> : (lowerBound = 0 and upperBound = 1
> ?
> : (lowerBound = 0 and upperBound = -1
> ? "[" "*" "]"
> : (lowerBound = 0 and upperBound = -1
> ? "[" "]"
> : (lowerBound = 1 and upperBound = -1
> ? "[" "+" "]"
> : (upperBound = -3 -- TODO equals lowerBound
> ? "[" lowerBound "]"
> : (upperBound = -1
> ? "[" lowerBound ".." "*" "]"
> : (upperBound = -2
> ? "[" lowerBound ".." "?" "]"
> : "[" lowerBound ".." upperBound"]"
> )
> )
> )
> )
> )
> )
> )
> );
>
> To do this in Xtext I've currently introduced the elements shown
> below into the meta-model and am about to write the m2m
> transformation that removes them from the meta-model that
> my application uses.
>
> ElementBound : SpecifiedBound | UnspecifiedBound | UnlimitedBound;
> SpecifiedBound : bound=INT;
> UnspecifiedBound : '?';
> UnlimitedBound : '*';
>
> ( '[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']' )?
>

Yes, we don't support assignment of literal values in actions.
Maybe we should consider adding support for that.

Feedback like this is vital to set the priorities right.

Thanks,
Sven
Re: [TCS] Grammar file ".g" [message #37876 is a reply to message #37557] Mon, 06 April 2009 11:04 Go to previous messageGo to next message
Eclipse UserFriend
>
> ElementBound : SpecifiedBound | UnspecifiedBound | UnlimitedBound;
> SpecifiedBound : bound=INT;
> UnspecifiedBound : '?';
> UnlimitedBound : '*';
>
> ( '[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']' )?
>

I think you can define your own terminal rule like that

terminal MULTI returns ecore::EInt : ('*'|'?'|('0'..'9')+);

and use value converter
(http://wiki.eclipse.org/Xtext/Documentation/ValueConverter). I suppose
it would do the trick (not tested).

Regards,
Krzysztof Kowalczyk
Re: [TCS] Grammar file ".g" [message #37975 is a reply to message #37876] Mon, 06 April 2009 11:14 Go to previous messageGo to next message
Eclipse UserFriend
"Krzysztof Kowalczyk" <kowalczyk.krzysztof@gmail.com> wrote in message
news:grd5l9$d5s$1@build.eclipse.org...
>
>>
>> ElementBound : SpecifiedBound | UnspecifiedBound | UnlimitedBound;
>> SpecifiedBound : bound=INT;
>> UnspecifiedBound : '?';
>> UnlimitedBound : '*';
>>
>> ( '[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']' )?
>>
>
> I think you can define your own terminal rule like that
>
> terminal MULTI returns ecore::EInt : ('*'|'?'|('0'..'9')+);
>
> and use value converter
> (http://wiki.eclipse.org/Xtext/Documentation/ValueConverter). I suppose it
> would do the trick (not tested).
>
> Regards,
> Krzysztof Kowalczyk

For a DSL developer, that's just moving around where they do
their implementation work. I'm also not sure that it would work
where an element in the list requires a grammar rule to
parse it.

Andy.
Re: [Xtext] Feedback (was Re: [TCS] Grammar file ".g") [message #38005 is a reply to message #37640] Mon, 06 April 2009 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sven,

>
> Yes, we don't support assignment of literal values in actions.
> Maybe we should consider adding support for that.
>

So there is no possibility to set "default" value of property and
actions can set some property with a variable but not with a literal?

What is the planned scope of actions? I see they can set the return type
and do some tricks with "current".
Can I use e.g. value of already set property to set value of another
property? Then I would be easy to provide same semantic to "2" and "2..2".

Regards,
Chris
Re: [TCS] Grammar file ".g" [message #38071 is a reply to message #37975] Mon, 06 April 2009 11:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi Andy,

ValueConverters can be used with datatype rules, which are actually
parser rules and therefore can call other parser rules:

Cardinality:
'[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']'
;

ElementBound returns ecore::EInt: // datatype rule
'*' | '?' | INT
;

All you have to do is to register a ValueConverter for ElementBound.

Regards,
Sebastian


Andy Carpenter schrieb:
> "Krzysztof Kowalczyk" <kowalczyk.krzysztof@gmail.com> wrote in message
> news:grd5l9$d5s$1@build.eclipse.org...
>>> ElementBound : SpecifiedBound | UnspecifiedBound | UnlimitedBound;
>>> SpecifiedBound : bound=INT;
>>> UnspecifiedBound : '?';
>>> UnlimitedBound : '*';
>>>
>>> ( '[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']' )?
>>>
>> I think you can define your own terminal rule like that
>>
>> terminal MULTI returns ecore::EInt : ('*'|'?'|('0'..'9')+);
>>
>> and use value converter
>> (http://wiki.eclipse.org/Xtext/Documentation/ValueConverter). I suppose it
>> would do the trick (not tested).
>>
>> Regards,
>> Krzysztof Kowalczyk
>
> For a DSL developer, that's just moving around where they do
> their implementation work. I'm also not sure that it would work
> where an element in the list requires a grammar rule to
> parse it.
>
> Andy.
>
>
Re: [TCS] Grammar file ".g" [message #38560 is a reply to message #38071] Tue, 07 April 2009 02:53 Go to previous message
Eclipse UserFriend
It's just that Andy wants to set two features with one syntactic value
(i.e. * results in lowerBound=0 upperBound=-1)

So in this case value converters won't do the trick, at least if Andy
does not want to make a compromise either in the concrete or abstract
syntax.

Sebastian Zarnekow schrieb:
> Hi Andy,
>
> ValueConverters can be used with datatype rules, which are actually
> parser rules and therefore can call other parser rules:
>
> Cardinality:
> '[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']'
> ;
>
> ElementBound returns ecore::EInt: // datatype rule
> '*' | '?' | INT
> ;
>
> All you have to do is to register a ValueConverter for ElementBound.
>
> Regards,
> Sebastian
>
>
> Andy Carpenter schrieb:
>> "Krzysztof Kowalczyk" <kowalczyk.krzysztof@gmail.com> wrote in message
>> news:grd5l9$d5s$1@build.eclipse.org...
>>>> ElementBound : SpecifiedBound | UnspecifiedBound | UnlimitedBound;
>>>> SpecifiedBound : bound=INT;
>>>> UnspecifiedBound : '?';
>>>> UnlimitedBound : '*';
>>>>
>>>> ( '[' lowerBound=ElementBound ('..' upperBound=ElementBound)? ']' )?
>>>>
>>> I think you can define your own terminal rule like that
>>>
>>> terminal MULTI returns ecore::EInt : ('*'|'?'|('0'..'9')+);
>>>
>>> and use value converter
>>> (http://wiki.eclipse.org/Xtext/Documentation/ValueConverter). I
>>> suppose it would do the trick (not tested).
>>>
>>> Regards,
>>> Krzysztof Kowalczyk
>>
>> For a DSL developer, that's just moving around where they do
>> their implementation work. I'm also not sure that it would work
>> where an element in the list requires a grammar rule to
>> parse it.
>>
>> Andy.
>>
>>
Previous Topic:[Xtext] Installing XText M6 on 3.5M6
Next Topic:XText Installation problems
Goto Forum:
  


Current Time: Sat May 03 13:45:47 EDT 2025

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

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

Back to the top