source: node_modules/refractor/lang/smali.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

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