Skip to content

Commit e12273a

Browse files
committed
updating readme & commenting main
1 parent 5158037 commit e12273a

3 files changed

Lines changed: 9 additions & 69 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- *BONUS*: Syntax error message (this is where we did the accept/reject string. If the given code aka. grammar is not a Python language, reject it. In other words, throw a syntax error message).
2121

2222
## How to Use/Run the Interpreter
23-
*insert instructions here*
23+
- In command line, navigate to src/com/popl and run "javac PythonInterpreter.java" and then navigate to src and run "java com/popl/python_interpreter/PythonInterpreter"
2424

2525
## Grading Criteria
2626
- A working interpreter – 60%

‎python_test_code.py‎

Lines changed: 0 additions & 67 deletions
This file was deleted.

‎src/com/popl/python_interpreter/PythonInterpreter.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,27 @@ public static void main(String[] args) {
1616
File pythonFile;
1717
List<String> fileLines = new ArrayList<>();
1818

19+
//prompt user to insert their file name and save variable for the file
1920
System.out.println("Enter the name of your Python file (ex: script.py): ");
2021
fileName = scan.nextLine();
2122

23+
//try to read the file
2224
try {
25+
//create a python file and scan it
2326
pythonFile = new File(fileName);
2427
fileScanner = new Scanner(pythonFile);
28+
//for every line in the file
2529
while (fileScanner.hasNextLine()) {
2630
String data = fileScanner.nextLine();
31+
//ignore lines with comments, read file
2732
if (!data.matches("#.*")) {
2833
fileLines.add(data);
2934
}
3035
}
3136
fileScanner.close();
32-
} catch (FileNotFoundException e) {
37+
}
38+
//throw errors
39+
catch (FileNotFoundException e) {
3340
System.out.println("An error occurred.");
3441
e.printStackTrace();
3542
}

0 commit comments

Comments
 (0)