summaryrefslogtreecommitdiff
path: root/submit/ast/VarType.java
blob: ba28946f9e3dceccfffb9d035152e2db225e0186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Code formatter project
 * CS 4481
 */
package submit.ast;

/**
 *
 * @author edwajohn
 */
public enum VarType {

  INT("int"), BOOL("bool"), CHAR("char");

  private final String value;

  private VarType(String value) {
    this.value = value;
  }

  public static VarType fromString(String s) {
    for (VarType vt : VarType.values()) {
      if (vt.value.equals(s)) {
        return vt;
      }
    }
    throw new RuntimeException("Illegal string in VarType.fromString()");
  }

  @Override
  public String toString() {
    return value;
  }

}