ParserOptions options = new ParserOptions().withTypeUsesMap( getTypeUsesMap() ) .withExpectedType( elem.getReturnType() ) .withTokenizerInstructor( getTokenizerInstructor() ) .withSuperType( superType ) .withFileContext( context ) .withCtxInferenceMgr( _ctxInferenceMgr.copy() ) .withGenRootExprAccess( isGenerateRootExpressionAccessForProgram() ) .asThrowawayProgram() .withScriptPartId(partId); IParseResult result = programParser.parseExpressionOrProgram( getScript(), getSymbolTable(), options ); IGosuProgramInternal p = (IGosuProgramInternal)result.getProgram();
qualifiedName = Gosu.GOSU_SCRATCHPAD_FQN + getCounter(); ParserOptions options = new ParserOptions() .withParser(scriptParser) .asThrowawayProgram() .withFileContext(new ProgramFileContext(null, qualifiedName)); IParseResult parseResult = programParser.parseExpressionOrProgram(strScript, scriptParser.getSymbolTable(), options); Object result = parseResult.getProgram().evaluate( null );
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(); }
new ParserOptions() .withFileContext(fileContext) .withTypeUsesMap(typeUses); return options;
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(); } }
ParserOptions options = new ParserOptions().withParser( scriptParser ); IParseResult parseResult = programParser.parseExpressionOrProgram( strScript, scriptParser.getSymbolTable(), options ); Object result = parseResult.getProgram().evaluate( null );
ParserOptions options = new ParserOptions() .withTypeUsesMap( usesMap ) .withEnclosingType( enclType.getName() ) .withExpectedType(type) .asThrowawayProgram() .asAnonymous();
ParserOptions options = new ParserOptions().withParser( _parser ).withSuperType( _programSuperType ); if( _expectedType != null ) options.withExpectedType( _expectedType );
ParserOptions options = new ParserOptions().withTypeUsesMap( usesMap ); IGosuParser parser = GosuParserFactory.createParser( _newExpressionAsString ); options.setParserOptions( parser ); return (INewExpression)parser.parseExp( new TypelessScriptPartId( toString() ), options.getExpectedType(), options.getFileContext(), false );
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( _parser ).withSuperType( _programSuperType ); IParseResult result = programParser.parseExpressionOrProgram( strText, _parser.getSymbolTable(), options ); _parsedGosuClass = result.getProgram();
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 ); } }
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)); }
ParserOptions options = new ParserOptions().withParser( parserJavadoc ); IParseResult result = programParser.parseExpressionOrProgram( sb.toString(), parserJavadoc.getSymbolTable(), options ); IGosuClass parsedGosuClass = result.getProgram();
ParserOptions options = new ParserOptions().withTypeUsesMap( usesMap ); IGosuParser parser = GosuParserFactory.createParser( _newExpressionAsString ); options.setParserOptions( parser ); return (INewExpression)parser.parseExp( new TypelessScriptPartId( toString() ), options.getExpectedType(), options.getFileContext(), false );
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 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(); } }
ParserOptions options = new ParserOptions().withFileContext( ctx ); IParseResult result = programParser.parseExpressionOrProgram( content, new StandardSymbolTable( true ), options ); IGosuProgram program = result.getProgram();
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().withTypeUsesMap( getTypeUsesMap() ) .withExpectedType( elem.getReturnType() ) .withTokenizerInstructor( getTokenizerInstructor() ) .withSuperType( superType ) .withFileContext( context ) .withCtxInferenceMgr( _ctxInferenceMgr.copy() ) .withGenRootExprAccess( isGenerateRootExpressionAccessForProgram() ) .asThrowawayProgram() .withScriptPartId(partId); IParseResult result = programParser.parseExpressionOrProgram( getScript(), getSymbolTable(), options ); IGosuProgramInternal p = (IGosuProgramInternal)result.getProgram();