Re: Adding a feature to a parsed Eiffel File

Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]>
Newsgroups gmane.comp.lang.eiffel.gobo.general
Organization Gobo
Message-ID <[email protected]>
urmuelle wrote:
> I am trying to add new features to already existing files by parsing
> them, adding the new features and then writing them back. What do i
> have to do apart from creating an instance of any of those feature
> types and adding it to a classes feature list?
> 
> Here is an example
> 
> a_class: ET_CLASS
> a_feature: ET_DEFERRED_PROCEDURE
> 
> a_class := ...
> 
> create a_feature.make (a_feature_name, Void, Void, Void, Void,
> clients, a_class)
> 
> create a_featurelist.make_with_capacity (a_class.features.count + 1)
> 				
> a_featurelist.force_first (a_feature)
> 
> from i:=0 until i=a_class.features.count loop
> 	i := i+1
> 	a_featurelist.force_first (a_class.features.item(i))
> end
> 
> a_class.set_features (a_featurelist, a_featurelist.count)
> 
> 
> 
> When going through the names after appending the new feature, it shows
> also the name of the new feature, but it is not appended when writing
> the AST back to a file.
> 
> 
> Can anyone help me?

When writing the AST back to a file using ET_AST_PRINTER, it
actually prints the features per feature clauses. The problem
is that your new feature is not part of a feature clause.

What to do: you can put your new feature in the feature clause
of an already existing feature from the same class:

    a_feature_clause: ET_FEATURE_CLAUSE
    ...
    a_feature_clause := other_feature.feature_clause
    a_feature.set_feature_clause (a_feature_clause)

Or you can decide to put it in a new feature clause. In
that case you will have to create a new object of type
ET_FEATURE_CLAUSE, add it to the class (create a new
`feature_clauses' with one more item, and assign it back
to the class using `set_feature_clauses'), and use
`set_feature_clause' to associate your new feature
with this new feature clause.

-- 
Eric Bezault
mailto:ericb-D6Qt/9opevxWk0Htik3J/[email protected]
http://www.gobosoft.com



To Post a message, send it to:   [email protected]
To Unsubscribe, send a blank message to: [email protected] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/gobo-eiffel/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.