Skip to content

Commit

Permalink
Start to thread option through
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltoli committed Oct 11, 2023
1 parent b84a314 commit 752ea57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class ParseInModule implements Serializable, AutoCloseable {
private final boolean forGlobalScanner;
private final FileUtil files;
private final String typeInferenceDebug;
private final boolean partialParseDebug;

ParseInModule(Module seedModule, boolean strict, boolean profileRules, boolean isBison, boolean forGlobalScanner, FileUtil files, String typeInferenceDebug) {
this(seedModule, null, null, null, null, strict, profileRules, isBison, forGlobalScanner, files, typeInferenceDebug);
Expand All @@ -84,6 +85,7 @@ private ParseInModule(Module seedModule, Module extensionModule, Module disambMo
this.forGlobalScanner = forGlobalScanner;
this.files = files;
this.typeInferenceDebug = typeInferenceDebug;
this.partialParseDebug = true;
}

/**
Expand Down Expand Up @@ -217,7 +219,7 @@ private void getParser(Scanner scanner, Sort startSymbol) {
EarleyParser p = parser;
if (p == null) {
Module m = getParsingModule();
p = new EarleyParser(m, scanner, startSymbol);
p = new EarleyParser(m, scanner, startSymbol, partialParseDebug);
parser = p;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,9 @@ public List<Integer> getColumns() {
* @param scanner The scanner used to tokenize strings over this grammar.
* @param startSymbol The start symbol to start parsing at.
*/
public EarleyParser(Module m, Scanner scanner, Sort startSymbol) {
public EarleyParser(Module m, Scanner scanner, Sort startSymbol, boolean partialParseDebug) {
this.scanner = scanner;
this.partialParseDebug = partialParseDebug;

// compute metadata about grammar
sorts = getSorts(m);
Expand Down Expand Up @@ -790,6 +791,8 @@ private BitSet[] computeFirstSet() {
private final BitSet nullable;
// the scanner to use to tokenize sentences before parsing them
private final Scanner scanner;
// whether to print detailed partial parse trees when an error occurs
private final boolean partialParseDebug;

/**
* Parse a sentence according to the grammar represented by this parser.
Expand Down Expand Up @@ -865,7 +868,7 @@ public Term parse(String input, Source source, int startLine, int startColumn) {
* @param S The set of {@link EarleyState}s for each end-index in the input
* @param k The end-index at which a parse error occurred. In other words, the index just prior to the first token that
*/
private void parseError(ParserMetadata data, EarleySet S, int k) {
private void parseError(ParserMetadata data, List<EarleySet> S, int k) {
int startLine, startColumn, endLine, endColumn;
if (data.words.length == 1) {
startLine = data.lines[0];
Expand Down

0 comments on commit 752ea57

Please sign in to comment.