Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
breck7 committed Jul 29, 2024
1 parent fa748c7 commit 84c2419
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrollsdk",
"version": "80.2.0",
"version": "80.3.0",
"description": "This npm package includes the Scroll Notation class, the Scroll Parser compiler-compiler, a Scroll IDE, and more, all implemented in TypeScript.",
"types": "./built/scrollsdk.node.d.ts",
"main": "./products/TreeNode.js",
Expand Down
11 changes: 11 additions & 0 deletions parsers/Parsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ interface arrowParser {
)
}

testTree.makeError = equal => {
// Arrange/Act/Assert
const program = makeJibberishProgram("")
const message = "My custom error"
const error = program.makeError(message)

// Assert
equal(error.message, message, "should be no errors")
equal(error.lineNumber, 1)
}

testTree.cellTypeTree = equal => {
// Act
const someJibberishProgram = makeJibberishProgram(`foo
Expand Down
16 changes: 16 additions & 0 deletions parsers/Parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ abstract class ParserBackedNode extends TreeNode {
return cellIndex === 0 ? this._getAutocompleteResultsForFirstWord(partialWord) : this._getAutocompleteResultsForCell(partialWord, cellIndex)
}

makeError(message: string) {
return new ParserDefinedError(this, message)
}

private _nodeIndex: {
[parserId: string]: ParserBackedNode[]
}
Expand Down Expand Up @@ -1288,6 +1292,18 @@ class UnknownParserError extends AbstractTreeError {
}
}

class ParserDefinedError extends AbstractTreeError {
constructor(node: ParserBackedNode, message: string) {
super()
this._node = node
this._message = message
}
private _message: string
get message() {
return this._message
}
}

class BlankLineError extends UnknownParserError {
get message(): string {
return super.message + ` Line: "${this.getNode().getLine()}". Blank lines are errors.`
Expand Down
13 changes: 13 additions & 0 deletions products/Parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class ParserBackedNode extends TreeNode {
getAutocompleteResults(partialWord, cellIndex) {
return cellIndex === 0 ? this._getAutocompleteResultsForFirstWord(partialWord) : this._getAutocompleteResultsForCell(partialWord, cellIndex)
}
makeError(message) {
return new ParserDefinedError(this, message)
}
get nodeIndex() {
// StringMap<int> {firstWord: index}
// When there are multiple tails with the same firstWord, _index stores the last content.
Expand Down Expand Up @@ -1034,6 +1037,16 @@ class UnknownParserError extends AbstractTreeError {
return this
}
}
class ParserDefinedError extends AbstractTreeError {
constructor(node, message) {
super()
this._node = node
this._message = message
}
get message() {
return this._message
}
}
class BlankLineError extends UnknownParserError {
get message() {
return super.message + ` Line: "${this.getNode().getLine()}". Blank lines are errors.`
Expand Down
13 changes: 13 additions & 0 deletions products/Parsers.ts.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class ParserBackedNode extends TreeNode {
getAutocompleteResults(partialWord, cellIndex) {
return cellIndex === 0 ? this._getAutocompleteResultsForFirstWord(partialWord) : this._getAutocompleteResultsForCell(partialWord, cellIndex)
}
makeError(message) {
return new ParserDefinedError(this, message)
}
get nodeIndex() {
// StringMap<int> {firstWord: index}
// When there are multiple tails with the same firstWord, _index stores the last content.
Expand Down Expand Up @@ -1032,6 +1035,16 @@ class UnknownParserError extends AbstractTreeError {
return this
}
}
class ParserDefinedError extends AbstractTreeError {
constructor(node, message) {
super()
this._node = node
this._message = message
}
get message() {
return this._message
}
}
class BlankLineError extends UnknownParserError {
get message() {
return super.message + ` Line: "${this.getNode().getLine()}". Blank lines are errors.`
Expand Down
2 changes: 1 addition & 1 deletion products/TreeNode.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ TreeNode.iris = `sepal_length,sepal_width,petal_length,petal_width,species
4.9,2.5,4.5,1.7,virginica
5.1,3.5,1.4,0.2,setosa
5,3.4,1.5,0.2,setosa`
TreeNode.getVersion = () => "80.2.0"
TreeNode.getVersion = () => "80.3.0"
class AbstractExtendibleTreeNode extends TreeNode {
_getFromExtended(firstWordPath) {
const hit = this._getNodeFromExtended(firstWordPath)
Expand Down
2 changes: 1 addition & 1 deletion products/TreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ TreeNode.iris = `sepal_length,sepal_width,petal_length,petal_width,species
4.9,2.5,4.5,1.7,virginica
5.1,3.5,1.4,0.2,setosa
5,3.4,1.5,0.2,setosa`
TreeNode.getVersion = () => "80.2.0"
TreeNode.getVersion = () => "80.3.0"
class AbstractExtendibleTreeNode extends TreeNode {
_getFromExtended(firstWordPath) {
const hit = this._getNodeFromExtended(firstWordPath)
Expand Down
3 changes: 3 additions & 0 deletions releaseNotes.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import changes.parsers

thinColumns 4

πŸ“¦ 80.3.0 2024-7-29
πŸŽ‰ added `makeError` method to ParserBackedNode

πŸ“¦ 80.2.0 2024-7-10
πŸŽ‰ now the ScrollSDK tools can be used straight from the WWS ~scroll/sdk/index.html

Expand Down
2 changes: 1 addition & 1 deletion treeNode/TreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3043,7 +3043,7 @@ class TreeNode extends AbstractNode {
return str ? indent + str.replace(/\n/g, indent) : ""
}

static getVersion = () => "80.2.0"
static getVersion = () => "80.3.0"

static fromDisk(path: string): TreeNode {
const format = this._getFileFormat(path)
Expand Down

0 comments on commit 84c2419

Please sign in to comment.