botanjs/src/Libraries/SyntaxHighlighter/Brush/Go.js
raw ยท 1733 bytes
/**
* Golang brush by ChatGPT
*/
;(function()
{
var ns = __namespace( "Libraries.SyntaxHighlighter.Brush" );
/** @type {Libraries.SyntaxHighlighter} */
var SyntaxHighlighter = __import( "Libraries.SyntaxHighlighter" );
/** @type {typeof Libraries.SyntaxHighlighterBrush} **/
var Brush = function()
{
var keywords =
'break default func interface select case defer go map struct ' +
'chan else goto package switch const fallthrough if range type ' +
'continue for import return var';
var builtins =
'append bool byte cap close complex complex64 complex128 copy delete error false ' +
'float32 float64 imag int int8 int16 int32 int64 iota len make new nil panic ' +
'print println real recover rune string true uint uint8 uint16 uint32 uint64 uintptr any comparable';
this.regexList = [
{ "regex": SyntaxHighlighter.regexLib.singleLineCComments, "css": "comments" },
{ "regex": SyntaxHighlighter.regexLib.multiLineCComments, "css": "comments" },
{ "regex": SyntaxHighlighter.regexLib.doubleQuotedString, "css": "string" },
{ "regex": /`[\s\S]*?`/g, "css": "string" },
{ "regex": /\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+\-]?\d[\d_]*)?)\b/g, "css": "value" },
{ "regex": /\b[A-Z][A-Za-z0-9_]*\b/g, "css": "color1" },
{ "regex": new RegExp(this.getKeywords(keywords), "gm"), "css": "keyword" },
{ "regex": new RegExp(this.getKeywords(builtins), "gm"), "css": "color2" }
];
};
Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = [ "go", "golang" ];
SyntaxHighlighter.brushes[ "Go" ] = Brush;
ns[ NS_EXPORT ]( EX_CLASS, "Go", Brush );
})();