Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FunC language #3583

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@
"require": "markup-templating",
"owner": "RunDevelopment"
},
"func": {
"alias": ["FunC", "Func"],
"owner": "sobolevn"
},
"gml": {
"title": "GameMaker Language",
"alias": "gamemakerlanguage",
Expand Down
53 changes: 53 additions & 0 deletions components/prism-func.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
(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));
1 change: 1 addition & 0 deletions components/prism-func.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@
"eta": "ejs",
"xlsx": "excel-formula",
"xls": "excel-formula",
"FunC": "func",
"Func": "func",
"gamemakerlanguage": "gml",
"po": "gettext",
"gni": "gn",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions tests/languages/func/comments.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{-
Multiline test
-}

{- Single line test -}

;; Single line

;;

;; Multiline
;; comment

8 ;; inline
12

----------------------------------------------------

[
["comment", "{-\r\n\tMultiline test\r\n-}"],

["comment", "{- Single line test -}"],

["comment", ";; Single line"],

["comment", ";;"],

["comment", ";; Multiline"],
["comment", ";; comment"],

["number", "8"], ["comment", ";; inline"],
["number", "12"]
]
Loading