Hi Andreas, old friend!

(Andreas helped me a lot with my first steps in ArgoUML more than 7 years ago, 
kudos to him!)

> I have a question: do you think it's feasable to use the rules in the
> Java grammar just as hooks and keep the Argo code in a separate file?
> So the java grammar could be updated without adding the entire Argo
> code every time?

Too many hooks required! Significant changes in the structure of the grammar 
would lead to changes in that hook interface. I think it's sufficient to keep 
all ArgoUML and model specifig code separated in Modeller.java, and let token 
specific string manipulations in the grammar.

Here an example of a grammar rule in the original grammar, compared to the 
ArgoUML version, which would require 5 hooks (without restructuring), and there 
are many of them:

Original:

variableDeclarator
    :   variableDeclaratorId ('=' variableInitializer)?
    ;

ArgoUML version:

variableDeclarator[String javadoc, short modifiers, String t]
@init{
    String b = "";
    String id = null;
    int ix;
    String trackedSoFar = null;
    String vi = null;
}
    :   vdi=variableDeclaratorId
        {
            id = $vdi.text;
            ix = id.indexOf('[');
            if (ix > 0) {
                b = id.substring(ix);
                id = id.substring(0, ix - 1);
            }
        }
        (
            {
                if ((parserMode & MODE_REVENG_SEQUENCE) != 0
                    && "new".equals(input.LT(2).getText())) {
                    createdObjectVarName = input.LT(0).getText();
                }
            }
            '='
            {
                trackedSoFar=getExpression();
                if (!isInCompoundStatement())
                    activateExpressionTracking();
            }
            vi=variableInitializer
            {
                expression=getExpression();
                if (isInCompoundStatement()) {
                    activateExpressionTracking();
                    appendExpression(trackedSoFar);
                    appendExpression(expression);
                } else {
                    deactivateExpressionTracking();
                }
                createdObjectVarName = null;
            }
        )?
        {
            if (!isInCompoundStatement() && level > 0) {
                getModeller().addAttribute(modifiers, t + b, id, vi, javadoc,
                    (parserMode == MODE_IMPORT_PASS2));
            }
            if ((parserMode & MODE_REVENG_SEQUENCE) != 0) {
                getModeller().addLocalVariableDeclaration(t + b, id);
            }
        }
    ;

> I once had a velocity based solution running, where one could edit the
> templates
> to change the generated code. But it was very rough and far from
> complete...

It was always a dream to control the code generation by a template! is there 
any chance that someone will build a clean and complete solution from that? 
Would make a nice GSOC project, but I won't do it.

Greetings from Berlin,
Thomas
-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to