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;
}
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);
}
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);
}
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();
}
}
Aggregations