-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tact, FunC, Fift, TL-B support (#13)
* Added Tact, FunC, Fift, TL-B support Whose are the common languages of [TON](https://ton.org). * chore: Updated list of supported languages * feat: support Tact 1.3.0
- Loading branch information
Showing
6 changed files
with
408 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/** | ||
* @file Prism.js definition for Fift | ||
* @link https://docs.ton.org/develop/fift/overview | ||
* @author Nikita Sobolev (https://github.com/sobolevn) | ||
* @license MIT | ||
*/ | ||
Prism.languages.fift = { | ||
'symbol': [ | ||
/[xX]\{[0-9a-fA-F_]*\}/, | ||
/[bB]\{[01]*\}/, | ||
/'\S+/, | ||
], | ||
'string': /"([^"\r\n\\]|\\.)*"/, | ||
|
||
'comment': [ | ||
{ | ||
pattern: /\/\*[\s\S]*?(?:\*\/|$)/, | ||
lookbehind: true, | ||
greedy: true, | ||
}, | ||
{ | ||
pattern: /\/\/.*/, | ||
lookbehind: true, | ||
greedy: true, | ||
}, | ||
], | ||
|
||
'operator': [ | ||
// Full list can be found in | ||
// Appendix A. List of Fift words | ||
// Ordered the same way source code does this. | ||
// Except: shorter words must follow | ||
// longer ones with the same base part. | ||
// Example: `#` comes after `#s` | ||
/#>/, /#s/, /\$#/, /#/, | ||
|
||
/\$\+/, /\$,/, /\$\d/, /\$=/, /\$(?=\()/, | ||
/\$>smca/, /\$>s/, | ||
/\$@\+/, /\$@\?\+/, /\$@\?/, /\$@/, | ||
/\$cmp/, /\$len/, /\$pos/, /\$reverse/, | ||
|
||
/%1<</, | ||
|
||
/\('\)/, /\(-trailing\)/, /\(\.\)/, /\(atom\)/, /\(b\.\)/, | ||
/\(compile\)/, /\(create\)/, /\(def\?\)/, /\(dump\)/, /\(execute\)/, | ||
/\(forget\)/, /\(number\)/, /\(x\.\)/, /\(\{\)/, /\(\}\)/, | ||
|
||
/\*\/cmod/, /\*\/c/, /\*\/mod/, /\*\/rmod/, /\*\/r/, /\*\//, | ||
/\*>>c/, /\*>>r/, /\*>>/, /\*mod/, /\*/, | ||
|
||
/\+!/, /\+/, /,/, /-!/, /-/, /!/, | ||
/-1<</, /\._/, /\.dump/, /\.l/, /\.sl/, /\.s/, /\.tc/, | ||
/\//, /\/\*/, /\/cmod/, /\/c/, /\/mod/, /\/rmod/, /\/r/, | ||
/0!/, /0<=/, /0<>/, /0</, /0=/, /0>=/, /0>/, | ||
/1\+!/, /1\+/, /1-!/, /1-/, /1<</, /1<<1-/, | ||
/2\*/, /2\+/, /2-/, /2\//, /2=:/, | ||
|
||
/::_/, /::/, /:_/, /=:/, /:/, | ||
|
||
/<#/, /<<\/c/, /<<\/r/, /<=/, /<>/, /<b/, /<s/, /<<\//, | ||
/<</, /</, /=/, | ||
|
||
/>=/, />>c/, />>r/, />>/, />/, | ||
|
||
/\?dup/, | ||
|
||
/@'/, /@/, | ||
|
||
/B\+/, /B,/, /B=/, /B>Li@\+/, /B>Li@/, /B>Lu@\+/, /B>Lu@/, /B>boc/, | ||
/B>file/, /B>i@\+/, /B>i@/, /B>u@\+/, /B>u@/, | ||
/B@\?\+/, /B@\+/, /B@\?/, /B@/, | ||
/Bcmp/, /BhashB/, /Bhashu/, /Bhash/, /Blen/, /Bx\./, | ||
/B\|/, /Li>B/, /Lu>B/, | ||
|
||
/\[\]/, /\[compile\]/, /\[/, /\]/, | ||
|
||
/atom\?/, | ||
|
||
/b\+/, /b\._/, /b\./, | ||
/b>idict!\+/, /b>idict!/, /b>sdict!\+/, /b>sdict!/, | ||
/b>udict!\+/, /b>udict!/, | ||
/b>/, /boc\+>B/, /boc>B/, | ||
|
||
/csr\./, | ||
/def\?/, | ||
/empty\?/, /eq\?/, | ||
/file-exists\?/, /file>B/, | ||
|
||
/i,/, /i>B/, /i@\+/, /i@\?\+/, /i@\?/, /i@/, | ||
/idict!\+/, /idict!/, /idict-/, /idict@-/, /idict@/, | ||
|
||
/null!/, /null\?/, | ||
/pfxdict!\+/, /pfxdict!/, /pfxdict@/, /priv>pub/, | ||
/ref@\+/, /ref@/, /ref@\?\+/, /ref@\?/, | ||
|
||
/s,/, /s>c/, /s>/, | ||
/sdict!\+/, /sdict!/, /sdict-/, /sdict@-/, /sdict@/, | ||
/smca>\$/, /sr,/, | ||
|
||
/tuple\?/, | ||
|
||
/u,/, /u>B/, /u@\+/, /u@\?\+/, /u@\?/, | ||
/udict!\+/, /udict!/, /udict-/, /udict@-/, /udict@/, | ||
/undef\?/, | ||
|
||
/x\._/, /x\./, | ||
|
||
/\|\+/, /\|/, /\|_/, | ||
|
||
/\?\./, /'/, | ||
|
||
// Should be the last: | ||
/\./, | ||
], | ||
|
||
'keyword': /\b(?:-roll|-rot|-trailing|-trailing0|2constant|2drop|2dup|2over|2swap|abort|abs|allot|and|anon|atom|bbitrefs|bbits|bl|box|brefs|brembitrefs|brembits|bremrefs|bye|caddr|cadr|car|cddr|cdr|char|chr|cmp|cond|cons|constant|count|cr|create|depth|dictmap|dictmerge|dictnew|does|drop|dup|ed25519_chksign|ed25519_sign|ed25519_sign_uint|emit|exch|exch2|execute|explode|find|first|fits|forget|gasrunvm|gasrunvmcode|gasrunvmctx|gasrunvmdict|halt|hash|hashB|hashu|hold|hole|if|ifnot|include|list|max|min|minmax|mod|negate|newkeypair|nil|nip|nop|not|now|null|or|over|pair|pick|quit|remaining|reverse|roll|rot|runvm|runvmcode|runvmctx|runvmdict|sbitrefs|sbits|second|sgn|shash|sign|single|skipspc|space|srefs|swap|ten|third|times|triple|tuck|tuple|type|ufits|uncons|unpair|unsingle|until|untriple|untuple|variable|while|word|words|xor)\b/, | ||
'boolean': /\b(?:false|true)\b/, | ||
|
||
'number': [ | ||
/(0[xX][0-9a-fA-F]+)/, | ||
/(0[bB][01]+)/, | ||
/(-?\d+(\/-?\d+)?)/, | ||
], | ||
'variable': /[\w$-]+/, | ||
|
||
'punctuation': /[\[\{\}\],\(\)]/, | ||
}; |
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,60 @@ | ||
/** | ||
* @file Prism.js definition for FunC | ||
* @link https://docs.ton.org/develop/func/overview | ||
* @version 0.2.0 | ||
* @author Nikita Sobolev (https://github.com/sobolevn) | ||
* @license MIT | ||
*/ | ||
(function (Prism) { | ||
// 1. Does not start from " | ||
// 2. Can start from ` and end with `, containing any character | ||
// 3. Starts with underscore or { or } and have more than 1 character after it | ||
// 4. Starts with letter, contains letters, numbers and underscores | ||
var identifier = /(?!")(`([^`]+)`|((?=_)_|(?=\{)\{|(?=\})\}|(?![_`{}]))([^;,\[\]\(\)\s~.]+))/; | ||
var string = /"[^\n"]+"[Hhcusa]?/; | ||
var number = /\b([\d_]+|0x[\d_a-fA-F]+|0b[1_0]+)\b/; | ||
|
||
Prism.languages.func = { | ||
'include': { | ||
pattern: /#include(.*);/, | ||
inside: { | ||
'keyword': /#include/, | ||
'string': string, | ||
'punctuation': /;/ | ||
}, | ||
}, | ||
'pragma': { | ||
pattern: /#pragma(.*);/, | ||
inside: { | ||
'keyword': /#pragma|not-version|version/, | ||
'number': /(\d+)(.\d+)?(.\d+)?/, | ||
'operator': [/>=/, /<=/, /=/, />/, /</, /\^/], | ||
'punctuation': /;/ | ||
} | ||
}, | ||
|
||
'comment': [ | ||
{ | ||
pattern: /;;.*/, | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
{ | ||
pattern: /\{-[\s\S]*?(?:-\}|$)/, | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
], | ||
|
||
'keyword': /\b(?:_(?=\s*:)|asm|const|do|else|elseif|elseifnot|forall|global|if|ifnot|impure|inline|inline_ref|method_id|repeat|return|until|while)\b/, | ||
'boolean': /\b(?:false|true)\b/, | ||
'builtin': /\b(?:_|builder|cell|cont|int|slice|tuple|var)\b/, | ||
|
||
'string': string, | ||
'number': number, | ||
'variable': identifier, | ||
|
||
'operator': /(<=>|>=|<=|!=|==|~>>=|~>>|\/%|\^%=|\^%|~%|\^\/=|\^\/|~\/=|~\/|\+=|-=|\*=|\/=|%=|<<=|>>=|\^>>=|\^>>|&=|>>|<<|\^=|\|=|\^|=|~|\/|%|-|\*|\+|>|<|&|\||:|\?)/, | ||
'punctuation': /[\.;\(\),\[\]~\{\}]/, | ||
}; | ||
}(Prism)); |
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,168 @@ | ||
/** | ||
* @file Prism.js definition for Tact | ||
* @link https://tact-lang.org | ||
* @version 1.2.0 | ||
* @author Novus Nota (https://github.com/novusnota) | ||
* @license MIT | ||
*/ | ||
(function(Prism) { | ||
Prism.languages.tact = { | ||
// reserved keywords | ||
'keyword': [ | ||
{ | ||
pattern: /\b(?:abstract|as|catch|const|contract(?!:)|do|else|extend|extends|foreach|fun|get|if|in|import|initOf|inline|let|message(?!:)|mutates|native|override|primitive|public|repeat|return|self|struct(?!:)|trait(?!:)|try|until|virtual|while|with)\b/, | ||
}, | ||
{ // keyword after as | ||
pattern: /(\bas\s+)\w+/, | ||
lookbehind: true, | ||
greedy: true, | ||
}, | ||
{ // reserved function names | ||
pattern: /\b(?:bounced|external|init|receive)\b/ | ||
}, | ||
], | ||
|
||
// built-in types | ||
'builtin': { | ||
pattern: /\b(?:Address|Bool|Builder|Cell|Int|Slice|String|StringBuilder)\b/, | ||
}, | ||
|
||
// SCREAMING_SNAKE_CASE for null values and names of constants | ||
'constant': [ | ||
{ | ||
pattern: /\bnull\b/, | ||
}, | ||
{ | ||
pattern: /\b[A-Z][A-Z0-9_]*\b/, | ||
}, | ||
], | ||
|
||
// UpperCamelCase for names of contracts, traits, structs, messages | ||
'class-name': { | ||
pattern: /\b[A-Z]\w*\b/, | ||
}, | ||
|
||
// mappings to FunC | ||
'attribute': [ | ||
{ // functions | ||
pattern: /@name/, | ||
inside: { | ||
'function': /.+/, | ||
}, | ||
}, | ||
{ // contract interfaces | ||
pattern: /@interface/, | ||
inside: { | ||
'function': /.+/, | ||
} | ||
} | ||
], | ||
|
||
'function': { | ||
pattern: /\b\w+(?=\()/, | ||
}, | ||
|
||
'boolean': { | ||
pattern: /\b(?:false|true)\b/, | ||
}, | ||
|
||
'number': [ | ||
{ // hexadecimal, case-insensitive /i | ||
pattern: /\b0x[0-9a-f](?:_?[0-9a-f])*\b/i, | ||
}, | ||
{ // octal, case-insensitive /i | ||
pattern: /\b0o[0-7](?:_?[0-7])*\b/i, | ||
}, | ||
{ // binary, case-insensitive /i | ||
pattern: /\b0b[01](?:_?[01])*\b/i, | ||
}, | ||
{ // decimal integers, starting with 0 | ||
pattern: /\b0\d*\b/, | ||
}, | ||
{ // other decimal integers | ||
pattern: /\b[1-9](?:_?\d)*\b/, | ||
}, | ||
], | ||
|
||
'string': undefined, | ||
|
||
'punctuation': { | ||
pattern: /[{}[\]();,.:?]/, | ||
}, | ||
|
||
'comment': [ | ||
{ // single-line | ||
pattern: /(^|[^\\:])\/\/.*/, | ||
lookbehind: true, | ||
greedy: true, | ||
}, | ||
{ // multi-line | ||
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, | ||
lookbehind: true, | ||
greedy: true, | ||
} | ||
], | ||
|
||
'operator': { | ||
'pattern': /![!=]?|[+\-*/%=]=?|[<>]=|<<?|>>?|\|\|?|&&?|\^/, | ||
}, | ||
|
||
}; | ||
|
||
// strings, made this way to not collide with other entities | ||
Prism.languages.insertBefore('tact', 'string', { | ||
'string-literal': { | ||
pattern: /(?:(")(?:\\.|(?!\1)[^\\\r\n])*\1(?!\1))/, | ||
greedy: true, | ||
inside: { | ||
'regex': [ | ||
{ // \\ \" \n \r \t \v \b \f | ||
pattern: /\\[\\"nrtvbf]/, | ||
}, | ||
{ // hexEscape, \x00 through \xFF | ||
pattern: /\\x[0-9a-fA-F]{2}/, | ||
}, | ||
{ // unicodeEscape, \u0000 through \uFFFF | ||
pattern: /\\u[0-9a-fA-F]{4}/, | ||
}, | ||
{ // unicodeCodePoint, \u{0} through \u{FFFFFF} | ||
pattern: /\\u\{[0-9a-fA-F]{1,6}\}/, | ||
}, | ||
], | ||
'string': { | ||
pattern: /[\s\S]+/, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
// map and bounced message generic type modifiers | ||
Prism.languages.insertBefore('tact', 'keyword', { | ||
'generics': { | ||
pattern: /(?:\b(?:bounced|map)\b<[^\\\r\n]*>)/, | ||
greedy: true, | ||
inside: { | ||
'builtin': [ | ||
Prism.languages['tact']['builtin'], | ||
{ | ||
pattern: /\b(?:bounced(?=<)|map(?=<))\b/ | ||
}, | ||
], | ||
'class-name': Prism.languages['tact']['class-name'], | ||
'punctuation': { | ||
pattern: /[<>(),.?]/, | ||
}, | ||
'keyword': [ | ||
{ | ||
pattern: /\bas\b/, | ||
}, | ||
{ | ||
pattern: /(\bas\s+)\w+/, | ||
lookbehind: true, | ||
greedy: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
}(Prism)); |
Oops, something went wrong.