use of php.runtime.launcher.Launcher in project jphp by jphp-compiler.
the class CLI method checkSyntax.
protected void checkSyntax(String filename) throws Throwable {
Launcher launcher = new Launcher("jphp.conf", args);
launcher.run(false, true);
File file = new File(filename);
Environment environment = new Environment(launcher.getCompileScope(), output);
Context context = new Context(file);
try {
SyntaxAnalyzer analyzer = new SyntaxAnalyzer(environment, new Tokenizer(context));
analyzer.getTree();
output.println(String.format("No syntax errors detected in %s", filename));
} catch (Exception e) {
environment.catchUncaught(e);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
} finally {
try {
environment.doFinal();
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
}
}
use of php.runtime.launcher.Launcher in project jphp by jphp-compiler.
the class CLI method executeFile.
protected void executeFile(String filename) throws Throwable {
Launcher launcher = new Launcher("jphp.conf", args);
launcher.run(false);
File file = new File(filename);
Environment environment = new Environment(launcher.getCompileScope(), output);
environment.getDefaultBuffer().setImplicitFlush(true);
try {
Context context = new Context(file);
ModuleEntity module = environment.importModule(context);
module.include(environment);
} catch (Exception e) {
environment.catchUncaught(e);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
} finally {
try {
environment.doFinal();
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
}
}
Aggregations