private JDefinedClass buildTemplateConstraint(String name) { try { JDefinedClass tplConstraint = codeModel._class(Config.CFG.getBasePackageName() + ".annot."+name, ClassType.ANNOTATION_TYPE_DECL); tplConstraint.annotate(Documented.class); tplConstraint.annotate(Retention.class).param("value", RetentionPolicy.RUNTIME); tplConstraint.annotate(Target.class).paramArray("value").param(ElementType.TYPE).param(ElementType.ANNOTATION_TYPE).param(ElementType.FIELD).param(ElementType.METHOD); // Using direct as I don't know how to build default { } with code model tplConstraint.direct("\n" + " Class<?>[] groups() default {};\n" + " String message() default \"Invalid value\";\n" + " Class<? extends Payload>[] payload() default {};\n"); // Hack to force the import of javax.validation.Payload tplConstraint.javadoc().addThrows((JClass) codeModel._ref(Payload.class)).add("Force import"); return tplConstraint; } catch (JClassAlreadyExistsException e) { throw new RuntimeException("Tried to create an already existing class: " + name, e); } }
@SuppressWarnings("unchecked") ClassGenerator(CodeGenerator<T> codeGenerator, MappingSet mappingSet, SignatureHolder signature, EvaluationVisitor eval, JDefinedClass clazz, JCodeModel model) throws JClassAlreadyExistsException { this.codeGenerator = codeGenerator; this.clazz = clazz; this.mappings = mappingSet; this.sig = signature; this.evaluationVisitor = eval; this.model = model; blocks = (LinkedList<JBlock>[]) new LinkedList[sig.size()]; for (int i =0; i < sig.size(); i++) { blocks[i] = Lists.newLinkedList(); } rotateBlock(); for (SignatureHolder child : signature.getChildHolders()) { String innerClassName = child.getSignatureClass().getSimpleName(); JDefinedClass innerClazz = clazz._class(Modifier.FINAL + Modifier.PRIVATE, innerClassName); innerClasses.put(innerClassName, new ClassGenerator<>(codeGenerator, mappingSet, child, eval, innerClazz, model)); } }
CodeGenerator(MappingSet mappingSet, TemplateClassDefinition<T> definition, FunctionImplementationRegistry funcRegistry) { Preconditions.checkNotNull(definition.getSignature(), "The signature for defintion %s was incorrectly initialized.", definition); this.definition = definition; this.className = definition.getExternalInterface().getSimpleName() + "Gen" + definition.getNextClassNumber(); this.fqcn = PACKAGE_NAME + "." + className; try { this.model = new JCodeModel(); JDefinedClass clazz = model._package(PACKAGE_NAME)._class(className); rootGenerator = new ClassGenerator<>(this, mappingSet, definition.getSignature(), new EvaluationVisitor( funcRegistry), clazz, model); } catch (JClassAlreadyExistsException e) { throw new IllegalStateException(e); } }
CodeGenerator(CodeCompiler compiler, MappingSet mappingSet, TemplateClassDefinition<T> definition) { Preconditions.checkNotNull(definition.getSignature(), "The signature for defintion %s was incorrectly initialized.", definition); this.definition = definition; this.compiler = compiler; this.className = definition.getExternalInterface().getSimpleName() + "Gen" + definition.getNextClassNumber(); this.fqcn = PACKAGE_NAME + "." + className; try { this.model = new JCodeModel(); JDefinedClass clazz = model._package(PACKAGE_NAME)._class(className); clazz = clazz._extends(model.directClass(definition.getTemplateClassName())); clazz.constructor(JMod.PUBLIC).body().invoke(SignatureHolder.INIT_METHOD); rootGenerator = new ClassGenerator<>(this, mappingSet, definition.getSignature(), new EvaluationVisitor(), clazz, model); } catch (JClassAlreadyExistsException e) { throw new IllegalStateException(e); } }
public JDefinedClass defineClass(AbstractType t, ClassType type) { String fullyQualifiedName = nameGenerator.fullyQualifiedName(t); try { JDefinedClass _class = mdl._class(fullyQualifiedName, type); if (config.addGenerated) { _class.annotate(Generated.class).param("value", JavaWriter.class.getPackage().getName()).param("date", new Date().toString()); } if (t.hasDirectMeta(Description.class)) { String description = t.oneMeta(Description.class).value(); _class.javadoc().add(description); } return _class; } catch (JClassAlreadyExistsException e) { throw new IllegalStateException(e); } }
@Override public void visitResourceStart(Resource resource) { try { if (outerResource == null) { outerResource = resource; createResourceInterface(resource); addMediaTypes(); } else if (innerResource == null) { innerResource = resource; } else { throw new GeneratorException("cannot handle resources nested more than two levels"); } } catch (JClassAlreadyExistsException exc) { throw Exceptions.unchecked(exc); } }
/** * Creates {@link #innerClassGenerator} with inner class * if {@link #hasMaxIndexValue()} returns {@code true}. * * @return true if splitting happened. */ private boolean createNestedClass() { if (hasMaxIndexValue()) { // all new fields will be declared in the class from innerClassGenerator if (innerClassGenerator == null) { try { JDefinedClass innerClazz = clazz._class(JMod.PRIVATE, clazz.name() + "0"); innerClassGenerator = new ClassGenerator<>(codeGenerator, mappings, sig, evaluationVisitor, innerClazz, model, optionManager); } catch (JClassAlreadyExistsException e) { throw new DrillRuntimeException(e); } oldBlocks = blocks; innerClassGenerator.index = index; innerClassGenerator.maxIndex += index; // blocks from the inner class should be used setupInnerClassBlocks(); return true; } return innerClassGenerator.createNestedClass(); } return false; }
CodeGenerator(MappingSet mappingSet, TemplateClassDefinition<T> definition, OptionSet optionManager) { Preconditions.checkNotNull(definition.getSignature(), "The signature for defintion %s was incorrectly initialized.", definition); this.definition = definition; this.className = definition.getExternalInterface().getSimpleName() + "Gen" + definition.getNextClassNumber(); this.fqcn = PACKAGE_NAME + "." + className; try { this.model = new JCodeModel(); JDefinedClass clazz = model._package(PACKAGE_NAME)._class(className); rootGenerator = new ClassGenerator<>(this, mappingSet, definition.getSignature(), new EvaluationVisitor(), clazz, model, optionManager); } catch (JClassAlreadyExistsException e) { throw new IllegalStateException(e); } }
public JDefinedClass getNamespaceClass(String namespace, ParsingContext context) { if (namespace == null) { return null; } JDefinedClass ret = namespaceClasses.get(namespace); if (ret == null) { try { ret = context.getCm()._class("generated." + namespace); ret.init().add(context.getCm().ref(BridJ.class).staticInvoke("register")); Map<String, String> nsToLib = (Map<String, String>) context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE_TO_LIB); String libName = nsToLib.get(namespace); if (libName != null) { ret.annotate(Library.class).param("value", libName); } namespaceClasses.put(namespace, ret); } catch (JClassAlreadyExistsException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ret; }
@Test public void applySpringMethodBodyRule_shouldCreate_valid_body() throws JClassAlreadyExistsException { SpringRestClientMethodBodyRule rule = new SpringRestClientMethodBodyRule("restTemplate", "baseUrl"); JPackage jPackage = jCodeModel.rootPackage(); JDefinedClass jClass = jPackage._class(JMod.PUBLIC, "MyClass"); JMethod jMethod = jClass.method(JMod.PUBLIC, Object.class, "getBase"); jMethod.param(jCodeModel._ref(String.class), "id"); rule.apply(getEndpointMetadata(2), CodeModelHelper.ext(jMethod, jCodeModel)); String serializeModel = serializeModel(); //ensure that we are adding the ACCEPT headers assertThat(serializeModel, containsString("httpHeaders.setAccept(acceptsList);")); //ensure that we are concatinating the base URL with the request URI to form the full url assertThat(serializeModel, containsString("String url = baseUrl.concat(\"/base/{id}\"")); //ensure that we are setting url paths vars in the uri assertThat(serializeModel, containsString("uriComponents = uriComponents.expand(uriParamMap)")); //ensure that the exchange invocation is as expected assertThat(serializeModel, containsString("return this.restTemplate.exchange(uriComponents.encode().toUri(), HttpMethod.GET, httpEntity, NamedResponseType.class);")); }
JDefinedClass declare(int mods, TIdentifier identifier, ClassType ctype, Optional<String> name) { if (current instanceof Scope.Typey) { try { Scope.Typey typeyScope = (Scope.Typey) current; Type t = typeyScope.declare(mods, identifier, ctype, name); global.addType(t); current = t.scope; scopeStack.push(current); //System.out.println("Pushing scope " + current); return t.definition; } catch (JClassAlreadyExistsException ex) { throw new RuntimeException(ex); } } else { Logger.error("Cannot add a type (" + identifier.getText() + ") to a Scope (" + current.getClass().getName() + ") that doesn't allow types!"); throw new RuntimeException("Invalid Scope for operation!"); } }
private static void createRetrieveClass(Retrieve retrieve, String packageName, File destinationDir) throws JClassAlreadyExistsException, IOException { JCodeModel codeModel = new JCodeModel(); JClass mapClass = codeModel.ref(String.format("%s.%sMap", packageName, retrieve.getId())); JDefinedClass retrieveClass = codeModel._class(String.format("%s.%sRetrieve", packageName, retrieve.getId())); retrieveClass.javadoc().append("Auto generated class. Do not modify!"); retrieveClass._extends(codeModel.ref(AbstractRetrieve.class).narrow(mapClass)); // Constructor JMethod constructor = retrieveClass.constructor(JMod.PUBLIC); constructor.param(String.class, "id"); constructor.body().invoke("super").arg(JExpr.ref("id")); // Implemented method JMethod getMapMethod = retrieveClass.method(JMod.PUBLIC, mapClass, "getMap"); getMapMethod.annotate(Override.class); getMapMethod.param(codeModel.ref(Map.class).narrow(String.class, Object.class), "data"); getMapMethod.body()._return(JExpr._new(mapClass).arg(JExpr.ref("data"))); codeModel.build(destinationDir); }
private JDefinedClass createServicesInterface(Service service, JDefinedClass jServiceClass) throws JClassAlreadyExistsException { // JDefinedClass _interface = // jServiceClass._interface(jServiceClass.name() + SUFIX_SERVICE_IFACE); JDefinedClass _interface = jServiceClass._interface(JMod.PUBLIC, SUFIX_SERVICE_IFACE); if (service.getParent() != null && service.getParent().isPresent()) { JClass jClassParent = (JClass) resolvName(service.getParent().get()); _interface._extends((JClass) resolvName(jClassParent.fullName() + "." + SUFIX_SERVICE_IFACE)); } for (ThriftMethod function : service.getMethods()) { createServicesMethod(function, _interface); } return _interface; }
private JDefinedClass createServicesAsyncInterface(Service service, JDefinedClass jServiceClass) throws JClassAlreadyExistsException { // JDefinedClass _interface = jServiceClass._interface(JMod.PUBLIC, // jServiceClass.name() + SUFIX_SERVICE_ASYNC_IFACE); JDefinedClass _interface = jServiceClass._interface(JMod.PUBLIC, SUFIX_SERVICE_ASYNC_IFACE); if (service.getParent().isPresent()) { JClass jClassParent = (JClass) resolvName(service.getParent().get()); _interface._extends((JClass) resolvName(jClassParent.fullName() + "." + SUFIX_SERVICE_ASYNC_IFACE)); } createServicesAsyncInterfaceMethod(service, _interface); return _interface; }
private JDefinedClass defineClass(String pckg, JCodeModel model, Framework f) throws JClassAlreadyExistsException{ String name = pckg == null ? NAME : pckg + "." + NAME; JDefinedClass c = CodeGenerator.appendJDocHeader( model._class(JMod.PUBLIC, name, ClassType.ENUM)); JVar str = c.field(JMod.PRIVATE+JMod.FINAL, String.class, "name"); JMethod cons = c.constructor(JMod.PRIVATE); cons.body().assign(JExpr._this().ref(str), cons.param(String.class, "name")); JMethod defCons = c.constructor(JMod.PRIVATE); defCons.body().assign(JExpr._this().ref(str), JExpr._null()); JMethod toString = c.method(JMod.PUBLIC, String.class, "toString"); toString.annotate(Override.class); toString.body()._if(str.eq(JExpr._null()))._then()._return(JExpr.invoke(JExpr._super(), "toString")); toString.body()._return(str); c._implements(f.getSymbolInterface()); JMethod type = c.method(JMod.PUBLIC, int.class, "type"); type.annotate(Override.class); type.body()._return(JExpr.invoke(JExpr._this(), "ordinal")); return c; }
JDefinedClass formatIdClass(JDefinedClass parent, String theid, ASTNode.FormatID node) { final Type nodetype = this.nodeType(node); final JDefinedClass nested; try { String parentParamClass = makeParamClass(theid); comment(parent, "parent paramClass=%s", parentParamClass); nested = parent._class(parentParamClass); } catch(JClassAlreadyExistsException e) { throw new SyntaxError(format("duplicate name: '%s'", theid)); } nested._extends(FormatId_t); comment_stamp(nested); comment(nested, "node.type=%s", typename(node.type)); comment(nested, "--> nodetype=%s", typename(nodetype)); final JMethod getter = classCacheMethod(parent, theid, nested); Metadata metadata = (Metadata) parent.metadata; metadata.registerParam(theid, nested, JExpr.invoke(getter)); return nested; }
JDefinedClass codecIdClass(JDefinedClass parent, String theid, ASTNode.CodecID node) { final Type nodetype = this.nodeType(node); final JDefinedClass nested; try { String parentParamClass = makeParamClass(theid); comment(parent, "parent paramClass=%s", parentParamClass); nested = parent._class(parentParamClass); } catch(JClassAlreadyExistsException e) { throw new SyntaxError(format("duplicate name: '%s'", theid)); } nested._extends(CodecId_t); comment_stamp(nested); comment(nested, "node.type=%s", typename(node.type)); comment(nested, "--> nodetype=%s", typename(nodetype)); final JMethod getter = classCacheMethod(parent, theid, nested); Metadata metadata = (Metadata) parent.metadata; metadata.registerParam(theid, nested, JExpr.invoke(getter)); return nested; }
public JDefinedClass headerClass(ASTNode.Header node, String id, JDefinedClass parent) { final JDefinedClass klass; try { klass = parent._class(id); } catch(JClassAlreadyExistsException e) { throw new SyntaxError(format("duplicate name: '%s'", id)); } klass._extends(jsignalml.codec.Header.class); comment_stamp(klass); klass.metadata = new Metadata(klass); log.info("%s.metadata has been set", klass); final JMethod getter = classCacheMethod(parent, id, klass); Metadata metadata = (Metadata) parent.metadata; metadata.registerContext(id, klass, JExpr.invoke(getter)); return klass; }
public JDefinedClass outerLoopClass(String id, JDefinedClass parent) { final JDefinedClass klass; try { klass = parent._class("Loop_" + id); } catch(JClassAlreadyExistsException e) { throw new SyntaxError(format("duplicate name: '%s'", id)); } klass._extends(jsignalml.codec.OuterLoopClass.class); klass.metadata = new Metadata(klass); log.info("%s.metadata has been set", klass); final JMethod getter = classCacheMethod(parent, id, klass); comment_stamp(getter.body()); Metadata metadata = (Metadata) parent.metadata; metadata.registerContext(id, klass, JExpr.invoke(getter)); return klass; }
public JDefinedClass loopClass(String id, JDefinedClass parent) { final JDefinedClass klass; try { klass = parent._class(id); } catch(JClassAlreadyExistsException e) { throw new SyntaxError(format("duplicate name: '%s'", id)); } klass._extends(jsignalml.codec.OuterLoopClass.LoopClass.class); comment_stamp(klass); klass.metadata = new Metadata(klass); log.info("%s.metadata has been set", klass); return klass; }
public JDefinedClass channelSetClass(String id, JDefinedClass parent) { final JDefinedClass klass; try { klass = parent._class("ChannelSet_" + id); } catch(JClassAlreadyExistsException e) { throw new SyntaxError(format("duplicate name: '%s'", id)); } klass._extends(jsignalml.codec.ChannelSetClass.class); comment_stamp(klass); klass.metadata = new Metadata(klass); log.info("%s.metadata has been set", klass); final JMethod getter = classCacheMethod(parent, id, klass); Metadata metadata = (Metadata) parent.metadata; metadata.registerContext(id, klass, JExpr.invoke(getter)); return klass; }
public JDefinedClass channelClass(String id, JDefinedClass parent) { final JDefinedClass klass; try { klass = parent._class("Channel_" + id); } catch(JClassAlreadyExistsException e) { throw new SyntaxError(format("duplicate name: '%s'", id)); } klass._extends(jsignalml.codec.ChannelClass.class); comment_stamp(klass); klass.metadata = new Metadata(klass); log.info("%s.metadata has been set", klass); final JMethod getter = classCacheMethod(parent, id, klass); Metadata metadata = (Metadata) parent.metadata; metadata.registerContext(id, klass, JExpr.invoke(getter)); // Private variable for channel number klass.field(4, model.INT, "channelNum", JExpr.ref("channelCounter").incr()); return klass; }
protected JDefinedClass generateNamedSchema(NamedDataSchema schema) throws JClassAlreadyExistsException { pushCurrentLocation(getSchemaResolver().nameToDataSchemaLocations().get(schema.getFullName())); String className = classNameForNamedSchema(schema); checkForClassNameConflict(className, schema); JDefinedClass templateClass; switch (schema.getType()) { case RECORD: templateClass = generateRecord((RecordDataSchema) schema); break; case ENUM: templateClass = generateEnum((EnumDataSchema) schema); break; case FIXED: templateClass = generateFixed((FixedDataSchema) schema); break; default: throw unrecognizedSchemaType(null, null, schema); } popCurrentLocation(); return templateClass; }
private JClass generateUnnamedComplexSchema(DataSchema schema, JDefinedClass parentClass, String memberName) throws JClassAlreadyExistsException { if (schema instanceof ArrayDataSchema) { return generateArray((ArrayDataSchema) schema, parentClass, memberName); } else if (schema instanceof MapDataSchema) { return generateMap((MapDataSchema) schema, parentClass, memberName); } else if (schema instanceof UnionDataSchema) { return generateUnion((UnionDataSchema) schema, parentClass, memberName); } else { throw unrecognizedSchemaType(parentClass, memberName, schema); } }
private JClass generateUnion(UnionDataSchema schema, JDefinedClass parentClass, String memberName) throws JClassAlreadyExistsException { if (parentClass == null || memberName == null) { throw new IllegalArgumentException("Cannot generate template for top level union: " + schema); } ClassInfo classInfo = classInfoForUnnamed(parentClass, memberName, schema); if (classInfo.existingClass != null) { return classInfo.existingClass; } JDefinedClass unionClass = classInfo.definedClass; registerGeneratedClass(schema, unionClass); return generateUnion(schema, unionClass); }
private JClass generateUnion(UnionDataSchema schema, TyperefDataSchema typerefDataSchema) throws JClassAlreadyExistsException { assert typerefDataSchema.getRef() == schema; pushCurrentLocation(getSchemaResolver().nameToDataSchemaLocations().get(typerefDataSchema.getFullName())); JDefinedClass unionClass = getPackage(typerefDataSchema.getNamespace())._class(JMod.PUBLIC, escapeReserved(typerefDataSchema.getName())); registerGeneratedClass(typerefDataSchema, unionClass); JDefinedClass typerefInfoClass = unionClass._class(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, "UnionTyperefInfo"); generateTyperef(typerefDataSchema, typerefInfoClass); JFieldVar typerefInfoField = unionClass.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, TyperefInfo.class, DataTemplateUtil.TYPEREFINFO_FIELD_NAME); typerefInfoField.init(JExpr._new(typerefInfoClass)); unionClass._implements(HasTyperefInfo.class); JMethod typerefInfoMethod = unionClass.method(JMod.PUBLIC, TyperefInfo.class, "typerefInfo"); typerefInfoMethod.body()._return(typerefInfoField); final JClass result = generateUnion(schema, unionClass); popCurrentLocation(); return result; }
private void createReportingValueClass(JCodeModel codeModel, String name, JPrimitiveType type) throws JClassAlreadyExistsException { JClass reportClazz = codeModel.ref("org.jpmml.evaluator.Report"); JDefinedClass clazz = codeModel._class(JMod.PUBLIC, "org.jpmml.evaluator.Reporting" + name, ClassType.CLASS); clazz._extends(codeModel.ref("org.jpmml.evaluator." + name)); clazz._implements(codeModel.ref("org.jpmml.evaluator.HasReport")); JFieldVar reportField = clazz.field(JMod.PRIVATE, reportClazz, "report", JExpr._null()); createCopyMethod(clazz); createOperationMethods(clazz, name, type); createReportMethod(clazz); createExpressionMethods(clazz); createAccessorMethods(clazz, reportField); createFormatMethod(clazz, type); }
private void generatePathSpecMethodsForUnion(JDefinedClass unionClass, UnionDataSchema schema) throws JClassAlreadyExistsException { JDefinedClass fieldsNestedClass = generatePathSpecNestedClass(unionClass); for (DataSchema unionMemberType : schema.getTypes()) { JClass fieldsRefType = _pathSpecClass; if (hasNestedFields(unionMemberType)) { JClass unionMemberClass = processSchema(unionMemberType, unionClass, unionMemberType.getUnionMemberKey()); fieldsRefType = getCodeModel().ref(unionMemberClass.fullName() + ".Fields"); } JMethod accessorMethod = fieldsNestedClass.method(JMod.PUBLIC, fieldsRefType, memberName(unionMemberType)); accessorMethod.body()._return(JExpr._new(fieldsRefType).arg(JExpr.invoke("getPathComponents")).arg(unionMemberType.getUnionMemberKey())); } }
private void generateSubResources(String sourceFile, ResourceSchemaArray subresources, Map<String, JClass> pathKeyTypes, Map<String, JClass> assocKeyTypes, Map<String, List<String>> pathToAssocKeys) throws JClassAlreadyExistsException, IOException { if (subresources == null) { return; } for (ResourceSchema resource : subresources) { generateResourceFacade(resource, sourceFile, pathKeyTypes, assocKeyTypes, pathToAssocKeys); } }
@Override public boolean run(final Outline outline, final Options opt, final ErrorHandler errorHandler) throws SAXException { final PluginContext pluginContext = PluginContext.get(outline, opt, errorHandler); for (final ClassOutline classOutline : outline.getClasses()) { try { final GroupInterfacePlugin groupInterfacePlugin = pluginContext.findPlugin(GroupInterfacePlugin.class); if (groupInterfacePlugin != null) { ModifierGenerator.generateClass(pluginContext, new DefinedClassOutline(pluginContext, classOutline), this.modifierClassName, this.modifierClassName, groupInterfacePlugin.getGroupInterfacesForClass(pluginContext, classOutline.implClass.fullName()), this.modifierMethodName); } else { ModifierGenerator.generateClass(pluginContext, new DefinedClassOutline(pluginContext, classOutline), this.modifierClassName, this.modifierMethodName); } } catch (final JClassAlreadyExistsException e) { errorHandler.error(new SAXParseException(e.getMessage(), classOutline.target.getLocator())); } } return true; }
private void generateMetaClass(final PluginContext pluginContext, final ClassOutline classOutline, final ErrorHandler errorHandler) throws SAXException { try { final JDefinedClass metaClass = classOutline.implClass._class(JMod.PUBLIC | JMod.STATIC, this.metaClassName); final JMethod visitMethod = generateVisitMethod(classOutline); for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) { if (this.extended) { generateExtendedMetaField(pluginContext, metaClass, visitMethod, fieldOutline); } else { generateNameOnlyMetaField(pluginContext, metaClass, fieldOutline); } } visitMethod.body()._return(JExpr._this()); } catch (final JClassAlreadyExistsException e) { errorHandler.error(new SAXParseException(getMessage("error.metaClassExists", classOutline.implClass.name(), this.metaClassName), classOutline.target.getLocator())); } }
@Override public void generateClasses() throws IOException, JClassAlreadyExistsException { String objectsAsString = readProductObjectsFile(); ObjectsGenerator objectGenerator = new ObjectsGenerator(objectsAsString, product, getRootDirectory(), objectPackageName); objectGenerator.cleanObjectDirectory(); //Need to create object classes first to be used in option callbacks objectGenerator.createEmptyObjectClasses(); generateOptions(); //Then enrich object with option fields objectGenerator.enrichObjectClassesWithFields(); objectGenerator.writeObjectClassesToDisk(); }
public CodeGenerator(String pckg, Grammar g){ try { Symbols symbols = new Symbols(g, EOF); Framework f = new Framework(model, pckg); SymbolsGenerator symGen = new SymbolsGenerator(pckg, model, g, f); NodeGenerator nodeGen = new NodeGenerator(symbols, pckg, model, f, symGen); TokenFactoryGenerator tokenFac = new TokenFactoryGenerator(pckg, model, nodeGen, symGen, g, f); ParsingEngineGenerator eng = new ParsingEngineGenerator(symbols, pckg, model, f, nodeGen, symGen); JDefinedClass printVisitor = MainGenerator.generatePrintVisitor( pckg, model, nodeGen.getVisitorInterface(), nodeGen.getTokenNodeClasses()); MainGenerator.generateMain(pckg, model, f, nodeGen, printVisitor, tokenFac, eng); } catch (JClassAlreadyExistsException e) { throw new RuntimeException(e); } }