prism-smali.js 1.9 KB

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