public List<Statement> parse(Map<String, Integer> labels) {
            List<Statement> statements = new ArrayList<Statement>();
            
            while (true) {
                // Ignore empty lines.
                while (match(TokenType.LINE));
                
                if (match(TokenType.LABEL)) {
                    // Mark the index of the statement after the label.
                    labels.put(last(1).text, statements.size());
                } else if (match(TokenType.WORD, TokenType.EQUALS)) {
                    String name = last(2).text;
                    Expression value = expression();
                    statements.add(new AssignStatement(name, value));
                } else if (match("print")) {
                    statements.add(new PrintStatement(expression()));
                } else if (match("input")) {
                    statements.add(new InputStatement(
                        consume(TokenType.WORD).text));
                } else if (match("goto")) {
                    statements.add(new GotoStatement(
                        consume(TokenType.WORD).text));
                } else if (match("if")) {
                    Expression condition = expression();
                    consume("then");
                    String label = consume(TokenType.WORD).text;
                    statements.add(new IfThenStatement(condition, label));
                } else break; // Unexpected token (likely EOF), so end.
            }
            
            return statements;
        }