Search in sources :

Example 1 with ErlMacroDef

use of org.erlide.engine.internal.model.erlang.ErlMacroDef in project erlide_eclipse by erlang.

the class ErlParser method addMacroDef.

private IErlMember addMacroDef(final IErlModule module, final OtpErlangObject pos, final OtpErlangObject val, final OtpErlangObject extra, final String nameS) {
    if (val instanceof OtpErlangAtom) {
        final String s = Util.stringValue(extra);
        final ErlMember r = new ErlMacroDef(module, ((OtpErlangAtom) val).atomValue(), s);
        setPos(r, pos);
        // r.setParseTree(val);
        return r;
    } else if (val instanceof OtpErlangList) {
        final OtpErlangList macroList = (OtpErlangList) val;
        if (macroList.elementAt(0) instanceof OtpErlangTuple) {
            final OtpErlangTuple macroNameTuple = (OtpErlangTuple) macroList.elementAt(0);
            OtpErlangObject o = macroNameTuple.elementAt(2);
            if (o instanceof OtpErlangTuple) {
                o = ((OtpErlangTuple) o).elementAt(2);
            }
            ErlMember r;
            if (o instanceof OtpErlangAtom) {
                final String macroName = ((OtpErlangAtom) o).atomValue();
                r = new ErlMacroDef(module, macroName, null);
            } else {
                // what do we do here? the define isn't correct
                // Erlang...
                ErlLogger.warn("Strange macro definition in %s: %s", module.getName(), o.toString());
                r = new ErlMacroDef(module, o.toString(), null);
            }
            setPos(r, pos);
            // r.setParseTree(val);
            return r;
        }
    }
    return addOtherAttribute(module, pos, val, extra, nameS);
}
Also used : ErlMacroDef(org.erlide.engine.internal.model.erlang.ErlMacroDef) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ErlMember(org.erlide.engine.internal.model.erlang.ErlMember) IErlMember(org.erlide.engine.model.erlang.IErlMember) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Aggregations

OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 ErlMacroDef (org.erlide.engine.internal.model.erlang.ErlMacroDef)1 ErlMember (org.erlide.engine.internal.model.erlang.ErlMember)1 IErlMember (org.erlide.engine.model.erlang.IErlMember)1