private IGosuProgram parseProgram( String expr ) throws ParseResultsException { IGosuProgramParser programParser = GosuParserFactory.createProgramParser(); ParserOptions parserOptions = new ParserOptions(); parserOptions.withTypeUsesMap( _interactiveTypeUsesMap ); IParseResult result = programParser.parseExpressionOrProgram( expr, _interactiveSymbolTable, parserOptions ); return result.getProgram(); }
private IGosuProgram parseProgram( String expr ) throws ParseResultsException { IGosuProgramParser programParser = GosuParserFactory.createProgramParser(); ParserOptions parserOptions = new ParserOptions(); parserOptions.withTypeUsesMap( _interactiveTypeUsesMap ); IParseResult result = programParser.parseExpressionOrProgram( expr, _interactiveSymbolTable, parserOptions ); return result.getProgram(); }
public static Object evalGosu(String script, ISymbolTable table) throws ParseResultsException { IGosuProgram gosuProgram = GosuParserFactory.createProgramParser().parseExpressionOrProgram( script, table, new ParserOptions() ).getProgram(); return gosuProgram.evaluate(new ExternalSymbolMapSymbolTableWrapper(table)); }
public void execute() throws BuildException { if (_expression.length() == 0) { throw new BuildException("no expression to evaluate"); } try { IGosuProgramParser parser = GosuParserFactory.createProgramParser(); String script = _expression.toString(); IParseResult result = parser.parseExpressionOrProgram(script, new StandardSymbolTable(true), createParserOptions()); IGosuProgram program = result.getProgram(); // To avoid dead-locking while loading classes. TypeSystem.lock(); try { program.evaluate(null); } finally { TypeSystem.unlock(); } } catch (IEvaluationException e) { if (e.getCause() != null && e.getCause() instanceof BuildException) { // TODO - blc - the Gosu stack trace could be useful here throw (BuildException) e.getCause(); } else { throw e; } } catch (Exception e) { throw new BuildException(e); } }
private static void runWithFile( File script, List<String> args ) throws IOException, ParseResultsException { _script = script; // set remaining arguments as arguments to the Gosu program _rawArgs = args; byte[] bytes = StreamUtil.getContent( new BufferedInputStream( new FileInputStream( script ) ) ); String content = StreamUtil.toString( bytes ); IFileContext ctx = new ProgramFileContext( script, makeFqn( script ) ); IGosuProgramParser programParser = GosuParserFactory.createProgramParser(); ParserOptions options = new ParserOptions().withFileContext( ctx ); IParseResult result = programParser.parseExpressionOrProgram( content, new StandardSymbolTable( true ), options ); IGosuProgram program = result.getProgram(); Object ret = program.getProgramInstance().evaluate( null ); // evaluate it IType expressionType = result.getType(); if( expressionType != null && !JavaTypes.pVOID().equals( expressionType ) ) { GosuShop.print( ret ); } }
IParseResult parseResult = programParser.parseExpressionOrProgram( strScript, scriptParser.getSymbolTable(), options ); Object result = parseResult.getProgram().evaluate( null ); if( result != null )
private static void runWithInlineScript( String script, List<String> args ) throws IOException, ParseResultsException { _script = null; // set remaining arguments as arguments to the Gosu program _rawArgs = args; IGosuProgramParser programParser = GosuParserFactory.createProgramParser(); IParseResult result = programParser.parseExpressionOrProgram( script, new StandardSymbolTable( true ), new ParserOptions() ); IGosuProgram program = result.getProgram(); Object ret = program.getProgramInstance().evaluate( null ); // evaluate it IType expressionType = result.getType(); if( expressionType != null && !JavaTypes.pVOID().equals( expressionType ) ) { GosuShop.print( ret ); } }
.asThrowawayProgram() .withFileContext(new ProgramFileContext(null, qualifiedName)); IParseResult parseResult = programParser.parseExpressionOrProgram(strScript, scriptParser.getSymbolTable(), options); Object result = parseResult.getProgram().evaluate( null ); if( result != null )
IParseResult result = programParser.parseExpressionOrProgram( sb.toString(), parserJavadoc.getSymbolTable(), options ); IGosuClass parsedGosuClass = result.getProgram(); ParseResultsException parseResultsException = parsedGosuClass.getParseResultsException();
public static AardvarkProgram parse(Project project, File baseDir, Reader reader) throws ParseResultsException { try { String content = StreamUtil.getContent(reader); IGosuProgramParser programParser = GosuParserFactory.createProgramParser(); List<String> packages = getDefaultTypeUsesPackages(); ITypeUsesMap typeUses = CommonServices.getGosuIndustrialPark().createTypeUsesMap(packages); for( String aPackage : packages ) { typeUses.addToDefaultTypeUses( aPackage ); } IType supertype = TypeSystem.getByFullName("gw.vark.AardvarkFile"); ParserOptions options = new ParserOptions().withTypeUsesMap(typeUses).withSuperType(supertype); IParseResult result = programParser.parseExpressionOrProgram( content, new StandardSymbolTable( true ), options ); AardvarkProgram aardvarkProgram = new AardvarkProgram(project, baseDir, result.getProgram()); project.addReference(REF_ID, aardvarkProgram); return aardvarkProgram; } catch (IOException e) { throw GosuExceptionUtil.forceThrow(e); } }
IParseResult result = programParser.parseExpressionOrProgram( sb.toString(), parserJavadoc.getSymbolTable(), options ); IGosuClass parsedGosuClass = result.getProgram(); ParseResultsException parseResultsException = parsedGosuClass.getParseResultsException();
IParseResult result = programParser.parseExpressionOrProgram( sb.toString(), parserJavadoc.getSymbolTable(), options ); IGosuClass parsedGosuClass = result.getProgram(); ParseResultsException parseResultsException = parsedGosuClass.getParseResultsException();
IParseResult result = programParser.parseExpressionOrProgram( content, new StandardSymbolTable( true ), options ); IGosuProgram program = result.getProgram();
IParseResult result = programParser.parseExpressionOrProgram( strText, _parser.getSymbolTable(), options ); _parsedGosuClass = result.getProgram(); ParseResultsException parseRes = _parsedGosuClass.getParseResultsException();
IParseResult result = programParser.parseExpressionOrProgram( strText, _parser.getSymbolTable(), options ); _parsedGosuClass = result.getProgram(); ParseResultsException parseRes = _parsedGosuClass.getParseResultsException();