// Path: src/stone/CodeDialog.java
// public class CodeDialog extends Reader {
//     private String buffer = null;
//     private int pos = 0;
// 
//     public int read(char[] cbuf, int off, int len) throws IOException {
//         if (buffer == null) {
//             String in = showDialog();
//             if (in == null)
//                 return -1;
//             else {
//                 print(in);
//                 buffer = in + "\n";  
//                 pos = 0;
//             }
//         }
// 
//         int size = 0;
//         int length = buffer.length();
//         while (pos < length && size < len)
//             cbuf[off + size++] = buffer.charAt(pos++);
//         if (pos == length)
//             buffer = null;
//         return size;
//     }
//     protected void print(String s) { System.out.println(s); }
//     public void close() throws IOException {}
//     protected String showDialog() {
//         JTextArea area = new JTextArea(20, 40);
//         JScrollPane pane = new JScrollPane(area);
//         int result = JOptionPane.showOptionDialog(null, pane, "Input",
//                                                   JOptionPane.OK_CANCEL_OPTION,
//                                                   JOptionPane.PLAIN_MESSAGE,
//                                                   null, null, null);
//         if (result == JOptionPane.OK_OPTION)
//             return area.getText();
//         else
//             return null;
//     }
//     public static Reader file() throws FileNotFoundException {
//         JFileChooser chooser = new JFileChooser();
//         if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
//             return new BufferedReader(new FileReader(chooser.getSelectedFile()));
//         else
//             throw new FileNotFoundException("no file specified");
//     }
// }


import java.io.IOException;
import java.io.Reader;
import stone.CodeDialog;
        }
        else if (isLetter(c)) {
            do {
                sb.append((char)c);
                c = getChar();
            } while (isLetter(c) || isDigit(c));
        }
        else if (c == '=') {
            c = getChar();
            if (c == '=')
                return "==";
            else {
                ungetChar(c);
                return "=";
            }
        }
        else
            throw new IOException();

        if (c >= 0)
            ungetChar(c);

        return sb.toString();
    }
    private static boolean isLetter(int c) {
        return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'; 
    }
    private static boolean isDigit(int c) { return '0' <= c && c <= '9'; }
    private static boolean isSpace(int c) { return 0 <= c && c <= ' '; }
    public static void main(String[] args) throws Exception {
// Path: src/stone/CodeDialog.java
// public class CodeDialog extends Reader {
//     private String buffer = null;
//     private int pos = 0;
// 
//     public int read(char[] cbuf, int off, int len) throws IOException {
//         if (buffer == null) {
//             String in = showDialog();
//             if (in == null)
//                 return -1;
//             else {
//                 print(in);
//                 buffer = in + "\n";  
//                 pos = 0;
//             }
//         }
// 
//         int size = 0;
//         int length = buffer.length();
//         while (pos < length && size < len)
//             cbuf[off + size++] = buffer.charAt(pos++);
//         if (pos == length)
//             buffer = null;
//         return size;
//     }
//     protected void print(String s) { System.out.println(s); }
//     public void close() throws IOException {}
//     protected String showDialog() {
//         JTextArea area = new JTextArea(20, 40);
//         JScrollPane pane = new JScrollPane(area);
//         int result = JOptionPane.showOptionDialog(null, pane, "Input",
//                                                   JOptionPane.OK_CANCEL_OPTION,
//                                                   JOptionPane.PLAIN_MESSAGE,
//                                                   null, null, null);
//         if (result == JOptionPane.OK_OPTION)
//             return area.getText();
//         else
//             return null;
//     }
//     public static Reader file() throws FileNotFoundException {
//         JFileChooser chooser = new JFileChooser();
//         if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
//             return new BufferedReader(new FileReader(chooser.getSelectedFile()));
//         else
//             throw new FileNotFoundException("no file specified");
//     }
// }


// Path: src/chapA/Lexer.java
import java.io.IOException;
import java.io.Reader;
import stone.CodeDialog;

        }
        else if (isLetter(c)) {
            do {
                sb.append((char)c);
                c = getChar();
            } while (isLetter(c) || isDigit(c));
        }
        else if (c == '=') {
            c = getChar();
            if (c == '=')
                return "==";
            else {
                ungetChar(c);
                return "=";
            }
        }
        else
            throw new IOException();

        if (c >= 0)
            ungetChar(c);

        return sb.toString();
    }
    private static boolean isLetter(int c) {
        return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'; 
    }
    private static boolean isDigit(int c) { return '0' <= c && c <= '9'; }
    private static boolean isSpace(int c) { return 0 <= c && c <= ' '; }
    public static void main(String[] args) throws Exception {
        Lexer l = new Lexer(new CodeDialog());