Ejemplo n.º 1
0
 public void setParsedStatement(int lineNumber, Statement stmt) {
   if (cursor.number == lineNumber) {
     cursor.lineStmt = stmt;
   } else {
     System.out.println("cursor not in the right position");
   }
 }
Ejemplo n.º 2
0
 // Insert a new statement helper function
 private void recInsertSorted(SourceLine program, int lineNumber, String source) {
   if (program == null || lineNumber < program.number) {
     // Create a new line
     SourceLine newLine = new SourceLine();
     newLine.number = lineNumber;
     newLine.source = source;
     newLine.next = program;
     program = newLine;
     cursor = newLine;
     System.out.println("new line added");
   } else if (lineNumber == program.number) {
     program.source = source;
     cursor = program;
     System.out.println("line modified");
   } else {
     recInsertSorted(program.next, lineNumber, source);
   }
 }