-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Debugging WIP * Fixing inline serialization * Several fixes * More tests, string quotes fix * Error mesages * Error test 2 * New test * Error display wip * WIP * Fix error messages * More errors fixed * MathGrammar debugging leftover cleanup
- Loading branch information
1 parent
52b0557
commit 7a33b38
Showing
20 changed files
with
1,612 additions
and
586 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,50 @@ | ||
/** | ||
* @template Value | ||
* @typedef {{ | ||
* status: Boolean, | ||
* value: Value, | ||
* position: Number, | ||
* }} Result | ||
*/ | ||
|
||
export default class Reply { | ||
|
||
/** | ||
* @template Value | ||
* @template T | ||
* @param {Number} position | ||
* @param {Value} value | ||
* @param {T} value | ||
* @param {PathNode} bestPath | ||
* @returns {Result<T>} | ||
*/ | ||
static makeSuccess(position, value) { | ||
return /** @type {Result<Value>} */({ | ||
static makeSuccess(position, value, bestPath = null, bestPosition = 0) { | ||
return { | ||
status: true, | ||
value: value, | ||
position: position, | ||
}) | ||
bestParser: bestPath, | ||
bestPosition: bestPosition, | ||
} | ||
} | ||
|
||
/** | ||
* @template Value | ||
* @param {Number} position | ||
* @param {PathNode} bestPath | ||
* @returns {Result<null>} | ||
*/ | ||
static makeFailure(position) { | ||
return /** @type {Result<Value>} */({ | ||
static makeFailure(position = 0, bestPath = null, bestPosition = 0) { | ||
return { | ||
status: false, | ||
value: null, | ||
position: position, | ||
}) | ||
position, | ||
bestParser: bestPath, | ||
bestPosition: bestPosition, | ||
} | ||
} | ||
|
||
/** @param {Parsernostrum<Parser<any>>} parsernostrum */ | ||
static makeContext(parsernostrum = null, input = "") { | ||
return /** @type {Context} */({ | ||
parsernostrum: parsernostrum, | ||
input: input, | ||
visited: new Map(), | ||
parsernostrum, | ||
input, | ||
highlighted: null, | ||
}) | ||
} | ||
|
||
static makePathNode(parser, index = 0, previous = null) { | ||
return /** @type {PathNode} */({ | ||
parent: previous, | ||
parser, | ||
index, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.