Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #18 from documente/tokenize-done-at-end-of-lines
Browse files Browse the repository at this point in the history
Tokenize 'done' at end of lines
  • Loading branch information
pckerneis authored Dec 25, 2023
2 parents cb026bd + ba53ebc commit 475c9da
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@ export function tokenize(sentence: string): Token[] {
throw new Error(prettyPrintError(message, sentence, { line, column }));
};

function isAtEndOfLine() {
let j = i;

while (j < sentence.length) {
const char = sentence[j];

if (char === ' ' || char === '\t') {
j++;
} else return char === '\n';
}
}

function pushToken() {
if (currentToken === '') {
return;
}

let kind: Token['kind'] = 'generic';

if (currentToken === 'done' && isAtStartOfLine) {
if (currentToken === 'done' && (isAtStartOfLine || isAtEndOfLine())) {
kind = 'done';
} else if (currentToken === '-' && isAtStartOfLine) {
kind = 'bullet';
Expand Down

0 comments on commit 475c9da

Please sign in to comment.