mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
60 lines (59 loc) • 2.19 kB
TypeScript
import { SyntaxError } from './InterpreterError';
/**
* Build project-level syntax errors from lexer/parser diagnostics.
*/
declare class SyntaxDiagnostic {
/**
* End-of-input diagnostics that ANTLR may emit for REPL-style snippets that
* MathJSLab accepts without a trailing separator.
*/
private static readonly benignEndOfInputMessages;
/**
* Create a syntax error with source location and a one-line excerpt.
*
* @param msg ANTLR diagnostic message.
* @param line One-based source line.
* @param column Zero-based source column.
* @param source Original source text, when available.
* @returns SyntaxError with normalized diagnostic text.
*/
static readonly error: (msg: string, line: number, column: number, source?: string) => SyntaxError;
/**
* Test whether an ANTLR diagnostic can be ignored for an accepted EOF form.
*
* @param msg ANTLR diagnostic message.
* @returns `true` when the message is a known benign EOF diagnostic.
*/
static readonly isBenignEndOfInput: (msg: string) => boolean;
/**
* Normalize unstable ANTLR message details before exposing them publicly.
*
* @param msg ANTLR diagnostic message.
* @returns Stable diagnostic message.
*/
private static readonly normalizeMessage;
/**
* Convert a zero-based source column to a rendered caret column.
*
* Tabs are preserved in the source excerpt but expanded to four columns for
* the caret line so diagnostics stay visually aligned in terminals.
*
* @param sourceLine Source line text.
* @param column Zero-based source column.
* @returns Zero-based display column.
*/
private static readonly displayColumn;
/**
* Return one source line using ANTLR's one-based line number.
*
* @param source Original source text.
* @param line One-based line number.
* @returns Source line text, or an empty string when unavailable.
*/
private static readonly sourceLine;
}
export { SyntaxDiagnostic };
declare const _default: {
SyntaxDiagnostic: typeof SyntaxDiagnostic;
};
export default _default;