示例#1
0
void UmlClass::importPrimitiveType(FileIn & in, Token & token, UmlItem *)
{
    WrapperStr id = token.xmiId();
    UmlTypeSpec t;

    t.explicit_type = token.valueOf("name");

    if (FromBouml) {
        if (! token.closed()) {
            BooL dummy;

            in.read(); 	// <xmi:Extension extender="Bouml">
            in.readWord(FALSE, dummy);	// <
            in.readWord(FALSE, dummy);	// basedOn
            t.type = dynamic_cast<UmlClass *>(All[in.readWord(FALSE, dummy)]);

            if (t.type != 0)
                // forget modifiers
                t.explicit_type = "";

            in.readWord(FALSE, dummy);	// /
            in.readWord(FALSE, dummy);	// >
            in.read(); 	// </xmi:Extension>
            in.read();	// end of token
        }
    }
    else if (! token.closed())
        in.finish(token.what());

    if (!id.isEmpty())
        PrimitiveTypes[id] = t;
}
示例#2
0
void Token::read(FileIn & in, bool any)
{
    _couples.clear();

    const char * k;
    BooL str;

    // bypass comment
    for (;;) {
        k = in.readWord(any, str);

        if (str || (*k != '<')) {
            if (any)
                continue;
            else
                in.error("'&lt;...' expected");
        }

        k = in.readWord(any, str);

        if (str || (*k != '!'))
            break;

        int minus = 0;

        for (;;) {
            char c = *in.readWord(TRUE, str);

            if (! str) {
                if (c == '-')
                    minus += 1;
                else if ((c == '>') && (minus == 2))
                    break;
                else
                    minus = 0;
            }
        }
    }


    char last;

    // note : k is not a string
    if (*k == '?') {
        last = '?';
        k = in.readWord(any, str);
    }
    else
        last = '/';

    if (!str && (*k == '/')) {
        _close = TRUE;
        k = in.readWord(any, str);
    }
    else
        _close = FALSE;

    if (str)
        in.error("syntax error \"" + WrapperStr(k) + "\" unexpected");

    _what = k;

    while (k = in.readWord(any, str), str || (*k != '>')) {
        if (!str && (*k == last)) {
            k = in.readWord(any, str);

            if (str || (*k != '>'))
                in.error("syntax error near '" + WrapperStr(k)  + "'>' expected");

            _closed = TRUE;
            return;
        }

        if (str) {
            if (!any)
                in.error("syntax error near '" + WrapperStr(k) + "'");
        }
        else {
            Couple cpl;

            cpl.key = k;

            if (!any || !strcmp(k, "xmi:id")) {
                if (!any && !valueOf(k).isNull())
                    in.error("'" + cpl.key + "' duplicated");

                if ((*in.readWord(FALSE, str) != '=') || str) {
                    if (! any)
                        in.error("syntax error near '" + WrapperStr(k) + "', '=' expected");
                }
                else {
                    cpl.value = in.readWord(FALSE, str);

                    if (str)
                        _couples.append(cpl);
                    else if (! any)
                        in.error("syntax error after '='");
                }
            }
        }
    }

    _closed = FALSE;
}