
/**
 * Created by Varun on 9/9/2017.
 */
public class Tokenizer {
    public enum Token { VAR, NUM, OP, EQ , OPEN, CLOSE, EOL, FAC }

    public static Token tokenize(String s) throws Exception {
        if(s.matches("\\d+")) {  // one or more digits
            return Token.NUM;
        } else if(s.matches("[a-z]")) {  // letter
            int index = s.charAt(0) - 'a';  // Convert var to index: a-z maps to 0-25
            return Token.VAR;
        } else if(s.equals("+") || s.equals("-") || s.equals("*") || s.equals("/") || s.equals("%") || s.equals("^") || s.equals("|")) {
            return Token.OP;
        } else if(s.equals("=")) {
            return Token.EQ;
        } else if(s.equals("(")) {
            return Token.OPEN;
        } else if(s.equals(")")) {
            return Token.CLOSE;
        } else if(s.equals("!")) {
            return Token.FAC;
        } else if(s.equals(";")) {
            return Token.EOL;
        } else {  // Error
            throw new Exception("Unknown token: " + s);
        }
    }
}

@@ -17,27 +17,130 @@
 d by
- Varun on 9/9/2017.
+%0D%0A * Group 50%0D%0A *%0D%0A * Varun Simha Balaraju%0D%0A * Venkata Sarath Chandra Prasad Nelapati%0D%0A * Jithin Paul%0D%0A * Sunit Mathew%0D%0A *
 %0D%0A *

Update Tokenizer.java