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(); }
IGosuProgram gp = res.getProgram(); if( !gp.isValid() )
public static IProgramInstance getProgramInstance( String strProgram, ISymbolTable symTable, IType expectedType ) throws Exception { IGosuProgramParser pcp = GosuParserFactory.createProgramParser(); IParseResult res = pcp.parseProgramOnly( strProgram, symTable, new ParserOptions().withExpectedType(expectedType) ); IGosuProgram gp = res.getProgram(); if( !gp.isValid() ) { throw gp.getParseResultsException(); } Class<?> javaClass = gp.getBackingClass(); return (IProgramInstance)javaClass.newInstance(); } }
public static IProgramInstance getProgramInstance( String strProgram, ISymbolTable symTable, IType expectedType ) throws Exception { IGosuProgramParser pcp = GosuParserFactory.createProgramParser(); IParseResult res = pcp.parseProgramOnly( strProgram, symTable, new ParserOptions().withExpectedType(expectedType) ); IGosuProgram gp = res.getProgram(); if( !gp.isValid() ) { throw gp.getParseResultsException(); } Class<?> javaClass = gp.getBackingClass(); return (IProgramInstance)javaClass.newInstance(); } }
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)); }
IGosuProgram gp = res.getProgram(); if( !gp.isValid() )
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 ); } }
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 ); } }
ParserOptions options = new ParserOptions().withParser( scriptParser ); IParseResult parseResult = programParser.parseExpressionOrProgram( strScript, scriptParser.getSymbolTable(), options ); Object result = parseResult.getProgram().evaluate( null ); if( result != null )
cacheProgram( typeName, (IGosuProgramInternal)res.getProgram() ); try gp = res.getProgram(); if( !gp.isValid() )
.withFileContext(new ProgramFileContext(null, qualifiedName)); IParseResult parseResult = programParser.parseExpressionOrProgram(strScript, scriptParser.getSymbolTable(), options); Object result = parseResult.getProgram().evaluate( null ); if( result != null )
ParserOptions options = new ParserOptions().withParser( parserJavadoc ); IParseResult result = programParser.parseExpressionOrProgram( sb.toString(), parserJavadoc.getSymbolTable(), options ); IGosuClass parsedGosuClass = result.getProgram(); ParseResultsException parseResultsException = parsedGosuClass.getParseResultsException(); if( parseResultsException != null )
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); } }
ParserOptions options = new ParserOptions().withParser( parserJavadoc ); IParseResult result = programParser.parseExpressionOrProgram( sb.toString(), parserJavadoc.getSymbolTable(), options ); IGosuClass parsedGosuClass = result.getProgram(); ParseResultsException parseResultsException = parsedGosuClass.getParseResultsException(); if( parseResultsException != null )
ParserOptions options = new ParserOptions().withParser( parserJavadoc ); IParseResult result = programParser.parseExpressionOrProgram( sb.toString(), parserJavadoc.getSymbolTable(), options ); IGosuClass parsedGosuClass = result.getProgram(); ParseResultsException parseResultsException = parsedGosuClass.getParseResultsException(); if( parseResultsException != null )
ParserOptions options = new ParserOptions().withFileContext( ctx ); IParseResult result = programParser.parseExpressionOrProgram( content, new StandardSymbolTable( true ), options ); IGosuProgram program = result.getProgram();
.withScriptPartId(partId); IParseResult result = programParser.parseExpressionOrProgram( getScript(), getSymbolTable(), options ); IGosuProgramInternal p = (IGosuProgramInternal)result.getProgram(); if( p == null )
.withScriptPartId(partId); IParseResult result = programParser.parseExpressionOrProgram( getScript(), getSymbolTable(), options ); IGosuProgramInternal p = (IGosuProgramInternal)result.getProgram(); if( p == null )