Search in sources :

Example 11 with Pair

use of com.eprosima.idl.util.Pair in project ihmc-pub-sub by ihmcrobotics.

the class IDLParser method struct_type.

public final Struct_typeContext struct_type() throws RecognitionException {
    Struct_typeContext _localctx = new Struct_typeContext(_ctx, getState());
    enterRule(_localctx, 154, RULE_struct_type);
    String name = null;
    Vector<TypeCode> vector = null;
    StructTypeCode structTP = null;
    TemplateGroup structTemplates = null;
    Token tk = null;
    String comments = null;
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(995);
            match(KW_STRUCT);
            setState(996);
            ((Struct_typeContext) _localctx).identifier = identifier();
            tk = _input.LT(1);
            comments = ctx.lookForComments(_input, tk, 50);
            name = ((Struct_typeContext) _localctx).identifier.id;
            structTP = ctx.createStructTypeCode(name, comments);
            for (ConstDeclaration constDeclaration : constDeclarations) structTP.addConstant(constDeclaration);
            constDeclarations.clear();
            setState(998);
            match(LEFT_BRACE);
            setState(999);
            member_list(structTP);
            setState(1000);
            match(RIGHT_BRACE);
            if (ctx.isInScopedFile() || ctx.isScopeLimitToAll()) {
                if (tmanager != null) {
                    structTemplates = tmanager.createTemplateGroup("struct_type");
                    structTemplates.setAttribute("ctx", ctx);
                    structTemplates.setAttribute("struct", structTP);
                }
            }
            // Return the returned data.
            vector = new Vector<TypeCode>();
            vector.add(structTP);
            ((Struct_typeContext) _localctx).returnPair = new Pair<Vector<TypeCode>, TemplateGroup>(vector, structTemplates);
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}
Also used : TemplateGroup(com.eprosima.idl.generator.manager.TemplateGroup) Vector(java.util.Vector) Pair(com.eprosima.idl.util.Pair)

Example 12 with Pair

use of com.eprosima.idl.util.Pair in project ihmc-pub-sub by ihmcrobotics.

the class IDLParser method annotation_def.

public final Annotation_defContext annotation_def() throws RecognitionException {
    Annotation_defContext _localctx = new Annotation_defContext(_ctx, getState());
    enterRule(_localctx, 142, RULE_annotation_def);
    TemplateGroup annotationTemplates = null;
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(958);
            ((Annotation_defContext) _localctx).annotation_header = annotation_header();
            setState(959);
            match(LEFT_BRACE);
            setState(960);
            annotation_body(((Annotation_defContext) _localctx).annotation_header.annotation);
            setState(961);
            match(RIGHT_BRACE);
            if (((Annotation_defContext) _localctx).annotation_header.annotation != null) {
                if (ctx.isInScopedFile() || ctx.isScopeLimitToAll()) {
                    if (tmanager != null) {
                        annotationTemplates = tmanager.createTemplateGroup("annotation");
                        annotationTemplates.setAttribute("ctx", ctx);
                        // Set the annotation object to the TemplateGroup of the annotation.
                        annotationTemplates.setAttribute("annotation", ((Annotation_defContext) _localctx).annotation_header.annotation);
                    }
                }
                ((Annotation_defContext) _localctx).returnPair = new Pair<AnnotationDeclaration, TemplateGroup>(((Annotation_defContext) _localctx).annotation_header.annotation, annotationTemplates);
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}
Also used : TemplateGroup(com.eprosima.idl.generator.manager.TemplateGroup) Pair(com.eprosima.idl.util.Pair)

Aggregations

Pair (com.eprosima.idl.util.Pair)12 TemplateGroup (com.eprosima.idl.generator.manager.TemplateGroup)11 Vector (java.util.Vector)4 ParseException (com.eprosima.idl.parser.exception.ParseException)2 com.eprosima.idl.parser.tree (com.eprosima.idl.parser.tree)2 org.antlr.v4.runtime.tree (org.antlr.v4.runtime.tree)2