Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [TCS] How to do a substring ?
[TCS] How to do a substring ? [message #377479] Thu, 10 May 2007 11:00 Go to next message
Guillaume Hillairet is currently offline Guillaume HillairetFriend
Messages: 97
Registered: July 2009
Member
Hi all,

Is it possible to do a sort of substring operation in TCS ?
In my example i've got a string like this "10101604" in my text file
and i want to cut it in 4 ones to put them in separate attributes.

For now i use an intermediate metamodel and a trasformation to get the
model i want. Can i do it without this intermediary model ?
any idea ?
Re: [TCS] How to do a substring ? [message #377483 is a reply to message #377479] Thu, 10 May 2007 12:16 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> Is it possible to do a sort of substring operation in TCS ?
> In my example i've got a string like this "10101604" in my text file and
> i want to cut it in 4 ones to put them in separate attributes.

TCS handles the syntax of DSLs (i.e., a grammar is generated from a TCS
model). The lexical aspects have to be handled in the lexer, which can
be defined in the TCS file, but using ANTLR syntax.

Once "10101604" has been recognized by the lexer as a single token, TCS
will not be able to break it apart.

> For now i use an intermediate metamodel and a trasformation to get the
> model i want. Can i do it without this intermediary model ?
> any idea ?

- You may change the lexer to tokenize your input according to what you
want. The documentation of ANTLR may be helpful:
http://www.antlr.org/doc/lexer.html#Lexical_Analysis_with_AN TLR

- You may keep only the intermediate metamodel and define a helper in
your transformations to break the string. This helper may be put in a
library if different transformations use it. This solution gets rid of
the additional transformation step but does not give you a "clean" model.


Regards,

Frédéric Jouault
Re: [TCS] How to do a substring ? [message #596119 is a reply to message #377479] Thu, 10 May 2007 12:16 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> Is it possible to do a sort of substring operation in TCS ?
> In my example i've got a string like this "10101604" in my text file and
> i want to cut it in 4 ones to put them in separate attributes.

TCS handles the syntax of DSLs (i.e., a grammar is generated from a TCS
model). The lexical aspects have to be handled in the lexer, which can
be defined in the TCS file, but using ANTLR syntax.

Once "10101604" has been recognized by the lexer as a single token, TCS
will not be able to break it apart.

> For now i use an intermediate metamodel and a trasformation to get the
> model i want. Can i do it without this intermediary model ?
> any idea ?

- You may change the lexer to tokenize your input according to what you
want. The documentation of ANTLR may be helpful:
http://www.antlr.org/doc/lexer.html#Lexical_Analysis_with_AN TLR

- You may keep only the intermediate metamodel and define a helper in
your transformations to break the string. This helper may be put in a
library if different transformations use it. This solution gets rid of
the additional transformation step but does not give you a "clean" model.


Regards,

Frédéric Jouault
Previous Topic:[MOFScript] functions
Next Topic:[MOFScript] functions
Goto Forum:
  


Current Time: Fri Apr 19 16:00:53 GMT 2024

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

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

Back to the top