diff --git a/.gitignore b/.gitignore index ed96f5c..811c835 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ grammar.json node_modules npm-debug.log debug-* +test.txt \ No newline at end of file diff --git a/README.md b/README.md index cba22fe..941024f 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ The ABL-specific scopes produced by the ABL grammar listed in the table below. T |punctuation.definition.string.end.abl | Closing `"` or `'` of a quoted string | |punctuation.section.abl | `{` and `}` | |punctuation.separator.comma.abl | `,` | -|punctuation.separator.continuation | `~` at the end of a line (preprocessor) | +|punctuation.separator.continuation.abl | `~` at the end of a line (preprocessor) | |punctuation.separator.period.abl | `.` | |punctuation.terminator.abl | `.` and `:` | |storage.data.database.abl | Statically-defined database names, e.g.in the `create alias` statement | diff --git a/abl.tmLanguage.json b/abl.tmLanguage.json index 64aad96..1453f3a 100644 --- a/abl.tmLanguage.json +++ b/abl.tmLanguage.json @@ -3213,35 +3213,24 @@ "match": "(~)\\s*$", "captures": { "1": { - "name": "punctuation.separator.continuation" + "name": "punctuation.separator.continuation.abl" } } }, "branch-return-value-double": { "comment": "RETURN \"return-value\"", - "begin": "(?i)\\s*(return)(\\s+(error))?\\s+(\")", - "beginCaptures": { + "match": "(?i)\\s*(return)(\\s+(error))?\\s+(?=\")", + "captures": { "1": { "name": "keyword.other.abl" }, - "2": { + "3": { "name": "keyword.other.abl" }, - "3": { + "4": { "name": "punctuation.definition.string.begin.abl" } - }, - "end": "(\")", - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.abl" - } - }, - "patterns": [ - { - "include": "#escape-char" - } - ] + } }, "branch-return-no-apply": { "comment": "RETURN NO-APPLY", diff --git a/spec/global-scoped-define/global-define.spec.js b/spec/global-scoped-define/global-define.spec.js index 1d135c6..e849ec0 100644 --- a/spec/global-scoped-define/global-define.spec.js +++ b/spec/global-scoped-define/global-define.spec.js @@ -21,7 +21,7 @@ SOMETHING value`; [ { "startIndex": 0, "endIndex": 1, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.definition.preprocessor.abl"] }, // '&' { "startIndex": 1, "endIndex": 14, "scopes": ["source.abl", "meta.preprocessor.abl", "keyword.control.directive.define.abl"] }, // 'global-define' - { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.separator.continuation"] } // '~' + { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.separator.continuation.abl"] } // '~' ], [ { "startIndex": 0, "endIndex": 9, "scopes": ["source.abl", "meta.preprocessor.abl", "entity.name.function.preprocessor.abl"] }, // 'SOMETHING' @@ -42,19 +42,19 @@ done`; [ { "startIndex": 0, "endIndex": 1, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.definition.preprocessor.abl"] }, // '&' { "startIndex": 1, "endIndex": 14, "scopes": ["source.abl", "meta.preprocessor.abl", "keyword.control.directive.define.abl"] }, // 'global-define' - { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.separator.continuation"] } // '~' + { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.separator.continuation.abl"] } // '~' ], [ { "startIndex": 0, "endIndex": 9, "scopes": ["source.abl", "meta.preprocessor.abl", "entity.name.function.preprocessor.abl"] }, // 'SOMETHING' { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl", "meta.preprocessor.abl"] }, // ' ' { "startIndex": 10, "endIndex": 15, "scopes": ["source.abl", "keyword.other.abl"] }, // 'value' - { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl", "punctuation.separator.continuation"] } // '~' + { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl", "punctuation.separator.continuation.abl"] } // '~' ], [ { "startIndex": 0, "endIndex": 4, "scopes": ["source.abl", "variable.other.abl"] }, // 'more' { "startIndex": 4, "endIndex": 5, "scopes": ["source.abl"] }, // ' ' { "startIndex": 5, "endIndex": 10, "scopes": ["source.abl", "keyword.other.abl"] }, // 'value' - { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl", "punctuation.separator.continuation"] } // '~' + { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl", "punctuation.separator.continuation.abl"] } // '~' ], [ { "startIndex": 0, "endIndex": 4, "scopes": ["source.abl", "variable.other.abl"] } // 'done' diff --git a/spec/global-scoped-define/scoped-define-with-procedure-keyword.spec.js b/spec/global-scoped-define/scoped-define-with-procedure-keyword.spec.js index 09a5b4e..3ab5612 100644 --- a/spec/global-scoped-define/scoped-define-with-procedure-keyword.spec.js +++ b/spec/global-scoped-define/scoped-define-with-procedure-keyword.spec.js @@ -55,12 +55,12 @@ Procedure`; { "startIndex": 0, "endIndex": 1, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.definition.preprocessor.abl"] }, // '&' { "startIndex": 1, "endIndex": 14, "scopes": ["source.abl", "meta.preprocessor.abl", "keyword.control.directive.define.abl"] }, // 'Scoped-define' { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "meta.preprocessor.abl"] }, // ' ' - { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.separator.continuation"] } // '~' + { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.separator.continuation.abl"] } // '~' ], [ { "startIndex": 0, "endIndex": 14, "scopes": ["source.abl", "meta.preprocessor.abl", "entity.name.function.preprocessor.abl"] }, // 'PROCEDURE-TYPE' { "startIndex": 14, "endIndex": 16, "scopes": ["source.abl", "meta.preprocessor.abl"] }, // ' ' - { "startIndex": 16, "endIndex": 17, "scopes": ["source.abl", "punctuation.separator.continuation"] } // '~' + { "startIndex": 16, "endIndex": 17, "scopes": ["source.abl", "punctuation.separator.continuation.abl"] } // '~' ], [ { "startIndex": 0, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] } // 'Procedure' diff --git a/spec/misc-statements/return-statement.spec.js b/spec/misc-statements/return-statement.spec.js index c854460..629f6a3 100644 --- a/spec/misc-statements/return-statement.spec.js +++ b/spec/misc-statements/return-statement.spec.js @@ -61,4 +61,78 @@ describe('', () => { { "startIndex": 19, "endIndex": 20, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' ]; shared.itShouldMatchExpectedScopes(statement, expectedTokens); +}) + +describe('', () => { + let statement = `PROCEDURE xyz: + RETURN ERROR "ok". + RETURN "ok". +END.`; + let expectedTokens = [ + [ + { "startIndex": 0, "endIndex": 9, "scopes": ["source.abl", "meta.procedure.abl", "keyword.other.abl"] }, // 'PROCEDURE' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl", "meta.procedure.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 13, "scopes": ["source.abl", "meta.procedure.abl", "entity.name.procedure.abl"] }, // 'xyz' + { "startIndex": 13, "endIndex": 14, "scopes": ["source.abl", "punctuation.terminator.abl"] } // ':' + ], + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 3, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'RETURN' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 15, "scopes": ["source.abl", "keyword.other.abl"] }, // 'ERROR' + { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 16, "endIndex": 17, "scopes": ["source.abl", "string.quoted.double.abl", "punctuation.definition.string.begin.abl"] }, // '"' + { "startIndex": 17, "endIndex": 19, "scopes": ["source.abl", "string.quoted.double.abl"] }, // 'ok' + { "startIndex": 19, "endIndex": 20, "scopes": ["source.abl", "string.quoted.double.abl", "punctuation.definition.string.end.abl"] }, // '"' + { "startIndex": 20, "endIndex": 21, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ], + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 3, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'RETURN' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl", "string.quoted.double.abl", "punctuation.definition.string.begin.abl"] }, // '"' + { "startIndex": 11, "endIndex": 13, "scopes": ["source.abl", "string.quoted.double.abl"] }, // 'ok' + { "startIndex": 13, "endIndex": 14, "scopes": ["source.abl", "string.quoted.double.abl", "punctuation.definition.string.end.abl"] }, // '"' + { "startIndex": 14, "endIndex": 15, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ], + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'END' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ] + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); +}) + +describe('', () => { + let statement = `FUNCTION X RETURNS CHARACTER(): + RETURN "asdfasdf". +END.`; + let expectedTokens = [ + [ + { "startIndex": 0, "endIndex": 8, "scopes": ["source.abl", "keyword.other.abl"] }, // 'FUNCTION' + { "startIndex": 8, "endIndex": 9, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl", "variable.other.abl"] }, // 'X' + { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 11, "endIndex": 18, "scopes": ["source.abl", "keyword.other.abl"] }, // 'RETURNS' + { "startIndex": 18, "endIndex": 19, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 19, "endIndex": 28, "scopes": ["source.abl", "entity.name.function.abl"] }, // 'CHARACTER' + { "startIndex": 28, "endIndex": 29, "scopes": ["source.abl", "meta.function.arguments.abl", "meta.brace.round.js"] }, // '(' + { "startIndex": 29, "endIndex": 30, "scopes": ["source.abl", "meta.brace.round.js"] }, // ')' + { "startIndex": 30, "endIndex": 31, "scopes": ["source.abl", "punctuation.terminator.abl"] } // ':' + ], + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 3, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'RETURN' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl", "string.quoted.double.abl", "punctuation.definition.string.begin.abl"] }, // '"' + { "startIndex": 11, "endIndex": 19, "scopes": ["source.abl", "string.quoted.double.abl"] }, // 'asdfasdf' + { "startIndex": 19, "endIndex": 20, "scopes": ["source.abl", "string.quoted.double.abl", "punctuation.definition.string.end.abl"] }, // '"' + { "startIndex": 20, "endIndex": 21, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ], + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'END' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ] + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); }) \ No newline at end of file