smali.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Language: Smali
  3. Author: Dennis Titze <[email protected]>
  4. Description: Basic Smali highlighting
  5. */
  6. function(hljs) {
  7. 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'];
  8. var smali_instr_high_prio = ['aget', 'aput', 'array', 'check', 'execute', 'fill', 'filled', 'goto/16', 'goto/32', 'iget', 'instance', 'invoke', 'iput', 'monitor', 'packed', 'sget', 'sparse'];
  9. var smali_keywords = ['transient', 'constructor', 'abstract', 'final', 'synthetic', 'public', 'private', 'protected', 'static', 'bridge', 'system'];
  10. return {
  11. aliases: ['smali'],
  12. contains: [
  13. {
  14. className: 'string',
  15. begin: '"', end: '"',
  16. relevance: 0
  17. },
  18. hljs.COMMENT(
  19. '#',
  20. '$',
  21. {
  22. relevance: 0
  23. }
  24. ),
  25. {
  26. className: 'keyword',
  27. variants: [
  28. {begin: '\\s*\\.end\\s[a-zA-Z0-9]*'},
  29. {begin: '^[ ]*\\.[a-zA-Z]*', relevance: 0},
  30. {begin: '\\s:[a-zA-Z_0-9]*', relevance: 0},
  31. {begin: '\\s(' + smali_keywords.join('|') + ')'}
  32. ]
  33. },
  34. {
  35. className: 'built_in',
  36. variants : [
  37. {
  38. begin: '\\s('+smali_instr_low_prio.join('|')+')\\s'
  39. },
  40. {
  41. begin: '\\s('+smali_instr_low_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)+\\s',
  42. relevance: 10
  43. },
  44. {
  45. begin: '\\s('+smali_instr_high_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)*\\s',
  46. relevance: 10
  47. },
  48. ]
  49. },
  50. {
  51. className: 'class',
  52. begin: 'L[^\(;:\n]*;',
  53. relevance: 0
  54. },
  55. {
  56. begin: '[vp][0-9]+',
  57. }
  58. ]
  59. };
  60. }