Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic TAU (steve huntington)
Decrease font size
Increase font size
Topic Title: PARSE IN TCL
Topic Summary:
Created On: 22-May-2006 10:04
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 22-May-2006 10:04
User is offline View Users Profile Print this message


Javier Martínez

Posts: 11
Joined: 22-Mar-2006

Hello,

We want to develop a short TCL script. The script must take a path where we have some files with U2P syntax. We are starting with the u2:arse operation but when we run this code, nothing is created in the explorer.

set curProject [std::GetActiveProject]
set model [std::GetModels -kind U2 -project $curProject]

set expr [u2:arse $model "class Car {public Integer a; }"]
std:utput "Expresion: $expr \n"

std::SaveAll

Am I forgeting  anything?

Thanks in advance.

Best Regards,

    Javier Martínez.

Report this to a Moderator Report this to a Moderator
 22-May-2006 19:19
User is offline View Users Profile Print this message


Ian Barnard

Posts: 91
Joined: 4-Jul-2002

Javier

Nice smilies :D. Just in case you didn't know, you can turn off 'emoticon parsing' when you post a message so the smilies don't appear unintentionally.

Having used u2::Parse to get a model fragment, you have to add this fragment into the model somewhere. Assuming you have a reference to e.g. a package in tcl variable pkg, you could do something like shown below (haven't tried this but it should work).

This is what the comment in the help for Parse that
quote:

It is the responsibility of the client to take care of the returned entities. They should either be inserted into the model, or deleted, to avoid a memory leak.
is about.

You could get the pkg reference from e.g. the user selection, or your script could create a new package directly under the Model element and put the parsed definitions in it.

...
set expr [u2::Parse $model "class Car {public Integer a; }" Definition]
std::output "Expresion: $expr \n"
# add the definition into the package pkg
u2::SetEntity $pkg OwnedMember $expr
...

Note I have added the Definition option to the u2::Parse; depending on what you are parsing this could be Expression or Action; refer the the help for Parse. These different types of parsing would be stored under different metafeatures from the result of parsing a Definition (i.e. not under OwnedMember). If I were you I would try to stick to parsing definitions because it's simpler to put them into the model.

Technically speaking, any metaclass which derives from Namespace has a metafeature OwnedMember. You can find out which metaclasses these are by looking at the TTDMetamodel (under Library).

HTH
Ian

-------------------------
=============
Ian Barnard
Principal Consultant
Telelogic UK, an IBM company


Edited: 22-May-2006 at 20:32 by Ian Barnard
Report this to a Moderator Report this to a Moderator
 24-May-2006 11:44
User is offline View Users Profile Print this message


Javier Martínez

Posts: 11
Joined: 22-Mar-2006

Thanks for your advice (Do not parse emoticons) and reply.

Report this to a Moderator Report this to a Moderator
 15-Jun-2006 21:07
User is offline View Users Profile Print this message


Greg Gorman

Posts: 75
Joined: 4-Oct-2002

If you are interested in browsing your model from a metamodel view, the SDK gives you a fascinating look. Grab it from the TAU SDK download page. Look on the left side of your screen.

Greg

-------------------------
Greg Gorman
Vice President, Product Management
Modeling and Test Products
Telelogic AB
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic TAU forum.
There are currently 1 users logged in.
The most users ever online was 15 on 31-Mar-2008 at 16:22.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.