Skip to content

Commit 5b6e17c

Browse files
committed
Correctly seperate statements when parsing document
Signed-off-by: worksofliam <[email protected]>
1 parent 6d7eb8a commit 5b6e17c

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/language/sql/document.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export default class Document {
5151
case `keyword`:
5252
switch (tokens[i].value?.toUpperCase()) {
5353
case `BEGIN`:
54+
case `DO`:
5455
// We include BEGIN in the current statement
5556
// then the next statement beings
5657
const statementTokens = tokens.slice(statementStart, i+1);

src/language/sql/statement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class Statement {
4343
// These statements can end with BEGIN, which signifies a block starter
4444
if ([StatementType.Create, StatementType.Declare].includes(this.type)) {
4545
const last = this.tokens[this.tokens.length-1];
46-
if (tokenIs(last, `keyword`, `BEGIN`)) {
46+
if (tokenIs(last, `keyword`, `BEGIN`) || tokenIs(last, `keyword`, `DO`)) {
4747
return true;
4848
}
4949
}

src/language/sql/tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class SQLTokeniser {
7474
{
7575
name: `KEYWORD`,
7676
match: [{ type: `word`, match: (value: string) => {
77-
return [`AS`, `FOR`, `OR`, `REPLACE`, `BEGIN`, `END`, `CURSOR`, `DEFAULT`, `HANDLER`, `REFERENCES`, `ON`, `UNIQUE`, `SPECIFIC`, `EXTERNAL`].includes(value.toUpperCase());
77+
return [`AS`, `FOR`, `OR`, `REPLACE`, `BEGIN`, `DO`, `END`, `CURSOR`, `DEFAULT`, `HANDLER`, `REFERENCES`, `ON`, `UNIQUE`, `SPECIFIC`, `EXTERNAL`].includes(value.toUpperCase());
7878
} }],
7979
becomes: `keyword`,
8080
},

0 commit comments

Comments
 (0)