1 33 34 package edu.rice.cs.drjava.model.repl.newjvm; 35 36 import koala.dynamicjava.parser.*; 38 import koala.dynamicjava.parser.wrapper.*; 39 40 44 public class SyntaxErrorResult implements InterpretResult { 45 private final int _startRow; 46 private final int _startCol; 47 private final int _endRow; 48 private final int _endCol; 49 50 private final String _errorMessage; 51 private final String _interaction; 52 53 public SyntaxErrorResult(ParseException pe, String s) { 54 _startRow = pe.getBeginLine(); 55 _startCol = pe.getBeginColumn(); 56 _endRow = pe.getEndLine(); 57 _endCol = pe.getEndColumn(); 58 _errorMessage = pe.getShortMessage(); 59 _interaction = s; 60 } 61 62 public SyntaxErrorResult(ParseError pe, String s) { 63 ParseException parseEx = pe.getParseException(); 64 if (parseEx != null) { 65 _startRow = parseEx.getBeginLine(); 66 _startCol = parseEx.getBeginColumn(); 67 _endRow = parseEx.getEndLine(); 68 _endCol = parseEx.getEndColumn(); 69 _errorMessage = parseEx.getShortMessage(); 70 } 71 else { 72 _startRow = _endRow = pe.getLine(); 73 _startCol = _endCol = pe.getColumn(); 74 _errorMessage = pe.getMessage(); 75 } 76 _interaction = s; 77 } 78 79 public SyntaxErrorResult(TokenMgrError pe, String s) { 80 _endRow = _startRow = pe.getErrorRow(); 81 _endCol = _startCol = pe.getErrorColumn() - 1; 84 _errorMessage = pe.getMessage(); 85 _interaction = s; 86 } 87 88 public String getErrorMessage() { return _errorMessage; } 89 90 public String getInteraction() { return _interaction; } 91 92 public int getStartRow() { return _startRow; } 93 public int getStartCol() { return _startCol; } 94 public int getEndRow() { return _endRow; } 95 public int getEndCol() { return _endCol; } 96 97 public <T> T apply(InterpretResultVisitor<T> v) { return v.forSyntaxErrorResult(this); } 98 99 public String toString() { return "(syntax error: " + _errorMessage + ")"; } 100 } | Popular Tags |