UNPKG

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