-
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.
The implementation wasn't fundamentally changed! Mainly, I shifted code closer to whatever was referencing it.
- Loading branch information
Showing
29 changed files
with
267 additions
and
312 deletions.
There are no files selected for viewing
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
23 changes: 8 additions & 15 deletions
23
src/Implementation/Parsing/Inline/Tokenizing/BacktrackedConventionHelper.ts
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,29 +1,22 @@ | ||
import { ConventionContext } from './ConventionContext' | ||
import { OpenConvention } from './OpenConvention' | ||
import { ConventionVariation } from './ConventionVariation' | ||
|
||
|
||
// We use this class to keep track of which conventions we've been forced to backtrack. | ||
export class BacktrackedConventionHelper { | ||
private failedConventionsByMarkupIndex: FailedConventionsByTextIndex = {} | ||
private failedConventionsByMarkupIndex: { | ||
[markupIndex: number]: ConventionVariation[] | ||
} = {} | ||
|
||
registerFailure(contextOfFailedConvention: ConventionContext): void { | ||
const { convention, snapshot } = contextOfFailedConvention | ||
const { markupIndex } = snapshot | ||
registerFailure(failure: OpenConvention): void { | ||
const { markupIndex } = failure.tokenizerSnapshotWhenOpening | ||
|
||
if (!this.failedConventionsByMarkupIndex[markupIndex]) { | ||
this.failedConventionsByMarkupIndex[markupIndex] = [] | ||
} | ||
|
||
this.failedConventionsByMarkupIndex[markupIndex].push(convention) | ||
this.failedConventionsByMarkupIndex[markupIndex] ??= [] | ||
this.failedConventionsByMarkupIndex[markupIndex].push(failure.convention) | ||
} | ||
|
||
hasFailed(convention: ConventionVariation, markupIndex: number): boolean { | ||
const failedConventions = (this.failedConventionsByMarkupIndex[markupIndex] ?? []) | ||
return failedConventions.some(failedConvention => failedConvention === convention) | ||
} | ||
} | ||
|
||
|
||
interface FailedConventionsByTextIndex { | ||
[markupIndex: number]: ConventionVariation[] | ||
} |
53 changes: 0 additions & 53 deletions
53
src/Implementation/Parsing/Inline/Tokenizing/ConventionContext.ts
This file was deleted.
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
10 changes: 5 additions & 5 deletions
10
...ng/ForgivingConventions/StartDelimiter.ts → ...givingConventions/ActiveStartDelimiter.ts
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,23 +1,23 @@ | ||
export class StartDelimiter { | ||
export class ActiveStartDelimiter { | ||
constructor( | ||
public tokenIndex: number, | ||
public delimiterText: string, | ||
public remainingLength = delimiterText.length) { | ||
} | ||
|
||
get isUnused(): boolean { | ||
isUnused(): boolean { | ||
return this.remainingLength === this.delimiterText.length | ||
} | ||
|
||
get isFullyExhausted(): boolean { | ||
isFullyExhausted(): boolean { | ||
return this.remainingLength <= 0 | ||
} | ||
|
||
shortenBy(length: number): void { | ||
this.remainingLength -= length | ||
} | ||
|
||
clone(): StartDelimiter { | ||
return new StartDelimiter(this.tokenIndex, this.delimiterText, this.remainingLength) | ||
clone(): ActiveStartDelimiter { | ||
return new ActiveStartDelimiter(this.tokenIndex, this.delimiterText, this.remainingLength) | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/Implementation/Parsing/Inline/Tokenizing/OpenConvention.ts
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ConventionVariation } from './ConventionVariation' | ||
import { ForgivingConventionHandler } from './ForgivingConventions/ForgivingConventionHandler' | ||
import { Token } from './Token' | ||
|
||
|
||
export class OpenConvention { | ||
constructor( | ||
public convention: ConventionVariation, | ||
public tokenizerSnapshotWhenOpening: { | ||
markupIndex: number | ||
markupIndexThatLastOpenedAConvention?: number | ||
bufferedContent: string | ||
tokens: Token[] | ||
openConventions: OpenConvention[] | ||
forgivingConventionHandlers: ForgivingConventionHandler[] | ||
}, | ||
public startTokenIndex = tokenizerSnapshotWhenOpening.tokens.length) { } | ||
|
||
clone(): OpenConvention { | ||
return new OpenConvention( | ||
this.convention, | ||
this.tokenizerSnapshotWhenOpening, | ||
this.startTokenIndex) | ||
} | ||
} |
Oops, something went wrong.