updates target definition and fixes error/warning handling
This commit is contained in:
@@ -45,7 +45,7 @@ class CoreDslJsonGenerator extends AbstractGenerator {
|
||||
}
|
||||
def JSONArray compile(CoreDef coreDef) {
|
||||
val insts = coreDef.allInstr
|
||||
val enabled_insts = insts.filter[it.isHls]
|
||||
val enabled_insts = insts//.filter[it.isHls]
|
||||
val res = enabled_insts.map[ inst | inst.jsonDescr ].toList
|
||||
return res.length>0?new JSONArray(res) :new JSONArray()
|
||||
}
|
||||
@@ -60,7 +60,11 @@ class CoreDslJsonGenerator extends AbstractGenerator {
|
||||
}
|
||||
|
||||
def String getSource(Statement stmt){
|
||||
(stmt.eResource as XtextResource).serializer.serialize(stmt)
|
||||
try {
|
||||
(stmt.eResource as XtextResource).serializer.serialize(stmt)
|
||||
} catch(RuntimeException e){
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
def Iterable<Instruction> allInstr(CoreDef core) {
|
||||
|
@@ -28,6 +28,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess
|
||||
import java.lang.reflect.MalformedParametersException
|
||||
import org.apache.log4j.Level
|
||||
import org.eclipse.emf.ecore.resource.Resource
|
||||
import org.eclipse.xtext.diagnostics.Severity
|
||||
|
||||
class Main implements Callable<Integer> {
|
||||
|
||||
@@ -83,10 +84,17 @@ class GeneratorMain {
|
||||
val resource = resourceSet.getResource(URI.createFileURI(file.absolutePath), true)
|
||||
// Validate the resource
|
||||
val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)
|
||||
if (!issues.empty) {
|
||||
logger.error("Error validating " + resource.URI)
|
||||
issues.forEach[logger.error(it)]
|
||||
throw new ParseException("error validating " + resource.URI)
|
||||
if (!issues.empty) {
|
||||
val errors = issues.filter[it.severity == Severity.ERROR]
|
||||
val warnings = issues.filter[it.severity == Severity.WARNING]
|
||||
if (!errors.empty) {
|
||||
logger.error("Error validating " + resource.URI)
|
||||
issues.forEach[logger.error(it)]
|
||||
throw new ParseException("error validating " + resource.URI)
|
||||
} else if (!warnings.empty) {
|
||||
logger.warn("There are warnings validating " + resource.URI)
|
||||
issues.forEach[logger.warn(it)]
|
||||
}
|
||||
}
|
||||
// Configure and start the generator
|
||||
resource.runGenerator(params.outputFile)
|
||||
|
Reference in New Issue
Block a user