Skip to content

Commit

Permalink
throw error on unexpected parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
asnewman committed Jan 2, 2025
1 parent ed2bc01 commit c9cedc6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The most basic application will look like this:
<head>
<meta charset="UTF-8" />
<title>Example</title>
<script src="https://cdn.jsdelivr.net/gh/asnewman/ashjs@v0.0.6/index.js"></script>
<script src="https://cdn.jsdelivr.net/gh/asnewman/ashjs@v0.0.9/index.js"></script>
</head>
<body class="">
<div id="ashjs"></div>
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@
};
this.currLevels[this.currDashLevel - 1].body.push(newStringExpression);
this.cursor++;
} else {
console.log({ tokens: this.tokens });
throw new Error(`Unexpected token ${JSON.stringify(this.tokens[this.cursor])} (token # ${this.cursor})`);
}
}
return this.result;
Expand Down
5 changes: 5 additions & 0 deletions parseMarkup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ export class Parser {
this.currLevels[this.currDashLevel - 1].body.push(newStringExpression);
this.cursor++;
}

else {
console.log({tokens: this.tokens})
throw new Error(`Unexpected token ${JSON.stringify(this.tokens[this.cursor])} (token # ${this.cursor})`)
}
}

return this.result;
Expand Down

0 comments on commit c9cedc6

Please sign in to comment.