Skip to content

Commit

Permalink
Fixed #509 parsing regression from infinite loop fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Jul 3, 2024
1 parent 0010660 commit bd228dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
We'll note all notable changes in this file, including bug fixes, enhancements, and all closed issues.
Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http://semver.org/) format.

## 0.10.3 2024-07-07

### Fixed

- [#509](https://github.com/wordplaydev/wordplay/issues/509) Fixed parsing regression from infinite loop fixes.

## 0.10.2 2024-06-29

### Fixed
Expand Down
7 changes: 5 additions & 2 deletions src/parser/Tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,19 @@ export default class Tokens {
/** Used to read the remainder of a line, unless there are no more tokens, or we reach the end of a code example. */
readLine() {
const nodes: Token[] = [];
let onFirst = true;

if (!this.hasNext()) return nodes;
// Read at least one token, then keep going until we reach a token with a line break.
// If there are more tokens, and and it's not the end of a code block in markup, and we're either on the first token, or the next token has a line break, read another token.
this.untilDo(
() =>
this.hasNext() &&
this.nextHasPrecedingLineBreak() === false &&
(onFirst === true ||
this.nextHasPrecedingLineBreak() === false) &&
this.nextIsnt(Sym.Code),
() => {
const next = this.read();
onFirst = false;
nodes.push(next);
},
);
Expand Down

0 comments on commit bd228dd

Please sign in to comment.