Search in sources :

Example 6 with Main

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

the class IncrementalModelBuilder method getStdLibCompilationUnit.

private CompilationUnit getStdLibCompilationUnit() {
    CompilationUnit stdLib;
    File bundle;
    try {
        stdLib = new Main().getStdLib();
        bundle = FileLocator.getBundleFile(Platform.getBundle(ABSFRONTEND_PLUGIN_ID));
    } catch (IOException e) {
        Activator.logException(e);
        // Your plugin is probably busted.
        return null;
    } catch (InternalBackendException e) {
        Activator.logException(e);
        // Your plugin is probably busted.
        return null;
    }
    File src = new File(bundle, stdLib.getFileName());
    if (!src.exists()) {
        src = new File(bundle, "src/" + stdLib.getFileName());
    }
    stdLib.setName(src.getAbsolutePath());
    return stdLib;
}
Also used : CompilationUnit(abs.frontend.ast.CompilationUnit) InternalBackendException(abs.backend.common.InternalBackendException) IOException(java.io.IOException) File(java.io.File) Main(abs.frontend.parser.Main)

Example 7 with Main

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

the class ABSTest method assertParseFileOk.

/**
 * Note: does not handle EXPECT_*.
 */
public static Model assertParseFileOk(String fileName, Config... config) throws IOException, WrongProgramArgumentException, InternalBackendException {
    Main main = new Main();
    main.setWithStdLib(isSet(WITH_STD_LIB, config));
    Model m = main.parseFiles(resolveFileName(fileName));
    m.evaluateAllProductDeclarations();
    return assertParseModelOk(m, config);
}
Also used : Model(abs.frontend.ast.Model) Main(abs.frontend.parser.Main)

Example 8 with Main

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

the class ABSTest method assertParseFilesOk.

protected Model assertParseFilesOk(Set<String> fileNames, Config... config) throws IOException, InternalBackendException {
    Main main = new Main();
    main.setWithStdLib(isSet(WITH_STD_LIB, config));
    Model m = main.parseFiles(fileNames.toArray(new String[0]));
    return assertParseModelOk(m, config);
}
Also used : Model(abs.frontend.ast.Model) Main(abs.frontend.parser.Main)

Example 9 with Main

use of abs.frontend.parser.Main 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

Main (abs.frontend.parser.Main)9 File (java.io.File)6 CompilationUnit (abs.frontend.ast.CompilationUnit)4 Model (abs.frontend.ast.Model)3 IOException (java.io.IOException)3 SemanticConditionList (abs.frontend.analyser.SemanticConditionList)2 StringReader (java.io.StringReader)2 ArrayList (java.util.ArrayList)2 PackageAbsFile (org.absmodels.abs.plugin.editor.outline.PackageAbsFile)2 NoModelException (org.absmodels.abs.plugin.internal.NoModelException)2 InternalBackendException (abs.backend.common.InternalBackendException)1 SemanticCondition (abs.frontend.analyser.SemanticCondition)1 ParseException (abs.frontend.parser.ParseException)1 PackageEntry (org.absmodels.abs.plugin.editor.outline.PackageEntry)1 TypecheckInternalException (org.absmodels.abs.plugin.internal.TypecheckInternalException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 Test (org.junit.Test)1