use of sugarVisitors.InjectionOnCore in project L42 by ElvisResearchGroup.
the class TranslationTest method tester.
public void tester(String cbStr, String eStr, String nameRes) {
TestHelper.configureForTest();
Program p = runTypeSystem(cbStr);
ExpCore _e = Desugar.of(Parser.parse(null, eStr)).accept(new InjectionOnCore());
ExpCore e = newTypeSystem.TypeSystem.instance().topTypeExpVoid(p, _e);
Translator code = Resources.withPDo(new PData(p), () -> Translator.translateProgram(p, e));
System.out.println(code);
Object o = Resources.withPDo(new PData(p), () -> code.runMap());
Assert.assertEquals(o.getClass().getName(), nameRes);
}
use of sugarVisitors.InjectionOnCore 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 sugarVisitors.InjectionOnCore in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method parseAndDesugar.
private static ExpCore parseAndDesugar(String s) {
Expression code1 = Parser.parse("PlgWrapperGenerator", s);
Expression code2 = Desugar.of(code1);
return code2.accept(new InjectionOnCore());
}
Aggregations