NonTerminalCall.java

/* Generated by: CongoCC Parser Generator. NonTerminalCall.java */
package de.schegge.rosinante.parser;

public class NonTerminalCall { 

    final String sourceFile;
    public final String productionName;
    final String parserClassName;
    final TokenSource tokenSource;
    final int position, line, column;
    int javaSourceLine;

    public NonTerminalCall(String parserClassName, Node location, String sourceFile, String productionName, int line, int column) { 
        this.parserClassName = parserClassName;
        this.tokenSource = location.getTokenSource();
        this.position = location.getBeginOffset();
        this.sourceFile = sourceFile;
        this.productionName = productionName;
        this.line = line;
        this.column = column;
    }

    public String getLocation() { 
        return tokenSource.getInputSource() + ":" + tokenSource.getLineFromOffset(position) + ":" + tokenSource.getCodePointColumnFromOffset(position);
    }

    StackTraceElement createStackTraceElement() { 
        return new StackTraceElement("ProtocolbuffersParser", productionName, sourceFile, line);
    }

    public String toString() { 
        StringBuilder buf = new StringBuilder();
        buf.append("at ");
        buf.append(getLocation());
        buf.append(" in ");
        String javaSourceLocation = javaSourceLine > 0 ? "," + parserClassName + ".java:" + javaSourceLine : "";
        return "at " + getLocation() + " in " + productionName + "(" + sourceFile + ":" + line + ":" + column + javaSourceLocation + ")\n";
    }
}