Skip to content

Commit

Permalink
Removed CycleMark stuff because it is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterOlivier committed Dec 14, 2024
1 parent 4f89f00 commit ea0a9aa
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module lang::rascal::tests::concrete::MemoCycleTest

import ParseTree;
import vis::Text;
import IO;

syntax S = T | U;

Expand All @@ -12,6 +11,7 @@ syntax U = X T? | "$";

syntax X = "b"? | "c";

// Test for regression of a bug in the node flattener
test bool memoCycleBug() {
Tree tree = parse(#S, "bc$", |unknown:///|, allowAmbiguity=true);
if (amb({appl1, appl2 }) := tree) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ protected static class IsInError{
/**
* Convert the given node.
*/
public T convert(INodeConstructorFactory<T, S> nodeConstructorFactory, AbstractNode node, IndexedStack<AbstractNode> stack, int depth, CycleMark cycleMark, PositionStore positionStore, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object environment){
public T convert(INodeConstructorFactory<T, S> nodeConstructorFactory, AbstractNode node, IndexedStack<AbstractNode> stack, int depth, PositionStore positionStore, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object environment){
switch(node.getTypeIdentifier()){
case CharNode.ID:
return charNodeConverter.convertToUPTR(nodeConstructorFactory, (CharNode) node);
case LiteralNode.ID:
return literalNodeConverter.convertToUPTR(nodeConstructorFactory, (LiteralNode) node);
case SortContainerNode.ID:
return sortContainerNodeConverter.convertToUPTR(this, nodeConstructorFactory, (SortContainerNode<P>) node, stack, depth, cycleMark, positionStore, filteringTracker, actionExecutor, environment);
return sortContainerNodeConverter.convertToUPTR(this, nodeConstructorFactory, (SortContainerNode<P>) node, stack, depth, positionStore, filteringTracker, actionExecutor, environment);
case ExpandableContainerNode.ID:
return listContainerNodeConverter.convertToUPTR(this, nodeConstructorFactory, (ExpandableContainerNode<P>) node, stack, depth, cycleMark, positionStore, filteringTracker, actionExecutor, environment);
return listContainerNodeConverter.convertToUPTR(this, nodeConstructorFactory, (ExpandableContainerNode<P>) node, stack, depth, positionStore, filteringTracker, actionExecutor, environment);
case RecoveredNode.ID:
return convert(nodeConstructorFactory, ((SortContainerNode<S>) node).getFirstAlternative().getNode(), stack, depth, cycleMark, positionStore, filteringTracker, actionExecutor, environment);
return convert(nodeConstructorFactory, ((SortContainerNode<S>) node).getFirstAlternative().getNode(), stack, depth, positionStore, filteringTracker, actionExecutor, environment);
case SkippedNode.ID:
return recoveryNodeConverter.convertToUPTR(nodeConstructorFactory, (SkippedNode) node);
default:
Expand All @@ -76,6 +76,6 @@ public T convert(INodeConstructorFactory<T, S> nodeConstructorFactory, AbstractN
* Converts the given parse tree to a tree in UPTR format.
*/
public T convert(INodeConstructorFactory<T, S> nodeConstructorFactory, AbstractNode parseTree, PositionStore positionStore, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object rootEnvironment){
return convert(nodeConstructorFactory, parseTree, new IndexedStack<AbstractNode>(), 0, new CycleMark(), positionStore, filteringTracker, actionExecutor, rootEnvironment);
return convert(nodeConstructorFactory, parseTree, new IndexedStack<>(), 0, positionStore, filteringTracker, actionExecutor, rootEnvironment);
}
}
29 changes: 1 addition & 28 deletions src/org/rascalmpl/parser/gtd/result/out/INodeFlattener.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,5 @@ public interface INodeFlattener<T, P>{
*/
T convert(INodeConstructorFactory<T, P> nodeConstructorFactory, AbstractNode parseTree, PositionStore positionStore, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object rootEnvironment);

T convert(INodeConstructorFactory<T, P> nodeConstructorFactory, AbstractNode parseTree, IndexedStack<AbstractNode> stack, int depth, CycleMark cycleMark, PositionStore positionStore, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object rootEnvironment);

/**
* Internal helper structure for cycle detection and handling.
*/
static class CycleMark{
public int depth = Integer.MAX_VALUE;

public CycleMark(){
super();
}

/**
* Marks the depth at which a cycle was detected.
*/
public void setMark(int depth){
if(depth < this.depth){
this.depth = depth;
}
}

/**
* Resets the mark.
*/
public void reset(){
depth = Integer.MAX_VALUE;
}
}
T convert(INodeConstructorFactory<T, P> nodeConstructorFactory, AbstractNode parseTree, IndexedStack<AbstractNode> stack, int depth, PositionStore positionStore, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object rootEnvironment);
}
Loading

0 comments on commit ea0a9aa

Please sign in to comment.