@Test public void testBlankLines() { Queue<Token> tokens = TokenBuilder.builder() .eol() .number(10.0).ident("A").syntax('=').number(42.0).eol() .eol() .tokens(); Parser parser = new Parser(tokens); Program program = parser.parse(); Assert.assertNotNull(program); }
public Program parse() { Program program = new Program(); while (!tokens.isEmpty()) { readLine(program).ifPresent(program.lines::add); } return program; }
Parser { public Program parse() { Program program = new Program(); while (!tokens.isEmpty()) { readLine(program).ifPresent(program.lines::add); } return program; } }
Parser { public Program parse() { Program program = new Program(); while (!tokens.isEmpty()) { readLine(program).ifPresent(program.lines::add); } return program; } Parser(Queue<Token> tokens); }
Parser { public Program parse() { Program program = new Program(); while (!tokens.isEmpty()) { readLine(program).ifPresent(program.lines::add); } return program; } Parser(Queue<Token> tokens); Program parse(); Optional<Line> readLine(Program program); Statement readStatement(); Optional<Integer> expectNumber(); }
Parser { public Program parse() { Program program = new Program(); while (!tokens.isEmpty()) { readLine(program).ifPresent(program.lines::add); } return program; } Parser(Queue<Token> tokens); Program parse(); Optional<Line> readLine(Program program); Statement readStatement(); Optional<Integer> expectNumber();  }