package org.example; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; public class lox { public static void main(String[] args) throws IOException { switch (args.length) { case 0: RunPropmt(); return; case 1: InerpritFile(args[0]); return; default: System.out.println("Invalid arguments"); } } private static void RunPropmt() throws IOException { InputStreamReader inp = new InputStreamReader(System.in); BufferedReader reader= new BufferedReader(inp); while (true) { System.out.print("$ "); String prompt = reader.readLine(); if (prompt == null) break; run(prompt); } } private static void InerpritFile(String fileName) throws IOException { byte[] bytes = Files.readAllBytes(Paths.get(fileName)); run(new String(bytes, Charset.defaultCharset())); } private static void run(String program) { System.out.println(program); } }