creating:scanning

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
creating:scanning [2026/11/17 04:47] – Minor spelling fixes ahelwercreating:scanning [2026/11/19 02:58] (current) – Change BufferedReader to class variable ahelwer
Line 8: Line 8:
  
 Almost everything in [[https://craftinginterpreters.com/scanning.html#the-interpreter-framework|section 4.1]] can be left unchanged from what's given, although of course it makes sense to change some of the names from "Lox" to "TlaPlus" or similar. Almost everything in [[https://craftinginterpreters.com/scanning.html#the-interpreter-framework|section 4.1]] can be left unchanged from what's given, although of course it makes sense to change some of the names from "Lox" to "TlaPlus" or similar.
-We do make one small functional modification: TLA⁺ source files are assumed to be encoded in UTF-8, a variable-width ASCII-compatible encoding, so we specify that when performing the file read.+We do make some small modifications: TLA⁺ source files are assumed to be encoded in UTF-8, a variable-width ASCII-compatible encoding, so we specify that when performing the file read; we also make the ''BufferedReader'' instance a class variable instead of a local variable, so ignore its definition in ''runPrompt()''.
 Here's our main file, ''TlaPlus.java'': Here's our main file, ''TlaPlus.java'':
  
-<code java [enable_line_numbers="true",highlight_lines_extra="1,6,11,27"]>+<code java [enable_line_numbers="true",highlight_lines_extra="1,6,11,12,13,29"]>
 package tla; package tla;
  
Line 23: Line 23:
  
 public class TlaPlus { public class TlaPlus {
 +  private static BufferedReader reader =
 +      new BufferedReader(new InputStreamReader(System.in));
   static boolean hadError = false;   static boolean hadError = false;
  
Line 45: Line 47:
  
   private static void runPrompt() throws IOException {   private static void runPrompt() throws IOException {
-    InputStreamReader input = new InputStreamReader(System.in); 
-    BufferedReader reader = new BufferedReader(input); 
  
     for (;;) {     for (;;) {
  • creating/scanning.txt
  • Last modified: 2026/11/19 02:58
  • by ahelwer