Search in sources :

Example 1 with DefaultErrorListener

use of com.eprosima.idl.parser.listener.DefaultErrorListener in project ihmc-pub-sub by ihmcrobotics.

the class IDLParser method specification.

public final SpecificationContext specification(Context context, TemplateManager templatemanager, TemplateGroup maintemplates) throws RecognitionException {
    SpecificationContext _localctx = new SpecificationContext(_ctx, getState(), context, templatemanager, maintemplates);
    enterRule(_localctx, 0, RULE_specification);
    // ! Used to catch each definition grammar element in the whole IDL file.
    Pair<Vector<Definition>, TemplateGroup> dtg = null;
    List<Definition> specificationChildren = new ArrayList<Definition>();
    ctx = context;
    tmanager = templatemanager;
    // Set error handler
    DefaultErrorListener listener = new DefaultErrorListener(ctx);
    this.setErrorHandler(DefaultErrorStrategy.INSTANCE);
    // Select listener for errors.
    ((Lexer) this._input.getTokenSource()).removeErrorListeners();
    ((Lexer) this._input.getTokenSource()).addErrorListener(listener);
    this.removeErrorListeners();
    this.addErrorListener(listener);
    int _la;
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(311);
            _errHandler.sync(this);
            _la = _input.LA(1);
            while (_la == KW_IMPORT) {
                {
                    {
                        setState(308);
                        import_decl();
                    }
                }
                setState(313);
                _errHandler.sync(this);
                _la = _input.LA(1);
            }
            setState(317);
            _errHandler.sync(this);
            _la = _input.LA(1);
            do {
                {
                    {
                        setState(314);
                        ((SpecificationContext) _localctx).definition = definition(null);
                        dtg = ((SpecificationContext) _localctx).definition.dtg;
                        if (dtg != null) {
                            if (maintemplates != null) {
                                maintemplates.setAttribute("definitions", dtg.second());
                            }
                            for (int count = 0; count < dtg.first().size(); ++count) {
                                ctx.addDefinition(dtg.first().get(count));
                                specificationChildren.add(dtg.first().get(count));
                            }
                        }
                    }
                }
                setState(319);
                _errHandler.sync(this);
                _la = _input.LA(1);
            } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << AT) | (1L << KW_TYPEDEF) | (1L << KW_CUSTOM) | (1L << KW_STRUCT) | (1L << KW_NATIVE) | (1L << KW_EVENTTYPE))) != 0) || ((((_la - 65)) & ~0x3f) == 0 && ((1L << (_la - 65)) & ((1L << (KW_ENUM - 65)) | (1L << (KW_HOME - 65)) | (1L << (KW_EXCEPTION - 65)) | (1L << (KW_CONST - 65)) | (1L << (KW_VALUETYPE - 65)) | (1L << (KW_MODULE - 65)) | (1L << (KW_UNION - 65)) | (1L << (KW_ABSTRACT - 65)) | (1L << (KW_TYPEPREFIX - 65)) | (1L << (KW_TYPEID - 65)) | (1L << (KW_LOCAL - 65)) | (1L << (KW_INTERFACE - 65)) | (1L << (KW_COMPONENT - 65)) | (1L << (KW_AT_ANNOTATION - 65)))) != 0));
            if (getNumberOfSyntaxErrors() == 0) {
                ((SpecificationContext) _localctx).spec = new Specification();
                _localctx.spec.setDefinitions(specificationChildren);
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}
Also used : DefaultErrorListener(com.eprosima.idl.parser.listener.DefaultErrorListener) TemplateGroup(com.eprosima.idl.generator.manager.TemplateGroup) ArrayList(java.util.ArrayList) Vector(java.util.Vector)

Aggregations

TemplateGroup (com.eprosima.idl.generator.manager.TemplateGroup)1 DefaultErrorListener (com.eprosima.idl.parser.listener.DefaultErrorListener)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1