diff options
Diffstat (limited to 'calculator-javacc')
-rw-r--r-- | calculator-javacc/Calculator.jj | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/calculator-javacc/Calculator.jj b/calculator-javacc/Calculator.jj index 770bf4c..89a5802 100644 --- a/calculator-javacc/Calculator.jj +++ b/calculator-javacc/Calculator.jj @@ -21,16 +21,14 @@ public class Calculator { String em = e.getMessage().substring(index);
String token = em.substring(1,4);
- if (token.equals("ILL")){
+ if (token.equals("ILL")){ // Illegal token
em = em.substring(7);
index = em.indexOf("\"")-1;
if (index == 0){ // Special case in which the illegal token would be '"'
index = 2;
}
System.out.println("Illegal token: '"+ em.substring(0 , index) +"'.");
- }else if(token.equals("EOL")){
- System.out.println("Last read token: '<EOL>', w"+em.substring(em.indexOf("\nW")+2));
- }else if(em.split("\n").length > 1){
+ }else if(em.split("\n").length > 1){ //Other generated error messages
index = em.indexOf("\"");
if (index == 0){ // Meaning the last token is not <TOK> but "char"
em = em.substring(1);
@@ -39,7 +37,7 @@ public class Calculator { index--;
}
System.out.println("Last read token: '"+ em.substring(0 , index)+"', w"+em.substring(em.indexOf("\nW")+2));
- }else{ //Those were error messages created by ourselves, they are one line messages
+ }else{ //Those were error messages created by ourselves, they are one line messages that we can directly print
System.out.println(e.getMessage());
}
|