use of ast.ErrorMessage in project L42 by ElvisResearchGroup.
the class TestShortPrograms method tp.
public static void tp(String... code) {
TestHelper.configureForTest();
FinalResult res0;
try {
res0 = facade.L42.runSlow(null, TestHelper.multiLine(code));
} catch (ErrorMessage msg) {
ErrorFormatter.topFormatErrorMessage(msg);
throw msg;
}
ClassB res = res0.getTopLevelProgram();
ClassB.NestedClass nc = (ClassB.NestedClass) res.getMs().get(res.getMs().size() - 1);
ExpCore ee2 = Desugar.of(Parser.parse(null, "{//@exitStatus\n//0\n\n}")).accept(new InjectionOnCore());
TestHelper.assertEqualExp(nc.getInner(), ee2);
}
use of ast.ErrorMessage in project L42 by ElvisResearchGroup.
the class Resources method isValid.
public static boolean isValid(Program p, Object res, Object[] xs) {
if (L42.trustPluginsAndFinalProgram) {
return true;
}
ExpCore ec0 = Revertable.doRevert(res);
List<ExpCore> es = new ArrayList<>();
for (Object o : xs) {
es.add(Revertable.doRevert(o));
}
boolean strict = true;
for (ExpCore ec : es) {
List<ClassB> cbs = CollectClassBs0.of(ec);
List<Path> ps = CollectPaths0.of(ec);
for (ClassB cb : cbs) {
if (!cb.getPhase().subtypeEq(Phase.Typed)) {
strict = false;
}
}
for (Path path : ps) {
if (path.isPrimitive()) {
continue;
}
ClassB extracted = p.extractClassB(path);
if (!extracted.getPhase().subtypeEq(Phase.Typed)) {
strict = false;
}
}
}
List<ClassB> cbs = CollectClassBs0.of(ec0);
for (ClassB cb : cbs) {
try {
newTypeSystem.TypeSystem.instance().topTypeLib(Phase.Typed, p.evilPush(cb));
} catch (ErrorMessage msg) {
System.err.println("__________PLUGIN error identified_________");
//to breakpoint here
throw msg;
}
}
return true;
}
use of ast.ErrorMessage in project L42 by ElvisResearchGroup.
the class ReplState method start.
public static ReplState start(String code) {
try {
Expression.ClassReuse code1 = (ClassReuse) Parser.parse("Repl", code);
auxiliaryGrammar.WellFormedness.checkAll(code1);
Expression.ClassReuse code2 = (ClassReuse) Desugar.of(code1);
assert auxiliaryGrammar.WellFormedness.checkAll(code2);
ExpCore.ClassB code3 = (ExpCore.ClassB) code2.accept(new InjectionOnCore());
assert coreVisitors.CheckNoVarDeclaredTwice.of(code3);
// TODO: will die after new reduction Refresh of position identities, it is used to generate correct Java code.
code3 = (ExpCore.ClassB) code3.accept(new CloneVisitor() {
@Override
public ExpCore visit(ExpCore.ClassB cb) {
Position p = cb.getP();
cb = cb.withP(new Position(p.getFile(), p.getLine1(), p.getPos1(), p.getLine2(), p.getPos2(), p.get_next()));
return super.visit(cb);
}
});
ExpCore.ClassB result = ProgramReduction.allSteps(code3);
return new ReplState(code, code2, result);
} catch (org.antlr.v4.runtime.misc.ParseCancellationException parser) {
System.out.println(parser.getMessage());
return null;
} catch (ErrorMessage msg) {
ErrorFormatter.topFormatErrorMessage(msg);
return null;
}
}
use of ast.ErrorMessage in project L42 by ElvisResearchGroup.
the class TestDummyCode method main.
public static void main(String[] arg) throws IOException {
L42.setRootPath(Paths.get("dummy"));
System.out.println(Paths.get("dummy").toUri());
TestHelper.configureForTest();
try {
Path path = Paths.get("dummy", "dummy.l42");
FinalResult res = L42.runSlow(path.toString(), L42.pathToString(path));
System.out.println("------------------------------");
System.out.println("END: " + res.getErrCode());
} catch (ErrorMessage msg) {
//System.out.println(L42.record.toString());
msg.printStackTrace();
//Executor.reportError(msg);
System.out.println(ErrorFormatter.formatError(Program.empty(), msg).getErrorTxt());
}
/* try{
FinalResult res = L42.runSlow(L42.pathToString(Paths.get("dummy","dummy.l42")));
System.out.println(L42.record.toString());
if(res.getResult()!=0){
System.out.println(res);
Executor.reportError(null);
}
}
catch(ErrorMessage msg){
System.out.println(L42.record.toString());
msg.printStackTrace();
Executor.reportError(msg);
}*/
}
use of ast.ErrorMessage in project L42 by ElvisResearchGroup.
the class TestL42SuperSlow method test15.
@Test
public void test15() throws IOException {
String s = TestHelper.multiLine("", "{reuse L42.is/microBase", "A:{() method Bool m(Void v) True() }", //,"NList:Collections.list(N)"
"AList:Collections.list(A)", "Util:{()", " class method A max(AList that){", //," var N candidate=that.top()"
" with ei in that.vals() (", " void", //," if ei>candidate (candidate:=ei)"
" )", //," return candidate"
" return A()", " }", " }", "C:{", " list=AList[A();]", " if Util.max(list).m(v:void) (return ExitCode.normal())", " return ExitCode.failure()", " }", "}");
try {
FinalResult res = L42.runSlow(null, s);
System.out.println(L42.record.toString());
if (res.getResult() != 0) {
System.out.println(res);
TestHelper.reportError(null);
}
} catch (ErrorMessage msg) {
System.out.println(L42.record.toString());
msg.printStackTrace();
TestHelper.reportError(msg);
}
}
Aggregations