Skip to content

Commit

Permalink
Version 0.1.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Sep 23, 2022
1 parent a23d084 commit d5ddc6d
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 82 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
We follow [Semantic Versions](https://semver.org/).


## Version 0.1.1

### Bugfixes

- Changes `puncuation` class name to `punctuation`
- Changes `className` to `scope`
- Fixes how `const` is highlighted
- Fixes URLs from `sobolevn/` to `highlightjs/`


## Version 0.1.0

- Initial release
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributors' Guide

## Building `dist` folder

To build `dist/` folder we utilize `highlight.js` standard way:
1. Copy the source
2. Symlink our project to `extra/` directory
3. Run the script

To automate this proccess, use `bash scripts/build.sh`

**Make sure that you run build script for each new package release**!
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `highlight.js` syntax definition for `FunC`

[![test](https://github.com/sobolevn/highlightjs-func/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/sobolevn/highlightjs-func/actions/workflows/test.yml)
[![test](https://github.com/highlightjs/highlightjs-func/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/highlightjs/highlightjs-func/actions/workflows/test.yml)

- For more about `FunC`, see https://ton.org/docs
- For more about `highlight.js`, see https://highlightjs.org/
Expand Down
29 changes: 15 additions & 14 deletions dist/func.es.min.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/*! `func` grammar compiled for Highlight.js 11.6.0 */
var hljsGrammar=(()=>{"use strict"
;const e=/\"[^\n\"]+\"[Hhcusa]?/,a=/(-?(?!_)([\d_]+|0x[\d_a-fA-F]+)|0b[1_0]+)(?<!_)(?=[\s\)\],;])/
;return s=>({name:"FunC",aliases:["func"],case_insensitive:!1,keywords:{
keyword:["if","ifnot","else","elseif","elseifnot|10","while","do","until","repeat","return","impure","method_id","forall","asm","inline","inline_ref|10"],
;const e=/\"[^\n\"]+\"[Hhcusa]?/,n=/(-?(?!_)([\d_]+|0x[\d_a-fA-F]+)|0b[1_0]+)(?<!_)(?=[\s\)\],;])/
;return t=>({name:"FunC",aliases:["func"],case_insensitive:!1,keywords:{
keyword:["if","ifnot","else","elseif","elseifnot|10","while","do","until","repeat","return","impure","method_id","forall","asm","inline","inline_ref|10","const","global"],
literal:["true","false"],
type:["var","int","slice","tuple","cell","builder","cont","_"],built_in:[]},
contains:[{className:"comment",begin:";;",end:/(?=\n)/},{className:"comment",
begin:"{-",end:"-}",contains:["self"]},{className:"meta",begin:/#pragma/,
end:/;/,contains:[{className:"keyword",match:/version|not-version/},{
className:"operator",match:s.regex.either(/>=/,/<=/,/=/,/>/,/</,/\^/)},{
className:"number",match:/([0-9]+)(.[0-9]+)?(.[0-9]+)?/}]},{className:"keyword",
begin:/#include/,end:/;/,contains:[{className:"string",match:e}]},{
className:"number",match:a},{className:"string",match:e},{className:"function",
contains:[{scope:"comment",begin:";;",end:/(?=\n)/},{scope:"comment",begin:"{-",
end:"-}",contains:["self"]},{scope:"meta",begin:/#pragma/,end:/;/,contains:[{
scope:"keyword",match:/version|not-version/},{scope:"operator",
match:t.regex.either(/>=/,/<=/,/=/,/>/,/</,/\^/)},{scope:"number",
match:/([0-9]+)(.[0-9]+)?(.[0-9]+)?/}]},{scope:"keyword",begin:/#include/,
end:/;/,contains:[{scope:"string",match:e}]},{scope:"number",match:n},{
scope:"string",match:e},{
match:[/\b(const|global)\b/,/\s+/,/\w+/,/\s+/,'(?!")(`([^`]+)`|((?=_)_|(?=\\{)\\{|(?=\\})\\}|(?![_`{}]))([^;,\\[\\]\\(\\)\\s~.]+))'],
scope:{1:"keyword",5:"variable.constant"}},{scope:"function",
match:/(?!")(`([^`]+)`|((?=_)_|(?=\{)\{|(?=\})\}|(?![_`{}]))([^;,\[\]\(\)\s~.]+))(?=[(])/
},{className:"variable.constant",match:/\b(const|global)\b/},{
className:"operator",
match:s.regex.either(/<=>/,/>=/,/<=/,/!=/,/==/,/\^>>/,/~>>/,/>>/,/<</,/\/%/,/\^%/,/~%/,/\^\//,/~\//,/\+=/,/-=/,/\*=/,/\/=/,/~\/=/,/\^\/=/,/%=/,/\^%=/,/<<=/,/>>=/,/~>>=/,/\^>>=/,/&=/,/\^=/,/\|=/,/\^/,/=/,/~/,/\//,/%/,/-/,/\*/,/\+/,/>/,/</,/&/,/\|/,/:/,/\?/)
},{className:"puncuation",match:/[.;(),\[\]~{}]/}]})})()
},{scope:"operator",
match:t.regex.either(/<=>/,/>=/,/<=/,/!=/,/==/,/\^>>/,/~>>/,/>>/,/<</,/\/%/,/\^%/,/~%/,/\^\//,/~\//,/\+=/,/-=/,/\*=/,/\/=/,/~\/=/,/\^\/=/,/%=/,/\^%=/,/<<=/,/>>=/,/~>>=/,/\^>>=/,/&=/,/\^=/,/\|=/,/\^/,/=/,/~/,/\//,/%/,/-/,/\*/,/\+/,/>/,/</,/&/,/\|/,/:/,/\?/)
},{scope:"punctuation",match:/[.;(),\[\]~{}]/}]})})()
;export default hljsGrammar;
29 changes: 15 additions & 14 deletions dist/func.min.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/*! `func` grammar compiled for Highlight.js 11.6.0 */
(()=>{var e=(()=>{"use strict"
;const e=/\"[^\n\"]+\"[Hhcusa]?/,a=/(-?(?!_)([\d_]+|0x[\d_a-fA-F]+)|0b[1_0]+)(?<!_)(?=[\s\)\],;])/
;return s=>({name:"FunC",aliases:["func"],case_insensitive:!1,keywords:{
keyword:["if","ifnot","else","elseif","elseifnot|10","while","do","until","repeat","return","impure","method_id","forall","asm","inline","inline_ref|10"],
;const e=/\"[^\n\"]+\"[Hhcusa]?/,n=/(-?(?!_)([\d_]+|0x[\d_a-fA-F]+)|0b[1_0]+)(?<!_)(?=[\s\)\],;])/
;return t=>({name:"FunC",aliases:["func"],case_insensitive:!1,keywords:{
keyword:["if","ifnot","else","elseif","elseifnot|10","while","do","until","repeat","return","impure","method_id","forall","asm","inline","inline_ref|10","const","global"],
literal:["true","false"],
type:["var","int","slice","tuple","cell","builder","cont","_"],built_in:[]},
contains:[{className:"comment",begin:";;",end:/(?=\n)/},{className:"comment",
begin:"{-",end:"-}",contains:["self"]},{className:"meta",begin:/#pragma/,
end:/;/,contains:[{className:"keyword",match:/version|not-version/},{
className:"operator",match:s.regex.either(/>=/,/<=/,/=/,/>/,/</,/\^/)},{
className:"number",match:/([0-9]+)(.[0-9]+)?(.[0-9]+)?/}]},{className:"keyword",
begin:/#include/,end:/;/,contains:[{className:"string",match:e}]},{
className:"number",match:a},{className:"string",match:e},{className:"function",
contains:[{scope:"comment",begin:";;",end:/(?=\n)/},{scope:"comment",begin:"{-",
end:"-}",contains:["self"]},{scope:"meta",begin:/#pragma/,end:/;/,contains:[{
scope:"keyword",match:/version|not-version/},{scope:"operator",
match:t.regex.either(/>=/,/<=/,/=/,/>/,/</,/\^/)},{scope:"number",
match:/([0-9]+)(.[0-9]+)?(.[0-9]+)?/}]},{scope:"keyword",begin:/#include/,
end:/;/,contains:[{scope:"string",match:e}]},{scope:"number",match:n},{
scope:"string",match:e},{
match:[/\b(const|global)\b/,/\s+/,/\w+/,/\s+/,'(?!")(`([^`]+)`|((?=_)_|(?=\\{)\\{|(?=\\})\\}|(?![_`{}]))([^;,\\[\\]\\(\\)\\s~.]+))'],
scope:{1:"keyword",5:"variable.constant"}},{scope:"function",
match:/(?!")(`([^`]+)`|((?=_)_|(?=\{)\{|(?=\})\}|(?![_`{}]))([^;,\[\]\(\)\s~.]+))(?=[(])/
},{className:"variable.constant",match:/\b(const|global)\b/},{
className:"operator",
match:s.regex.either(/<=>/,/>=/,/<=/,/!=/,/==/,/\^>>/,/~>>/,/>>/,/<</,/\/%/,/\^%/,/~%/,/\^\//,/~\//,/\+=/,/-=/,/\*=/,/\/=/,/~\/=/,/\^\/=/,/%=/,/\^%=/,/<<=/,/>>=/,/~>>=/,/\^>>=/,/&=/,/\^=/,/\|=/,/\^/,/=/,/~/,/\//,/%/,/-/,/\*/,/\+/,/>/,/</,/&/,/\|/,/:/,/\?/)
},{className:"puncuation",match:/[.;(),\[\]~{}]/}]})})()
},{scope:"operator",
match:t.regex.either(/<=>/,/>=/,/<=/,/!=/,/==/,/\^>>/,/~>>/,/>>/,/<</,/\/%/,/\^%/,/~%/,/\^\//,/~\//,/\+=/,/-=/,/\*=/,/\/=/,/~\/=/,/\^\/=/,/%=/,/\^%=/,/<<=/,/>>=/,/~>>=/,/\^>>=/,/&=/,/\^=/,/\|=/,/\^/,/=/,/~/,/\//,/%/,/-/,/\*/,/\+/,/>/,/</,/&/,/\|/,/:/,/\?/)
},{scope:"punctuation",match:/[.;(),\[\]~{}]/}]})})()
;hljs.registerLanguage("func",e)})();
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "highlightjs-func",
"version": "0.1.0",
"version": "0.1.1",
"description": "highlight.js syntax definition for TON's FunC language",
"main": "src/index.js",
"type": "module",
Expand All @@ -21,9 +21,9 @@
"author": "Nikita Sobolev <mail@sobolevn.me>",
"license": "MIT",
"bugs": {
"url": "https://github.com/sobolevn/highlightjs-func/issues"
"url": "https://github.com/highlightjs/highlightjs-func/issues"
},
"homepage": "https://github.com/sobolevn/highlightjs-func#readme",
"homepage": "https://github.com/highlightjs/highlightjs-func#readme",
"scripts": {
"test": "mocha --reporter spec --reporter-option maxDiffSize=0"
},
Expand Down
41 changes: 27 additions & 14 deletions src/languages/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function(hljs) {
'while', 'do', 'until', 'repeat',
'return', 'impure', 'method_id',
'forall', 'asm', 'inline', 'inline_ref|10',
'const', 'global',
],
'literal': ['true', 'false'],
'type': ['var', 'int', 'slice', 'tuple', 'cell', 'builder', 'cont', '_'],
Expand All @@ -35,51 +36,63 @@ export default function(hljs) {

'contains': [
// Comments
{ 'className': 'comment', 'begin': ';;', 'end': /(?=\n)/ },
{ 'scope': 'comment', 'begin': ';;', 'end': /(?=\n)/ },
{
'className': 'comment',
'scope': 'comment',
'begin': '{-',
'end': '-}',
'contains': ['self'],
},

// Directives
{
'className': 'meta',
'scope': 'meta',
'begin': /#pragma/,
'end': /;/,
'contains': [
{ 'className': 'keyword', 'match': /version|not-version/ },
{ 'scope': 'keyword', 'match': /version|not-version/ },
{
'className': 'operator',
'scope': 'operator',
'match': hljs.regex.either(/>=/, /<=/, /=/, />/, /</, /\^/),
},
{
'className': 'number',
'scope': 'number',
'match': /([0-9]+)(.[0-9]+)?(.[0-9]+)?/
},
],
},
{
'className': 'keyword',
'scope': 'keyword',
'begin': /#include/,
'end': /;/,
'contains': [
{ 'className': 'string', 'match': STRING },
{ 'scope': 'string', 'match': STRING },
],
},

// Primitives
{ 'className': 'number', 'match': NUMBER },
{ 'className': 'string', 'match': STRING },
{ 'scope': 'number', 'match': NUMBER },
{ 'scope': 'string', 'match': STRING },

// Constans / Variables / Functions
{ 'className': 'function', 'match': new RegExp(IDENTIFIER + '(?=[\(])') },
{ 'className': 'variable.constant', 'match': /\b(const|global)\b/ },
{
'match': [
/\b(const|global)\b/,
/\s+/,
/\w+/, // in real world this is just a type, but we allow any text
/\s+/,
IDENTIFIER,
],
'scope': {
1: 'keyword',
5: 'variable.constant',
},
},
{ 'scope': 'function', 'match': new RegExp(IDENTIFIER + '(?=[\(])') },

// Punctuation
{
'className': 'operator',
'scope': 'operator',
'match': hljs.regex.either(
/<=>/, />=/, /<=/, /!=/, /==/, /\^>>/, /~>>/,
/>>/, /<</, /\/%/, /\^%/, /~%/, /\^\//, /~\//, /\+=/,
Expand All @@ -89,7 +102,7 @@ export default function(hljs) {
/</, /&/, /\|/, /:/, /\?/,
),
},
{ 'className': 'puncuation', 'match': /[.;(),\[\]~{}]/ },
{ 'scope': 'punctuation', 'match': /[.;(),\[\]~{}]/ },
]
}
}
Loading

0 comments on commit d5ddc6d

Please sign in to comment.