javascript-支持LLVM的HTML / JS / CSS语法荧光笔
作者:互联网
我目前正在使用google-code-prettify进行语法突出显示.它似乎不支持LLVM.这是格式化LLVM时的样子:
这很丑.是否有任何支持LLVM的前端语法荧光笔?
解决方法:
我从LLVM TextMate Bundle project抓起了LLVM汇编语法突出显示的模式,并为google-code-prettify 编写了一个插件.
PR['registerLangHandler'](
PR['createSimpleLexer'](
[
// Whitespace
[PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
// A double quoted, possibly multi-line, string.
[PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'],
// comment.llvm
[PR['PR_COMMENT'], /^;[^\r\n]*/, null, ';'],
],
[
// llvm instructions
[PR['PR_KEYWORD'], /^\b(?:add|alloca|and|ashr|bitcast|br|call|eq|exact|extractelement|extractvalue|fadd|fcmp|fdiv|fmul|fpext|fptosi|fptoui|fptrunc|free|frem|fsub|getelementptr|icmp|inbounds|indirectbr|insertelement|insertvalue|inttoptr|invoke|load|lshr|malloc|mul|ne|nsw|nuw|oeq|oge|ogt|ole|olt|one|or|ord|phi|ptrtoint|ret|sdiv|select|sext|sge|sgt|shl|shufflevector|sitofp|sle|slt|srem|store|sub|switch|trunc|udiv|ueq|uge|uge|ugt|ugt|uitofp|ule|ule|ult|ult|une|uno|unreachable|unwind|urem|va_arg|xor|zext)\b/, null],
// llvm keywords
[PR['PR_KEYWORD'], /^\b(?:addrspace|alias|align|alignstack|alwaysinline|appending|asm|blockaddress|byval|c|cc|ccc|coldcc|common|constant|datalayout|declare|default|define|deplibs|dllexport|dllimport|except|extern_weak|external|fastcc|gc|global|hidden|inlinehint|inreg|internal|linkonce|linkonce_odr|metadata|module|naked|nest|noalias|nocapture|noimplicitfloat|noinline|noredzone|noreturn|nounwind|optsize|private|protected|ptx_device|ptx_kernel|readnone|readonly|section|sideeffect|signext|sret|ssp|sspreq|tail|target|thread_local|to|triple|uwtable|volatile|weak|weak_odr|x86_fastcallcc|x86_stdcallcc|zeroext)\b/, null],
// variable.llvm
[PR['PR_TYPE'], /^\s(?:[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*)/],
// variable.language.llvm
[PR['PR_TYPE'], /^\s(?:[%]\d+)/],
// storage.type.language.llvm
[PR['PR_PLAIN'], /^\b(?:i\d+\**)/],
// variable.metadata.llvm
[PR['PR_PLAIN'], /^(!\d+)/],
// constant.numeric.float.llvm
[PR['PR_LITERAL'], /^\b\d+\.\d+\b/],
// constant.numeric.integer.llvm
[PR['PR_LITERAL'], /^\b(?:\d+|0(?:x|X)[a-fA-F0-9]+)\b/],
]),
['llvm', 'll']);
这是带有演示页面和自述文件的demo jsFiddle和Gist的链接.
标签:syntax-highlighting,google-code-prettify,css,html,javascript 来源: https://codeday.me/bug/20191101/1982407.html