private ArrayList<Definition> parse(Lexer lex) throws ParseException, IOException { if (s.useFile()) startTimer(); Parser p = new Parser(); ArrayList<Definition> defs = p.parse(lex); if (s.useFile()) stopTimer(); // falls includes vorhanden, füge hinzu if (includes.size() != 0) { includes.addAll(defs); return includes; } return defs; }
protected static String resolveEntity(String entityName, EOEditingContext ec) { if (entityName == null) return null; try { EOEntity entity = EOUtilities.entityNamed(ec, entityName); if (entity != null) { return entityName; } } catch (EOObjectNotAvailableException naex) { } entityName = SettingsReader.stringForKeyPath("interfaces." + entityName, null); int dot = entityName.lastIndexOf('.'); if (dot > 0) { entityName = entityName.substring(dot + 1); } // return resolveEntity(entityName); if (entityName == null) return null; try { EOEntity entity = EOUtilities.entityNamed(ec, entityName); if (entity != null) { return entityName; } } catch (EOObjectNotAvailableException naex2) { } return null; }
private void addIncludes() throws IOException, ParseException { String[] includes = s.getIncludes(); if (includes != null) { for (int i = 0; i < includes.length; i++) { include(includes[0]); } } }
/* * runs a sasl job using the given settings */ public void run() { if (s.help()) { msg(s.getHelp()); return; } msg(" - SASL Compiler 0.3 - \n\n"); try { if (s.useSysIn()) { lexStream = System.in; } if (s.useFile()) { msg("Using " + s.filePath() + "\n"); lexStream = new FileInputStream(s.filePath()); } if (s.outputUseFile()) { outputStream = new PrintStream(new FileOutputStream(s.outputfilePath())); } if (s.useFile()) { msg("Lexing & Parsing " + s.filePath() + "... "); } if (s.useSysIn()) { msg("Code must be terminated by EOF (Unix:CTRL+D, Windows:CTRL+Z) \n"); msg("\n[sasl]: "); } addIncludes(); // lex Lexer lex = new Lexer(lexStream); // parse Node cTree = compile(parse(lex)); // can be used to print the Tree to a dot file // DotPrinter dp = new DotPrinter(cTree); // System.out.println(dp.print()); // reduce Node reduced = reduce(cTree); // print msg("\nResult:\n\n"); Printer.print(outputStream, reduced); msg("\n\n"); outputStream.close(); stopTimer(); } catch (ParseException e) { errorStream.println(e.getMessage()); } catch (ReduceException e) { errorStream.println(e.getMessage()); } catch (EOFException e) { errorStream.print("Error: Unexpected end of stream."); } catch (IOException e) { if (s.html()) { errorStream.print("Error IO: " + e.getMessage().replace("\n", "<br>")); } } }
/* * print msg to outputstream if quiet-mode is disabled */ public void msg(String msg) { if (!s.beQuiet()) { statusStream.print(msg); } }