/** * Description : This program is inspired from python running on my Systems Comand Prompt terminal. * I started this program with the idea of making a calculator * Later i open my window and thought about what if i make it feel like python running * But its actually JAVA my old buddy :-) * ------------------------------------------------------------------------------------------------ * @Rohit_Roy * @version 2021.0 (created on 01.12.2021) * @Student, Bsc CS Hons. (1st Year) * @SXC, Kolkata * ------------------------------------------------------------------------------------------------ */ /**# * PythonTerminal => String input errors updated w.r.t quotes and blank spaces */ import java.util.*; // import java.lang.String; public class PythonTerminal { static String inputs; // gets the string from user static double num[]; // to store the numbers or the operands static char opera[]; // to store the operators static int size; // stores the number of operators static int count; // no. of spaces present public static void accept() { Scanner sc=new Scanner(System.in); //System.out.println("Your Calculator is here..."); System.out.print("\n>>> "); inputs = sc.nextLine(); int len=inputs.length(); size=0; for(int i=0;i\", line 1"); System.out.println(" "+ x); System.out.println(" ^"); System.out.println("SyntaxError: unterminated string literal (detected at line1)"); } else if( end == '\"' || end == '\'' ) { System.out.println(" File \"\", line 1"); System.out.println(" "+ x); System.out.println(" "+ addChar(x,' ')+"^"); System.out.println("SyntaxError: unterminated string literal (detected at line1)"); } else if(count>=1) { System.out.println(" File \"\", line 1"); System.out.println(" "+ x); System.out.println(" "+addChar(x,'^')); System.out.println("SyntaxError: invalid syntax. Perhaps you forget a comma?"); } else { System.out.println("Traceback (most recent call last):"); System.out.println(" File \"\", line 1, in "); System.out.println("NameError: name '"+x+ "' is not defined"); } } } public static void main(String[] args) { accept(); if(inputs.equals("exit()") || inputs.equals("exit(0)")) { System.exit(0); } else { num=new double[size+1]; opera=new char[size]; fillArray(inputs+" ","",0,0); /* for(int i=0;i0) System.out.println(result); else recognize(inputs); } main(args); // calls the main function }// end of main() } // end of class