本文整理汇总了Java中org.spoofax.jsglr.shared.SGLRException类的典型用法代码示例。如果您正苦于以下问题:Java SGLRException类的具体用法?Java SGLRException怎么用?Java SGLRException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SGLRException类属于org.spoofax.jsglr.shared包,在下文中一共展示了SGLRException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parse
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Override
public IStrategoTerm parse(Source src, @Nullable String overridingStartSymbol) {
if (parser == null) {
createParser();
}
String startSymbol = this.startSymbol;
if (overridingStartSymbol != null) {
startSymbol = overridingStartSymbol;
}
try {
final Disambiguator disambiguator = parser.getDisambiguator();
disambiguator.setFilterPriorities(false);
SGLRParseResult parseResult = parser.parse(IOUtils.toString(src.getInputStream(), Charset.defaultCharset()),
src.getPath(), startSymbol);
IStrategoTerm term = (IStrategoTerm) parseResult.output;
return term;
} catch (SGLRException | InterruptedException | IOException e) {
throw new IllegalStateException("File failed to parse", e);
}
}
开发者ID:metaborg,项目名称:dynsem,代码行数:23,代码来源:DynSemLanguageParser.java
示例2: main
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
/**
* @param args
* @throws InvalidParseTableException
* @throws IOException
* @throws SGLRException
* @throws ParseError
* @throws ParseException
* @throws BadTokenException
* @throws TokenExpectedException
*/
public static void main(String[] args) throws SGLRException, IOException, InvalidParseTableException {
JavaParser.init();
STermCursor term = JavaParser.parseStream(Class2Table.class.getResourceAsStream("../examples/Example.java.ex"), "Example.java");
// final MultiMap<String, String> resultMap = aspectVariant(term);
final MultiMap<String, String> resultMap2 = ancestorVariant(term);
for(Entry<String, List<String>> entry : resultMap2.entrySet()) {
System.out.printf("%25s calls: ", entry.getKey());
for(String s : entry.getValue()) {
System.out.print(s + " ");
}
System.out.println();
}
// System.out.println("aspectVariant(t).equals(ancestorVariant(t)) = " + resultMap.equals(resultMap2));
}
开发者ID:nuthatchery,项目名称:nuthatch-javafront,代码行数:27,代码来源:CallAnalysis.java
示例3: testMove001
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testMove001() throws TokenExpectedException, FileNotFoundException, BadTokenException, ParseException, IOException, SGLRException, InterruptedException
{
String fname1 = "tests/test-inputs/test-move1-001.java";
String fname2 = "tests/test-inputs/test-move2-001.java";
IStrategoTerm trm1 = parseFile(fname1);
IStrategoTerm trm2 = parseFile(fname2);
AbstractTreeMatcher treeMatcher = new HeuristicTreeMatcher(false, false, true);
TreeEditDistance editDistance = new TreeEditDistance();
editDistance.detectTreeEditActions(trm1, trm2, treeMatcher);
Assert.assertEquals(83, countMatches(trm2));
assertEquals(0, editDistance.getDeletionCount());
assertEquals(0, editDistance.getInsertionCount());
assertEquals(1, editDistance.getMovedCount());
assertEquals(0, editDistance.getRelabeledCount());
assertEquals(0, editDistance.getValueChangeCount());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:19,代码来源:TestEditDistance.java
示例4: testMove004
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testMove004() throws TokenExpectedException, FileNotFoundException, BadTokenException, ParseException, IOException, SGLRException, InterruptedException
{
String fname1 = "tests/test-inputs/test-move1-004.java";
String fname2 = "tests/test-inputs/test-move2-004.java";
IStrategoTerm trm1 = parseFile(fname1);
IStrategoTerm trm2 = parseFile(fname2);
AbstractTreeMatcher treeMatcher = new HeuristicTreeMatcher(false, false, false);
TreeEditDistance editDistance = new TreeEditDistance();
editDistance.detectTreeEditActions(trm1, trm2, treeMatcher);
Assert.assertEquals(121, countMatches(trm2));
assertEquals(0, editDistance.getDeletionCount());
assertEquals(0, editDistance.getInsertionCount());
assertEquals(4, editDistance.getMovedCount());
assertEquals(0, editDistance.getRelabeledCount());
assertEquals(0, editDistance.getValueChangeCount());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:19,代码来源:TestEditDistance.java
示例5: test_no_recovery_1
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void test_no_recovery_1() throws FileNotFoundException, IOException, TokenExpectedException, BadTokenException, ParseException, SGLRException, InterruptedException {
// [] -> strategy
// ---
// _ -> strategy
String path = "tests-editregions/stratego/edit-sequence";
String fname_corr = path + "/edit_"+ 26 + ".str.scn";
String fname_err = path + "/edit_"+ 27 + ".str.scn";
lastErr0AST = parseFile(fname_corr);
String erroneousInput = loadAsString(fname_err);
editRegionRecovery = new EditRegionDetector(lastErr0AST, erroneousInput);
try {
parseString(editRegionRecovery.getRecoveredInput());
System.out.println("recovered: " + fname_err);
}
catch (Exception e) {
System.err.println("failed: " + fname_err);
System.err.println(editRegionRecovery.getDeletedSubstrings());
System.err.println(editRegionRecovery.getInsertedSubstrings());
System.err.println(editRegionRecovery.getEditedRegionsCorrect());
System.err.println(editRegionRecovery.getEditedRegionsErroneous());
System.err.println(editRegionRecovery.getEditedTerms());
}
}
开发者ID:metaborg,项目名称:jsglr,代码行数:27,代码来源:TestEditSequenceStratego.java
示例6: test_no_recovery_2
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void test_no_recovery_2() throws FileNotFoundException, IOException, TokenExpectedException, BadTokenException, ParseException, SGLRException, InterruptedException {
// ;result := $[Seq([strategy], [<concat-listOfIfs(|x)> xs])]
// ---
// ; result := $[Seq([strategy], [])]
String path = "tests-editregions/stratego/edit-sequence";
String fname_corr = path + "/edit_"+ 35 + ".str.scn";
String fname_err = path + "/edit_"+ 36 + ".str.scn";
lastErr0AST = parseFile(fname_corr);
String erroneousInput = loadAsString(fname_err);
editRegionRecovery = new EditRegionDetector(lastErr0AST, erroneousInput);
try {
parseString(editRegionRecovery.getRecoveredInput());
System.out.println("recovered: " + fname_err);
}
catch (Exception e) {
System.err.println("failed: " + fname_err);
System.err.println(editRegionRecovery.getDeletedSubstrings());
System.err.println(editRegionRecovery.getInsertedSubstrings());
System.err.println(editRegionRecovery.getEditedRegionsCorrect());
System.err.println(editRegionRecovery.getEditedRegionsErroneous());
System.err.println(editRegionRecovery.getEditedTerms());
}
}
开发者ID:metaborg,项目名称:jsglr,代码行数:27,代码来源:TestEditSequenceStratego.java
示例7: testSuccessByJSGLR1
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
protected void testSuccessByJSGLR1(String inputString) {
for(JSGLR2Variants.Variant variant : JSGLR2Variants.testVariants()) {
IParseTable parseTable = getParseTable(variant.parseTable);
IStrategoTerm actualOutputAst = testSuccess(parseTable, variant.parser, null, inputString);
try {
IStrategoTerm expectedOutputAst = (IStrategoTerm) getJSGLR1().parse(inputString, null, null).output;
assertEqualTermExpansions(expectedOutputAst, actualOutputAst);
} catch(SGLRException | InterruptedException | InvalidParseTableException e) {
e.printStackTrace();
fail();
}
}
}
开发者ID:metaborg,项目名称:jsglr,代码行数:17,代码来源:BaseTestWithJSGLR1.java
示例8: main
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
public static void main(String[] args) throws SGLRException, IOException, InvalidParseTableException {
JavaParser.init();
STermCursor term = JavaParser.parseStream(Class2Table.class.getResourceAsStream("../examples/Example.java.ex"), "Example.java");
Collection<Table> tables = transform(term);
for(Table t : tables) {
System.out.println(t.toSQL());
}
}
开发者ID:nuthatchery,项目名称:nuthatch-javafront,代码行数:10,代码来源:Class2Table.java
示例9: getInitEditorServices
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
public List<IStrategoTerm> getInitEditorServices() {
if (initEditorServices == null) {
try {
initEditorServices = ATermCommands.parseEditorServiceFile(StdLib.editorServicesParser, getInitEditor());
} catch (SGLRException | InterruptedException | IOException e) {
e.printStackTrace();
initEditorServices = Collections.emptyList();
}
}
return initEditorServices;
}
开发者ID:sugar-lang,项目名称:base-lang,代码行数:12,代码来源:AbstractBaseLanguage.java
示例10: testMove002
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testMove002() throws TokenExpectedException, FileNotFoundException, BadTokenException, ParseException, IOException, SGLRException, InterruptedException
{
String fname1 = "tests/test-inputs/test-move1-002.java";
String fname2 = "tests/test-inputs/test-move2-002.java";
IStrategoTerm trm1 = parseFile(fname1);
IStrategoTerm trm2 = parseFile(fname2);
AbstractTreeMatcher treeMatcher = new HeuristicTreeMatcher(false, false, true);
TreeEditDistance editDistance = new TreeEditDistance();
editDistance.detectTreeEditActions(trm1, trm2, treeMatcher);
Assert.assertEquals(83, countMatches(trm2));
assertEquals(0, editDistance.getDeletionCount());
assertEquals(0, editDistance.getInsertionCount());
assertEquals(1, editDistance.getMovedCount());
assertEquals(0, editDistance.getRelabeledCount());
assertEquals(0, editDistance.getValueChangeCount());
IStrategoTerm trm_1 = parseFile(fname1);
IStrategoTerm trm_2 = parseFile(fname2);
AbstractTreeMatcher treeMatcher2 = new HeuristicTreeMatcher(false, false, false);
TreeEditDistance editDistance2 = new TreeEditDistance();
editDistance2.detectTreeEditActions(trm_1, trm_2, treeMatcher2);
Assert.assertEquals(67, countMatches(trm_2));
assertEquals(16, editDistance2.getDeletionCount());
assertEquals(16, editDistance2.getInsertionCount());
assertEquals(0, editDistance2.getMovedCount());
assertEquals(0, editDistance2.getRelabeledCount());
assertEquals(0, editDistance2.getValueChangeCount());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:32,代码来源:TestEditDistance.java
示例11: testInsertion
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testInsertion() throws TokenExpectedException, FileNotFoundException, BadTokenException, ParseException, IOException, SGLRException, InterruptedException, InterruptedException
{
String fname1 = "tests/test-inputs/test-insertion1-001.java";
String fname2 = "tests/test-inputs/test-insertion2-001.java";
IStrategoTerm trm1 = parseFile(fname1);
IStrategoTerm trm2 = parseFile(fname2);
AbstractTreeMatcher treeMatcher = new HeuristicTreeMatcher(false, false, false);
TreeEditDistance editDistance = new TreeEditDistance();
editDistance.detectTreeEditActions(trm1, trm2, treeMatcher);
Assert.assertEquals(68, countMatches(trm2));
assertEquals(0, editDistance.getDeletionCount());
assertEquals(15, editDistance.getInsertionCount());
assertEquals(0, editDistance.getMovedCount());
assertEquals(0, editDistance.getRelabeledCount());
assertEquals(0, editDistance.getValueChangeCount());
//With support for matching moved terms
AbstractTreeMatcher treeMatcher_move = new HeuristicTreeMatcher(false, false, true);
TreeEditDistance editDistance2 = new TreeEditDistance();
IStrategoTerm trm_1 = parseFile(fname1);
IStrategoTerm trm_2 = parseFile(fname2);
editDistance2.detectTreeEditActions(trm_1, trm_2, treeMatcher_move);
TreeEditDistance editDistance_move = editDistance2;
Assert.assertEquals(68, countMatches(trm_2));
assertEquals(0, editDistance_move.getDeletionCount());
assertEquals(15, editDistance_move.getInsertionCount());
assertEquals(0, editDistance_move.getMovedCount());
assertEquals(0, editDistance_move.getRelabeledCount());
assertEquals(0, editDistance_move.getValueChangeCount());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:33,代码来源:TestEditDistance.java
示例12: applyTopSortFilter
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
protected AbstractParseNode applyTopSortFilter(String sort, AbstractParseNode t) throws SGLRException {
if (Tools.debugging) {
Tools.debug("applyTopSortFilter() - ", t);
}
if (sort != null && filterTopSort) {
t = selectOnTopSort(t, sort);
if (t == null) {
throw new StartSymbolException(parser, "Desired start symbol not found: " + sort);
}
}
return t;
}
开发者ID:metaborg,项目名称:jsglr,代码行数:16,代码来源:Disambiguator.java
示例13: checkImmediateAcceptance
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
private Frame checkImmediateAcceptance(String startSymbol) throws InterruptedException {
if(acceptingStack == null) {
int tmpToken = currentToken.getToken();
int tmpTokenOffset = currentToken.getOffset();
ArrayDeque<Frame> tmpActiveStacks = new ArrayDeque<Frame>(activeStacks);
ArrayDeque<Frame> tmpForActor = new ArrayDeque<Frame>(forActor);
currentToken.setToken(256);
currentToken.setOffset(Integer.MAX_VALUE);
; // EOF
try {
parseCharacter();
} finally {
currentToken.setToken(tmpToken);
currentToken.setOffset(tmpTokenOffset);
activeStacks.clear();
activeStacks.addAll(tmpActiveStacks);
forActor.clear();
forActor.addAll(tmpForActor);
}
}
// if we now have an accepting stack
if(acceptingStack != null) {
Object node = null;
try {
node = disambiguator.applyTopSortFilter(startSymbol, acceptingStack.findDirectLink(startFrame).label);
} catch(SGLRException e) {
// ignore here
}
if(node == null)
acceptingStack = null;
}
Frame result = acceptingStack;
acceptingStack = null;
return result;
}
开发者ID:metaborg,项目名称:jsglr,代码行数:40,代码来源:SGLR.java
示例14: testMove005
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testMove005() throws TokenExpectedException, FileNotFoundException, BadTokenException, ParseException, IOException, SGLRException, InterruptedException
{
//fail();//TODO: check results manually
String fname1 = "tests/test-inputs/test-move1-005.java";
String fname2 = "tests/test-inputs/test-move2-005.java";
IStrategoTerm trm1 = parseFile(fname1);
IStrategoTerm trm2 = parseFile(fname2);
AbstractTreeMatcher treeMatcher = new HeuristicTreeMatcher(false, false, false);
TreeEditDistance editDistance = new TreeEditDistance();
editDistance.detectTreeEditActions(trm1, trm2, treeMatcher);
Assert.assertEquals(79, countMatches(trm2));
assertEquals(12, editDistance.getDeletionCount());
assertEquals(39, editDistance.getInsertionCount());
assertEquals(1, editDistance.getMovedCount());
assertEquals(0, editDistance.getRelabeledCount());
assertEquals(0, editDistance.getValueChangeCount());
//With support for matching moved terms
AbstractTreeMatcher treeMatcher_move = new HeuristicTreeMatcher(false, false, true);
TreeEditDistance editDistance2 = new TreeEditDistance();
IStrategoTerm trm_1 = parseFile(fname1);
IStrategoTerm trm_2 = parseFile(fname2);
editDistance2.detectTreeEditActions(trm_1, trm_2, treeMatcher_move);
TreeEditDistance editDistance_move = editDistance2;
Assert.assertEquals(91, countMatches(trm_2));
assertEquals(0, editDistance_move.getDeletionCount());
assertEquals(27, editDistance_move.getInsertionCount());
assertEquals(1, editDistance_move.getMovedCount());
assertEquals(0, editDistance_move.getRelabeledCount());
assertEquals(0, editDistance_move.getValueChangeCount());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:34,代码来源:TestEditDistance.java
示例15: testDeletedRegion
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testDeletedRegion() throws IOException, InvalidParseTableException, TokenExpectedException, BadTokenException, ParseException, SGLRException, InterruptedException {
String pathToErroneousFile = pathToJavaTestInputs + "/deletion.java";
String erroneousInput = loadAsString(pathToErroneousFile);
ArrayList<Integer> discardOffsets = super.getDiscardOffsets(lastErr0AST, erroneousInput);
String concatenated = concatenatedDiscardChars(erroneousInput, discardOffsets);
super.parseString(editRegionRecovery.getRecoveredInput());
Assert.assertEquals("v+=\n\t\t", concatenated);
}
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:TestEditRegionBasic.java
示例16: testMultipleDeletedRegions
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testMultipleDeletedRegions() throws IOException, InvalidParseTableException, TokenExpectedException, BadTokenException, ParseException, SGLRException, InterruptedException {
String pathToErroneousFile = pathToJavaTestInputs + "/multiple-deletions.java";
String erroneousInput = loadAsString(pathToErroneousFile);
//System.out.println(lastErr0AST);
ArrayList<Integer> discardOffsets = super.getDiscardOffsets(lastErr0AST, erroneousInput);
String concatenated = concatenatedDiscardChars(erroneousInput, discardOffsets);
//Assert.assertEquals("package \n\t\t= 10;\n\t\tSystem..println(v);", concatenated);
super.parseString(editRegionRecovery.getRecoveredInput());
Assert.assertEquals("package = .", concatenated);
}
开发者ID:metaborg,项目名称:jsglr,代码行数:12,代码来源:TestEditRegionBasic.java
示例17: testDeletionAndInsertion
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testDeletionAndInsertion() throws IOException, InvalidParseTableException, TokenExpectedException, BadTokenException, ParseException, SGLRException, InterruptedException {
String pathToErroneousFile = pathToJavaTestInputs + "/deletion-and-insertion.java";
String erroneousInput = loadAsString(pathToErroneousFile);
ArrayList<Integer> discardOffsets = super.getDiscardOffsets(lastErr0AST, erroneousInput);
String concatenated = concatenatedDiscardChars(erroneousInput, discardOffsets);
super.parseString(editRegionRecovery.getRecoveredInput());
Assert.assertEquals(" + 5 +\n\t\tSystem.out.println(v", concatenated);
//System.out.println(editRegionRecovery.getRecoveredInput());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:11,代码来源:TestEditRegionBasic.java
示例18: testReplacement
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testReplacement() throws IOException, InvalidParseTableException, TokenExpectedException, BadTokenException, ParseException, SGLRException, InterruptedException {
String pathToErroneousFile = pathToJavaTestInputs + "/replacement.java";
String erroneousInput = loadAsString(pathToErroneousFile);
ArrayList<Integer> discardOffsets = super.getDiscardOffsets(lastErr0AST, erroneousInput);
String concatenated = concatenatedDiscardChars(erroneousInput, discardOffsets);
super.parseString(editRegionRecovery.getRecoveredInput());
Assert.assertEquals("v = v +;\n\t\t", concatenated);
Assert.assertEquals(127, editRegionRecovery.getCorrectInput().length());
Assert.assertEquals(128, editRegionRecovery.getErroneousInput().length());
Assert.assertEquals(128, editRegionRecovery.getRecoveredInput().length());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:13,代码来源:TestEditRegionBasic.java
示例19: testDelInsNesting
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testDelInsNesting() throws IOException, InvalidParseTableException, TokenExpectedException, BadTokenException, ParseException, SGLRException, InterruptedException {
String pathToErroneousFile = pathToJavaTestInputs + "/del-ins-nesting.java";
String erroneousInput = loadAsString(pathToErroneousFile);
ArrayList<Integer> discardOffsets = super.getDiscardOffsets(lastErr0AST, erroneousInput);
String concatenated = concatenatedDiscardChars(erroneousInput, discardOffsets);
super.parseString(editRegionRecovery.getRecoveredInput());
Assert.assertEquals("private void m(int x, int y, int z{\n int v = 10;\n v+= 10;\n print(\n System.out.println(v);\n }", concatenated);
}
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:TestEditRegionBasic.java
示例20: testDeletedOperator1
import org.spoofax.jsglr.shared.SGLRException; //导入依赖的package包/类
@Test
public void testDeletedOperator1() throws IOException, InvalidParseTableException, TokenExpectedException, BadTokenException, ParseException, SGLRException {
String expectedConcatenatedDiscards = "3 ";
String pathToErroneousFile = pathToJavaTestInputs + "/delete-operator-1.java";
testDiscardedCharacters(expectedConcatenatedDiscards, pathToErroneousFile);
super.parseString(editRegionRecovery.getRecoveredInput());
}
开发者ID:metaborg,项目名称:jsglr,代码行数:8,代码来源:TestEditRegionOperators.java
注:本文中的org.spoofax.jsglr.shared.SGLRException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论