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