From 5b6de005a3111548096b020d0422189e2b77be57 Mon Sep 17 00:00:00 2001 From: Maƫl Gassmann Date: Sat, 12 Jun 2021 18:10:06 +0200 Subject: [~] small correction and added comments --- calculator-javacc/Calculator.jj | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'calculator-javacc') 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: '', 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 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()); } -- cgit v1.2.3