Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #32 from Serhioromano/master
Browse files Browse the repository at this point in the history
Add new language ST
  • Loading branch information
alexdima authored May 3, 2018
2 parents 6f34b63 + 63308cf commit 7195ea6
Show file tree
Hide file tree
Showing 6 changed files with 409 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ bundleOne('ruby/ruby');
bundleOne('rust/rust');
bundleOne('scss/scss');
bundleOne('sql/sql');
bundleOne('st/st');
bundleOne('swift/swift');
bundleOne('vb/vb');
bundleOne('xml/xml');
Expand Down
1 change: 1 addition & 0 deletions src/monaco.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import './sb/sb.contribution';
import './scss/scss.contribution';
import './solidity/solidity.contribution';
import './sql/sql.contribution';
import './st/st.contribution';
import './swift/swift.contribution';
import './vb/vb.contribution';
import './xml/xml.contribution';
Expand Down
17 changes: 17 additions & 0 deletions src/st/st.contribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*---------------------------------------------------------------------------------------------
* 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 { registerLanguage } from '../_.contribution';

// Allow for running under nodejs/requirejs in tests
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);

registerLanguage({
id: 'st',
extensions: ['.st', '.iecst', '.iecplc', '.lc3lib'],
aliases: ['StructuredText', 'scl', 'stl'],
loader: () => _monaco.Promise.wrap(import('./st'))
});
133 changes: 133 additions & 0 deletions src/st/st.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*---------------------------------------------------------------------------------------------
* 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 '../test/testRunner';
testTokenization('st', [
[{
line: "xVar : BOOL;",
tokens: [
{ startIndex: 0, type: 'identifier.st' },
{ startIndex: 4, type: 'white.st' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'white.st' },
{ startIndex: 7, type: 'type.st' },
{ startIndex: 11, type: 'delimiter.st' },
]
}],
[{
line: "xStart AT %IX0.0.1: BOOL := TRUE;",
tokens: [
{ startIndex: 0, type: 'identifier.st' },
{ startIndex: 6, type: 'white.st' },
{ startIndex: 7, type: 'keyword.st' },
{ startIndex: 9, type: 'white.st' },
{ startIndex: 10, type: 'tag.st' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'white.st' },
{ startIndex: 20, type: 'type.st' },
{ startIndex: 24, type: 'white.st' },
{ startIndex: 25, type: '' },
{ startIndex: 27, type: 'white.st' },
{ startIndex: 28, type: 'constant.st' },
{ startIndex: 32, type: 'delimiter.st' },
]
}],
[{
line: "IF a > 2#0000_0110 THEN (* Somethign ' happens *)",
tokens: [
{ startIndex: 0, type: 'keyword.st' },
{ startIndex: 2, type: 'white.st' },
{ startIndex: 3, type: 'identifier.st' },
{ startIndex: 4, type: 'white.st' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'white.st' },
{ startIndex: 7, type: 'number.binary.st' },
{ startIndex: 18, type: 'white.st' },
{ startIndex: 19, type: 'keyword.st' },
{ startIndex: 23, type: 'white.st' },
{ startIndex: 24, type: 'comment.st' },
]
}],
[{
line: "TON1(IN := TRUE, PT := T#20ms, Q => xStart); // Run timer",
tokens: [
{ startIndex: 0, type: 'identifier.st' },
{ startIndex: 4, type: 'delimiter.parenthesis.st' },
{ startIndex: 5, type: 'identifier.st' },
{ startIndex: 7, type: 'white.st' },
{ startIndex: 8, type: '' },
{ startIndex: 10, type: 'white.st' },
{ startIndex: 11, type: 'constant.st' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'white.st' },
{ startIndex: 17, type: 'identifier.st' },
{ startIndex: 19, type: 'white.st' },
{ startIndex: 20, type: '' },
{ startIndex: 22, type: 'white.st' },
{ startIndex: 23, type: 'tag.st' },
{ startIndex: 29, type: '' },
{ startIndex: 30, type: 'white.st' },
{ startIndex: 31, type: 'identifier.st' },
{ startIndex: 32, type: 'white.st' },
{ startIndex: 33, type: '' },
{ startIndex: 35, type: 'white.st' },
{ startIndex: 36, type: 'identifier.st' },
{ startIndex: 42, type: 'delimiter.parenthesis.st' },
{ startIndex: 43, type: 'delimiter.st' },
{ startIndex: 44, type: 'white.st' },
{ startIndex: 45, type: 'comment.st' },
]
}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.st' }
]
}],

[{
line: '0.0',
tokens: [
{ startIndex: 0, type: 'number.float.st' }
]
}],

[{
line: '2#000_0101',
tokens: [
{ startIndex: 0, type: 'number.binary.st' }
]
}],
[{
line: '16#0f',
tokens: [
{ startIndex: 0, type: 'number.hex.st' }
]
}],

[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'number.float.st' }
]
}],

[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'number.float.st' }
]
}],

[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'number.float.st' }
]
}],
]);
Loading

0 comments on commit 7195ea6

Please sign in to comment.