This repository has been archived by the owner on Nov 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pascaligo: adding pascaligo language support
Pascaligo is a layer 2 smart contract language for the Tezos blockchain. For more info please see: https://ligolang.org/
- Loading branch information
1 parent
d033572
commit 31041b3
Showing
6 changed files
with
288 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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'; | ||
|
||
registerLanguage({ | ||
id: 'pascaligo', | ||
extensions: ['.ligo'], | ||
aliases: ['Pascaligo', 'ligo'], | ||
loader: () => import('./pascaligo') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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('pascaligo', [ | ||
|
||
// Comments - single line | ||
[{ | ||
line: '//', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
[{ | ||
line: ' // a comment', | ||
tokens: [ | ||
{ startIndex: 0, type: 'white.pascaligo' }, | ||
{ startIndex: 4, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
[{ | ||
line: '// a comment', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
[{ | ||
line: '//sticky comment', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
// Comments - multi line (single line) | ||
[{ | ||
line: '(**)', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
[{ | ||
line: ' (* a comment *)', | ||
tokens: [ | ||
{ startIndex: 0, type: 'white.pascaligo' }, | ||
{ startIndex: 4, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
[{ | ||
line: '(* a comment *)', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
[{ | ||
line: '(*sticky comment*)', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo' } | ||
] | ||
}], | ||
|
||
// Comments - multi line (multi line) | ||
[{ | ||
line: '(* start of multiline comment ', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo' } | ||
] | ||
}, { | ||
line: 'a comment between curly', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo'} | ||
] | ||
}, { | ||
line: 'end of multiline comment*)', | ||
tokens: [ | ||
{ startIndex: 0, type: 'comment.pascaligo'} | ||
] | ||
}], | ||
|
||
// Keywords | ||
[{ | ||
line: 'function add (const a', | ||
tokens: [ | ||
{ startIndex: 0, type: 'keyword.function.pascaligo'}, | ||
{ startIndex: 8, type: 'white.pascaligo'}, | ||
{ startIndex: 9, type: 'identifier.pascaligo'}, | ||
{ startIndex: 12, type: 'white.pascaligo'}, | ||
{ startIndex: 13, type: 'delimiter.parenthesis.pascaligo'}, | ||
{ startIndex: 14, type: 'keyword.const.pascaligo'}, | ||
{ startIndex: 19, type: 'white.pascaligo'}, | ||
{ startIndex: 20, type: 'identifier.pascaligo'}, | ||
] | ||
}], | ||
|
||
// Numbers | ||
[{ | ||
line: '0', | ||
tokens: [ | ||
{ startIndex: 0, type: 'number.pascaligo'} | ||
] | ||
}], | ||
[{ | ||
line: '0;', | ||
tokens: [ | ||
{ startIndex: 0, type: 'number.pascaligo'}, | ||
{ startIndex: 1, type: 'delimiter.pascaligo'} | ||
] | ||
}], | ||
[{ | ||
line: '2.4', | ||
tokens: [ | ||
{ startIndex: 0, type: 'number.float.pascaligo'} | ||
] | ||
}], | ||
[{ | ||
line: '2.4;', | ||
tokens: [ | ||
{ startIndex: 0, type: 'number.float.pascaligo'}, | ||
{ startIndex: 3, type: 'delimiter.pascaligo'} | ||
] | ||
}], | ||
[{ | ||
line: '$123FF', | ||
tokens: [ | ||
{ startIndex: 0, type: 'number.hex.pascaligo'} | ||
] | ||
}] | ||
|
||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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: '//', | ||
blockComment: ['(*', '*)'], | ||
}, | ||
brackets: [ | ||
['{', '}'], | ||
['[', ']'], | ||
['(', ')'], | ||
['<', '>'], | ||
], | ||
autoClosingPairs: [ | ||
{ open: '{', close: '}' }, | ||
{ open: '[', close: ']' }, | ||
{ open: '(', close: ')' }, | ||
{ open: '<', close: '>' }, | ||
{ open: '\'', close: '\'' }, | ||
], | ||
surroundingPairs: [ | ||
{ open: '{', close: '}' }, | ||
{ open: '[', close: ']' }, | ||
{ open: '(', close: ')' }, | ||
{ open: '<', close: '>' }, | ||
{ open: '\'', close: '\'' }, | ||
] | ||
}; | ||
|
||
export const language = <ILanguage>{ | ||
defaultToken: '', | ||
tokenPostfix: '.pascaligo', | ||
ignoreCase: true, | ||
|
||
brackets: [ | ||
{ open: '{', close: '}', token: 'delimiter.curly' }, | ||
{ open: '[', close: ']', token: 'delimiter.square' }, | ||
{ open: '(', close: ')', token: 'delimiter.parenthesis' }, | ||
{ open: '<', close: '>', token: 'delimiter.angle' } | ||
], | ||
|
||
keywords: [ | ||
'begin', 'block', 'case', 'const', 'else', 'end', | ||
'fail', 'for', 'from', 'function', 'if', 'is', 'nil', | ||
'of', 'remove', 'return', 'skip', 'then', 'type', 'var', | ||
'while', 'with', 'option', 'None', 'transaction' | ||
], | ||
|
||
typeKeywords: [ | ||
'bool', 'int', 'list', 'map', 'nat', 'record', | ||
'string', 'unit', 'address', 'map', 'mtz', 'xtz' | ||
], | ||
|
||
operators: [ | ||
'=', '>', '<', '<=', '>=', '<>', ':', ':=', 'and', 'mod', 'or', | ||
'+', '-', '*', '/', '@', '&', '^', '%' | ||
], | ||
|
||
// we include these common regular expressions | ||
symbols: /[=><:@\^&|+\-*\/\^%]+/, | ||
|
||
// The main tokenizer for our languages | ||
tokenizer: { | ||
root: [ | ||
// identifiers and keywords | ||
[/[a-zA-Z_][\w]*/, { | ||
cases: { | ||
'@keywords': { token: 'keyword.$0' }, | ||
'@default': 'identifier' | ||
} | ||
}], | ||
|
||
// whitespace | ||
{ include: '@whitespace' }, | ||
|
||
// delimiters and operators | ||
[/[{}()\[\]]/, '@brackets'], | ||
[/[<>](?!@symbols)/, '@brackets'], | ||
[/@symbols/, { | ||
cases: { | ||
'@operators': 'delimiter', | ||
'@default': '' | ||
} | ||
}], | ||
|
||
// numbers | ||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'], | ||
[/\$[0-9a-fA-F]{1,16}/, 'number.hex'], | ||
[/\d+/, 'number'], | ||
|
||
// delimiter: after number because of .\d floats | ||
[/[;,.]/, 'delimiter'], | ||
|
||
// strings | ||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string | ||
[/'/, 'string', '@string'], | ||
|
||
// characters | ||
[/'[^\\']'/, 'string'], | ||
[/'/, 'string.invalid'], | ||
[/\#\d+/,'string'] | ||
], | ||
/* */ | ||
|
||
comment: [ | ||
[/[^\(\*]+/, 'comment' ], | ||
//[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-( | ||
[/\*\)/, 'comment', '@pop' ], | ||
[/\(\*/, 'comment' ] | ||
], | ||
|
||
string: [ | ||
[/[^\\']+/, 'string'], | ||
[/\\./, 'string.escape.invalid'], | ||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' } ] | ||
], | ||
|
||
whitespace: [ | ||
[/[ \t\r\n]+/, 'white'], | ||
[/\(\*/, 'comment', '@comment' ], | ||
[/\/\/.*$/, 'comment'], | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters