public void readConfig() { InputStream resource = classLoader.getResourceAsStream("JPHP-INF/launcher.conf"); if (resource != null) { try { config.load(resource); for (String name : config.stringPropertyNames()){ scope.configuration.put(name, new StringMemory(config.getProperty(name))); } isDebug = Startup.isDebug(); scope.setDebugMode(isDebug); scope.setLangMode( LangMode.valueOf(getConfigValue("env.langMode", LangMode.MODERN.name()).toString().toUpperCase()) ); } catch (IOException e) { throw new LaunchException(e.getMessage()); } } }
compileScope.setLangMode( LangMode.valueOf(getConfigValue("env.langMode", LangMode.MODERN.name()).toString().toUpperCase()) );
protected SyntaxAnalyzer getSyntax(Context context){ Tokenizer tokenizer = null; try { tokenizer = new Tokenizer(context); } catch (IOException e) { throw new RuntimeException(e); } environment.scope.setLangMode(LangMode.DEFAULT); return new SyntaxAnalyzer(environment, tokenizer); }
protected List<Token> getSyntaxTree(String code){ Tokenizer tokenizer = null; try { tokenizer = new Tokenizer(new Context(code)); environment.scope.setLangMode(LangMode.DEFAULT); SyntaxAnalyzer analyzer = new SyntaxAnalyzer(environment, tokenizer); return analyzer.getTree(); } catch (IOException e) { throw new RuntimeException(e); } } }
private ASMExpression getASMExpression(String expr){ environment.scope.setLangMode(LangMode.DEFAULT); Tokenizer tokenizer = null; try { tokenizer = new Tokenizer(context = new Context(expr + ";")); } catch (IOException e) { throw new RuntimeException(e); } SyntaxAnalyzer analyzer = new SyntaxAnalyzer(environment, tokenizer); Assert.assertTrue(analyzer.getTree().size() == 1); Assert.assertTrue(analyzer.getTree().get(0) instanceof ExprStmtToken); return new ASMExpression( null, context, (ExprStmtToken)analyzer.getTree().get(0) ); }
@Test(expected = ErrorException.class) public void testUnexpectedEnd() throws IOException { Tokenizer tokenizer = new Tokenizer(new Context("foobar")); environment.scope.setLangMode(LangMode.DEFAULT); new SyntaxAnalyzer(environment, tokenizer); } }
protected CompileScope newScope(){ CompileScope compileScope = new CompileScope(); compileScope.setDebugMode(true); compileScope.setLangMode(LangMode.DEFAULT); compileScope.registerExtension(new CoreExtension()); compileScope.registerExtension(new SPLExtension()); return compileScope; }