From 70ffd3f0c269ac27cd748ed9ffed3ea18b020738 Mon Sep 17 00:00:00 2001 From: marlenecota Date: Sat, 29 Jul 2017 21:03:23 -0700 Subject: [PATCH 1/4] added support for Small Basic --- gulpfile.js | 3 +- src/monaco.contribution.ts | 6 + src/sb.ts | 114 +++++++++++++++++ test/all.js | 1 + test/sb.test.ts | 256 +++++++++++++++++++++++++++++++++++++ 5 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 src/sb.ts create mode 100644 test/sb.test.ts diff --git a/gulpfile.js b/gulpfile.js index e671c5e9..5e7479b7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -76,7 +76,8 @@ gulp.task('release', ['clean-release','compile'], function() { bundleOne('src/vb'), bundleOne('src/xml'), bundleOne('src/yaml'), - bundleOne('src/solidity') + bundleOne('src/solidity'), + bundleOne('src/sb') ) .pipe(uglify({ output: { diff --git a/src/monaco.contribution.ts b/src/monaco.contribution.ts index 9073acd1..55879f3a 100644 --- a/src/monaco.contribution.ts +++ b/src/monaco.contribution.ts @@ -266,3 +266,9 @@ registerLanguage({ aliases: ['sol', 'solidity', 'Solidity'], module: './solidity' }); +registerLanguage({ + id: 'sb', + extensions: ['.sb'], + aliases: ['Small Basic', 'sb'], + module: './sb' +}); diff --git a/src/sb.ts b/src/sb.ts new file mode 100644 index 00000000..3f9bd87e --- /dev/null +++ b/src/sb.ts @@ -0,0 +1,114 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export const conf: IRichLanguageConfiguration = { + comments: { + lineComment: '\'', + }, + brackets: [ + ['(', ')'], ['[', ']'], + ['If', 'EndIf'], + ['While', 'EndWhile'], + ['For', 'EndFor'], + ['Sub', 'EndSub'] + ], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + ] +}; + +export const language = { + defaultToken: '', + tokenPostfix: '.sb', + ignoreCase: true, + + brackets: [ + { token: 'delimiter.array', open: '[', close: ']' }, + { token: 'delimiter.parenthesis', open: '(', close: ')' }, + + // Special bracket statement pairs + { token: 'keyword.tag-if', open: 'If', close: 'EndIf' }, + { token: 'keyword.tag-while', open: 'While', close: 'EndWhile' }, + { token: 'keyword.tag-for', open: 'For', close: 'EndFor' }, + { token: 'keyword.tag-sub', open: 'Sub', close: 'EndSub' }, + ], + + keywords: [ + 'And', 'Else', 'ElseIf', 'EndFor', 'EndIf', 'EndSub', 'EndWhile', + 'For', 'Goto', 'If', 'Or', 'Step', 'Sub', 'Then', 'To', 'While' + ], + + tagwords: [ + 'If', 'Sub', 'While', 'For' + ], + + operators: [ + '>', '<', '<>', '<=', '>=', 'And', + 'Or', '+', '-', '*', '/', '=', + ], + + // we include these common regular expressions + symbols: /[=><.,:+\-\/]+/, + escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, + + // The main tokenizer for our languages + tokenizer: { + root: [ + + // whitespace + { include: '@whitespace' }, + + // usual ending tags + [/end([a-zA-Z_]\w*)/, { token: 'keyword.tag-$1' }], + + // identifiers, tagwords, and keywords + [/[a-zA-Z_]\w*/, { + cases: { + '@tagwords': { token: 'keyword.tag-$0' }, + '@keywords': { token: 'keyword.$0' }, + '@default': 'identifier' + } + }], + + // Preprocessor directive + [/^\s*#\w+/, 'keyword'], + + // numbers + [/\d*\.\d+/, 'number.float'], + [/\d+/, 'number'], + + // date literal + [/#.*#/, 'number'], + + // delimiters and operators + [/[()\[\]]/, '@brackets'], + [/@symbols/, 'delimiter'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"/, 'string', '@string'], + + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [/(\'|REM(?!\w)).*$/, 'comment'], + ], + + string: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"C?/, 'string', '@pop'] + ], + }, +}; diff --git a/test/all.js b/test/all.js index 0800a46c..91cd206b 100644 --- a/test/all.js +++ b/test/all.js @@ -58,6 +58,7 @@ requirejs([ 'out/test/xml.test', 'out/test/yaml.test', 'out/test/solidity.test', + 'out/test/sb.test' ], function() { run(); // We can launch the tests! }); diff --git a/test/sb.test.ts b/test/sb.test.ts new file mode 100644 index 00000000..c68ebb8f --- /dev/null +++ b/test/sb.test.ts @@ -0,0 +1,256 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { testTokenization } from './testRunner'; + +testTokenization('sb', [ + + // Comments - single line + [{ + line: '\'', + tokens: [ + { startIndex: 0, type: 'comment.sb' } + ] + }], + + [{ + line: ' \' a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.sb' } + ] + }], + + [{ + line: '\' a comment', + tokens: [ + { startIndex: 0, type: 'comment.sb' } + ] + }], + + [{ + line: '\'sticky comment', + tokens: [ + { startIndex: 0, type: 'comment.sb' } + ] + }], + + [{ + line: '1 \' 2< \' comment', + tokens: [ + { startIndex: 0, type: 'number.sb' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'comment.sb' } + ] + }], + + [{ + line: 'x = 1 \' my comment \'\' is a nice one', + tokens: [ + { startIndex: 0, type: 'identifier.sb' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.sb' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.sb' } + ] + }], + + // Numbers + [{ + line: '0', + tokens: [ + { startIndex: 0, type: 'number.sb' } + ] + }], + + [{ + line: '0.0', + tokens: [ + { startIndex: 0, type: 'number.float.sb' } + ] + }], + + [{ + line: '23.5', + tokens: [ + { startIndex: 0, type: 'number.float.sb' } + ] + }], + + [{ + line: '1 -0', + tokens: [ + { startIndex: 0, type: 'number.sb' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 3, type: 'number.sb' } + ] + }], + + [{ + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.sb' }, + { startIndex: 3, type: 'delimiter.sb' }, + { startIndex: 4, type: 'number.sb' } + ] + }], + + [{ + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.sb' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.sb' } + ] + }], + + // Keywords + [{ + line: 'Sub Foo', + tokens: [ + { startIndex: 0, type: 'keyword.tag-sub.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.sb' } + ] + }], + + // Strings + [{ + line: 's = "string"', + tokens: [ + { startIndex: 0, type: 'identifier.sb' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.sb' } + ] + }], + + [{ + line: '"use strict";', + tokens: [ + { startIndex: 0, type: 'string.sb' }, + { startIndex: 12, type: '' } + ] + }], + + // Tags + [{ + line: 'sub ToString', + tokens: [ + { startIndex: 0, type: 'keyword.tag-sub.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.sb' } + ] + }], + + [{ + line: 'While For If Sub EndWhile EndFor EndIf endsub', + tokens: [ + { startIndex: 0, type: 'keyword.tag-while.sb' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.tag-for.sb' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'keyword.tag-if.sb' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.tag-sub.sb' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'keyword.tag-while.sb' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'keyword.tag-for.sb' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'keyword.tag-if.sb' }, + { startIndex: 38, type: '' }, + { startIndex: 39, type: 'keyword.tag-sub.sb' } + ] + }], + + [{ + line: 'While while WHILE WHile whiLe', + tokens: [ + { startIndex: 0, type: 'keyword.tag-while.sb' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.tag-while.sb' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'keyword.tag-while.sb' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'keyword.tag-while.sb' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'keyword.tag-while.sb' } + ] + }], + + [{ + line: 'If b(i) = col Then', + tokens: [ + { startIndex: 0, type: 'keyword.tag-if.sb' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'identifier.sb' }, + { startIndex: 4, type: 'delimiter.parenthesis.sb' }, + { startIndex: 5, type: 'identifier.sb' }, + { startIndex: 6, type: 'delimiter.parenthesis.sb' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.sb' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.sb' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.then.sb' } + ] + }], + + [{ + line: 'For i = 0 To 10 Step 2 DoStuff EndFor', + tokens: [ + { startIndex: 0, type: 'keyword.tag-for.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.sb' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.sb' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.sb' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'keyword.to.sb' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'number.sb' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'keyword.step.sb' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'number.sb' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'identifier.sb' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'keyword.tag-for.sb' } + ] + }], + + [{ + line: 'For stuff EndFor', + tokens: [ + { startIndex: 0, type: 'keyword.tag-for.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.sb' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'keyword.tag-for.sb' }, + ] + }], + + [{ + line: 'for stuff endfor', + tokens: [ + { startIndex: 0, type: 'keyword.tag-for.sb' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.sb' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'keyword.tag-for.sb' }, + ] + }] +]); From 0281b3f960b8ed27a8517820b51e47ec3cdabb16 Mon Sep 17 00:00:00 2001 From: marlenecota Date: Sat, 29 Jul 2017 22:03:44 -0700 Subject: [PATCH 2/4] removed date and REM --- src/sb.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/sb.ts b/src/sb.ts index 3f9bd87e..43b32faf 100644 --- a/src/sb.ts +++ b/src/sb.ts @@ -86,9 +86,6 @@ export const language = { [/\d*\.\d+/, 'number.float'], [/\d+/, 'number'], - // date literal - [/#.*#/, 'number'], - // delimiters and operators [/[()\[\]]/, '@brackets'], [/@symbols/, 'delimiter'], @@ -101,7 +98,6 @@ export const language = { whitespace: [ [/[ \t\r\n]+/, ''], - [/(\'|REM(?!\w)).*$/, 'comment'], ], string: [ From 72904610c74d45df10475386f249b62aaecfbc57 Mon Sep 17 00:00:00 2001 From: marlenecota Date: Sat, 29 Jul 2017 22:23:33 -0700 Subject: [PATCH 3/4] fix comment tokenizer --- src/sb.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sb.ts b/src/sb.ts index 43b32faf..ce5c8a33 100644 --- a/src/sb.ts +++ b/src/sb.ts @@ -98,6 +98,7 @@ export const language = { whitespace: [ [/[ \t\r\n]+/, ''], + [/(\').*$/, 'comment'] ], string: [ From 9e1afc2619d7f302159bdbde775a4864126b728b Mon Sep 17 00:00:00 2001 From: marlenecota Date: Mon, 31 Jul 2017 01:00:19 -0700 Subject: [PATCH 4/4] added class and member detection --- README.md | 1 + src/sb.ts | 39 ++++++---- test/sb.test.ts | 197 ++++++++++++++++++++++++++++-------------------- 3 files changed, 138 insertions(+), 99 deletions(-) diff --git a/README.md b/README.md index 742b298c..0cfdc1f8 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Colorization and configuration supports for multiple languages for the Monaco Ed * swift * vb * xml +* small basic Also `css` dialects: diff --git a/src/sb.ts b/src/sb.ts index ce5c8a33..5d5332af 100644 --- a/src/sb.ts +++ b/src/sb.ts @@ -43,44 +43,46 @@ export const language = { ], keywords: [ - 'And', 'Else', 'ElseIf', 'EndFor', 'EndIf', 'EndSub', 'EndWhile', - 'For', 'Goto', 'If', 'Or', 'Step', 'Sub', 'Then', 'To', 'While' + 'Else', 'ElseIf', 'EndFor', 'EndIf', 'EndSub', 'EndWhile', + 'For', 'Goto', 'If', 'Step', 'Sub', 'Then', 'To', 'While' ], tagwords: [ 'If', 'Sub', 'While', 'For' ], - operators: [ - '>', '<', '<>', '<=', '>=', 'And', - 'Or', '+', '-', '*', '/', '=', - ], + operators: [ '>', '<', '<>', '<=', '>=', 'And', 'Or', '+', '-', '*', '/', '=' ], // we include these common regular expressions - symbols: /[=><.,:+\-\/]+/, + identifier: /[a-zA-Z_][\w]*/, + symbols: /[=><:+\-*\/%\.,]+/, escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, // The main tokenizer for our languages tokenizer: { root: [ - // whitespace { include: '@whitespace' }, - // usual ending tags - [/end([a-zA-Z_]\w*)/, { token: 'keyword.tag-$1' }], + // classes + [/(@identifier)(?=[.])/, 'type'], // identifiers, tagwords, and keywords - [/[a-zA-Z_]\w*/, { + [/@identifier/, { cases: { - '@tagwords': { token: 'keyword.tag-$0' }, '@keywords': { token: 'keyword.$0' }, - '@default': 'identifier' + '@operators': 'operator', + '@default': 'variable.name' } }], - // Preprocessor directive - [/^\s*#\w+/, 'keyword'], + // methods, properties, and events + [/([.])(@identifier)/, { + cases: { + '$2': ['delimiter', 'type.member'], + '@default': '' + } + }], // numbers [/\d*\.\d+/, 'number.float'], @@ -88,7 +90,12 @@ export const language = { // delimiters and operators [/[()\[\]]/, '@brackets'], - [/@symbols/, 'delimiter'], + [/@symbols/, { + cases: { + '@operators': 'operator', + '@default': 'delimiter' + } + }], // strings [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string diff --git a/test/sb.test.ts b/test/sb.test.ts index c68ebb8f..1f1a7cae 100644 --- a/test/sb.test.ts +++ b/test/sb.test.ts @@ -9,7 +9,7 @@ import { testTokenization } from './testRunner'; testTokenization('sb', [ - // Comments - single line + // Comments [{ line: '\'', tokens: [ @@ -49,15 +49,13 @@ testTokenization('sb', [ }], [{ - line: 'x = 1 \' my comment \'\' is a nice one', + line: 'x=1 \' my comment \'\' is a nice one', tokens: [ - { startIndex: 0, type: 'identifier.sb' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 0, type: 'variable.name.sb' }, // x + { startIndex: 1, type: 'operator.sb' }, // = + { startIndex: 2, type: 'number.sb' }, // 1 { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.sb' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'comment.sb' } + { startIndex: 4, type: 'comment.sb' } ] }], @@ -88,7 +86,7 @@ testTokenization('sb', [ tokens: [ { startIndex: 0, type: 'number.sb' }, { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 2, type: 'operator.sb' }, { startIndex: 3, type: 'number.sb' } ] }], @@ -97,7 +95,7 @@ testTokenization('sb', [ line: '100+10', tokens: [ { startIndex: 0, type: 'number.sb' }, - { startIndex: 3, type: 'delimiter.sb' }, + { startIndex: 3, type: 'operator.sb' }, { startIndex: 4, type: 'number.sb' } ] }], @@ -107,7 +105,7 @@ testTokenization('sb', [ tokens: [ { startIndex: 0, type: 'number.sb' }, { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 2, type: 'operator.sb' }, { startIndex: 3, type: '' }, { startIndex: 4, type: 'number.sb' } ] @@ -115,11 +113,65 @@ testTokenization('sb', [ // Keywords [{ - line: 'Sub Foo', + line: 'For i = 0 To 10 Step 2', tokens: [ - { startIndex: 0, type: 'keyword.tag-sub.sb' }, + { startIndex: 0, type: 'keyword.for.sb' }, // For { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.sb' } + { startIndex: 4, type: 'variable.name.sb' }, // i + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'operator.sb' }, // = + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.sb' }, // 0 + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'keyword.to.sb' }, // To + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'number.sb' }, // 10 + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'keyword.step.sb' }, // Step + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'number.sb' } // 2 + ] + }], + + [{ + line: 'if x <> 23.7 thEn', + tokens: [ + { startIndex: 0, type: 'keyword.if.sb' }, // if + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'variable.name.sb' }, // x + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'operator.sb' }, // <> + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.float.sb' }, // 23.7 + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.then.sb' } // thEn + ] + }], + + [{ + line: 'ElseIf b[i] And col Then', + tokens: [ + { startIndex: 0, type: 'keyword.elseif.sb' }, // ElseIf + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'variable.name.sb' }, // b + { startIndex: 8, type: 'delimiter.array.sb' }, // [ + { startIndex: 9, type: 'variable.name.sb' }, // i + { startIndex: 10, type: 'delimiter.array.sb' }, // ] + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'operator.sb' }, // And + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'variable.name.sb' }, // col + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'keyword.then.sb' } // Then + ] + }], + + [{ + line: 'GoTo location', + tokens: [ + { startIndex: 0, type: 'keyword.goto.sb' }, // GoTo + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'variable.name.sb' }, // location ] }], @@ -127,19 +179,19 @@ testTokenization('sb', [ [{ line: 's = "string"', tokens: [ - { startIndex: 0, type: 'identifier.sb' }, + { startIndex: 0, type: 'variable.name.sb' }, // s { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.sb' }, + { startIndex: 2, type: 'operator.sb' }, // = { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.sb' } + { startIndex: 4, type: 'string.sb' } // "string" ] }], [{ line: '"use strict";', tokens: [ - { startIndex: 0, type: 'string.sb' }, - { startIndex: 12, type: '' } + { startIndex: 0, type: 'string.sb' }, // "use strict" + { startIndex: 12, type: '' } // ; ] }], @@ -147,110 +199,89 @@ testTokenization('sb', [ [{ line: 'sub ToString', tokens: [ - { startIndex: 0, type: 'keyword.tag-sub.sb' }, + { startIndex: 0, type: 'keyword.sub.sb' }, // sub { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.sb' } + { startIndex: 4, type: 'variable.name.sb' } // ToString ] }], [{ line: 'While For If Sub EndWhile EndFor EndIf endsub', tokens: [ - { startIndex: 0, type: 'keyword.tag-while.sb' }, + { startIndex: 0, type: 'keyword.while.sb' }, // While { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.tag-for.sb' }, + { startIndex: 6, type: 'keyword.for.sb' }, // For { startIndex: 9, type: '' }, - { startIndex: 10, type: 'keyword.tag-if.sb' }, + { startIndex: 10, type: 'keyword.if.sb' }, // If { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.tag-sub.sb' }, + { startIndex: 13, type: 'keyword.sub.sb' }, // Sub { startIndex: 16, type: '' }, - { startIndex: 17, type: 'keyword.tag-while.sb' }, + { startIndex: 17, type: 'keyword.endwhile.sb' }, // EndWhile { startIndex: 25, type: '' }, - { startIndex: 26, type: 'keyword.tag-for.sb' }, + { startIndex: 26, type: 'keyword.endfor.sb' }, // EndFor { startIndex: 32, type: '' }, - { startIndex: 33, type: 'keyword.tag-if.sb' }, + { startIndex: 33, type: 'keyword.endif.sb' }, // EndIf { startIndex: 38, type: '' }, - { startIndex: 39, type: 'keyword.tag-sub.sb' } + { startIndex: 39, type: 'keyword.endsub.sb' } //endsub ] }], [{ line: 'While while WHILE WHile whiLe', tokens: [ - { startIndex: 0, type: 'keyword.tag-while.sb' }, + { startIndex: 0, type: 'keyword.while.sb' }, // While { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.tag-while.sb' }, + { startIndex: 6, type: 'keyword.while.sb' }, // while { startIndex: 11, type: '' }, - { startIndex: 12, type: 'keyword.tag-while.sb' }, + { startIndex: 12, type: 'keyword.while.sb' }, // WHILE { startIndex: 17, type: '' }, - { startIndex: 18, type: 'keyword.tag-while.sb' }, + { startIndex: 18, type: 'keyword.while.sb' }, // WHile { startIndex: 23, type: '' }, - { startIndex: 24, type: 'keyword.tag-while.sb' } + { startIndex: 24, type: 'keyword.while.sb' } // whiLe ] }], + // types and members [{ - line: 'If b(i) = col Then', + line: 'Else TextWindow.Write("text")', tokens: [ - { startIndex: 0, type: 'keyword.tag-if.sb' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'identifier.sb' }, - { startIndex: 4, type: 'delimiter.parenthesis.sb' }, - { startIndex: 5, type: 'identifier.sb' }, - { startIndex: 6, type: 'delimiter.parenthesis.sb' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.sb' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.sb' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.then.sb' } + { startIndex: 0, type: 'keyword.else.sb' }, // Else + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'type.sb' }, // TextWindow + { startIndex: 15, type: 'delimiter.sb' }, // . + { startIndex: 16, type: 'type.member.sb' }, // Write + { startIndex: 21, type: 'delimiter.parenthesis.sb' }, // ( + { startIndex: 22, type: 'string.sb' }, // "text" + { startIndex: 28, type: 'delimiter.parenthesis.sb' } // ) ] }], [{ - line: 'For i = 0 To 10 Step 2 DoStuff EndFor', + line: 'class.method (x, y)', tokens: [ - { startIndex: 0, type: 'keyword.tag-for.sb' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.sb' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.sb' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.sb' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'keyword.to.sb' }, + { startIndex: 0, type: 'type.sb' }, // class + { startIndex: 5, type: 'delimiter.sb' }, // . + { startIndex: 6, type: 'type.member.sb' }, // method { startIndex: 12, type: '' }, - { startIndex: 13, type: 'number.sb' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'keyword.step.sb' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'number.sb' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'identifier.sb' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'keyword.tag-for.sb' } - ] - }], - - [{ - line: 'For stuff EndFor', - tokens: [ - { startIndex: 0, type: 'keyword.tag-for.sb' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.sb' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'keyword.tag-for.sb' }, + { startIndex: 13, type: 'delimiter.parenthesis.sb' }, // ( + { startIndex: 14, type: 'variable.name.sb' }, // x + { startIndex: 15, type: 'delimiter.sb' }, // , + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'variable.name.sb' }, // y + { startIndex: 18, type: 'delimiter.parenthesis.sb' } // ) ] }], [{ - line: 'for stuff endfor', + line: 'const = Math.PI', tokens: [ - { startIndex: 0, type: 'keyword.tag-for.sb' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.sb' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'keyword.tag-for.sb' }, + { startIndex: 0, type: 'variable.name.sb' }, // const + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'operator.sb' }, // = + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'type.sb' }, // Math + { startIndex: 12, type: 'delimiter.sb' }, // . + { startIndex: 13, type: 'type.member.sb' } // PI ] }] ]);