public static IExpression compileExpression( String script, ISymbolTable table, boolean bThrowOnWarning ) throws ParseResultsException { IGosuParser parser = GosuParserFactory.createParser(script, table, ScriptabilityModifiers.SCRIPTABLE); parser.setThrowParseExceptionForWarnings( bThrowOnWarning ); return parser.parseExpOrProgram( null ); }
public static IProgram compileProgram(String script, ISymbolTable table) throws ParseResultsException { IGosuParser parser = GosuParserFactory.createParser(script, table, ScriptabilityModifiers.SCRIPTABLE); parser.setEditorParser(true); return parser.parseProgram(null); }
public static IExpression compileExpression( String script, ISymbolTable table ) throws ParseResultsException { IGosuParser parser = GosuParserFactory.createParser(script, table, ScriptabilityModifiers.SCRIPTABLE); parser.setThrowParseExceptionForWarnings( false ); return parser.parseExpOrProgram( null ); }
/** * Parses a type name such as Iterable<Claim>. * @param typeName the name to parse * @return the type */ public static IType parseTypeLiteral(String typeName) { try { IType type = GosuParserFactory.createParser(typeName).parseTypeLiteral(null).getType().getType(); if (type instanceof IErrorType) { throw new RuntimeException("Type not found: " + typeName); } return type; } catch (ParseResultsException e) { throw new RuntimeException("Type not found: " + typeName, e); } }
/** * Parses a type name such as Iterable<Claim>. * @param typeName the name to parse * @return the type */ public static IType parseTypeLiteral(String typeName) { try { IType type = GosuParserFactory.createParser(typeName).parseTypeLiteral(null).getType().getType(); if (type instanceof IErrorType) { throw new RuntimeException("Type not found: " + typeName); } return type; } catch (ParseResultsException e) { throw new RuntimeException("Type not found: " + typeName, e); } }
public static IExpression compileExpression( String script, boolean bThrowOnWarning ) throws ParseResultsException { IGosuParser parser = GosuParserFactory.createParser(script, new StandardSymbolTable(true), ScriptabilityModifiers.SCRIPTABLE); parser.setThrowParseExceptionForWarnings( bThrowOnWarning ); return parser.parseExpOrProgram( null ); }
private static void verifyType( boolean includeWarnings, ArrayList<IVerificationResults> errors, Object o, CharSequence typeName ) { try { IType type = TypeSystem.getByFullNameIfValid( o.toString() ); if( type instanceof ITemplateType ) { ITemplateGenerator generator = ((ITemplateType) type).getTemplateGenerator(); try { generator.verify(GosuParserFactory.createParser(null)); } catch ( ParseResultsException e) { errors.add( new GosuTypeVerificationResults( typeName.toString(), e.getParseIssues() ) ); } } else if( type instanceof IGosuClass ) { boolean valid = type.isValid(); List<IParseIssue> parseIssues = ((IGosuClass)type).getClassStatement().getParseIssues(); if( parseIssues.size() > 0 && (!valid || includeWarnings) ) { errors.add( new GosuTypeVerificationResults( typeName.toString(), parseIssues ) ); } } } catch( Throwable e ) { errors.add( new ExceptionTypeVerificationResults( typeName.toString(), e.getMessage() ) ); } }
GosuParser usesParser = (GosuParser) GosuParserFactory.createParser(_scriptStr); usesParser.setTokenizerInstructor( new TemplateTokenizerInstructor(usesParser.getTokenizer()) ); if( _fqn != null ) { GosuParser parser = (GosuParser) GosuParserFactory.createParser(strSignature); parser.setEditorParser(_useStudioEditorParser); parser.setTypeUsesMap(usesParser.getTypeUsesMap());
GosuParser usesParser = (GosuParser) GosuParserFactory.createParser(_scriptStr); usesParser.setTokenizerInstructor( new TemplateTokenizerInstructor(usesParser.getTokenizer()) ); if( _fqn != null ) { GosuParser parser = (GosuParser) GosuParserFactory.createParser(strSignature); parser.setEditorParser(_useStudioEditorParser); parser.setTypeUsesMap(usesParser.getTypeUsesMap());
public String[] evaluate( String strScript ) IGosuParser scriptParser = GosuParserFactory.createParser(strScript);
public String[] evaluate( String strScript ) IGosuParser scriptParser = GosuParserFactory.createParser(strScript);
addEnclosingPackages(usesMap, enclosingType ); try { GosuParser scriptParser = (GosuParser)GosuParserFactory.createParser( text ); maybePushEnumTypes( scriptParser.getSymbolTable(), resultType ); pushLocalConstants( scriptParser.getSymbolTable(), enclosingType );
try { text = Java7ToGosuLexicalConversion(text); GosuParser scriptParser = (GosuParser)GosuParserFactory.createParser( text ); maybePushEnumTypes( scriptParser.getSymbolTable(), resultType ); pushLocalConstants( scriptParser.getSymbolTable(), enclosingType );
@Override public Object getInstance() { ITypeInfo autocreateTypeInfo = GosuTypes.AUTOCREATE().getTypeInfo(); if ( _concreteType != null && JavaTypes.LIST().isAssignableFrom( _concreteType ) ) { for ( IConstructorInfo constructor : autocreateTypeInfo.getConstructors()) { IParameterInfo[] constructorParams = constructor.getParameters(); if (constructorParams.length > 0 && constructorParams[0].getFeatureType() instanceof IBlockType ) { try { IGosuParser parser = GosuParserFactory.createParser( "\\ -> new java.util.ArrayList()" ); IExpression expr = parser.parseExp( new TypelessScriptPartId( "Xml Schema autocreate block" ) ); Object block = expr.evaluate(); return constructor.getConstructor().newInstance(block); } catch (Exception e) { throw new RuntimeException(e); } } } } return autocreateTypeInfo.getConstructor().getConstructor().newInstance(); }
private GosuParser createParser(CompiledGosuClassSymbolTable symbolTable) { GosuParser parser = (GosuParser) GosuParserFactory.createParser(symbolTable, ScriptabilityModifiers.SCRIPTABLE); parser.pushScriptPart( new ScriptPartId( getOrCreateTypeReference(), null ) ); ICompilableTypeInternal enclosingType = getEnclosingType(); if( enclosingType != null ) { IGosuParser enclosingParser = enclosingType.getParser(); if ( enclosingParser != null ) { parser.setThrowParseExceptionForWarnings( enclosingParser.isThrowParseResultsExceptionForWarnings() ); parser.setWarnOnCaseIssue(enclosingParser.isThrowParseResultsExceptionForWarnings()); parser.setEditorParser(enclosingParser.isThrowParseResultsExceptionForWarnings()); } else { parser.setThrowParseExceptionForWarnings(enclosingType.isCreateEditorParser()); parser.setWarnOnCaseIssue(enclosingType.isCreateEditorParser()); parser.setEditorParser(enclosingType.isCreateEditorParser()); } } else { parser.setThrowParseExceptionForWarnings(_bEditorParser); parser.setWarnOnCaseIssue(_bEditorParser); parser.setEditorParser(_bEditorParser); } return parser; }
private GosuParser createParser(CompiledGosuClassSymbolTable symbolTable) { GosuParser parser = (GosuParser) GosuParserFactory.createParser(symbolTable, ScriptabilityModifiers.SCRIPTABLE); parser.pushScriptPart( new ScriptPartId( getOrCreateTypeReference(), null ) ); ICompilableTypeInternal enclosingType = getEnclosingType(); if( enclosingType != null ) { IGosuParser enclosingParser = enclosingType.getParser(); if ( enclosingParser != null ) { parser.setThrowParseExceptionForWarnings( enclosingParser.isThrowParseResultsExceptionForWarnings() ); parser.setWarnOnCaseIssue(enclosingParser.isThrowParseResultsExceptionForWarnings()); parser.setEditorParser(enclosingParser.isThrowParseResultsExceptionForWarnings()); } else { parser.setThrowParseExceptionForWarnings(enclosingType.isCreateEditorParser()); parser.setWarnOnCaseIssue(enclosingType.isCreateEditorParser()); parser.setEditorParser(enclosingType.isCreateEditorParser()); } } else { parser.setThrowParseExceptionForWarnings(_bEditorParser); parser.setWarnOnCaseIssue(_bEditorParser); parser.setEditorParser(_bEditorParser); } return parser; }
IGosuParser parser = GosuParserFactory.createParser( _newExpressionAsString ); options.setParserOptions( parser );
template.setForStringLiteral( true ); TemplateStringLiteral e = new TemplateStringLiteral( template ); GosuParser parser = (GosuParser)GosuParserFactory.createParser( _symTable, ScriptabilityModifiers.SCRIPTABLE ); IScriptPartId scriptPart = getScriptPart(); parser.pushScriptPart( scriptPart );
private IGosuFragment parseImpl( String script, ISymbolTable table, ParserOptions options, String name, HashMap<String, ISymbol> externalSymbols, boolean parseExpression ) throws ParseResultsException { IGosuParser parser = GosuParserFactory.createParser( script ); options.setParserOptions( parser );
private IGosuFragment parseImpl( String script, ISymbolTable table, ParserOptions options, String name, HashMap<String, ISymbol> externalSymbols, boolean parseExpression ) throws ParseResultsException { IGosuParser parser = GosuParserFactory.createParser( script ); parser.putDfsDeclsInTable( table ); options.setParserOptions( parser );