Beispiel #1
0
  private void error(int kind, String arg) {
    StringBuilder out = new StringBuilder();

    String origin = this.input.origin;

    int errPos = input.positionOfMark(); // note use of source adjusted position
    int ln = input.getLnNum(errPos);
    int col = input.getColPos(errPos);

    String msg =
        (ContextStatics.useVerboseErrors ? "[Compiler] Error #" + kind + ": " : "")
            + ctx.errorString(kind);

    if (debug) {
      msg = "[Scanner] " + msg;
    }

    int nextLoc = Context.replaceStringArg(out, msg, 0, arg);
    if (nextLoc != -1) // append msg remainder after replacement point, if any
    out.append(msg.substring(nextLoc, msg.length()));

    ctx.localizedError(origin, ln, col, out.toString(), input.getLineText(errPos), kind);
    skiperror(kind);
  }
Beispiel #2
0
 private void error(String msg) {
   ctx.internalError(msg);
   error(kError_Lexical_General, msg);
 }
Beispiel #3
0
 public Scanner(Context cx, String in, String origin, boolean save_comments) {
   init(cx, save_comments);
   this.input = new InputBuffer(in, origin);
   cx.input = this.input; // FIXME: how nicely external state altering.
 }
Beispiel #4
0
 /**
  * This contructor is used by Flex direct AST generation. It allows Flex to pass in a specialized
  * InputBuffer.
  */
 public Scanner(Context cx, InputBuffer input) {
   init(cx, true);
   this.input = input;
   cx.input = input; // so now we get to look around to find out who does this...
 }
Beispiel #5
0
 public Scanner(
     Context cx, InputStream in, String encoding, String origin, boolean save_comments) {
   init(cx, save_comments);
   this.input = new InputBuffer(in, encoding, origin);
   cx.input = this.input;
 }