Search in sources :

Example 1 with ParseException

use of abs.frontend.parser.ParseException in project abstools by abstools.

the class SyntaxErrorCollector method syntaxError.

@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
    SyntaxError err = new SyntaxError(msg, line, charPositionInLine + 1);
    err.setFile(filename);
    parserErrors.add(err);
    // super.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
    if (raiseExceptions) {
        throw new ParseException(err);
    }
}
Also used : SyntaxError(abs.frontend.parser.SyntaxError) ParseException(abs.frontend.parser.ParseException)

Example 2 with ParseException

use of abs.frontend.parser.ParseException in project abstools by abstools.

the class ABSCodeScanner method setRange.

/**
 * Gets called before the first {@link #nextToken()}. Parses the current document.
 *
 * @see org.eclipse.jface.text.rules.ITokenScanner#setRange(org.eclipse.jface.text.IDocument, int, int)
 */
@Override
public void setRange(IDocument document, int offset, int length) {
    Assert.isLegal(document != null);
    final int documentLength = document.getLength();
    checkRange(offset, length, documentLength);
    fDocument = document;
    fOffset = offset;
    fRangeEnd = offset + length;
    String[] delimiters = fDocument.getLegalLineDelimiters();
    fDelimiters = new char[delimiters.length][];
    for (int i = 0; i < delimiters.length; i++) fDelimiters[i] = delimiters[i].toCharArray();
    String doccontent = document.get();
    try {
        compilationUnit = null;
        Main absParser = new Main();
        absParser.setTypeChecking(false);
        compilationUnit = absParser.parseUnit(new File(fEditor.getEditorInput().getName()), doccontent, new StringReader(doccontent));
        Model m;
        // Redmine #86: inh eq CompilationUnit...lookupModule() requires a parent.
        (m = new Model()).addCompilationUnit(compilationUnit);
    } catch (ParseException e) {
        if (doDebug)
            e.printStackTrace();
    } catch (Exception e) {
        if (doDebug)
            e.printStackTrace();
    }
}
Also used : StringReader(java.io.StringReader) ParseException(abs.frontend.parser.ParseException) Main(abs.frontend.parser.Main) File(java.io.File) ParseException(abs.frontend.parser.ParseException) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

ParseException (abs.frontend.parser.ParseException)2 Main (abs.frontend.parser.Main)1 SyntaxError (abs.frontend.parser.SyntaxError)1 File (java.io.File)1 StringReader (java.io.StringReader)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1