]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/llvm.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / llvm.js
1 /*! `llvm` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: LLVM IR
7 Author: Michael Rodler <contact@f0rki.at>
8 Description: language used as intermediate representation in the LLVM compiler framework
9 Website: https://llvm.org/docs/LangRef.html
10 Category: assembler
11 Audit: 2020
12 */
13
14 /** @type LanguageFn */
15 function llvm(hljs) {
16 const regex = hljs.regex;
17 const IDENT_RE = /([-a-zA-Z$._][\w$.-]*)/;
18 const TYPE = {
19 className: 'type',
20 begin: /\bi\d+(?=\s|\b)/
21 };
22 const OPERATOR = {
23 className: 'operator',
24 relevance: 0,
25 begin: /=/
26 };
27 const PUNCTUATION = {
28 className: 'punctuation',
29 relevance: 0,
30 begin: /,/
31 };
32 const NUMBER = {
33 className: 'number',
34 variants: [
35 { begin: /[su]?0[xX][KMLHR]?[a-fA-F0-9]+/ },
36 { begin: /[-+]?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?/ }
37 ],
38 relevance: 0
39 };
40 const LABEL = {
41 className: 'symbol',
42 variants: [ { begin: /^\s*[a-z]+:/ }, // labels
43 ],
44 relevance: 0
45 };
46 const VARIABLE = {
47 className: 'variable',
48 variants: [
49 { begin: regex.concat(/%/, IDENT_RE) },
50 { begin: /%\d+/ },
51 { begin: /#\d+/ },
52 ]
53 };
54 const FUNCTION = {
55 className: 'title',
56 variants: [
57 { begin: regex.concat(/@/, IDENT_RE) },
58 { begin: /@\d+/ },
59 { begin: regex.concat(/!/, IDENT_RE) },
60 { begin: regex.concat(/!\d+/, IDENT_RE) },
61 // https://llvm.org/docs/LangRef.html#namedmetadatastructure
62 // obviously a single digit can also be used in this fashion
63 { begin: /!\d+/ }
64 ]
65 };
66
67 return {
68 name: 'LLVM IR',
69 // TODO: split into different categories of keywords
70 keywords: {
71 keyword: 'begin end true false declare define global '
72 + 'constant private linker_private internal '
73 + 'available_externally linkonce linkonce_odr weak '
74 + 'weak_odr appending dllimport dllexport common '
75 + 'default hidden protected extern_weak external '
76 + 'thread_local zeroinitializer undef null to tail '
77 + 'target triple datalayout volatile nuw nsw nnan '
78 + 'ninf nsz arcp fast exact inbounds align '
79 + 'addrspace section alias module asm sideeffect '
80 + 'gc dbg linker_private_weak attributes blockaddress '
81 + 'initialexec localdynamic localexec prefix unnamed_addr '
82 + 'ccc fastcc coldcc x86_stdcallcc x86_fastcallcc '
83 + 'arm_apcscc arm_aapcscc arm_aapcs_vfpcc ptx_device '
84 + 'ptx_kernel intel_ocl_bicc msp430_intrcc spir_func '
85 + 'spir_kernel x86_64_sysvcc x86_64_win64cc x86_thiscallcc '
86 + 'cc c signext zeroext inreg sret nounwind '
87 + 'noreturn noalias nocapture byval nest readnone '
88 + 'readonly inlinehint noinline alwaysinline optsize ssp '
89 + 'sspreq noredzone noimplicitfloat naked builtin cold '
90 + 'nobuiltin noduplicate nonlazybind optnone returns_twice '
91 + 'sanitize_address sanitize_memory sanitize_thread sspstrong '
92 + 'uwtable returned type opaque eq ne slt sgt '
93 + 'sle sge ult ugt ule uge oeq one olt ogt '
94 + 'ole oge ord uno ueq une x acq_rel acquire '
95 + 'alignstack atomic catch cleanup filter inteldialect '
96 + 'max min monotonic nand personality release seq_cst '
97 + 'singlethread umax umin unordered xchg add fadd '
98 + 'sub fsub mul fmul udiv sdiv fdiv urem srem '
99 + 'frem shl lshr ashr and or xor icmp fcmp '
100 + 'phi call trunc zext sext fptrunc fpext uitofp '
101 + 'sitofp fptoui fptosi inttoptr ptrtoint bitcast '
102 + 'addrspacecast select va_arg ret br switch invoke '
103 + 'unwind unreachable indirectbr landingpad resume '
104 + 'malloc alloca free load store getelementptr '
105 + 'extractelement insertelement shufflevector getresult '
106 + 'extractvalue insertvalue atomicrmw cmpxchg fence '
107 + 'argmemonly',
108 type: 'void half bfloat float double fp128 x86_fp80 ppc_fp128 '
109 + 'x86_amx x86_mmx ptr label token metadata opaque'
110 },
111 contains: [
112 TYPE,
113 // this matches "empty comments"...
114 // ...because it's far more likely this is a statement terminator in
115 // another language than an actual comment
116 hljs.COMMENT(/;\s*$/, null, { relevance: 0 }),
117 hljs.COMMENT(/;/, /$/),
118 {
119 className: 'string',
120 begin: /"/,
121 end: /"/,
122 contains: [
123 {
124 className: 'char.escape',
125 match: /\\\d\d/
126 }
127 ]
128 },
129 FUNCTION,
130 PUNCTUATION,
131 OPERATOR,
132 VARIABLE,
133 LABEL,
134 NUMBER
135 ]
136 };
137 }
138
139 return llvm;
140
141 })();
142 ;
143 export default hljsGrammar;