source: node_modules/refractor/lang/batch.js

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

Initial commit

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[d24f17c]1'use strict'
2
3module.exports = batch
4batch.displayName = 'batch'
5batch.aliases = []
6function batch(Prism) {
7 ;(function (Prism) {
8 var variable = /%%?[~:\w]+%?|!\S+!/
9 var parameter = {
10 pattern: /\/[a-z?]+(?=[ :]|$):?|-[a-z]\b|--[a-z-]+\b/im,
11 alias: 'attr-name',
12 inside: {
13 punctuation: /:/
14 }
15 }
16 var string = /"(?:[\\"]"|[^"])*"(?!")/
17 var number = /(?:\b|-)\d+\b/
18 Prism.languages.batch = {
19 comment: [
20 /^::.*/m,
21 {
22 pattern: /((?:^|[&(])[ \t]*)rem\b(?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
23 lookbehind: true
24 }
25 ],
26 label: {
27 pattern: /^:.*/m,
28 alias: 'property'
29 },
30 command: [
31 {
32 // FOR command
33 pattern:
34 /((?:^|[&(])[ \t]*)for(?: \/[a-z?](?:[ :](?:"[^"]*"|[^\s"/]\S*))?)* \S+ in \([^)]+\) do/im,
35 lookbehind: true,
36 inside: {
37 keyword: /\b(?:do|in)\b|^for\b/i,
38 string: string,
39 parameter: parameter,
40 variable: variable,
41 number: number,
42 punctuation: /[()',]/
43 }
44 },
45 {
46 // IF command
47 pattern:
48 /((?:^|[&(])[ \t]*)if(?: \/[a-z?](?:[ :](?:"[^"]*"|[^\s"/]\S*))?)* (?:not )?(?:cmdextversion \d+|defined \w+|errorlevel \d+|exist \S+|(?:"[^"]*"|(?!")(?:(?!==)\S)+)?(?:==| (?:equ|geq|gtr|leq|lss|neq) )(?:"[^"]*"|[^\s"]\S*))/im,
49 lookbehind: true,
50 inside: {
51 keyword:
52 /\b(?:cmdextversion|defined|errorlevel|exist|not)\b|^if\b/i,
53 string: string,
54 parameter: parameter,
55 variable: variable,
56 number: number,
57 operator: /\^|==|\b(?:equ|geq|gtr|leq|lss|neq)\b/i
58 }
59 },
60 {
61 // ELSE command
62 pattern: /((?:^|[&()])[ \t]*)else\b/im,
63 lookbehind: true,
64 inside: {
65 keyword: /^else\b/i
66 }
67 },
68 {
69 // SET command
70 pattern:
71 /((?:^|[&(])[ \t]*)set(?: \/[a-z](?:[ :](?:"[^"]*"|[^\s"/]\S*))?)* (?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
72 lookbehind: true,
73 inside: {
74 keyword: /^set\b/i,
75 string: string,
76 parameter: parameter,
77 variable: [variable, /\w+(?=(?:[*\/%+\-&^|]|<<|>>)?=)/],
78 number: number,
79 operator: /[*\/%+\-&^|]=?|<<=?|>>=?|[!~_=]/,
80 punctuation: /[()',]/
81 }
82 },
83 {
84 // Other commands
85 pattern:
86 /((?:^|[&(])[ \t]*@?)\w+\b(?:"(?:[\\"]"|[^"])*"(?!")|[^"^&)\r\n]|\^(?:\r\n|[\s\S]))*/m,
87 lookbehind: true,
88 inside: {
89 keyword: /^\w+\b/,
90 string: string,
91 parameter: parameter,
92 label: {
93 pattern: /(^\s*):\S+/m,
94 lookbehind: true,
95 alias: 'property'
96 },
97 variable: variable,
98 number: number,
99 operator: /\^/
100 }
101 }
102 ],
103 operator: /[&@]/,
104 punctuation: /[()']/
105 }
106 })(Prism)
107}
Note: See TracBrowser for help on using the repository browser.