use of com.eprosima.idl.generator.manager.TemplateGroup 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;
}
use of com.eprosima.idl.generator.manager.TemplateGroup in project ihmc-pub-sub by ihmcrobotics.
the class IDLParser method union_type.
public final Union_typeContext union_type() throws RecognitionException {
Union_typeContext _localctx = new Union_typeContext(_ctx, getState());
enterRule(_localctx, 162, RULE_union_type);
String name = null;
int line = 0;
TypeCode dist_type = null;
Vector<TypeCode> vector = null;
UnionTypeCode unionTP = null;
TemplateGroup unionTemplates = null;
try {
enterOuterAlt(_localctx, 1);
{
setState(1025);
match(KW_UNION);
setState(1026);
((Union_typeContext) _localctx).identifier = identifier();
name = ((Union_typeContext) _localctx).identifier.id;
setState(1028);
match(KW_SWITCH);
setState(1029);
match(LEFT_BRACKET);
setState(1030);
((Union_typeContext) _localctx).switch_type_spec = switch_type_spec();
dist_type = ((Union_typeContext) _localctx).switch_type_spec.typecode;
setState(1032);
match(RIGHT_BRACKET);
// TODO Check supported types for discriminator: long, enumeration, etc...
unionTP = new UnionTypeCode(ctx.getScope(), name, dist_type);
line = _input.LT(1) != null ? _input.LT(1).getLine() - ctx.getCurrentIncludeLine() : 1;
setState(1034);
match(LEFT_BRACE);
setState(1035);
switch_body(unionTP);
setState(1036);
match(RIGHT_BRACE);
// Calculate default label.
TemplateUtil.setUnionDefaultLabel(unionTP, ctx.getScopeFile(), line);
if (ctx.isInScopedFile() || ctx.isScopeLimitToAll()) {
if (tmanager != null) {
unionTemplates = tmanager.createTemplateGroup("union_type");
unionTemplates.setAttribute("ctx", ctx);
unionTemplates.setAttribute("union", unionTP);
}
}
// Return the returned data.
vector = new Vector<TypeCode>();
vector.add(unionTP);
((Union_typeContext) _localctx).returnPair = new Pair<Vector<TypeCode>, TemplateGroup>(vector, unionTemplates);
}
} catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
} finally {
exitRule();
}
return _localctx;
}
use of com.eprosima.idl.generator.manager.TemplateGroup in project ihmc-pub-sub by ihmcrobotics.
the class IDLParser method param_decl.
public final Param_declContext param_decl() throws RecognitionException {
Param_declContext _localctx = new Param_declContext(_ctx, getState());
enterRule(_localctx, 206, RULE_param_decl);
TemplateGroup paramTemplate = null;
if (tmanager != null) {
paramTemplate = tmanager.createTemplateGroup("param");
}
TypeCode typecode = null;
String literalStr = _input.LT(1).getText();
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(1231);
_la = _input.LA(1);
if (!(((((_la - 39)) & ~0x3f) == 0 && ((1L << (_la - 39)) & ((1L << (KW_OUT - 39)) | (1L << (KW_IN - 39)) | (1L << (KW_INOUT - 39)))) != 0))) {
_errHandler.recoverInline(this);
}
consume();
setState(1232);
((Param_declContext) _localctx).param_type_spec = param_type_spec();
typecode = ((Param_declContext) _localctx).param_type_spec.typecode;
setState(1234);
((Param_declContext) _localctx).simple_declarator = simple_declarator();
if (typecode != null) {
Param param = null;
if (literalStr.equals("in"))
param = ctx.createParam(((Param_declContext) _localctx).simple_declarator.ret.first().first(), typecode, Param.Kind.IN_PARAM);
else if (literalStr.equals("out"))
param = ctx.createParam(((Param_declContext) _localctx).simple_declarator.ret.first().first(), typecode, Param.Kind.OUT_PARAM);
else if (literalStr.equals("inout"))
param = ctx.createParam(((Param_declContext) _localctx).simple_declarator.ret.first().first(), typecode, Param.Kind.INOUT_PARAM);
if (paramTemplate != null) {
paramTemplate.setAttribute("parameter", param);
}
((Param_declContext) _localctx).returnPair = new Pair<Param, TemplateGroup>(param, paramTemplate);
}
}
} catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
} finally {
exitRule();
}
return _localctx;
}
use of com.eprosima.idl.generator.manager.TemplateGroup in project ihmc-pub-sub by ihmcrobotics.
the class IDLParser method const_decl.
public final Const_declContext const_decl() throws RecognitionException {
Const_declContext _localctx = new Const_declContext(_ctx, getState());
enterRule(_localctx, 58, RULE_const_decl);
ConstDeclaration constDecl = null;
TypeCode typecode = null;
String constName = null, constValue = null;
TemplateGroup constTemplates = null;
if (tmanager != null) {
constTemplates = tmanager.createTemplateGroup("const_decl");
}
Token tk = null;
String comments = null;
try {
enterOuterAlt(_localctx, 1);
{
setState(610);
match(KW_CONST);
setState(611);
((Const_declContext) _localctx).const_type = const_type();
typecode = ((Const_declContext) _localctx).const_type.typecode;
tk = _input.LT(1);
setState(613);
((Const_declContext) _localctx).identifier = identifier();
constName = ((Const_declContext) _localctx).identifier.id;
setState(615);
match(EQUAL);
setState(616);
((Const_declContext) _localctx).const_exp = const_exp();
constValue = ((Const_declContext) _localctx).const_exp.literalStr;
if (typecode != null) {
comments = ctx.lookForComments(_input, tk, 50);
String modifiedName = constName.contains("__") ? constName.substring(constName.indexOf("__") + 2) : constName;
constDecl = new ConstDeclaration(ctx.getScopeFile(), ctx.isInScopedFile(), ctx.getScope(), modifiedName, typecode, constValue, tk, comments);
constDeclarations.add(constDecl);
if (constTemplates != null) {
constTemplates.setAttribute("ctx", ctx);
constTemplates.setAttribute("const", constDecl);
}
((Const_declContext) _localctx).returnPair = new Pair<ConstDeclaration, TemplateGroup>(constDecl, constTemplates);
}
}
} catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
} finally {
exitRule();
}
return _localctx;
}
use of com.eprosima.idl.generator.manager.TemplateGroup in project ihmc-pub-sub by ihmcrobotics.
the class IDLParser method type_declarator.
public final Type_declaratorContext type_declarator() throws RecognitionException {
Type_declaratorContext _localctx = new Type_declaratorContext(_ctx, getState());
enterRule(_localctx, 88, RULE_type_declarator);
Vector<TypeCode> vector = null;
AliasTypeCode typedefTypecode = null;
TemplateGroup typedefTemplates = null;
if (tmanager != null) {
typedefTemplates = tmanager.createTemplateGroup("typedef_decl");
}
try {
enterOuterAlt(_localctx, 1);
{
setState(796);
((Type_declaratorContext) _localctx).type_spec = type_spec();
setState(797);
((Type_declaratorContext) _localctx).declarators = declarators();
if (((Type_declaratorContext) _localctx).type_spec.typecode != null) {
vector = new Vector<TypeCode>();
for (int count = 0; count < ((Type_declaratorContext) _localctx).declarators.ret.size(); ++count) {
typedefTypecode = new AliasTypeCode(ctx.getScope(), ((Type_declaratorContext) _localctx).declarators.ret.get(count).first().first());
if (((Type_declaratorContext) _localctx).declarators.ret.get(count).second() != null) {
// Array declaration
((Type_declaratorContext) _localctx).declarators.ret.get(count).second().setContentTypeCode(((Type_declaratorContext) _localctx).type_spec.typecode);
typedefTypecode.setContentTypeCode(((Type_declaratorContext) _localctx).declarators.ret.get(count).second());
} else {
// Simple declaration
typedefTypecode.setContentTypeCode(((Type_declaratorContext) _localctx).type_spec.typecode);
}
if (typedefTemplates != null) {
typedefTemplates.setAttribute("typedefs", typedefTypecode);
}
vector.add(typedefTypecode);
}
if (typedefTemplates != null) {
typedefTemplates.setAttribute("ctx", ctx);
}
((Type_declaratorContext) _localctx).returnPair = new Pair<Vector<TypeCode>, TemplateGroup>(vector, typedefTemplates);
}
}
} catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
} finally {
exitRule();
}
return _localctx;
}
Aggregations