aboutsummaryrefslogtreecommitdiff
path: root/calculator-javacc
diff options
context:
space:
mode:
authorMaël Gassmann <mael.gassmann@students.bfh.ch>2021-06-12 18:10:06 +0200
committerMaël Gassmann <mael.gassmann@students.bfh.ch>2021-06-12 18:10:06 +0200
commit5b6de005a3111548096b020d0422189e2b77be57 (patch)
treed480c27c0ea1ff30522d4af988bb9011c6ea54ab /calculator-javacc
parent3bc2064a0999f1b635028156be43190da439be13 (diff)
[~] small correction and added comments
Diffstat (limited to 'calculator-javacc')
-rw-r--r--calculator-javacc/Calculator.jj8
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());
}