use of ast.ErrorMessage.FinalResult in project L42 by ElvisResearchGroup.
the class DeploySimpleLib method testLibUse.
private static void testLibUse() {
try {
FinalResult res = L42.runSlow(null, TestHelper.multiLine("", " {reuse L42.is/miniBase", " Lib:Load[]<{reuse L42.is/SimpleLib}", " Main:{", " Lib.printHelloWorld()", " return ExitCode.normal()", " }", " }"));
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());
}
}
use of ast.ErrorMessage.FinalResult in project L42 by ElvisResearchGroup.
the class L42 method main.
public static void main(String[] arg) throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
//assert false;
setClassPath(Paths.get("Plugins"));
L42.programArgs = arg;
try {
Configuration.loadAll();
Path path = Paths.get(arg[arg.length - 1]);
String code = null;
if (Files.isDirectory(path)) {
L42.setRootPath(path);
code = L42.pathToString(path.resolve("This.L42"));
} else {
L42.setRootPath(path.getParent());
code = L42.pathToString(path);
}
FinalResult res = L42.runSlow(path.toString(), code);
System.out.println("------------------------------");
System.out.println("END (zero for success): " + res.getErrCode());
} catch (ParseCancellationException parser) {
System.out.println(parser.getMessage());
//parser.printStackTrace(System.out);
} catch (ErrorMessage msg) {
ErrorFormatter.topFormatErrorMessage(msg);
} finally {
if (L42.profilerPrintOn) {
System.out.print(Timer.report());
}
}
}
use of ast.ErrorMessage.FinalResult 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.FinalResult 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.FinalResult 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