prism-smali.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Test files for the parser itself:
  2. // https://github.com/JesusFreke/smali/tree/master/smali/src/test/resources/LexerTest
  3. Prism.languages.smali = {
  4. 'comment': /#.*/,
  5. 'string': {
  6. pattern: /"(?:[^\r\n\\"]|\\.)*"|'(?:[^\r\n\\']|\\(?:.|u[\da-fA-F]{4}))'/,
  7. greedy: true
  8. },
  9. 'class-name': {
  10. pattern: /L(?:(?:\w+|`[^`\r\n]*`)\/)*(?:[\w$]+|`[^`\r\n]*`)(?=\s*;)/,
  11. inside: {
  12. 'class-name': {
  13. pattern: /(^L|\/)(?:[\w$]+|`[^`\r\n]*`)$/,
  14. lookbehind: true
  15. },
  16. 'namespace': {
  17. pattern: /^(L)(?:(?:\w+|`[^`\r\n]*`)\/)+/,
  18. lookbehind: true,
  19. inside: {
  20. 'punctuation': /\//
  21. }
  22. },
  23. 'builtin': /^L/
  24. }
  25. },
  26. 'builtin': [
  27. {
  28. // Reference: https://github.com/JesusFreke/smali/wiki/TypesMethodsAndFields#types
  29. pattern: /([();\[])[BCDFIJSVZ]+/,
  30. lookbehind: true
  31. },
  32. {
  33. // e.g. .field mWifiOnUid:I
  34. pattern: /([\w$>]:)[BCDFIJSVZ]/,
  35. lookbehind: true
  36. }
  37. ],
  38. 'keyword': [
  39. {
  40. pattern: /(\.end\s+)[\w-]+/,
  41. lookbehind: true
  42. },
  43. {
  44. pattern: /(^|[^\w.-])\.(?!\d)[\w-]+/,
  45. lookbehind: true
  46. },
  47. {
  48. pattern: /(^|[^\w.-])(?:abstract|annotation|bridge|constructor|enum|final|interface|private|protected|public|runtime|static|synthetic|system|transient)(?![\w.-])/,
  49. lookbehind: true
  50. }
  51. ],
  52. 'function': {
  53. pattern: /(^|[^\w.-])(?:\w+|<[\w$-]+>)(?=\()/,
  54. lookbehind: true
  55. },
  56. 'field': {
  57. pattern: /[\w$]+(?=:)/,
  58. alias: 'variable'
  59. },
  60. 'register': {
  61. pattern: /(^|[^\w.-])[vp]\d(?![\w.-])/,
  62. lookbehind: true,
  63. alias: 'variable'
  64. },
  65. 'boolean': {
  66. pattern: /(^|[^\w.-])(?:true|false)(?![\w.-])/,
  67. lookbehind: true
  68. },
  69. 'number': {
  70. pattern: /(^|[^/\w.-])-?(?:NAN|INFINITY|0x(?:[\dA-F]+(?:\.[\dA-F]*)?|\.[\dA-F]+)(?:p[+-]?[\dA-F]+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)[dflst]?(?![\w.-])/i,
  71. lookbehind: true
  72. },
  73. 'label': {
  74. pattern: /(:)\w+/,
  75. lookbehind: true,
  76. alias: 'property'
  77. },
  78. 'operator': /->|\.\.|[\[=]/,
  79. 'punctuation': /[{}(),;:]/
  80. };