Skip to content

Commit

Permalink
Added backwards compatible 'parser' function
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterOlivier committed Sep 4, 2024
1 parent bcb2753 commit 5a2266b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/ParseTree.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ extend List;
extend Set;
import String;
import IO;
import Node;
@synopsis{The Tree data type as produced by the parser.}
Expand Down Expand Up @@ -401,6 +400,7 @@ catch ParseError(loc l): {
}
```
}
&T<:Tree parse(type[&T<:Tree] begin, str input, bool allowAmbiguity=false, bool allowRecovery=false, bool hasSideEffects=false, set[Tree(Tree)] filters={})
= parser(begin, allowAmbiguity=allowAmbiguity, allowRecovery=allowRecovery, hasSideEffects=hasSideEffects, filters=filters)(input, |unknown:///|);
Expand Down
4 changes: 4 additions & 0 deletions src/org/rascalmpl/library/Prelude.java
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,10 @@ public IFunction parser(IValue start, IBool allowAmbiguity, IBool allowRecovery
return rascalValues.parser(start, allowAmbiguity, allowRecovery, hasSideEffects, values.bool(false), filters);
}

public IFunction parser(IValue start, IBool allowAmbiguity, IBool hasSideEffects, ISet filters) {
return rascalValues.parser(start, allowAmbiguity, values.bool(false), hasSideEffects, values.bool(false), filters);

Check warning on line 2385 in src/org/rascalmpl/library/Prelude.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/library/Prelude.java#L2385

Added line #L2385 was not covered by tests
}

public IFunction firstAmbiguityFinder(IValue start, IBool allowRecovery, IBool hasSideEffects, ISet filters) {
return rascalValues.parser(start, values.bool(true), allowRecovery, hasSideEffects, values.bool(true), filters);
}
Expand Down
4 changes: 2 additions & 2 deletions src/org/rascalmpl/parser/gtd/SGTDBF.java
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ private void queueMatchableNode(AbstractStackNode<P> node, int length, AbstractN
terminalsTodo.push(node, result);
}

/**
/**
* Inserts a recovery node into the todoList, and possibly
* rewinds the parser to an earlier location in the input
*/
Expand Down Expand Up @@ -1043,7 +1043,7 @@ private boolean handleExpects(AbstractStackNode<P>[] expects, EdgesSet<P> cached
first = first.getCleanCopyWithResult(location, result);

queueMatchableNode(first, length, result);
}else{
} else {
first = first.getCleanCopy(location);
stacksToExpand.push(first);
}
Expand Down

0 comments on commit 5a2266b

Please sign in to comment.