@Test public void linefeed_letter() throws Exception { Lexer lexer = new Lexer("\nx"); List<RobotLine> lines = lexer.lex(); assertEquals(2, lines.size()); RobotLine line1 = lines.get(0); assertThat(line1.lineNo, is(0)); assertThat(line1.lineCharPos, is(0)); assertThat(line1.arguments.size(), is(0)); RobotLine line2 = lines.get(1); assertThat(line2.lineNo, is(1)); assertThat(line2.lineCharPos, is(1)); assertThat(line2.arguments.size(), is(1)); }
public List<RobotLine> lex() throws CoreException { try { System.out.println("Lexing " + filename); CountingLineReader contents = new CountingLineReader(filestream); String line; int lineNo = 0; int charPos = 0; while (null != (line = contents.readLine())) { if (monitor.isCanceled()) { return null; } try { lexLine(line, lineNo, charPos); } catch (CoreException e) { throw new RuntimeException("Error when lexing line " + lineNo + ": '" + line + "'", e); } catch (RuntimeException e) { throw new RuntimeException("Internal error when lexing line " + lineNo + ": '" + line + "'", e); } ++lineNo; charPos = contents.getCharPos(); } } catch (Exception e) { throw new RuntimeException("Error lexing robot file " + filename, e); } finally { try { filestream.close(); } catch (IOException e) { } } return lexLines; }
Lexer { public List<RobotLine> lex() throws CoreException { try { System.out.println("Lexing " + filename); CountingLineReader contents = new CountingLineReader(filestream); String line; int lineNo = 0; int charPos = 0; while (null != (line = contents.readLine())) { if (monitor.isCanceled()) { return null; } try { lexLine(line, lineNo, charPos); } catch (CoreException e) { throw new RuntimeException("Error when lexing line " + lineNo + ": '" + line + "'", e); } catch (RuntimeException e) { throw new RuntimeException("Internal error when lexing line " + lineNo + ": '" + line + "'", e); } ++lineNo; charPos = contents.getCharPos(); } } catch (Exception e) { throw new RuntimeException("Error lexing robot file " + filename, e); } finally { try { filestream.close(); } catch (IOException e) { } } return lexLines; } }
Lexer { public List<RobotLine> lex() throws CoreException { try { System.out.println("Lexing " + filename); CountingLineReader contents = new CountingLineReader(filestream); String line; int lineNo = 0; int charPos = 0; while (null != (line = contents.readLine())) { if (monitor.isCanceled()) { return null; } try { lexLine(line, lineNo, charPos); } catch (CoreException e) { throw new RuntimeException("Error when lexing line " + lineNo + ": '" + line + "'", e); } catch (RuntimeException e) { throw new RuntimeException("Internal error when lexing line " + lineNo + ": '" + line + "'", e); } ++lineNo; charPos = contents.getCharPos(); } } catch (Exception e) { throw new RuntimeException("Error lexing robot file " + filename, e); } finally { try { filestream.close(); } catch (IOException e) { } } return lexLines; } Lexer(final IFile file, IProgressMonitor monitor);  Lexer(File file, String charset);  Lexer(String fileContents);  Lexer(IDocument document); }
Lexer { public List<RobotLine> lex() throws CoreException { try { System.out.println("Lexing " + filename); CountingLineReader contents = new CountingLineReader(filestream); String line; int lineNo = 0; int charPos = 0; while (null != (line = contents.readLine())) { if (monitor.isCanceled()) { return null; } try { lexLine(line, lineNo, charPos); } catch (CoreException e) { throw new RuntimeException("Error when lexing line " + lineNo + ": '" + line + "'", e); } catch (RuntimeException e) { throw new RuntimeException("Internal error when lexing line " + lineNo + ": '" + line + "'", e); } ++lineNo; charPos = contents.getCharPos(); } } catch (Exception e) { throw new RuntimeException("Error lexing robot file " + filename, e); } finally { try { filestream.close(); } catch (IOException e) { } } return lexLines; } Lexer(final IFile file, IProgressMonitor monitor);  Lexer(File file, String charset);  Lexer(String fileContents);  Lexer(IDocument document); List<RobotLine> lex(); }
Lexer { public List<RobotLine> lex() throws CoreException { try { System.out.println("Lexing " + filename); CountingLineReader contents = new CountingLineReader(filestream); String line; int lineNo = 0; int charPos = 0; while (null != (line = contents.readLine())) { if (monitor.isCanceled()) { return null; } try { lexLine(line, lineNo, charPos); } catch (CoreException e) { throw new RuntimeException("Error when lexing line " + lineNo + ": '" + line + "'", e); } catch (RuntimeException e) { throw new RuntimeException("Internal error when lexing line " + lineNo + ": '" + line + "'", e); } ++lineNo; charPos = contents.getCharPos(); } } catch (Exception e) { throw new RuntimeException("Error lexing robot file " + filename, e); } finally { try { filestream.close(); } catch (IOException e) { } } return lexLines; } Lexer(final IFile file, IProgressMonitor monitor);  Lexer(File file, String charset);  Lexer(String fileContents);  Lexer(IDocument document); List<RobotLine> lex();  }