smali.js (1953B)
1 /* 2 Language: Smali 3 Author: Dennis Titze <dennis.titze@gmail.com> 4 Description: Basic Smali highlighting 5 Website: https://github.com/JesusFreke/smali 6 */ 7 8 function smali(hljs) { 9 var smali_instr_low_prio = ['add', 'and', 'cmp', 'cmpg', 'cmpl', 'const', 'div', 'double', 'float', 'goto', 'if', 'int', 'long', 'move', 'mul', 'neg', 'new', 'nop', 'not', 'or', 'rem', 'return', 'shl', 'shr', 'sput', 'sub', 'throw', 'ushr', 'xor']; 10 var smali_instr_high_prio = ['aget', 'aput', 'array', 'check', 'execute', 'fill', 'filled', 'goto/16', 'goto/32', 'iget', 'instance', 'invoke', 'iput', 'monitor', 'packed', 'sget', 'sparse']; 11 var smali_keywords = ['transient', 'constructor', 'abstract', 'final', 'synthetic', 'public', 'private', 'protected', 'static', 'bridge', 'system']; 12 return { 13 name: 'Smali', 14 aliases: ['smali'], 15 contains: [ 16 { 17 className: 'string', 18 begin: '"', end: '"', 19 relevance: 0 20 }, 21 hljs.COMMENT( 22 '#', 23 '$', 24 { 25 relevance: 0 26 } 27 ), 28 { 29 className: 'keyword', 30 variants: [ 31 {begin: '\\s*\\.end\\s[a-zA-Z0-9]*'}, 32 {begin: '^[ ]*\\.[a-zA-Z]*', relevance: 0}, 33 {begin: '\\s:[a-zA-Z_0-9]*', relevance: 0}, 34 {begin: '\\s(' + smali_keywords.join('|') + ')'} 35 ] 36 }, 37 { 38 className: 'built_in', 39 variants : [ 40 { 41 begin: '\\s('+smali_instr_low_prio.join('|')+')\\s' 42 }, 43 { 44 begin: '\\s('+smali_instr_low_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)+\\s', 45 relevance: 10 46 }, 47 { 48 begin: '\\s('+smali_instr_high_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)*\\s', 49 relevance: 10 50 }, 51 ] 52 }, 53 { 54 className: 'class', 55 begin: 'L[^\(;:\n]*;', 56 relevance: 0 57 }, 58 { 59 begin: '[vp][0-9]+', 60 } 61 ] 62 }; 63 } 64 65 module.exports = smali;