Show More
The requested changes are too big and content was truncated. Show full diff
@@ -0,0 +1,173 b'' | |||
|
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | ||
|
4 | (function(mod) { | |
|
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
|
6 | mod(require("../../lib/codemirror")); | |
|
7 | else if (typeof define == "function" && define.amd) // AMD | |
|
8 | define(["../../lib/codemirror"], mod); | |
|
9 | else // Plain browser env | |
|
10 | mod(CodeMirror); | |
|
11 | })(function(CodeMirror) { | |
|
12 | "use strict"; | |
|
13 | ||
|
14 | CodeMirror.defineMode("fcl", function(config) { | |
|
15 | var indentUnit = config.indentUnit; | |
|
16 | ||
|
17 | var keywords = { | |
|
18 | "term": true, | |
|
19 | "method": true, "accu": true, | |
|
20 | "rule": true, "then": true, "is": true, "and": true, "or": true, | |
|
21 | "if": true, "default": true | |
|
22 | }; | |
|
23 | ||
|
24 | var start_blocks = { | |
|
25 | "var_input": true, | |
|
26 | "var_output": true, | |
|
27 | "fuzzify": true, | |
|
28 | "defuzzify": true, | |
|
29 | "function_block": true, | |
|
30 | "ruleblock": true | |
|
31 | }; | |
|
32 | ||
|
33 | var end_blocks = { | |
|
34 | "end_ruleblock": true, | |
|
35 | "end_defuzzify": true, | |
|
36 | "end_function_block": true, | |
|
37 | "end_fuzzify": true, | |
|
38 | "end_var": true | |
|
39 | }; | |
|
40 | ||
|
41 | var atoms = { | |
|
42 | "true": true, "false": true, "nan": true, | |
|
43 | "real": true, "min": true, "max": true, "cog": true, "cogs": true | |
|
44 | }; | |
|
45 | ||
|
46 | var isOperatorChar = /[+\-*&^%:=<>!|\/]/; | |
|
47 | ||
|
48 | function tokenBase(stream, state) { | |
|
49 | var ch = stream.next(); | |
|
50 | ||
|
51 | if (/[\d\.]/.test(ch)) { | |
|
52 | if (ch == ".") { | |
|
53 | stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/); | |
|
54 | } else if (ch == "0") { | |
|
55 | stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/); | |
|
56 | } else { | |
|
57 | stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/); | |
|
58 | } | |
|
59 | return "number"; | |
|
60 | } | |
|
61 | ||
|
62 | if (ch == "/" || ch == "(") { | |
|
63 | if (stream.eat("*")) { | |
|
64 | state.tokenize = tokenComment; | |
|
65 | return tokenComment(stream, state); | |
|
66 | } | |
|
67 | if (stream.eat("/")) { | |
|
68 | stream.skipToEnd(); | |
|
69 | return "comment"; | |
|
70 | } | |
|
71 | } | |
|
72 | if (isOperatorChar.test(ch)) { | |
|
73 | stream.eatWhile(isOperatorChar); | |
|
74 | return "operator"; | |
|
75 | } | |
|
76 | stream.eatWhile(/[\w\$_\xa1-\uffff]/); | |
|
77 | ||
|
78 | var cur = stream.current().toLowerCase(); | |
|
79 | if (keywords.propertyIsEnumerable(cur) || | |
|
80 | start_blocks.propertyIsEnumerable(cur) || | |
|
81 | end_blocks.propertyIsEnumerable(cur)) { | |
|
82 | return "keyword"; | |
|
83 | } | |
|
84 | if (atoms.propertyIsEnumerable(cur)) return "atom"; | |
|
85 | return "variable"; | |
|
86 | } | |
|
87 | ||
|
88 | ||
|
89 | function tokenComment(stream, state) { | |
|
90 | var maybeEnd = false, ch; | |
|
91 | while (ch = stream.next()) { | |
|
92 | if ((ch == "/" || ch == ")") && maybeEnd) { | |
|
93 | state.tokenize = tokenBase; | |
|
94 | break; | |
|
95 | } | |
|
96 | maybeEnd = (ch == "*"); | |
|
97 | } | |
|
98 | return "comment"; | |
|
99 | } | |
|
100 | ||
|
101 | function Context(indented, column, type, align, prev) { | |
|
102 | this.indented = indented; | |
|
103 | this.column = column; | |
|
104 | this.type = type; | |
|
105 | this.align = align; | |
|
106 | this.prev = prev; | |
|
107 | } | |
|
108 | ||
|
109 | function pushContext(state, col, type) { | |
|
110 | return state.context = new Context(state.indented, col, type, null, state.context); | |
|
111 | } | |
|
112 | ||
|
113 | function popContext(state) { | |
|
114 | if (!state.context.prev) return; | |
|
115 | var t = state.context.type; | |
|
116 | if (t == "end_block") | |
|
117 | state.indented = state.context.indented; | |
|
118 | return state.context = state.context.prev; | |
|
119 | } | |
|
120 | ||
|
121 | // Interface | |
|
122 | ||
|
123 | return { | |
|
124 | startState: function(basecolumn) { | |
|
125 | return { | |
|
126 | tokenize: null, | |
|
127 | context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), | |
|
128 | indented: 0, | |
|
129 | startOfLine: true | |
|
130 | }; | |
|
131 | }, | |
|
132 | ||
|
133 | token: function(stream, state) { | |
|
134 | var ctx = state.context; | |
|
135 | if (stream.sol()) { | |
|
136 | if (ctx.align == null) ctx.align = false; | |
|
137 | state.indented = stream.indentation(); | |
|
138 | state.startOfLine = true; | |
|
139 | } | |
|
140 | if (stream.eatSpace()) return null; | |
|
141 | ||
|
142 | var style = (state.tokenize || tokenBase)(stream, state); | |
|
143 | if (style == "comment") return style; | |
|
144 | if (ctx.align == null) ctx.align = true; | |
|
145 | ||
|
146 | var cur = stream.current().toLowerCase(); | |
|
147 | ||
|
148 | if (start_blocks.propertyIsEnumerable(cur)) pushContext(state, stream.column(), "end_block"); | |
|
149 | else if (end_blocks.propertyIsEnumerable(cur)) popContext(state); | |
|
150 | ||
|
151 | state.startOfLine = false; | |
|
152 | return style; | |
|
153 | }, | |
|
154 | ||
|
155 | indent: function(state, textAfter) { | |
|
156 | if (state.tokenize != tokenBase && state.tokenize != null) return 0; | |
|
157 | var ctx = state.context; | |
|
158 | ||
|
159 | var closing = end_blocks.propertyIsEnumerable(textAfter); | |
|
160 | if (ctx.align) return ctx.column + (closing ? 0 : 1); | |
|
161 | else return ctx.indented + (closing ? 0 : indentUnit); | |
|
162 | }, | |
|
163 | ||
|
164 | electricChars: "ryk", | |
|
165 | fold: "brace", | |
|
166 | blockCommentStart: "(*", | |
|
167 | blockCommentEnd: "*)", | |
|
168 | lineComment: "//" | |
|
169 | }; | |
|
170 | }); | |
|
171 | ||
|
172 | CodeMirror.defineMIME("text/x-fcl", "fcl"); | |
|
173 | }); |
@@ -0,0 +1,129 b'' | |||
|
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | ||
|
4 | (function(mod) { | |
|
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
|
6 | mod(require("../../lib/codemirror")); | |
|
7 | else if (typeof define == "function" && define.amd) // AMD | |
|
8 | define(["../../lib/codemirror"], mod); | |
|
9 | else // Plain browser env | |
|
10 | mod(CodeMirror); | |
|
11 | })(function(CodeMirror) { | |
|
12 | "use strict"; | |
|
13 | ||
|
14 | var rfc2822 = [ | |
|
15 | "From", "Sender", "Reply-To", "To", "Cc", "Bcc", "Message-ID", | |
|
16 | "In-Reply-To", "References", "Resent-From", "Resent-Sender", "Resent-To", | |
|
17 | "Resent-Cc", "Resent-Bcc", "Resent-Message-ID", "Return-Path", "Received" | |
|
18 | ]; | |
|
19 | var rfc2822NoEmail = [ | |
|
20 | "Date", "Subject", "Comments", "Keywords", "Resent-Date" | |
|
21 | ]; | |
|
22 | ||
|
23 | CodeMirror.registerHelper("hintWords", "mbox", rfc2822.concat(rfc2822NoEmail)); | |
|
24 | ||
|
25 | var whitespace = /^[ \t]/; | |
|
26 | var separator = /^From /; // See RFC 4155 | |
|
27 | var rfc2822Header = new RegExp("^(" + rfc2822.join("|") + "): "); | |
|
28 | var rfc2822HeaderNoEmail = new RegExp("^(" + rfc2822NoEmail.join("|") + "): "); | |
|
29 | var header = /^[^:]+:/; // Optional fields defined in RFC 2822 | |
|
30 | var email = /^[^ ]+@[^ ]+/; | |
|
31 | var untilEmail = /^.*?(?=[^ ]+?@[^ ]+)/; | |
|
32 | var bracketedEmail = /^<.*?>/; | |
|
33 | var untilBracketedEmail = /^.*?(?=<.*>)/; | |
|
34 | ||
|
35 | function styleForHeader(header) { | |
|
36 | if (header === "Subject") return "header"; | |
|
37 | return "string"; | |
|
38 | } | |
|
39 | ||
|
40 | function readToken(stream, state) { | |
|
41 | if (stream.sol()) { | |
|
42 | // From last line | |
|
43 | state.inSeparator = false; | |
|
44 | if (state.inHeader && stream.match(whitespace)) { | |
|
45 | // Header folding | |
|
46 | return null; | |
|
47 | } else { | |
|
48 | state.inHeader = false; | |
|
49 | state.header = null; | |
|
50 | } | |
|
51 | ||
|
52 | if (stream.match(separator)) { | |
|
53 | state.inHeaders = true; | |
|
54 | state.inSeparator = true; | |
|
55 | return "atom"; | |
|
56 | } | |
|
57 | ||
|
58 | var match; | |
|
59 | var emailPermitted = false; | |
|
60 | if ((match = stream.match(rfc2822HeaderNoEmail)) || | |
|
61 | (emailPermitted = true) && (match = stream.match(rfc2822Header))) { | |
|
62 | state.inHeaders = true; | |
|
63 | state.inHeader = true; | |
|
64 | state.emailPermitted = emailPermitted; | |
|
65 | state.header = match[1]; | |
|
66 | return "atom"; | |
|
67 | } | |
|
68 | ||
|
69 | // Use vim's heuristics: recognize custom headers only if the line is in a | |
|
70 | // block of legitimate headers. | |
|
71 | if (state.inHeaders && (match = stream.match(header))) { | |
|
72 | state.inHeader = true; | |
|
73 | state.emailPermitted = true; | |
|
74 | state.header = match[1]; | |
|
75 | return "atom"; | |
|
76 | } | |
|
77 | ||
|
78 | state.inHeaders = false; | |
|
79 | stream.skipToEnd(); | |
|
80 | return null; | |
|
81 | } | |
|
82 | ||
|
83 | if (state.inSeparator) { | |
|
84 | if (stream.match(email)) return "link"; | |
|
85 | if (stream.match(untilEmail)) return "atom"; | |
|
86 | stream.skipToEnd(); | |
|
87 | return "atom"; | |
|
88 | } | |
|
89 | ||
|
90 | if (state.inHeader) { | |
|
91 | var style = styleForHeader(state.header); | |
|
92 | ||
|
93 | if (state.emailPermitted) { | |
|
94 | if (stream.match(bracketedEmail)) return style + " link"; | |
|
95 | if (stream.match(untilBracketedEmail)) return style; | |
|
96 | } | |
|
97 | stream.skipToEnd(); | |
|
98 | return style; | |
|
99 | } | |
|
100 | ||
|
101 | stream.skipToEnd(); | |
|
102 | return null; | |
|
103 | }; | |
|
104 | ||
|
105 | CodeMirror.defineMode("mbox", function() { | |
|
106 | return { | |
|
107 | startState: function() { | |
|
108 | return { | |
|
109 | // Is in a mbox separator | |
|
110 | inSeparator: false, | |
|
111 | // Is in a mail header | |
|
112 | inHeader: false, | |
|
113 | // If bracketed email is permitted. Only applicable when inHeader | |
|
114 | emailPermitted: false, | |
|
115 | // Name of current header | |
|
116 | header: null, | |
|
117 | // Is in a region of mail headers | |
|
118 | inHeaders: false | |
|
119 | }; | |
|
120 | }, | |
|
121 | token: readToken, | |
|
122 | blankLine: function(state) { | |
|
123 | state.inHeaders = state.inSeparator = state.inHeader = false; | |
|
124 | } | |
|
125 | }; | |
|
126 | }); | |
|
127 | ||
|
128 | CodeMirror.defineMIME("application/mbox", "mbox"); | |
|
129 | }); |
@@ -0,0 +1,398 b'' | |||
|
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | ||
|
4 | (function(mod) { | |
|
5 | 'use strict'; | |
|
6 | if (typeof exports == 'object' && typeof module == 'object') // CommonJS | |
|
7 | mod(require('../../lib/codemirror')); | |
|
8 | else if (typeof define == 'function' && define.amd) // AMD | |
|
9 | define(['../../lib/codemirror'], mod); | |
|
10 | else // Plain browser env | |
|
11 | mod(window.CodeMirror); | |
|
12 | })(function(CodeMirror) { | |
|
13 | 'use strict'; | |
|
14 | ||
|
15 | CodeMirror.defineMode('powershell', function() { | |
|
16 | function buildRegexp(patterns, options) { | |
|
17 | options = options || {}; | |
|
18 | var prefix = options.prefix !== undefined ? options.prefix : '^'; | |
|
19 | var suffix = options.suffix !== undefined ? options.suffix : '\\b'; | |
|
20 | ||
|
21 | for (var i = 0; i < patterns.length; i++) { | |
|
22 | if (patterns[i] instanceof RegExp) { | |
|
23 | patterns[i] = patterns[i].source; | |
|
24 | } | |
|
25 | else { | |
|
26 | patterns[i] = patterns[i].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); | |
|
27 | } | |
|
28 | } | |
|
29 | ||
|
30 | return new RegExp(prefix + '(' + patterns.join('|') + ')' + suffix, 'i'); | |
|
31 | } | |
|
32 | ||
|
33 | var notCharacterOrDash = '(?=[^A-Za-z\\d\\-_]|$)'; | |
|
34 | var varNames = /[\w\-:]/ | |
|
35 | var keywords = buildRegexp([ | |
|
36 | /begin|break|catch|continue|data|default|do|dynamicparam/, | |
|
37 | /else|elseif|end|exit|filter|finally|for|foreach|from|function|if|in/, | |
|
38 | /param|process|return|switch|throw|trap|try|until|where|while/ | |
|
39 | ], { suffix: notCharacterOrDash }); | |
|
40 | ||
|
41 | var punctuation = /[\[\]{},;`\.]|@[({]/; | |
|
42 | var wordOperators = buildRegexp([ | |
|
43 | 'f', | |
|
44 | /b?not/, | |
|
45 | /[ic]?split/, 'join', | |
|
46 | /is(not)?/, 'as', | |
|
47 | /[ic]?(eq|ne|[gl][te])/, | |
|
48 | /[ic]?(not)?(like|match|contains)/, | |
|
49 | /[ic]?replace/, | |
|
50 | /b?(and|or|xor)/ | |
|
51 | ], { prefix: '-' }); | |
|
52 | var symbolOperators = /[+\-*\/%]=|\+\+|--|\.\.|[+\-*&^%:=!|\/]|<(?!#)|(?!#)>/; | |
|
53 | var operators = buildRegexp([wordOperators, symbolOperators], { suffix: '' }); | |
|
54 | ||
|
55 | var numbers = /^((0x[\da-f]+)|((\d+\.\d+|\d\.|\.\d+|\d+)(e[\+\-]?\d+)?))[ld]?([kmgtp]b)?/i; | |
|
56 | ||
|
57 | var identifiers = /^[A-Za-z\_][A-Za-z\-\_\d]*\b/; | |
|
58 | ||
|
59 | var symbolBuiltins = /[A-Z]:|%|\?/i; | |
|
60 | var namedBuiltins = buildRegexp([ | |
|
61 | /Add-(Computer|Content|History|Member|PSSnapin|Type)/, | |
|
62 | /Checkpoint-Computer/, | |
|
63 | /Clear-(Content|EventLog|History|Host|Item(Property)?|Variable)/, | |
|
64 | /Compare-Object/, | |
|
65 | /Complete-Transaction/, | |
|
66 | /Connect-PSSession/, | |
|
67 | /ConvertFrom-(Csv|Json|SecureString|StringData)/, | |
|
68 | /Convert-Path/, | |
|
69 | /ConvertTo-(Csv|Html|Json|SecureString|Xml)/, | |
|
70 | /Copy-Item(Property)?/, | |
|
71 | /Debug-Process/, | |
|
72 | /Disable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/, | |
|
73 | /Disconnect-PSSession/, | |
|
74 | /Enable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/, | |
|
75 | /(Enter|Exit)-PSSession/, | |
|
76 | /Export-(Alias|Clixml|Console|Counter|Csv|FormatData|ModuleMember|PSSession)/, | |
|
77 | /ForEach-Object/, | |
|
78 | /Format-(Custom|List|Table|Wide)/, | |
|
79 | new RegExp('Get-(Acl|Alias|AuthenticodeSignature|ChildItem|Command|ComputerRestorePoint|Content|ControlPanelItem|Counter|Credential' | |
|
80 | + '|Culture|Date|Event|EventLog|EventSubscriber|ExecutionPolicy|FormatData|Help|History|Host|HotFix|Item|ItemProperty|Job' | |
|
81 | + '|Location|Member|Module|PfxCertificate|Process|PSBreakpoint|PSCallStack|PSDrive|PSProvider|PSSession|PSSessionConfiguration' | |
|
82 | + '|PSSnapin|Random|Service|TraceSource|Transaction|TypeData|UICulture|Unique|Variable|Verb|WinEvent|WmiObject)'), | |
|
83 | /Group-Object/, | |
|
84 | /Import-(Alias|Clixml|Counter|Csv|LocalizedData|Module|PSSession)/, | |
|
85 | /ImportSystemModules/, | |
|
86 | /Invoke-(Command|Expression|History|Item|RestMethod|WebRequest|WmiMethod)/, | |
|
87 | /Join-Path/, | |
|
88 | /Limit-EventLog/, | |
|
89 | /Measure-(Command|Object)/, | |
|
90 | /Move-Item(Property)?/, | |
|
91 | new RegExp('New-(Alias|Event|EventLog|Item(Property)?|Module|ModuleManifest|Object|PSDrive|PSSession|PSSessionConfigurationFile' | |
|
92 | + '|PSSessionOption|PSTransportOption|Service|TimeSpan|Variable|WebServiceProxy|WinEvent)'), | |
|
93 | /Out-(Default|File|GridView|Host|Null|Printer|String)/, | |
|
94 | /Pause/, | |
|
95 | /(Pop|Push)-Location/, | |
|
96 | /Read-Host/, | |
|
97 | /Receive-(Job|PSSession)/, | |
|
98 | /Register-(EngineEvent|ObjectEvent|PSSessionConfiguration|WmiEvent)/, | |
|
99 | /Remove-(Computer|Event|EventLog|Item(Property)?|Job|Module|PSBreakpoint|PSDrive|PSSession|PSSnapin|TypeData|Variable|WmiObject)/, | |
|
100 | /Rename-(Computer|Item(Property)?)/, | |
|
101 | /Reset-ComputerMachinePassword/, | |
|
102 | /Resolve-Path/, | |
|
103 | /Restart-(Computer|Service)/, | |
|
104 | /Restore-Computer/, | |
|
105 | /Resume-(Job|Service)/, | |
|
106 | /Save-Help/, | |
|
107 | /Select-(Object|String|Xml)/, | |
|
108 | /Send-MailMessage/, | |
|
109 | new RegExp('Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item(Property)?|Location|PSBreakpoint|PSDebug' + | |
|
110 | '|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance)'), | |
|
111 | /Show-(Command|ControlPanelItem|EventLog)/, | |
|
112 | /Sort-Object/, | |
|
113 | /Split-Path/, | |
|
114 | /Start-(Job|Process|Service|Sleep|Transaction|Transcript)/, | |
|
115 | /Stop-(Computer|Job|Process|Service|Transcript)/, | |
|
116 | /Suspend-(Job|Service)/, | |
|
117 | /TabExpansion2/, | |
|
118 | /Tee-Object/, | |
|
119 | /Test-(ComputerSecureChannel|Connection|ModuleManifest|Path|PSSessionConfigurationFile)/, | |
|
120 | /Trace-Command/, | |
|
121 | /Unblock-File/, | |
|
122 | /Undo-Transaction/, | |
|
123 | /Unregister-(Event|PSSessionConfiguration)/, | |
|
124 | /Update-(FormatData|Help|List|TypeData)/, | |
|
125 | /Use-Transaction/, | |
|
126 | /Wait-(Event|Job|Process)/, | |
|
127 | /Where-Object/, | |
|
128 | /Write-(Debug|Error|EventLog|Host|Output|Progress|Verbose|Warning)/, | |
|
129 | /cd|help|mkdir|more|oss|prompt/, | |
|
130 | /ac|asnp|cat|cd|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|dnsn|ebp/, | |
|
131 | /echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps/, | |
|
132 | /group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md/, | |
|
133 | /measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri/, | |
|
134 | /rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls/, | |
|
135 | /sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|where|wjb|write/ | |
|
136 | ], { prefix: '', suffix: '' }); | |
|
137 | var variableBuiltins = buildRegexp([ | |
|
138 | /[$?^_]|Args|ConfirmPreference|ConsoleFileName|DebugPreference|Error|ErrorActionPreference|ErrorView|ExecutionContext/, | |
|
139 | /FormatEnumerationLimit|Home|Host|Input|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount/, | |
|
140 | /MaximumHistoryCount|MaximumVariableCount|MyInvocation|NestedPromptLevel|OutputEncoding|Pid|Profile|ProgressPreference/, | |
|
141 | /PSBoundParameters|PSCommandPath|PSCulture|PSDefaultParameterValues|PSEmailServer|PSHome|PSScriptRoot|PSSessionApplicationName/, | |
|
142 | /PSSessionConfigurationName|PSSessionOption|PSUICulture|PSVersionTable|Pwd|ShellId|StackTrace|VerbosePreference/, | |
|
143 | /WarningPreference|WhatIfPreference/, | |
|
144 | ||
|
145 | /Event|EventArgs|EventSubscriber|Sender/, | |
|
146 | /Matches|Ofs|ForEach|LastExitCode|PSCmdlet|PSItem|PSSenderInfo|This/, | |
|
147 | /true|false|null/ | |
|
148 | ], { prefix: '\\$', suffix: '' }); | |
|
149 | ||
|
150 | var builtins = buildRegexp([symbolBuiltins, namedBuiltins, variableBuiltins], { suffix: notCharacterOrDash }); | |
|
151 | ||
|
152 | var grammar = { | |
|
153 | keyword: keywords, | |
|
154 | number: numbers, | |
|
155 | operator: operators, | |
|
156 | builtin: builtins, | |
|
157 | punctuation: punctuation, | |
|
158 | identifier: identifiers | |
|
159 | }; | |
|
160 | ||
|
161 | // tokenizers | |
|
162 | function tokenBase(stream, state) { | |
|
163 | // Handle Comments | |
|
164 | //var ch = stream.peek(); | |
|
165 | ||
|
166 | var parent = state.returnStack[state.returnStack.length - 1]; | |
|
167 | if (parent && parent.shouldReturnFrom(state)) { | |
|
168 | state.tokenize = parent.tokenize; | |
|
169 | state.returnStack.pop(); | |
|
170 | return state.tokenize(stream, state); | |
|
171 | } | |
|
172 | ||
|
173 | if (stream.eatSpace()) { | |
|
174 | return null; | |
|
175 | } | |
|
176 | ||
|
177 | if (stream.eat('(')) { | |
|
178 | state.bracketNesting += 1; | |
|
179 | return 'punctuation'; | |
|
180 | } | |
|
181 | ||
|
182 | if (stream.eat(')')) { | |
|
183 | state.bracketNesting -= 1; | |
|
184 | return 'punctuation'; | |
|
185 | } | |
|
186 | ||
|
187 | for (var key in grammar) { | |
|
188 | if (stream.match(grammar[key])) { | |
|
189 | return key; | |
|
190 | } | |
|
191 | } | |
|
192 | ||
|
193 | var ch = stream.next(); | |
|
194 | ||
|
195 | // single-quote string | |
|
196 | if (ch === "'") { | |
|
197 | return tokenSingleQuoteString(stream, state); | |
|
198 | } | |
|
199 | ||
|
200 | if (ch === '$') { | |
|
201 | return tokenVariable(stream, state); | |
|
202 | } | |
|
203 | ||
|
204 | // double-quote string | |
|
205 | if (ch === '"') { | |
|
206 | return tokenDoubleQuoteString(stream, state); | |
|
207 | } | |
|
208 | ||
|
209 | if (ch === '<' && stream.eat('#')) { | |
|
210 | state.tokenize = tokenComment; | |
|
211 | return tokenComment(stream, state); | |
|
212 | } | |
|
213 | ||
|
214 | if (ch === '#') { | |
|
215 | stream.skipToEnd(); | |
|
216 | return 'comment'; | |
|
217 | } | |
|
218 | ||
|
219 | if (ch === '@') { | |
|
220 | var quoteMatch = stream.eat(/["']/); | |
|
221 | if (quoteMatch && stream.eol()) { | |
|
222 | state.tokenize = tokenMultiString; | |
|
223 | state.startQuote = quoteMatch[0]; | |
|
224 | return tokenMultiString(stream, state); | |
|
225 | } else if (stream.eol()) { | |
|
226 | return 'error'; | |
|
227 | } else if (stream.peek().match(/[({]/)) { | |
|
228 | return 'punctuation'; | |
|
229 | } else if (stream.peek().match(varNames)) { | |
|
230 | // splatted variable | |
|
231 | return tokenVariable(stream, state); | |
|
232 | } | |
|
233 | } | |
|
234 | return 'error'; | |
|
235 | } | |
|
236 | ||
|
237 | function tokenSingleQuoteString(stream, state) { | |
|
238 | var ch; | |
|
239 | while ((ch = stream.peek()) != null) { | |
|
240 | stream.next(); | |
|
241 | ||
|
242 | if (ch === "'" && !stream.eat("'")) { | |
|
243 | state.tokenize = tokenBase; | |
|
244 | return 'string'; | |
|
245 | } | |
|
246 | } | |
|
247 | ||
|
248 | return 'error'; | |
|
249 | } | |
|
250 | ||
|
251 | function tokenDoubleQuoteString(stream, state) { | |
|
252 | var ch; | |
|
253 | while ((ch = stream.peek()) != null) { | |
|
254 | if (ch === '$') { | |
|
255 | state.tokenize = tokenStringInterpolation; | |
|
256 | return 'string'; | |
|
257 | } | |
|
258 | ||
|
259 | stream.next(); | |
|
260 | if (ch === '`') { | |
|
261 | stream.next(); | |
|
262 | continue; | |
|
263 | } | |
|
264 | ||
|
265 | if (ch === '"' && !stream.eat('"')) { | |
|
266 | state.tokenize = tokenBase; | |
|
267 | return 'string'; | |
|
268 | } | |
|
269 | } | |
|
270 | ||
|
271 | return 'error'; | |
|
272 | } | |
|
273 | ||
|
274 | function tokenStringInterpolation(stream, state) { | |
|
275 | return tokenInterpolation(stream, state, tokenDoubleQuoteString); | |
|
276 | } | |
|
277 | ||
|
278 | function tokenMultiStringReturn(stream, state) { | |
|
279 | state.tokenize = tokenMultiString; | |
|
280 | state.startQuote = '"' | |
|
281 | return tokenMultiString(stream, state); | |
|
282 | } | |
|
283 | ||
|
284 | function tokenHereStringInterpolation(stream, state) { | |
|
285 | return tokenInterpolation(stream, state, tokenMultiStringReturn); | |
|
286 | } | |
|
287 | ||
|
288 | function tokenInterpolation(stream, state, parentTokenize) { | |
|
289 | if (stream.match('$(')) { | |
|
290 | var savedBracketNesting = state.bracketNesting; | |
|
291 | state.returnStack.push({ | |
|
292 | /*jshint loopfunc:true */ | |
|
293 | shouldReturnFrom: function(state) { | |
|
294 | return state.bracketNesting === savedBracketNesting; | |
|
295 | }, | |
|
296 | tokenize: parentTokenize | |
|
297 | }); | |
|
298 | state.tokenize = tokenBase; | |
|
299 | state.bracketNesting += 1; | |
|
300 | return 'punctuation'; | |
|
301 | } else { | |
|
302 | stream.next(); | |
|
303 | state.returnStack.push({ | |
|
304 | shouldReturnFrom: function() { return true; }, | |
|
305 | tokenize: parentTokenize | |
|
306 | }); | |
|
307 | state.tokenize = tokenVariable; | |
|
308 | return state.tokenize(stream, state); | |
|
309 | } | |
|
310 | } | |
|
311 | ||
|
312 | function tokenComment(stream, state) { | |
|
313 | var maybeEnd = false, ch; | |
|
314 | while ((ch = stream.next()) != null) { | |
|
315 | if (maybeEnd && ch == '>') { | |
|
316 | state.tokenize = tokenBase; | |
|
317 | break; | |
|
318 | } | |
|
319 | maybeEnd = (ch === '#'); | |
|
320 | } | |
|
321 | return 'comment'; | |
|
322 | } | |
|
323 | ||
|
324 | function tokenVariable(stream, state) { | |
|
325 | var ch = stream.peek(); | |
|
326 | if (stream.eat('{')) { | |
|
327 | state.tokenize = tokenVariableWithBraces; | |
|
328 | return tokenVariableWithBraces(stream, state); | |
|
329 | } else if (ch != undefined && ch.match(varNames)) { | |
|
330 | stream.eatWhile(varNames); | |
|
331 | state.tokenize = tokenBase; | |
|
332 | return 'variable-2'; | |
|
333 | } else { | |
|
334 | state.tokenize = tokenBase; | |
|
335 | return 'error'; | |
|
336 | } | |
|
337 | } | |
|
338 | ||
|
339 | function tokenVariableWithBraces(stream, state) { | |
|
340 | var ch; | |
|
341 | while ((ch = stream.next()) != null) { | |
|
342 | if (ch === '}') { | |
|
343 | state.tokenize = tokenBase; | |
|
344 | break; | |
|
345 | } | |
|
346 | } | |
|
347 | return 'variable-2'; | |
|
348 | } | |
|
349 | ||
|
350 | function tokenMultiString(stream, state) { | |
|
351 | var quote = state.startQuote; | |
|
352 | if (stream.sol() && stream.match(new RegExp(quote + '@'))) { | |
|
353 | state.tokenize = tokenBase; | |
|
354 | } | |
|
355 | else if (quote === '"') { | |
|
356 | while (!stream.eol()) { | |
|
357 | var ch = stream.peek(); | |
|
358 | if (ch === '$') { | |
|
359 | state.tokenize = tokenHereStringInterpolation; | |
|
360 | return 'string'; | |
|
361 | } | |
|
362 | ||
|
363 | stream.next(); | |
|
364 | if (ch === '`') { | |
|
365 | stream.next(); | |
|
366 | } | |
|
367 | } | |
|
368 | } | |
|
369 | else { | |
|
370 | stream.skipToEnd(); | |
|
371 | } | |
|
372 | ||
|
373 | return 'string'; | |
|
374 | } | |
|
375 | ||
|
376 | var external = { | |
|
377 | startState: function() { | |
|
378 | return { | |
|
379 | returnStack: [], | |
|
380 | bracketNesting: 0, | |
|
381 | tokenize: tokenBase | |
|
382 | }; | |
|
383 | }, | |
|
384 | ||
|
385 | token: function(stream, state) { | |
|
386 | return state.tokenize(stream, state); | |
|
387 | }, | |
|
388 | ||
|
389 | blockCommentStart: '<#', | |
|
390 | blockCommentEnd: '#>', | |
|
391 | lineComment: '#', | |
|
392 | fold: 'brace' | |
|
393 | }; | |
|
394 | return external; | |
|
395 | }); | |
|
396 | ||
|
397 | CodeMirror.defineMIME('application/x-powershell', 'powershell'); | |
|
398 | }); |
@@ -0,0 +1,69 b'' | |||
|
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | ||
|
4 | (function(mod) { | |
|
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
|
6 | mod(require("../../lib/codemirror")); | |
|
7 | else if (typeof define == "function" && define.amd) // AMD | |
|
8 | define(["../../lib/codemirror"], mod); | |
|
9 | else // Plain browser env | |
|
10 | mod(CodeMirror); | |
|
11 | })(function(CodeMirror) { | |
|
12 | "use strict"; | |
|
13 | ||
|
14 | function wordRegexp(words) { | |
|
15 | return new RegExp("^((" + words.join(")|(") + "))\\b", "i"); | |
|
16 | }; | |
|
17 | ||
|
18 | var keywordArray = [ | |
|
19 | "package", "message", "import", "syntax", | |
|
20 | "required", "optional", "repeated", "reserved", "default", "extensions", "packed", | |
|
21 | "bool", "bytes", "double", "enum", "float", "string", | |
|
22 | "int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64", | |
|
23 | "option", "service", "rpc", "returns" | |
|
24 | ]; | |
|
25 | var keywords = wordRegexp(keywordArray); | |
|
26 | ||
|
27 | CodeMirror.registerHelper("hintWords", "protobuf", keywordArray); | |
|
28 | ||
|
29 | var identifiers = new RegExp("^[_A-Za-z\xa1-\uffff][_A-Za-z0-9\xa1-\uffff]*"); | |
|
30 | ||
|
31 | function tokenBase(stream) { | |
|
32 | // whitespaces | |
|
33 | if (stream.eatSpace()) return null; | |
|
34 | ||
|
35 | // Handle one line Comments | |
|
36 | if (stream.match("//")) { | |
|
37 | stream.skipToEnd(); | |
|
38 | return "comment"; | |
|
39 | } | |
|
40 | ||
|
41 | // Handle Number Literals | |
|
42 | if (stream.match(/^[0-9\.+-]/, false)) { | |
|
43 | if (stream.match(/^[+-]?0x[0-9a-fA-F]+/)) | |
|
44 | return "number"; | |
|
45 | if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/)) | |
|
46 | return "number"; | |
|
47 | if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/)) | |
|
48 | return "number"; | |
|
49 | } | |
|
50 | ||
|
51 | // Handle Strings | |
|
52 | if (stream.match(/^"([^"]|(""))*"/)) { return "string"; } | |
|
53 | if (stream.match(/^'([^']|(''))*'/)) { return "string"; } | |
|
54 | ||
|
55 | // Handle words | |
|
56 | if (stream.match(keywords)) { return "keyword"; } | |
|
57 | if (stream.match(identifiers)) { return "variable"; } ; | |
|
58 | ||
|
59 | // Handle non-detected items | |
|
60 | stream.next(); | |
|
61 | return null; | |
|
62 | }; | |
|
63 | ||
|
64 | CodeMirror.defineMode("protobuf", function() { | |
|
65 | return {token: tokenBase}; | |
|
66 | }); | |
|
67 | ||
|
68 | CodeMirror.defineMIME("text/x-protobuf", "protobuf"); | |
|
69 | }); |
This diff has been collapsed as it changes many lines, (591 lines changed) Show them Hide them | |||
@@ -0,0 +1,591 b'' | |||
|
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | ||
|
4 | (function(mod) { | |
|
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
|
6 | mod(require("../../lib/codemirror"), require("../javascript/javascript"), require("../css/css"), require("../htmlmixed/htmlmixed")); | |
|
7 | else if (typeof define == "function" && define.amd) // AMD | |
|
8 | define(["../../lib/codemirror", "../javascript/javascript", "../css/css", "../htmlmixed/htmlmixed"], mod); | |
|
9 | else // Plain browser env | |
|
10 | mod(CodeMirror); | |
|
11 | })(function(CodeMirror) { | |
|
12 | "use strict"; | |
|
13 | ||
|
14 | CodeMirror.defineMode("pug", function (config) { | |
|
15 | // token types | |
|
16 | var KEYWORD = 'keyword'; | |
|
17 | var DOCTYPE = 'meta'; | |
|
18 | var ID = 'builtin'; | |
|
19 | var CLASS = 'qualifier'; | |
|
20 | ||
|
21 | var ATTRS_NEST = { | |
|
22 | '{': '}', | |
|
23 | '(': ')', | |
|
24 | '[': ']' | |
|
25 | }; | |
|
26 | ||
|
27 | var jsMode = CodeMirror.getMode(config, 'javascript'); | |
|
28 | ||
|
29 | function State() { | |
|
30 | this.javaScriptLine = false; | |
|
31 | this.javaScriptLineExcludesColon = false; | |
|
32 | ||
|
33 | this.javaScriptArguments = false; | |
|
34 | this.javaScriptArgumentsDepth = 0; | |
|
35 | ||
|
36 | this.isInterpolating = false; | |
|
37 | this.interpolationNesting = 0; | |
|
38 | ||
|
39 | this.jsState = CodeMirror.startState(jsMode); | |
|
40 | ||
|
41 | this.restOfLine = ''; | |
|
42 | ||
|
43 | this.isIncludeFiltered = false; | |
|
44 | this.isEach = false; | |
|
45 | ||
|
46 | this.lastTag = ''; | |
|
47 | this.scriptType = ''; | |
|
48 | ||
|
49 | // Attributes Mode | |
|
50 | this.isAttrs = false; | |
|
51 | this.attrsNest = []; | |
|
52 | this.inAttributeName = true; | |
|
53 | this.attributeIsType = false; | |
|
54 | this.attrValue = ''; | |
|
55 | ||
|
56 | // Indented Mode | |
|
57 | this.indentOf = Infinity; | |
|
58 | this.indentToken = ''; | |
|
59 | ||
|
60 | this.innerMode = null; | |
|
61 | this.innerState = null; | |
|
62 | ||
|
63 | this.innerModeForLine = false; | |
|
64 | } | |
|
65 | /** | |
|
66 | * Safely copy a state | |
|
67 | * | |
|
68 | * @return {State} | |
|
69 | */ | |
|
70 | State.prototype.copy = function () { | |
|
71 | var res = new State(); | |
|
72 | res.javaScriptLine = this.javaScriptLine; | |
|
73 | res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon; | |
|
74 | res.javaScriptArguments = this.javaScriptArguments; | |
|
75 | res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth; | |
|
76 | res.isInterpolating = this.isInterpolating; | |
|
77 | res.interpolationNesting = this.interpolationNesting; | |
|
78 | ||
|
79 | res.jsState = CodeMirror.copyState(jsMode, this.jsState); | |
|
80 | ||
|
81 | res.innerMode = this.innerMode; | |
|
82 | if (this.innerMode && this.innerState) { | |
|
83 | res.innerState = CodeMirror.copyState(this.innerMode, this.innerState); | |
|
84 | } | |
|
85 | ||
|
86 | res.restOfLine = this.restOfLine; | |
|
87 | ||
|
88 | res.isIncludeFiltered = this.isIncludeFiltered; | |
|
89 | res.isEach = this.isEach; | |
|
90 | res.lastTag = this.lastTag; | |
|
91 | res.scriptType = this.scriptType; | |
|
92 | res.isAttrs = this.isAttrs; | |
|
93 | res.attrsNest = this.attrsNest.slice(); | |
|
94 | res.inAttributeName = this.inAttributeName; | |
|
95 | res.attributeIsType = this.attributeIsType; | |
|
96 | res.attrValue = this.attrValue; | |
|
97 | res.indentOf = this.indentOf; | |
|
98 | res.indentToken = this.indentToken; | |
|
99 | ||
|
100 | res.innerModeForLine = this.innerModeForLine; | |
|
101 | ||
|
102 | return res; | |
|
103 | }; | |
|
104 | ||
|
105 | function javaScript(stream, state) { | |
|
106 | if (stream.sol()) { | |
|
107 | // if javaScriptLine was set at end of line, ignore it | |
|
108 | state.javaScriptLine = false; | |
|
109 | state.javaScriptLineExcludesColon = false; | |
|
110 | } | |
|
111 | if (state.javaScriptLine) { | |
|
112 | if (state.javaScriptLineExcludesColon && stream.peek() === ':') { | |
|
113 | state.javaScriptLine = false; | |
|
114 | state.javaScriptLineExcludesColon = false; | |
|
115 | return; | |
|
116 | } | |
|
117 | var tok = jsMode.token(stream, state.jsState); | |
|
118 | if (stream.eol()) state.javaScriptLine = false; | |
|
119 | return tok || true; | |
|
120 | } | |
|
121 | } | |
|
122 | function javaScriptArguments(stream, state) { | |
|
123 | if (state.javaScriptArguments) { | |
|
124 | if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== '(') { | |
|
125 | state.javaScriptArguments = false; | |
|
126 | return; | |
|
127 | } | |
|
128 | if (stream.peek() === '(') { | |
|
129 | state.javaScriptArgumentsDepth++; | |
|
130 | } else if (stream.peek() === ')') { | |
|
131 | state.javaScriptArgumentsDepth--; | |
|
132 | } | |
|
133 | if (state.javaScriptArgumentsDepth === 0) { | |
|
134 | state.javaScriptArguments = false; | |
|
135 | return; | |
|
136 | } | |
|
137 | ||
|
138 | var tok = jsMode.token(stream, state.jsState); | |
|
139 | return tok || true; | |
|
140 | } | |
|
141 | } | |
|
142 | ||
|
143 | function yieldStatement(stream) { | |
|
144 | if (stream.match(/^yield\b/)) { | |
|
145 | return 'keyword'; | |
|
146 | } | |
|
147 | } | |
|
148 | ||
|
149 | function doctype(stream) { | |
|
150 | if (stream.match(/^(?:doctype) *([^\n]+)?/)) { | |
|
151 | return DOCTYPE; | |
|
152 | } | |
|
153 | } | |
|
154 | ||
|
155 | function interpolation(stream, state) { | |
|
156 | if (stream.match('#{')) { | |
|
157 | state.isInterpolating = true; | |
|
158 | state.interpolationNesting = 0; | |
|
159 | return 'punctuation'; | |
|
160 | } | |
|
161 | } | |
|
162 | ||
|
163 | function interpolationContinued(stream, state) { | |
|
164 | if (state.isInterpolating) { | |
|
165 | if (stream.peek() === '}') { | |
|
166 | state.interpolationNesting--; | |
|
167 | if (state.interpolationNesting < 0) { | |
|
168 | stream.next(); | |
|
169 | state.isInterpolating = false; | |
|
170 | return 'punctuation'; | |
|
171 | } | |
|
172 | } else if (stream.peek() === '{') { | |
|
173 | state.interpolationNesting++; | |
|
174 | } | |
|
175 | return jsMode.token(stream, state.jsState) || true; | |
|
176 | } | |
|
177 | } | |
|
178 | ||
|
179 | function caseStatement(stream, state) { | |
|
180 | if (stream.match(/^case\b/)) { | |
|
181 | state.javaScriptLine = true; | |
|
182 | return KEYWORD; | |
|
183 | } | |
|
184 | } | |
|
185 | ||
|
186 | function when(stream, state) { | |
|
187 | if (stream.match(/^when\b/)) { | |
|
188 | state.javaScriptLine = true; | |
|
189 | state.javaScriptLineExcludesColon = true; | |
|
190 | return KEYWORD; | |
|
191 | } | |
|
192 | } | |
|
193 | ||
|
194 | function defaultStatement(stream) { | |
|
195 | if (stream.match(/^default\b/)) { | |
|
196 | return KEYWORD; | |
|
197 | } | |
|
198 | } | |
|
199 | ||
|
200 | function extendsStatement(stream, state) { | |
|
201 | if (stream.match(/^extends?\b/)) { | |
|
202 | state.restOfLine = 'string'; | |
|
203 | return KEYWORD; | |
|
204 | } | |
|
205 | } | |
|
206 | ||
|
207 | function append(stream, state) { | |
|
208 | if (stream.match(/^append\b/)) { | |
|
209 | state.restOfLine = 'variable'; | |
|
210 | return KEYWORD; | |
|
211 | } | |
|
212 | } | |
|
213 | function prepend(stream, state) { | |
|
214 | if (stream.match(/^prepend\b/)) { | |
|
215 | state.restOfLine = 'variable'; | |
|
216 | return KEYWORD; | |
|
217 | } | |
|
218 | } | |
|
219 | function block(stream, state) { | |
|
220 | if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) { | |
|
221 | state.restOfLine = 'variable'; | |
|
222 | return KEYWORD; | |
|
223 | } | |
|
224 | } | |
|
225 | ||
|
226 | function include(stream, state) { | |
|
227 | if (stream.match(/^include\b/)) { | |
|
228 | state.restOfLine = 'string'; | |
|
229 | return KEYWORD; | |
|
230 | } | |
|
231 | } | |
|
232 | ||
|
233 | function includeFiltered(stream, state) { | |
|
234 | if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match('include')) { | |
|
235 | state.isIncludeFiltered = true; | |
|
236 | return KEYWORD; | |
|
237 | } | |
|
238 | } | |
|
239 | ||
|
240 | function includeFilteredContinued(stream, state) { | |
|
241 | if (state.isIncludeFiltered) { | |
|
242 | var tok = filter(stream, state); | |
|
243 | state.isIncludeFiltered = false; | |
|
244 | state.restOfLine = 'string'; | |
|
245 | return tok; | |
|
246 | } | |
|
247 | } | |
|
248 | ||
|
249 | function mixin(stream, state) { | |
|
250 | if (stream.match(/^mixin\b/)) { | |
|
251 | state.javaScriptLine = true; | |
|
252 | return KEYWORD; | |
|
253 | } | |
|
254 | } | |
|
255 | ||
|
256 | function call(stream, state) { | |
|
257 | if (stream.match(/^\+([-\w]+)/)) { | |
|
258 | if (!stream.match(/^\( *[-\w]+ *=/, false)) { | |
|
259 | state.javaScriptArguments = true; | |
|
260 | state.javaScriptArgumentsDepth = 0; | |
|
261 | } | |
|
262 | return 'variable'; | |
|
263 | } | |
|
264 | if (stream.match(/^\+#{/, false)) { | |
|
265 | stream.next(); | |
|
266 | state.mixinCallAfter = true; | |
|
267 | return interpolation(stream, state); | |
|
268 | } | |
|
269 | } | |
|
270 | function callArguments(stream, state) { | |
|
271 | if (state.mixinCallAfter) { | |
|
272 | state.mixinCallAfter = false; | |
|
273 | if (!stream.match(/^\( *[-\w]+ *=/, false)) { | |
|
274 | state.javaScriptArguments = true; | |
|
275 | state.javaScriptArgumentsDepth = 0; | |
|
276 | } | |
|
277 | return true; | |
|
278 | } | |
|
279 | } | |
|
280 | ||
|
281 | function conditional(stream, state) { | |
|
282 | if (stream.match(/^(if|unless|else if|else)\b/)) { | |
|
283 | state.javaScriptLine = true; | |
|
284 | return KEYWORD; | |
|
285 | } | |
|
286 | } | |
|
287 | ||
|
288 | function each(stream, state) { | |
|
289 | if (stream.match(/^(- *)?(each|for)\b/)) { | |
|
290 | state.isEach = true; | |
|
291 | return KEYWORD; | |
|
292 | } | |
|
293 | } | |
|
294 | function eachContinued(stream, state) { | |
|
295 | if (state.isEach) { | |
|
296 | if (stream.match(/^ in\b/)) { | |
|
297 | state.javaScriptLine = true; | |
|
298 | state.isEach = false; | |
|
299 | return KEYWORD; | |
|
300 | } else if (stream.sol() || stream.eol()) { | |
|
301 | state.isEach = false; | |
|
302 | } else if (stream.next()) { | |
|
303 | while (!stream.match(/^ in\b/, false) && stream.next()); | |
|
304 | return 'variable'; | |
|
305 | } | |
|
306 | } | |
|
307 | } | |
|
308 | ||
|
309 | function whileStatement(stream, state) { | |
|
310 | if (stream.match(/^while\b/)) { | |
|
311 | state.javaScriptLine = true; | |
|
312 | return KEYWORD; | |
|
313 | } | |
|
314 | } | |
|
315 | ||
|
316 | function tag(stream, state) { | |
|
317 | var captures; | |
|
318 | if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) { | |
|
319 | state.lastTag = captures[1].toLowerCase(); | |
|
320 | if (state.lastTag === 'script') { | |
|
321 | state.scriptType = 'application/javascript'; | |
|
322 | } | |
|
323 | return 'tag'; | |
|
324 | } | |
|
325 | } | |
|
326 | ||
|
327 | function filter(stream, state) { | |
|
328 | if (stream.match(/^:([\w\-]+)/)) { | |
|
329 | var innerMode; | |
|
330 | if (config && config.innerModes) { | |
|
331 | innerMode = config.innerModes(stream.current().substring(1)); | |
|
332 | } | |
|
333 | if (!innerMode) { | |
|
334 | innerMode = stream.current().substring(1); | |
|
335 | } | |
|
336 | if (typeof innerMode === 'string') { | |
|
337 | innerMode = CodeMirror.getMode(config, innerMode); | |
|
338 | } | |
|
339 | setInnerMode(stream, state, innerMode); | |
|
340 | return 'atom'; | |
|
341 | } | |
|
342 | } | |
|
343 | ||
|
344 | function code(stream, state) { | |
|
345 | if (stream.match(/^(!?=|-)/)) { | |
|
346 | state.javaScriptLine = true; | |
|
347 | return 'punctuation'; | |
|
348 | } | |
|
349 | } | |
|
350 | ||
|
351 | function id(stream) { | |
|
352 | if (stream.match(/^#([\w-]+)/)) { | |
|
353 | return ID; | |
|
354 | } | |
|
355 | } | |
|
356 | ||
|
357 | function className(stream) { | |
|
358 | if (stream.match(/^\.([\w-]+)/)) { | |
|
359 | return CLASS; | |
|
360 | } | |
|
361 | } | |
|
362 | ||
|
363 | function attrs(stream, state) { | |
|
364 | if (stream.peek() == '(') { | |
|
365 | stream.next(); | |
|
366 | state.isAttrs = true; | |
|
367 | state.attrsNest = []; | |
|
368 | state.inAttributeName = true; | |
|
369 | state.attrValue = ''; | |
|
370 | state.attributeIsType = false; | |
|
371 | return 'punctuation'; | |
|
372 | } | |
|
373 | } | |
|
374 | ||
|
375 | function attrsContinued(stream, state) { | |
|
376 | if (state.isAttrs) { | |
|
377 | if (ATTRS_NEST[stream.peek()]) { | |
|
378 | state.attrsNest.push(ATTRS_NEST[stream.peek()]); | |
|
379 | } | |
|
380 | if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) { | |
|
381 | state.attrsNest.pop(); | |
|
382 | } else if (stream.eat(')')) { | |
|
383 | state.isAttrs = false; | |
|
384 | return 'punctuation'; | |
|
385 | } | |
|
386 | if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) { | |
|
387 | if (stream.peek() === '=' || stream.peek() === '!') { | |
|
388 | state.inAttributeName = false; | |
|
389 | state.jsState = CodeMirror.startState(jsMode); | |
|
390 | if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') { | |
|
391 | state.attributeIsType = true; | |
|
392 | } else { | |
|
393 | state.attributeIsType = false; | |
|
394 | } | |
|
395 | } | |
|
396 | return 'attribute'; | |
|
397 | } | |
|
398 | ||
|
399 | var tok = jsMode.token(stream, state.jsState); | |
|
400 | if (state.attributeIsType && tok === 'string') { | |
|
401 | state.scriptType = stream.current().toString(); | |
|
402 | } | |
|
403 | if (state.attrsNest.length === 0 && (tok === 'string' || tok === 'variable' || tok === 'keyword')) { | |
|
404 | try { | |
|
405 | Function('', 'var x ' + state.attrValue.replace(/,\s*$/, '').replace(/^!/, '')); | |
|
406 | state.inAttributeName = true; | |
|
407 | state.attrValue = ''; | |
|
408 | stream.backUp(stream.current().length); | |
|
409 | return attrsContinued(stream, state); | |
|
410 | } catch (ex) { | |
|
411 | //not the end of an attribute | |
|
412 | } | |
|
413 | } | |
|
414 | state.attrValue += stream.current(); | |
|
415 | return tok || true; | |
|
416 | } | |
|
417 | } | |
|
418 | ||
|
419 | function attributesBlock(stream, state) { | |
|
420 | if (stream.match(/^&attributes\b/)) { | |
|
421 | state.javaScriptArguments = true; | |
|
422 | state.javaScriptArgumentsDepth = 0; | |
|
423 | return 'keyword'; | |
|
424 | } | |
|
425 | } | |
|
426 | ||
|
427 | function indent(stream) { | |
|
428 | if (stream.sol() && stream.eatSpace()) { | |
|
429 | return 'indent'; | |
|
430 | } | |
|
431 | } | |
|
432 | ||
|
433 | function comment(stream, state) { | |
|
434 | if (stream.match(/^ *\/\/(-)?([^\n]*)/)) { | |
|
435 | state.indentOf = stream.indentation(); | |
|
436 | state.indentToken = 'comment'; | |
|
437 | return 'comment'; | |
|
438 | } | |
|
439 | } | |
|
440 | ||
|
441 | function colon(stream) { | |
|
442 | if (stream.match(/^: */)) { | |
|
443 | return 'colon'; | |
|
444 | } | |
|
445 | } | |
|
446 | ||
|
447 | function text(stream, state) { | |
|
448 | if (stream.match(/^(?:\| ?| )([^\n]+)/)) { | |
|
449 | return 'string'; | |
|
450 | } | |
|
451 | if (stream.match(/^(<[^\n]*)/, false)) { | |
|
452 | // html string | |
|
453 | setInnerMode(stream, state, 'htmlmixed'); | |
|
454 | state.innerModeForLine = true; | |
|
455 | return innerMode(stream, state, true); | |
|
456 | } | |
|
457 | } | |
|
458 | ||
|
459 | function dot(stream, state) { | |
|
460 | if (stream.eat('.')) { | |
|
461 | var innerMode = null; | |
|
462 | if (state.lastTag === 'script' && state.scriptType.toLowerCase().indexOf('javascript') != -1) { | |
|
463 | innerMode = state.scriptType.toLowerCase().replace(/"|'/g, ''); | |
|
464 | } else if (state.lastTag === 'style') { | |
|
465 | innerMode = 'css'; | |
|
466 | } | |
|
467 | setInnerMode(stream, state, innerMode); | |
|
468 | return 'dot'; | |
|
469 | } | |
|
470 | } | |
|
471 | ||
|
472 | function fail(stream) { | |
|
473 | stream.next(); | |
|
474 | return null; | |
|
475 | } | |
|
476 | ||
|
477 | ||
|
478 | function setInnerMode(stream, state, mode) { | |
|
479 | mode = CodeMirror.mimeModes[mode] || mode; | |
|
480 | mode = config.innerModes ? config.innerModes(mode) || mode : mode; | |
|
481 | mode = CodeMirror.mimeModes[mode] || mode; | |
|
482 | mode = CodeMirror.getMode(config, mode); | |
|
483 | state.indentOf = stream.indentation(); | |
|
484 | ||
|
485 | if (mode && mode.name !== 'null') { | |
|
486 | state.innerMode = mode; | |
|
487 | } else { | |
|
488 | state.indentToken = 'string'; | |
|
489 | } | |
|
490 | } | |
|
491 | function innerMode(stream, state, force) { | |
|
492 | if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) { | |
|
493 | if (state.innerMode) { | |
|
494 | if (!state.innerState) { | |
|
495 | state.innerState = state.innerMode.startState ? CodeMirror.startState(state.innerMode, stream.indentation()) : {}; | |
|
496 | } | |
|
497 | return stream.hideFirstChars(state.indentOf + 2, function () { | |
|
498 | return state.innerMode.token(stream, state.innerState) || true; | |
|
499 | }); | |
|
500 | } else { | |
|
501 | stream.skipToEnd(); | |
|
502 | return state.indentToken; | |
|
503 | } | |
|
504 | } else if (stream.sol()) { | |
|
505 | state.indentOf = Infinity; | |
|
506 | state.indentToken = null; | |
|
507 | state.innerMode = null; | |
|
508 | state.innerState = null; | |
|
509 | } | |
|
510 | } | |
|
511 | function restOfLine(stream, state) { | |
|
512 | if (stream.sol()) { | |
|
513 | // if restOfLine was set at end of line, ignore it | |
|
514 | state.restOfLine = ''; | |
|
515 | } | |
|
516 | if (state.restOfLine) { | |
|
517 | stream.skipToEnd(); | |
|
518 | var tok = state.restOfLine; | |
|
519 | state.restOfLine = ''; | |
|
520 | return tok; | |
|
521 | } | |
|
522 | } | |
|
523 | ||
|
524 | ||
|
525 | function startState() { | |
|
526 | return new State(); | |
|
527 | } | |
|
528 | function copyState(state) { | |
|
529 | return state.copy(); | |
|
530 | } | |
|
531 | /** | |
|
532 | * Get the next token in the stream | |
|
533 | * | |
|
534 | * @param {Stream} stream | |
|
535 | * @param {State} state | |
|
536 | */ | |
|
537 | function nextToken(stream, state) { | |
|
538 | var tok = innerMode(stream, state) | |
|
539 | || restOfLine(stream, state) | |
|
540 | || interpolationContinued(stream, state) | |
|
541 | || includeFilteredContinued(stream, state) | |
|
542 | || eachContinued(stream, state) | |
|
543 | || attrsContinued(stream, state) | |
|
544 | || javaScript(stream, state) | |
|
545 | || javaScriptArguments(stream, state) | |
|
546 | || callArguments(stream, state) | |
|
547 | ||
|
548 | || yieldStatement(stream) | |
|
549 | || doctype(stream) | |
|
550 | || interpolation(stream, state) | |
|
551 | || caseStatement(stream, state) | |
|
552 | || when(stream, state) | |
|
553 | || defaultStatement(stream) | |
|
554 | || extendsStatement(stream, state) | |
|
555 | || append(stream, state) | |
|
556 | || prepend(stream, state) | |
|
557 | || block(stream, state) | |
|
558 | || include(stream, state) | |
|
559 | || includeFiltered(stream, state) | |
|
560 | || mixin(stream, state) | |
|
561 | || call(stream, state) | |
|
562 | || conditional(stream, state) | |
|
563 | || each(stream, state) | |
|
564 | || whileStatement(stream, state) | |
|
565 | || tag(stream, state) | |
|
566 | || filter(stream, state) | |
|
567 | || code(stream, state) | |
|
568 | || id(stream) | |
|
569 | || className(stream) | |
|
570 | || attrs(stream, state) | |
|
571 | || attributesBlock(stream, state) | |
|
572 | || indent(stream) | |
|
573 | || text(stream, state) | |
|
574 | || comment(stream, state) | |
|
575 | || colon(stream) | |
|
576 | || dot(stream, state) | |
|
577 | || fail(stream); | |
|
578 | ||
|
579 | return tok === true ? null : tok; | |
|
580 | } | |
|
581 | return { | |
|
582 | startState: startState, | |
|
583 | copyState: copyState, | |
|
584 | token: nextToken | |
|
585 | }; | |
|
586 | }, 'javascript', 'css', 'htmlmixed'); | |
|
587 | ||
|
588 | CodeMirror.defineMIME('text/x-pug', 'pug'); | |
|
589 | CodeMirror.defineMIME('text/x-jade', 'pug'); | |
|
590 | ||
|
591 | }); |
@@ -0,0 +1,303 b'' | |||
|
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | ||
|
4 | ||
|
5 | // SAS mode copyright (c) 2016 Jared Dean, SAS Institute | |
|
6 | // Created by Jared Dean | |
|
7 | ||
|
8 | // TODO | |
|
9 | // indent and de-indent | |
|
10 | // identify macro variables | |
|
11 | ||
|
12 | ||
|
13 | //Definitions | |
|
14 | // comment -- text within * ; or /* */ | |
|
15 | // keyword -- SAS language variable | |
|
16 | // variable -- macro variables starts with '&' or variable formats | |
|
17 | // variable-2 -- DATA Step, proc, or macro names | |
|
18 | // string -- text within ' ' or " " | |
|
19 | // operator -- numeric operator + / - * ** le eq ge ... and so on | |
|
20 | // builtin -- proc %macro data run mend | |
|
21 | // atom | |
|
22 | // def | |
|
23 | ||
|
24 | (function(mod) { | |
|
25 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
|
26 | mod(require("../../lib/codemirror")); | |
|
27 | else if (typeof define == "function" && define.amd) // AMD | |
|
28 | define(["../../lib/codemirror"], mod); | |
|
29 | else // Plain browser env | |
|
30 | mod(CodeMirror); | |
|
31 | })(function(CodeMirror) { | |
|
32 | "use strict"; | |
|
33 | ||
|
34 | CodeMirror.defineMode("sas", function () { | |
|
35 | var words = {}; | |
|
36 | var isDoubleOperatorSym = { | |
|
37 | eq: 'operator', | |
|
38 | lt: 'operator', | |
|
39 | le: 'operator', | |
|
40 | gt: 'operator', | |
|
41 | ge: 'operator', | |
|
42 | "in": 'operator', | |
|
43 | ne: 'operator', | |
|
44 | or: 'operator' | |
|
45 | }; | |
|
46 | var isDoubleOperatorChar = /(<=|>=|!=|<>)/; | |
|
47 | var isSingleOperatorChar = /[=\(:\),{}.*<>+\-\/^\[\]]/; | |
|
48 | ||
|
49 | // Takes a string of words separated by spaces and adds them as | |
|
50 | // keys with the value of the first argument 'style' | |
|
51 | function define(style, string, context) { | |
|
52 | if (context) { | |
|
53 | var split = string.split(' '); | |
|
54 | for (var i = 0; i < split.length; i++) { | |
|
55 | words[split[i]] = {style: style, state: context}; | |
|
56 | } | |
|
57 | } | |
|
58 | } | |
|
59 | //datastep | |
|
60 | define('def', 'stack pgm view source debug nesting nolist', ['inDataStep']); | |
|
61 | define('def', 'if while until for do do; end end; then else cancel', ['inDataStep']); | |
|
62 | define('def', 'label format _n_ _error_', ['inDataStep']); | |
|
63 | define('def', 'ALTER BUFNO BUFSIZE CNTLLEV COMPRESS DLDMGACTION ENCRYPT ENCRYPTKEY EXTENDOBSCOUNTER GENMAX GENNUM INDEX LABEL OBSBUF OUTREP PW PWREQ READ REPEMPTY REPLACE REUSE ROLE SORTEDBY SPILL TOBSNO TYPE WRITE FILECLOSE FIRSTOBS IN OBS POINTOBS WHERE WHEREUP IDXNAME IDXWHERE DROP KEEP RENAME', ['inDataStep']); | |
|
64 | define('def', 'filevar finfo finv fipname fipnamel fipstate first firstobs floor', ['inDataStep']); | |
|
65 | define('def', 'varfmt varinfmt varlabel varlen varname varnum varray varrayx vartype verify vformat vformatd vformatdx vformatn vformatnx vformatw vformatwx vformatx vinarray vinarrayx vinformat vinformatd vinformatdx vinformatn vinformatnx vinformatw vinformatwx vinformatx vlabel vlabelx vlength vlengthx vname vnamex vnferr vtype vtypex weekday', ['inDataStep']); | |
|
66 | define('def', 'zipfips zipname zipnamel zipstate', ['inDataStep']); | |
|
67 | define('def', 'put putc putn', ['inDataStep']); | |
|
68 | define('builtin', 'data run', ['inDataStep']); | |
|
69 | ||
|
70 | ||
|
71 | //proc | |
|
72 | define('def', 'data', ['inProc']); | |
|
73 | ||
|
74 | // flow control for macros | |
|
75 | define('def', '%if %end %end; %else %else; %do %do; %then', ['inMacro']); | |
|
76 | ||
|
77 | //everywhere | |
|
78 | define('builtin', 'proc run; quit; libname filename %macro %mend option options', ['ALL']); | |
|
79 | ||
|
80 | define('def', 'footnote title libname ods', ['ALL']); | |
|
81 | define('def', '%let %put %global %sysfunc %eval ', ['ALL']); | |
|
82 | // automatic macro variables http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003167023.htm | |
|
83 | define('variable', '&sysbuffr &syscc &syscharwidth &syscmd &sysdate &sysdate9 &sysday &sysdevic &sysdmg &sysdsn &sysencoding &sysenv &syserr &syserrortext &sysfilrc &syshostname &sysindex &sysinfo &sysjobid &syslast &syslckrc &syslibrc &syslogapplname &sysmacroname &sysmenv &sysmsg &sysncpu &sysodspath &sysparm &syspbuff &sysprocessid &sysprocessname &sysprocname &sysrc &sysscp &sysscpl &sysscpl &syssite &sysstartid &sysstartname &systcpiphostname &systime &sysuserid &sysver &sysvlong &sysvlong4 &syswarningtext', ['ALL']); | |
|
84 | ||
|
85 | //footnote[1-9]? title[1-9]? | |
|
86 | ||
|
87 | //options statement | |
|
88 | define('def', 'source2 nosource2 page pageno pagesize', ['ALL']); | |
|
89 | ||
|
90 | //proc and datastep | |
|
91 | define('def', '_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni read recfm register regr remote remove rename repeat replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max', ['inDataStep', 'inProc']); | |
|
92 | define('operator', 'and not ', ['inDataStep', 'inProc']); | |
|
93 | ||
|
94 | // Main function | |
|
95 | function tokenize(stream, state) { | |
|
96 | // Finally advance the stream | |
|
97 | var ch = stream.next(); | |
|
98 | ||
|
99 | // BLOCKCOMMENT | |
|
100 | if (ch === '/' && stream.eat('*')) { | |
|
101 | state.continueComment = true; | |
|
102 | return "comment"; | |
|
103 | } else if (state.continueComment === true) { // in comment block | |
|
104 | //comment ends at the beginning of the line | |
|
105 | if (ch === '*' && stream.peek() === '/') { | |
|
106 | stream.next(); | |
|
107 | state.continueComment = false; | |
|
108 | } else if (stream.skipTo('*')) { //comment is potentially later in line | |
|
109 | stream.skipTo('*'); | |
|
110 | stream.next(); | |
|
111 | if (stream.eat('/')) | |
|
112 | state.continueComment = false; | |
|
113 | } else { | |
|
114 | stream.skipToEnd(); | |
|
115 | } | |
|
116 | return "comment"; | |
|
117 | } | |
|
118 | ||
|
119 | if (ch == "*" && stream.column() == stream.indentation()) { | |
|
120 | stream.skipToEnd() | |
|
121 | return "comment" | |
|
122 | } | |
|
123 | ||
|
124 | // DoubleOperator match | |
|
125 | var doubleOperator = ch + stream.peek(); | |
|
126 | ||
|
127 | if ((ch === '"' || ch === "'") && !state.continueString) { | |
|
128 | state.continueString = ch | |
|
129 | return "string" | |
|
130 | } else if (state.continueString) { | |
|
131 | if (state.continueString == ch) { | |
|
132 | state.continueString = null; | |
|
133 | } else if (stream.skipTo(state.continueString)) { | |
|
134 | // quote found on this line | |
|
135 | stream.next(); | |
|
136 | state.continueString = null; | |
|
137 | } else { | |
|
138 | stream.skipToEnd(); | |
|
139 | } | |
|
140 | return "string"; | |
|
141 | } else if (state.continueString !== null && stream.eol()) { | |
|
142 | stream.skipTo(state.continueString) || stream.skipToEnd(); | |
|
143 | return "string"; | |
|
144 | } else if (/[\d\.]/.test(ch)) { //find numbers | |
|
145 | if (ch === ".") | |
|
146 | stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/); | |
|
147 | else if (ch === "0") | |
|
148 | stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/); | |
|
149 | else | |
|
150 | stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/); | |
|
151 | return "number"; | |
|
152 | } else if (isDoubleOperatorChar.test(ch + stream.peek())) { // TWO SYMBOL TOKENS | |
|
153 | stream.next(); | |
|
154 | return "operator"; | |
|
155 | } else if (isDoubleOperatorSym.hasOwnProperty(doubleOperator)) { | |
|
156 | stream.next(); | |
|
157 | if (stream.peek() === ' ') | |
|
158 | return isDoubleOperatorSym[doubleOperator.toLowerCase()]; | |
|
159 | } else if (isSingleOperatorChar.test(ch)) { // SINGLE SYMBOL TOKENS | |
|
160 | return "operator"; | |
|
161 | } | |
|
162 | ||
|
163 | // Matches one whole word -- even if the word is a character | |
|
164 | var word; | |
|
165 | if (stream.match(/[%&;\w]+/, false) != null) { | |
|
166 | word = ch + stream.match(/[%&;\w]+/, true); | |
|
167 | if (/&/.test(word)) return 'variable' | |
|
168 | } else { | |
|
169 | word = ch; | |
|
170 | } | |
|
171 | // the word after DATA PROC or MACRO | |
|
172 | if (state.nextword) { | |
|
173 | stream.match(/[\w]+/); | |
|
174 | // match memname.libname | |
|
175 | if (stream.peek() === '.') stream.skipTo(' '); | |
|
176 | state.nextword = false; | |
|
177 | return 'variable-2'; | |
|
178 | } | |
|
179 | ||
|
180 | word = word.toLowerCase() | |
|
181 | // Are we in a DATA Step? | |
|
182 | if (state.inDataStep) { | |
|
183 | if (word === 'run;' || stream.match(/run\s;/)) { | |
|
184 | state.inDataStep = false; | |
|
185 | return 'builtin'; | |
|
186 | } | |
|
187 | // variable formats | |
|
188 | if ((word) && stream.next() === '.') { | |
|
189 | //either a format or libname.memname | |
|
190 | if (/\w/.test(stream.peek())) return 'variable-2'; | |
|
191 | else return 'variable'; | |
|
192 | } | |
|
193 | // do we have a DATA Step keyword | |
|
194 | if (word && words.hasOwnProperty(word) && | |
|
195 | (words[word].state.indexOf("inDataStep") !== -1 || | |
|
196 | words[word].state.indexOf("ALL") !== -1)) { | |
|
197 | //backup to the start of the word | |
|
198 | if (stream.start < stream.pos) | |
|
199 | stream.backUp(stream.pos - stream.start); | |
|
200 | //advance the length of the word and return | |
|
201 | for (var i = 0; i < word.length; ++i) stream.next(); | |
|
202 | return words[word].style; | |
|
203 | } | |
|
204 | } | |
|
205 | // Are we in an Proc statement? | |
|
206 | if (state.inProc) { | |
|
207 | if (word === 'run;' || word === 'quit;') { | |
|
208 | state.inProc = false; | |
|
209 | return 'builtin'; | |
|
210 | } | |
|
211 | // do we have a proc keyword | |
|
212 | if (word && words.hasOwnProperty(word) && | |
|
213 | (words[word].state.indexOf("inProc") !== -1 || | |
|
214 | words[word].state.indexOf("ALL") !== -1)) { | |
|
215 | stream.match(/[\w]+/); | |
|
216 | return words[word].style; | |
|
217 | } | |
|
218 | } | |
|
219 | // Are we in a Macro statement? | |
|
220 | if (state.inMacro) { | |
|
221 | if (word === '%mend') { | |
|
222 | if (stream.peek() === ';') stream.next(); | |
|
223 | state.inMacro = false; | |
|
224 | return 'builtin'; | |
|
225 | } | |
|
226 | if (word && words.hasOwnProperty(word) && | |
|
227 | (words[word].state.indexOf("inMacro") !== -1 || | |
|
228 | words[word].state.indexOf("ALL") !== -1)) { | |
|
229 | stream.match(/[\w]+/); | |
|
230 | return words[word].style; | |
|
231 | } | |
|
232 | ||
|
233 | return 'atom'; | |
|
234 | } | |
|
235 | // Do we have Keywords specific words? | |
|
236 | if (word && words.hasOwnProperty(word)) { | |
|
237 | // Negates the initial next() | |
|
238 | stream.backUp(1); | |
|
239 | // Actually move the stream | |
|
240 | stream.match(/[\w]+/); | |
|
241 | if (word === 'data' && /=/.test(stream.peek()) === false) { | |
|
242 | state.inDataStep = true; | |
|
243 | state.nextword = true; | |
|
244 | return 'builtin'; | |
|
245 | } | |
|
246 | if (word === 'proc') { | |
|
247 | state.inProc = true; | |
|
248 | state.nextword = true; | |
|
249 | return 'builtin'; | |
|
250 | } | |
|
251 | if (word === '%macro') { | |
|
252 | state.inMacro = true; | |
|
253 | state.nextword = true; | |
|
254 | return 'builtin'; | |
|
255 | } | |
|
256 | if (/title[1-9]/.test(word)) return 'def'; | |
|
257 | ||
|
258 | if (word === 'footnote') { | |
|
259 | stream.eat(/[1-9]/); | |
|
260 | return 'def'; | |
|
261 | } | |
|
262 | ||
|
263 | // Returns their value as state in the prior define methods | |
|
264 | if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1) | |
|
265 | return words[word].style; | |
|
266 | if (state.inProc === true && words[word].state.indexOf("inProc") !== -1) | |
|
267 | return words[word].style; | |
|
268 | if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1) | |
|
269 | return words[word].style; | |
|
270 | if (words[word].state.indexOf("ALL") !== -1) | |
|
271 | return words[word].style; | |
|
272 | return null; | |
|
273 | } | |
|
274 | // Unrecognized syntax | |
|
275 | return null; | |
|
276 | } | |
|
277 | ||
|
278 | return { | |
|
279 | startState: function () { | |
|
280 | return { | |
|
281 | inDataStep: false, | |
|
282 | inProc: false, | |
|
283 | inMacro: false, | |
|
284 | nextword: false, | |
|
285 | continueString: null, | |
|
286 | continueComment: false | |
|
287 | }; | |
|
288 | }, | |
|
289 | token: function (stream, state) { | |
|
290 | // Strip the spaces, but regex will account for them either way | |
|
291 | if (stream.eatSpace()) return null; | |
|
292 | // Go through the main process | |
|
293 | return tokenize(stream, state); | |
|
294 | }, | |
|
295 | ||
|
296 | blockCommentStart: "/*", | |
|
297 | blockCommentEnd: "*/" | |
|
298 | }; | |
|
299 | ||
|
300 | }); | |
|
301 | ||
|
302 | CodeMirror.defineMIME("text/x-sas", "sas"); | |
|
303 | }); |
|
1 | NO CONTENT: new file 100644 | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: new file 100644 | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -5,6 +5,7 b'' | |||
|
5 | 5 | font-family: monospace; |
|
6 | 6 | height: 300px; |
|
7 | 7 | color: black; |
|
8 | direction: ltr; | |
|
8 | 9 | border-radius: @border-radius; |
|
9 | 10 | border: @border-thickness solid @grey6; |
|
10 | 11 | margin: 0 0 @padding; |
@@ -15,7 +16,8 b'' | |||
|
15 | 16 | .CodeMirror-lines { |
|
16 | 17 | padding: 4px 0; /* Vertical padding around content */ |
|
17 | 18 | } |
|
18 |
.CodeMirror pre |
|
|
19 | .CodeMirror pre.CodeMirror-line, | |
|
20 | .CodeMirror pre.CodeMirror-line-like { | |
|
19 | 21 | padding: 0 4px; /* Horizontal padding of content */ |
|
20 | 22 | } |
|
21 | 23 | |
@@ -44,28 +46,36 b'' | |||
|
44 | 46 | |
|
45 | 47 | /* CURSOR */ |
|
46 | 48 | |
|
47 |
|
|
|
49 | .CodeMirror-cursor { | |
|
48 | 50 | border-left: 1px solid black; |
|
51 | border-right: none; | |
|
52 | width: 0; | |
|
49 | 53 | } |
|
50 | 54 | /* Shown when moving in bi-directional text */ |
|
51 | 55 | .CodeMirror div.CodeMirror-secondarycursor { |
|
52 | 56 | border-left: 1px solid silver; |
|
53 | 57 | } |
|
54 |
|
|
|
58 | .cm-fat-cursor .CodeMirror-cursor { | |
|
55 | 59 | width: auto; |
|
56 | border: 0; | |
|
60 | border: 0 !important; | |
|
57 | 61 | background: @grey6; |
|
58 | 62 | } |
|
59 |
|
|
|
63 | .cm-fat-cursor div.CodeMirror-cursors { | |
|
60 | 64 | z-index: 1; |
|
61 | 65 | } |
|
62 | ||
|
66 | .cm-fat-cursor-mark { | |
|
67 | background-color: rgba(20, 255, 20, 0.5); | |
|
68 | -webkit-animation: blink 1.06s steps(1) infinite; | |
|
69 | -moz-animation: blink 1.06s steps(1) infinite; | |
|
70 | animation: blink 1.06s steps(1) infinite; | |
|
71 | } | |
|
63 | 72 | .cm-animate-fat-cursor { |
|
64 | 73 | width: auto; |
|
65 | 74 | border: 0; |
|
66 | 75 | -webkit-animation: blink 1.06s steps(1) infinite; |
|
67 | 76 | -moz-animation: blink 1.06s steps(1) infinite; |
|
68 | 77 | animation: blink 1.06s steps(1) infinite; |
|
78 | background-color: #7e7; | |
|
69 | 79 | } |
|
70 | 80 | @-moz-keyframes blink { |
|
71 | 81 | 0% { background: #7e7; } |
@@ -84,12 +94,18 b'' | |||
|
84 | 94 | } |
|
85 | 95 | |
|
86 | 96 | /* Can style cursor different in overwrite (non-insert) mode */ |
|
87 |
|
|
|
97 | .CodeMirror-overwrite .CodeMirror-cursor {} | |
|
88 | 98 | |
|
89 | 99 | .cm-tab { display: inline-block; text-decoration: inherit; } |
|
90 | 100 | |
|
101 | .CodeMirror-rulers { | |
|
102 | position: absolute; | |
|
103 | left: 0; right: 0; top: -50px; bottom: 0; | |
|
104 | overflow: hidden; | |
|
105 | } | |
|
91 | 106 | .CodeMirror-ruler { |
|
92 | 107 | border-left: 1px solid #ccc; |
|
108 | top: 0; bottom: 0; | |
|
93 | 109 | position: absolute; |
|
94 | 110 | } |
|
95 | 111 | |
@@ -113,7 +129,7 b' div.CodeMirror-overwrite div.CodeMirror-' | |||
|
113 | 129 | .cm-s-default .cm-property, |
|
114 | 130 | .cm-s-default .cm-operator {} |
|
115 | 131 | .cm-s-default .cm-variable-2 {color: #05a;} |
|
116 | .cm-s-default .cm-variable-3 {color: #085;} | |
|
132 | .cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;} | |
|
117 | 133 | .cm-s-default .cm-comment {color: #a50;} |
|
118 | 134 | .cm-s-default .cm-string {color: #a11;} |
|
119 | 135 | .cm-s-default .cm-string-2 {color: #f50;} |
@@ -133,8 +149,8 b' div.CodeMirror-overwrite div.CodeMirror-' | |||
|
133 | 149 | |
|
134 | 150 | /* Default styles for common addons */ |
|
135 | 151 | |
|
136 |
div.CodeMirror span.CodeMirror-matchingbracket {color: #0 |
|
|
137 |
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: # |
|
|
152 | div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} | |
|
153 | div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} | |
|
138 | 154 | .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } |
|
139 | 155 | .CodeMirror-activeline-background {background: #e8f2ff;} |
|
140 | 156 | |
@@ -191,20 +207,21 b' div.CodeMirror span.CodeMirror-nonmatchi' | |||
|
191 | 207 | |
|
192 | 208 | .CodeMirror-gutters { |
|
193 | 209 | position: absolute; left: 0; top: 0; |
|
210 | min-height: 100%; | |
|
194 | 211 | z-index: 3; |
|
195 | 212 | } |
|
196 | 213 | .CodeMirror-gutter { |
|
197 | 214 | white-space: normal; |
|
198 | 215 | height: 100%; |
|
199 | 216 | display: inline-block; |
|
217 | vertical-align: top; | |
|
200 | 218 | margin-bottom: -30px; |
|
201 | /* Hack to make IE7 behave */ | |
|
202 | *zoom:1; | |
|
203 | *display:inline; | |
|
204 | 219 | } |
|
205 | 220 | .CodeMirror-gutter-wrapper { |
|
206 | 221 | position: absolute; |
|
207 | 222 | z-index: 4; |
|
223 | background: none !important; | |
|
224 | border: none !important; | |
|
208 | 225 | height: 100%; |
|
209 | 226 | } |
|
210 | 227 | .CodeMirror-gutter-background { |
@@ -227,7 +244,8 b' div.CodeMirror span.CodeMirror-nonmatchi' | |||
|
227 | 244 | cursor: text; |
|
228 | 245 | min-height: 1px; /* prevents collapsing before first draw */ |
|
229 | 246 | } |
|
230 |
.CodeMirror pre |
|
|
247 | .CodeMirror pre.CodeMirror-line, | |
|
248 | .CodeMirror pre.CodeMirror-line-like { | |
|
231 | 249 | /* Reset some styles that the rest of the page might have set */ |
|
232 | 250 | -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; |
|
233 | 251 | border-width: 0; |
@@ -243,8 +261,11 b' div.CodeMirror span.CodeMirror-nonmatchi' | |||
|
243 | 261 | position: relative; |
|
244 | 262 | overflow: visible; |
|
245 | 263 | -webkit-tap-highlight-color: transparent; |
|
264 | -webkit-font-variant-ligatures: contextual; | |
|
265 | font-variant-ligatures: contextual; | |
|
246 | 266 | } |
|
247 |
.CodeMirror-wrap pre |
|
|
267 | .CodeMirror-wrap pre.CodeMirror-line, | |
|
268 | .CodeMirror-wrap pre.CodeMirror-line-like { | |
|
248 | 269 | word-wrap: break-word; |
|
249 | 270 | white-space: pre-wrap; |
|
250 | 271 | word-break: normal; |
@@ -259,11 +280,14 b' div.CodeMirror span.CodeMirror-nonmatchi' | |||
|
259 | 280 | .CodeMirror-linewidget { |
|
260 | 281 | position: relative; |
|
261 | 282 | z-index: 2; |
|
283 | padding: 0.1px; /* Force widget margins to stay inside of the container */ | |
|
262 | 284 | overflow: auto; |
|
263 | 285 | } |
|
264 | 286 | |
|
265 | 287 | .CodeMirror-widget {} |
|
266 | 288 | |
|
289 | .CodeMirror-rtl pre { direction: rtl; } | |
|
290 | ||
|
267 | 291 | .CodeMirror-code { |
|
268 | 292 | outline: none; |
|
269 | 293 | } |
@@ -286,13 +310,12 b' div.CodeMirror span.CodeMirror-nonmatchi' | |||
|
286 | 310 | visibility: hidden; |
|
287 | 311 | } |
|
288 | 312 | |
|
289 | ||
|
290 | .CodeMirror div.CodeMirror-cursor { | |
|
313 | .CodeMirror-cursor { | |
|
291 | 314 | position: absolute; |
|
315 | pointer-events: none; | |
|
292 | 316 | border-right: none; |
|
293 | 317 | width: 0; |
|
294 | 318 | } |
|
295 | ||
|
296 | 319 | .CodeMirror-measure pre { position: static; } |
|
297 | 320 | |
|
298 | 321 | div.CodeMirror-cursors { |
@@ -315,13 +338,10 b' div.CodeMirror-dragcursors {' | |||
|
315 | 338 | .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } |
|
316 | 339 | |
|
317 | 340 | .cm-searching { |
|
318 | background: #ffa; | |
|
319 | background: rgba(255, 255, 0, .4); | |
|
341 | background-color: #ffa; | |
|
342 | background-color: rgba(255, 255, 0, .4); | |
|
320 | 343 | } |
|
321 | 344 | |
|
322 | /* IE7 hack to prevent it from returning funny offsetTops on the spans */ | |
|
323 | .CodeMirror span { *vertical-align: text-bottom; } | |
|
324 | ||
|
325 | 345 | /* Used to force a border model for a node */ |
|
326 | 346 | .cm-force-border { padding-right: .1px; } |
|
327 | 347 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -68,6 +68,7 b'' | |||
|
68 | 68 | }); |
|
69 | 69 | |
|
70 | 70 | CodeMirror.defineMIME("application/pgp", "asciiarmor"); |
|
71 | CodeMirror.defineMIME("application/pgp-encrypted", "asciiarmor"); | |
|
71 | 72 | CodeMirror.defineMIME("application/pgp-keys", "asciiarmor"); |
|
72 | 73 | CodeMirror.defineMIME("application/pgp-signature", "asciiarmor"); |
|
73 | 74 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /* |
|
5 | 5 | * ===================================================================================== |
@@ -9,7 +9,7 b'' | |||
|
9 | 9 | * Description: CodeMirror mode for Asterisk dialplan |
|
10 | 10 | * |
|
11 | 11 | * Created: 05/17/2012 09:20:25 PM |
|
12 | * Revision: none | |
|
12 | * Revision: 08/05/2019 AstLinux Project: Support block-comments | |
|
13 | 13 | * |
|
14 | 14 | * Author: Stas Kobzar (stas@modulis.ca), |
|
15 | 15 | * Company: Modulis.ca Inc. |
@@ -67,7 +67,26 b' CodeMirror.defineMode("asterisk", functi' | |||
|
67 | 67 | var cur = ''; |
|
68 | 68 | var ch = stream.next(); |
|
69 | 69 | // comment |
|
70 | if (state.blockComment) { | |
|
71 | if (ch == "-" && stream.match("-;", true)) { | |
|
72 | state.blockComment = false; | |
|
73 | } else if (stream.skipTo("--;")) { | |
|
74 | stream.next(); | |
|
75 | stream.next(); | |
|
76 | stream.next(); | |
|
77 | state.blockComment = false; | |
|
78 | } else { | |
|
79 | stream.skipToEnd(); | |
|
80 | } | |
|
81 | return "comment"; | |
|
82 | } | |
|
70 | 83 | if(ch == ";") { |
|
84 | if (stream.match("--", true)) { | |
|
85 | if (!stream.match("-", false)) { // Except ;--- is not a block comment | |
|
86 | state.blockComment = true; | |
|
87 | return "comment"; | |
|
88 | } | |
|
89 | } | |
|
71 | 90 | stream.skipToEnd(); |
|
72 | 91 | return "comment"; |
|
73 | 92 | } |
@@ -124,6 +143,7 b' CodeMirror.defineMode("asterisk", functi' | |||
|
124 | 143 | return { |
|
125 | 144 | startState: function() { |
|
126 | 145 | return { |
|
146 | blockComment: false, | |
|
127 | 147 | extenStart: false, |
|
128 | 148 | extenSame: false, |
|
129 | 149 | extenInclude: false, |
@@ -187,7 +207,11 b' CodeMirror.defineMode("asterisk", functi' | |||
|
187 | 207 | } |
|
188 | 208 | |
|
189 | 209 | return null; |
|
190 | } | |
|
210 | }, | |
|
211 | ||
|
212 | blockCommentStart: ";--", | |
|
213 | blockCommentEnd: "--;", | |
|
214 | lineComment: ";" | |
|
191 | 215 | }; |
|
192 | 216 | }); |
|
193 | 217 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11 |
|
5 | 5 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -11,6 +11,41 b'' | |||
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | function Context(indented, column, type, info, align, prev) { | |
|
15 | this.indented = indented; | |
|
16 | this.column = column; | |
|
17 | this.type = type; | |
|
18 | this.info = info; | |
|
19 | this.align = align; | |
|
20 | this.prev = prev; | |
|
21 | } | |
|
22 | function pushContext(state, col, type, info) { | |
|
23 | var indent = state.indented; | |
|
24 | if (state.context && state.context.type == "statement" && type != "statement") | |
|
25 | indent = state.context.indented; | |
|
26 | return state.context = new Context(indent, col, type, info, null, state.context); | |
|
27 | } | |
|
28 | function popContext(state) { | |
|
29 | var t = state.context.type; | |
|
30 | if (t == ")" || t == "]" || t == "}") | |
|
31 | state.indented = state.context.indented; | |
|
32 | return state.context = state.context.prev; | |
|
33 | } | |
|
34 | ||
|
35 | function typeBefore(stream, state, pos) { | |
|
36 | if (state.prevToken == "variable" || state.prevToken == "type") return true; | |
|
37 | if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true; | |
|
38 | if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true; | |
|
39 | } | |
|
40 | ||
|
41 | function isTopScope(context) { | |
|
42 | for (;;) { | |
|
43 | if (!context || context.type == "top") return true; | |
|
44 | if (context.type == "}" && context.prev.info != "namespace") return false; | |
|
45 | context = context.prev; | |
|
46 | } | |
|
47 | } | |
|
48 | ||
|
14 | 49 | CodeMirror.defineMode("clike", function(config, parserConfig) { |
|
15 | 50 | var indentUnit = config.indentUnit, |
|
16 | 51 | statementIndentUnit = parserConfig.statementIndentUnit || indentUnit, |
@@ -30,7 +65,10 b' CodeMirror.defineMode("clike", function(' | |||
|
30 | 65 | numberStart = parserConfig.numberStart || /[\d\.]/, |
|
31 | 66 | number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i, |
|
32 | 67 | isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/, |
|
33 | endStatement = parserConfig.endStatement || /^[;:,]$/; | |
|
68 | isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/, | |
|
69 | // An optional function that takes a {string} token and returns true if it | |
|
70 | // should be treated as a builtin. | |
|
71 | isReservedIdentifier = parserConfig.isReservedIdentifier || false; | |
|
34 | 72 | |
|
35 | 73 | var curPunc, isDefKeyword; |
|
36 | 74 | |
@@ -64,12 +102,12 b' CodeMirror.defineMode("clike", function(' | |||
|
64 | 102 | } |
|
65 | 103 | } |
|
66 | 104 | if (isOperatorChar.test(ch)) { |
|
67 | stream.eatWhile(isOperatorChar); | |
|
105 | while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {} | |
|
68 | 106 | return "operator"; |
|
69 | 107 | } |
|
70 | stream.eatWhile(/[\w\$_\xa1-\uffff]/); | |
|
108 | stream.eatWhile(isIdentifierChar); | |
|
71 | 109 | if (namespaceSeparator) while (stream.match(namespaceSeparator)) |
|
72 | stream.eatWhile(/[\w\$_\xa1-\uffff]/); | |
|
110 | stream.eatWhile(isIdentifierChar); | |
|
73 | 111 | |
|
74 | 112 | var cur = stream.current(); |
|
75 | 113 | if (contains(keywords, cur)) { |
@@ -77,8 +115,9 b' CodeMirror.defineMode("clike", function(' | |||
|
77 | 115 | if (contains(defKeywords, cur)) isDefKeyword = true; |
|
78 | 116 | return "keyword"; |
|
79 | 117 | } |
|
80 |
if (contains(types, cur)) return " |
|
|
81 |
if (contains(builtin, cur) |
|
|
118 | if (contains(types, cur)) return "type"; | |
|
119 | if (contains(builtin, cur) | |
|
120 | || (isReservedIdentifier && isReservedIdentifier(cur))) { | |
|
82 | 121 | if (contains(blockKeywords, cur)) curPunc = "newstatement"; |
|
83 | 122 | return "builtin"; |
|
84 | 123 | } |
@@ -111,40 +150,9 b' CodeMirror.defineMode("clike", function(' | |||
|
111 | 150 | return "comment"; |
|
112 | 151 | } |
|
113 | 152 | |
|
114 | function Context(indented, column, type, align, prev) { | |
|
115 | this.indented = indented; | |
|
116 | this.column = column; | |
|
117 | this.type = type; | |
|
118 | this.align = align; | |
|
119 | this.prev = prev; | |
|
120 | } | |
|
121 | function isStatement(type) { | |
|
122 | return type == "statement" || type == "switchstatement" || type == "namespace"; | |
|
123 | } | |
|
124 | function pushContext(state, col, type) { | |
|
125 | var indent = state.indented; | |
|
126 | if (state.context && isStatement(state.context.type) && !isStatement(type)) | |
|
127 | indent = state.context.indented; | |
|
128 | return state.context = new Context(indent, col, type, null, state.context); | |
|
129 | } | |
|
130 | function popContext(state) { | |
|
131 | var t = state.context.type; | |
|
132 | if (t == ")" || t == "]" || t == "}") | |
|
133 | state.indented = state.context.indented; | |
|
134 | return state.context = state.context.prev; | |
|
135 | } | |
|
136 | ||
|
137 | function typeBefore(stream, state) { | |
|
138 | if (state.prevToken == "variable" || state.prevToken == "variable-3") return true; | |
|
139 | if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true; | |
|
140 | } | |
|
141 | ||
|
142 | function isTopScope(context) { | |
|
143 | for (;;) { | |
|
144 | if (!context || context.type == "top") return true; | |
|
145 | if (context.type == "}" && context.prev.type != "namespace") return false; | |
|
146 | context = context.prev; | |
|
147 | } | |
|
153 | function maybeEOL(stream, state) { | |
|
154 | if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context)) | |
|
155 | state.typeAtEndOfLine = typeBefore(stream, state, stream.pos) | |
|
148 | 156 | } |
|
149 | 157 | |
|
150 | 158 | // Interface |
@@ -153,7 +161,7 b' CodeMirror.defineMode("clike", function(' | |||
|
153 | 161 | startState: function(basecolumn) { |
|
154 | 162 | return { |
|
155 | 163 | tokenize: null, |
|
156 | context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), | |
|
164 | context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false), | |
|
157 | 165 | indented: 0, |
|
158 | 166 | startOfLine: true, |
|
159 | 167 | prevToken: null |
@@ -167,36 +175,32 b' CodeMirror.defineMode("clike", function(' | |||
|
167 | 175 | state.indented = stream.indentation(); |
|
168 | 176 | state.startOfLine = true; |
|
169 | 177 | } |
|
170 | if (stream.eatSpace()) return null; | |
|
178 | if (stream.eatSpace()) { maybeEOL(stream, state); return null; } | |
|
171 | 179 | curPunc = isDefKeyword = null; |
|
172 | 180 | var style = (state.tokenize || tokenBase)(stream, state); |
|
173 | 181 | if (style == "comment" || style == "meta") return style; |
|
174 | 182 | if (ctx.align == null) ctx.align = true; |
|
175 | 183 | |
|
176 | if (endStatement.test(curPunc)) while (isStatement(state.context.type)) popContext(state); | |
|
184 | if (curPunc == ";" || curPunc == ":" || (curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false))) | |
|
185 | while (state.context.type == "statement") popContext(state); | |
|
177 | 186 | else if (curPunc == "{") pushContext(state, stream.column(), "}"); |
|
178 | 187 | else if (curPunc == "[") pushContext(state, stream.column(), "]"); |
|
179 | 188 | else if (curPunc == "(") pushContext(state, stream.column(), ")"); |
|
180 | 189 | else if (curPunc == "}") { |
|
181 |
while ( |
|
|
190 | while (ctx.type == "statement") ctx = popContext(state); | |
|
182 | 191 | if (ctx.type == "}") ctx = popContext(state); |
|
183 |
while ( |
|
|
192 | while (ctx.type == "statement") ctx = popContext(state); | |
|
184 | 193 | } |
|
185 | 194 | else if (curPunc == ctx.type) popContext(state); |
|
186 | 195 | else if (indentStatements && |
|
187 | 196 | (((ctx.type == "}" || ctx.type == "top") && curPunc != ";") || |
|
188 |
|
|
|
189 | var type = "statement"; | |
|
190 | if (curPunc == "newstatement" && indentSwitch && stream.current() == "switch") | |
|
191 | type = "switchstatement"; | |
|
192 | else if (style == "keyword" && stream.current() == "namespace") | |
|
193 | type = "namespace"; | |
|
194 | pushContext(state, stream.column(), type); | |
|
197 | (ctx.type == "statement" && curPunc == "newstatement"))) { | |
|
198 | pushContext(state, stream.column(), "statement", stream.current()); | |
|
195 | 199 | } |
|
196 | 200 | |
|
197 | 201 | if (style == "variable" && |
|
198 | 202 | ((state.prevToken == "def" || |
|
199 | (parserConfig.typeFirstDefinitions && typeBefore(stream, state) && | |
|
203 | (parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) && | |
|
200 | 204 | isTopScope(state.context) && stream.match(/^\s*\(/, false))))) |
|
201 | 205 | style = "def"; |
|
202 | 206 | |
@@ -209,24 +213,28 b' CodeMirror.defineMode("clike", function(' | |||
|
209 | 213 | |
|
210 | 214 | state.startOfLine = false; |
|
211 | 215 | state.prevToken = isDefKeyword ? "def" : style || curPunc; |
|
216 | maybeEOL(stream, state); | |
|
212 | 217 | return style; |
|
213 | 218 | }, |
|
214 | 219 | |
|
215 | 220 | indent: function(state, textAfter) { |
|
216 | if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; | |
|
221 | if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass; | |
|
217 | 222 | var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); |
|
218 | if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev; | |
|
223 | var closing = firstChar == ctx.type; | |
|
224 | if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; | |
|
225 | if (parserConfig.dontIndentStatements) | |
|
226 | while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info)) | |
|
227 | ctx = ctx.prev | |
|
219 | 228 | if (hooks.indent) { |
|
220 | var hook = hooks.indent(state, ctx, textAfter); | |
|
229 | var hook = hooks.indent(state, ctx, textAfter, indentUnit); | |
|
221 | 230 | if (typeof hook == "number") return hook |
|
222 | 231 | } |
|
223 | var closing = firstChar == ctx.type; | |
|
224 | var switchBlock = ctx.prev && ctx.prev.type == "switchstatement"; | |
|
232 | var switchBlock = ctx.prev && ctx.prev.info == "switch"; | |
|
225 | 233 | if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) { |
|
226 | 234 | while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev |
|
227 | 235 | return ctx.indented |
|
228 | 236 | } |
|
229 |
if ( |
|
|
237 | if (ctx.type == "statement") | |
|
230 | 238 | return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); |
|
231 | 239 | if (ctx.align && (!dontAlignCalls || ctx.type != ")")) |
|
232 | 240 | return ctx.column + (closing ? 0 : 1); |
@@ -240,6 +248,7 b' CodeMirror.defineMode("clike", function(' | |||
|
240 | 248 | electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/, |
|
241 | 249 | blockCommentStart: "/*", |
|
242 | 250 | blockCommentEnd: "*/", |
|
251 | blockCommentContinue: " * ", | |
|
243 | 252 | lineComment: "//", |
|
244 | 253 | fold: "brace" |
|
245 | 254 | }; |
@@ -258,8 +267,52 b' CodeMirror.defineMode("clike", function(' | |||
|
258 | 267 | } |
|
259 | 268 | } |
|
260 | 269 | var cKeywords = "auto if break case register continue return default do sizeof " + |
|
261 |
"static else struct switch extern typedef union for goto while enum const |
|
|
262 | var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t"; | |
|
270 | "static else struct switch extern typedef union for goto while enum const " + | |
|
271 | "volatile inline restrict asm fortran"; | |
|
272 | ||
|
273 | // Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20. | |
|
274 | var cppKeywords = "alignas alignof and and_eq audit axiom bitand bitor catch " + | |
|
275 | "class compl concept constexpr const_cast decltype delete dynamic_cast " + | |
|
276 | "explicit export final friend import module mutable namespace new noexcept " + | |
|
277 | "not not_eq operator or or_eq override private protected public " + | |
|
278 | "reinterpret_cast requires static_assert static_cast template this " + | |
|
279 | "thread_local throw try typeid typename using virtual xor xor_eq"; | |
|
280 | ||
|
281 | var objCKeywords = "bycopy byref in inout oneway out self super atomic nonatomic retain copy " + | |
|
282 | "readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " + | |
|
283 | "@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " + | |
|
284 | "@public @package @private @protected @required @optional @try @catch @finally @import " + | |
|
285 | "@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available"; | |
|
286 | ||
|
287 | var objCBuiltins = "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION " + | |
|
288 | " NS_RETURNS_RETAINEDNS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER " + | |
|
289 | "NS_DESIGNATED_INITIALIZER NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION " + | |
|
290 | "NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT" | |
|
291 | ||
|
292 | // Do not use this. Use the cTypes function below. This is global just to avoid | |
|
293 | // excessive calls when cTypes is being called multiple times during a parse. | |
|
294 | var basicCTypes = words("int long char short double float unsigned signed " + | |
|
295 | "void bool"); | |
|
296 | ||
|
297 | // Do not use this. Use the objCTypes function below. This is global just to avoid | |
|
298 | // excessive calls when objCTypes is being called multiple times during a parse. | |
|
299 | var basicObjCTypes = words("SEL instancetype id Class Protocol BOOL"); | |
|
300 | ||
|
301 | // Returns true if identifier is a "C" type. | |
|
302 | // C type is defined as those that are reserved by the compiler (basicTypes), | |
|
303 | // and those that end in _t (Reserved by POSIX for types) | |
|
304 | // http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html | |
|
305 | function cTypes(identifier) { | |
|
306 | return contains(basicCTypes, identifier) || /.+_t$/.test(identifier); | |
|
307 | } | |
|
308 | ||
|
309 | // Returns true if identifier is a "Objective C" type. | |
|
310 | function objCTypes(identifier) { | |
|
311 | return cTypes(identifier) || contains(basicObjCTypes, identifier); | |
|
312 | } | |
|
313 | ||
|
314 | var cBlockKeywords = "case do else for if switch while struct enum union"; | |
|
315 | var cDefKeywords = "struct enum union"; | |
|
263 | 316 | |
|
264 | 317 | function cppHook(stream, state) { |
|
265 | 318 | if (!state.startOfLine) return false |
@@ -277,10 +330,18 b' CodeMirror.defineMode("clike", function(' | |||
|
277 | 330 | } |
|
278 | 331 | |
|
279 | 332 | function pointerHook(_stream, state) { |
|
280 |
if (state.prevToken == " |
|
|
333 | if (state.prevToken == "type") return "type"; | |
|
281 | 334 | return false; |
|
282 | 335 | } |
|
283 | 336 | |
|
337 | // For C and C++ (and ObjC): identifiers starting with __ | |
|
338 | // or _ followed by a capital letter are reserved for the compiler. | |
|
339 | function cIsReservedIdentifier(token) { | |
|
340 | if (!token || token.length < 2) return false; | |
|
341 | if (token[0] != '_') return false; | |
|
342 | return (token[1] == '_') || (token[1] !== token[1].toLowerCase()); | |
|
343 | } | |
|
344 | ||
|
284 | 345 | function cpp14Literal(stream) { |
|
285 | 346 | stream.eatWhile(/[\w\.']/); |
|
286 | 347 | return "number"; |
@@ -311,7 +372,7 b' CodeMirror.defineMode("clike", function(' | |||
|
311 | 372 | } |
|
312 | 373 | |
|
313 | 374 | function cppLooksLikeConstructor(word) { |
|
314 | var lastTwo = /(\w+)::(\w+)$/.exec(word); | |
|
375 | var lastTwo = /(\w+)::~?(\w+)$/.exec(word); | |
|
315 | 376 | return lastTwo && lastTwo[1] == lastTwo[2]; |
|
316 | 377 | } |
|
317 | 378 | |
@@ -363,29 +424,30 b' CodeMirror.defineMode("clike", function(' | |||
|
363 | 424 | def(["text/x-csrc", "text/x-c", "text/x-chdr"], { |
|
364 | 425 | name: "clike", |
|
365 | 426 | keywords: words(cKeywords), |
|
366 | types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " + | |
|
367 | "int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " + | |
|
368 | "uint32_t uint64_t"), | |
|
369 | blockKeywords: words("case do else for if switch while struct"), | |
|
370 | defKeywords: words("struct"), | |
|
427 | types: cTypes, | |
|
428 | blockKeywords: words(cBlockKeywords), | |
|
429 | defKeywords: words(cDefKeywords), | |
|
371 | 430 | typeFirstDefinitions: true, |
|
372 |
atoms: words(" |
|
|
373 | hooks: {"#": cppHook, "*": pointerHook}, | |
|
431 | atoms: words("NULL true false"), | |
|
432 | isReservedIdentifier: cIsReservedIdentifier, | |
|
433 | hooks: { | |
|
434 | "#": cppHook, | |
|
435 | "*": pointerHook, | |
|
436 | }, | |
|
374 | 437 | modeProps: {fold: ["brace", "include"]} |
|
375 | 438 | }); |
|
376 | 439 | |
|
377 | 440 | def(["text/x-c++src", "text/x-c++hdr"], { |
|
378 | 441 | name: "clike", |
|
379 | keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " + | |
|
380 | "static_cast typeid catch operator template typename class friend private " + | |
|
381 | "this using const_cast inline public throw virtual delete mutable protected " + | |
|
382 | "alignas alignof constexpr decltype nullptr noexcept thread_local final " + | |
|
383 | "static_assert override"), | |
|
384 | types: words(cTypes + " bool wchar_t"), | |
|
385 | blockKeywords: words("catch class do else finally for if struct switch try while"), | |
|
386 | defKeywords: words("class namespace struct enum union"), | |
|
442 | keywords: words(cKeywords + " " + cppKeywords), | |
|
443 | types: cTypes, | |
|
444 | blockKeywords: words(cBlockKeywords + " class try catch"), | |
|
445 | defKeywords: words(cDefKeywords + " class namespace"), | |
|
387 | 446 | typeFirstDefinitions: true, |
|
388 | atoms: words("true false null"), | |
|
447 | atoms: words("true false NULL nullptr"), | |
|
448 | dontIndentStatements: /^template$/, | |
|
449 | isIdentifierChar: /[\w\$_~\xa1-\uffff]/, | |
|
450 | isReservedIdentifier: cIsReservedIdentifier, | |
|
389 | 451 | hooks: { |
|
390 | 452 | "#": cppHook, |
|
391 | 453 | "*": pointerHook, |
@@ -418,19 +480,22 b' CodeMirror.defineMode("clike", function(' | |||
|
418 | 480 | def("text/x-java", { |
|
419 | 481 | name: "clike", |
|
420 | 482 | keywords: words("abstract assert break case catch class const continue default " + |
|
421 |
"do else enum extends final finally f |
|
|
483 | "do else enum extends final finally for goto if implements import " + | |
|
422 | 484 | "instanceof interface native new package private protected public " + |
|
423 | 485 | "return static strictfp super switch synchronized this throw throws transient " + |
|
424 | "try volatile while"), | |
|
486 | "try volatile while @interface"), | |
|
425 | 487 | types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " + |
|
426 | 488 | "Integer Long Number Object Short String StringBuffer StringBuilder Void"), |
|
427 | 489 | blockKeywords: words("catch class do else finally for if switch try while"), |
|
428 |
defKeywords: words("class interface |
|
|
490 | defKeywords: words("class interface enum @interface"), | |
|
429 | 491 | typeFirstDefinitions: true, |
|
430 | 492 | atoms: words("true false null"), |
|
431 | endStatement: /^[;:]$/, | |
|
493 | number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i, | |
|
432 | 494 | hooks: { |
|
433 | 495 | "@": function(stream) { |
|
496 | // Don't match the @interface keyword. | |
|
497 | if (stream.match('interface', false)) return false; | |
|
498 | ||
|
434 | 499 | stream.eatWhile(/[\w\$_]/); |
|
435 | 500 | return "meta"; |
|
436 | 501 | } |
@@ -479,25 +544,42 b' CodeMirror.defineMode("clike", function(' | |||
|
479 | 544 | return "string"; |
|
480 | 545 | } |
|
481 | 546 | |
|
547 | function tokenNestedComment(depth) { | |
|
548 | return function (stream, state) { | |
|
549 | var ch | |
|
550 | while (ch = stream.next()) { | |
|
551 | if (ch == "*" && stream.eat("/")) { | |
|
552 | if (depth == 1) { | |
|
553 | state.tokenize = null | |
|
554 | break | |
|
555 | } else { | |
|
556 | state.tokenize = tokenNestedComment(depth - 1) | |
|
557 | return state.tokenize(stream, state) | |
|
558 | } | |
|
559 | } else if (ch == "/" && stream.eat("*")) { | |
|
560 | state.tokenize = tokenNestedComment(depth + 1) | |
|
561 | return state.tokenize(stream, state) | |
|
562 | } | |
|
563 | } | |
|
564 | return "comment" | |
|
565 | } | |
|
566 | } | |
|
567 | ||
|
482 | 568 | def("text/x-scala", { |
|
483 | 569 | name: "clike", |
|
484 | 570 | keywords: words( |
|
485 | ||
|
486 | 571 | /* scala */ |
|
487 | 572 | "abstract case catch class def do else extends final finally for forSome if " + |
|
488 | 573 | "implicit import lazy match new null object override package private protected return " + |
|
489 |
"sealed super this throw trait try type val var while with yield _ |
|
|
490 | "<% >: # @ " + | |
|
574 | "sealed super this throw trait try type val var while with yield _ " + | |
|
491 | 575 | |
|
492 | 576 | /* package scala */ |
|
493 | 577 | "assert assume require print println printf readLine readBoolean readByte readShort " + |
|
494 |
"readChar readInt readLong readFloat readDouble |
|
|
495 | ||
|
496 | ":: #:: " | |
|
578 | "readChar readInt readLong readFloat readDouble" | |
|
497 | 579 | ), |
|
498 | 580 | types: words( |
|
499 | 581 | "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " + |
|
500 | "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " + | |
|
582 | "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " + | |
|
501 | 583 | "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " + |
|
502 | 584 | "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " + |
|
503 | 585 | "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " + |
@@ -509,11 +591,12 b' CodeMirror.defineMode("clike", function(' | |||
|
509 | 591 | "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" |
|
510 | 592 | ), |
|
511 | 593 | multiLineStrings: true, |
|
512 | blockKeywords: words("catch class do else finally for forSome if match switch try while"), | |
|
513 | defKeywords: words("class def object package trait type val var"), | |
|
594 | blockKeywords: words("catch class enum do else finally for forSome if match switch try while"), | |
|
595 | defKeywords: words("class enum def object package trait type val var"), | |
|
514 | 596 | atoms: words("true false null"), |
|
515 | 597 | indentStatements: false, |
|
516 | 598 | indentSwitch: false, |
|
599 | isOperatorChar: /[+\-*&%=<>!?|\/#:@]/, | |
|
517 | 600 | hooks: { |
|
518 | 601 | "@": function(stream) { |
|
519 | 602 | stream.eatWhile(/[\w\$_]/); |
@@ -527,9 +610,24 b' CodeMirror.defineMode("clike", function(' | |||
|
527 | 610 | "'": function(stream) { |
|
528 | 611 | stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
|
529 | 612 | return "atom"; |
|
613 | }, | |
|
614 | "=": function(stream, state) { | |
|
615 | var cx = state.context | |
|
616 | if (cx.type == "}" && cx.align && stream.eat(">")) { | |
|
617 | state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev) | |
|
618 | return "operator" | |
|
619 | } else { | |
|
620 | return false | |
|
621 | } | |
|
622 | }, | |
|
623 | ||
|
624 | "/": function(stream, state) { | |
|
625 | if (!stream.eat("*")) return false | |
|
626 | state.tokenize = tokenNestedComment(1) | |
|
627 | return state.tokenize(stream, state) | |
|
530 | 628 | } |
|
531 | 629 | }, |
|
532 | modeProps: {closeBrackets: {triples: '"'}} | |
|
630 | modeProps: {closeBrackets: {pairs: '()[]{}""', triples: '"'}} | |
|
533 | 631 | }); |
|
534 | 632 | |
|
535 | 633 | function tokenKotlinString(tripleString){ |
@@ -553,33 +651,59 b' CodeMirror.defineMode("clike", function(' | |||
|
553 | 651 | name: "clike", |
|
554 | 652 | keywords: words( |
|
555 | 653 | /*keywords*/ |
|
556 | "package as typealias class interface this super val " + | |
|
557 | "var fun for is in This throw return " + | |
|
654 | "package as typealias class interface this super val operator " + | |
|
655 | "var fun for is in This throw return annotation " + | |
|
558 | 656 | "break continue object if else while do try when !in !is as? " + |
|
559 | 657 | |
|
560 | 658 | /*soft keywords*/ |
|
561 | 659 | "file import where by get set abstract enum open inner override private public internal " + |
|
562 | 660 | "protected catch finally out final vararg reified dynamic companion constructor init " + |
|
563 | 661 | "sealed field property receiver param sparam lateinit data inline noinline tailrec " + |
|
564 | "external annotation crossinline const operator infix" | |
|
662 | "external annotation crossinline const operator infix suspend actual expect setparam" | |
|
565 | 663 | ), |
|
566 | 664 | types: words( |
|
567 | 665 | /* package java.lang */ |
|
568 | 666 | "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " + |
|
569 | 667 | "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " + |
|
570 | 668 | "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " + |
|
571 | "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" | |
|
669 | "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void Annotation Any BooleanArray " + | |
|
670 | "ByteArray Char CharArray DeprecationLevel DoubleArray Enum FloatArray Function Int IntArray Lazy " + | |
|
671 | "LazyThreadSafetyMode LongArray Nothing ShortArray Unit" | |
|
572 | 672 | ), |
|
573 | 673 | intendSwitch: false, |
|
574 | 674 | indentStatements: false, |
|
575 | 675 | multiLineStrings: true, |
|
676 | number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i, | |
|
576 | 677 | blockKeywords: words("catch class do else finally for if where try while enum"), |
|
577 |
defKeywords: words("class val var object |
|
|
678 | defKeywords: words("class val var object interface fun"), | |
|
578 | 679 | atoms: words("true false null this"), |
|
579 | 680 | hooks: { |
|
681 | "@": function(stream) { | |
|
682 | stream.eatWhile(/[\w\$_]/); | |
|
683 | return "meta"; | |
|
684 | }, | |
|
685 | '*': function(_stream, state) { | |
|
686 | return state.prevToken == '.' ? 'variable' : 'operator'; | |
|
687 | }, | |
|
580 | 688 | '"': function(stream, state) { |
|
581 | 689 | state.tokenize = tokenKotlinString(stream.match('""')); |
|
582 | 690 | return state.tokenize(stream, state); |
|
691 | }, | |
|
692 | "/": function(stream, state) { | |
|
693 | if (!stream.eat("*")) return false; | |
|
694 | state.tokenize = tokenNestedComment(1); | |
|
695 | return state.tokenize(stream, state) | |
|
696 | }, | |
|
697 | indent: function(state, ctx, textAfter, indentUnit) { | |
|
698 | var firstChar = textAfter && textAfter.charAt(0); | |
|
699 | if ((state.prevToken == "}" || state.prevToken == ")") && textAfter == "") | |
|
700 | return state.indented; | |
|
701 | if ((state.prevToken == "operator" && textAfter != "}" && state.context.type != "}") || | |
|
702 | state.prevToken == "variable" && firstChar == "." || | |
|
703 | (state.prevToken == "}" || state.prevToken == ")") && firstChar == ".") | |
|
704 | return indentUnit * 2 + ctx.indented; | |
|
705 | if (ctx.align && ctx.type == "}") | |
|
706 | return ctx.indented + (state.context.type == (textAfter || "").charAt(0) ? 0 : indentUnit); | |
|
583 | 707 | } |
|
584 | 708 | }, |
|
585 | 709 | modeProps: {closeBrackets: {triples: '"'}} |
@@ -646,11 +770,11 b' CodeMirror.defineMode("clike", function(' | |||
|
646 | 770 | |
|
647 | 771 | def("text/x-nesc", { |
|
648 | 772 | name: "clike", |
|
649 | keywords: words(cKeywords + "as atomic async call command component components configuration event generic " + | |
|
773 | keywords: words(cKeywords + " as atomic async call command component components configuration event generic " + | |
|
650 | 774 | "implementation includes interface module new norace nx_struct nx_union post provides " + |
|
651 | 775 | "signal task uses abstract extends"), |
|
652 |
types: |
|
|
653 | blockKeywords: words("case do else for if switch while struct"), | |
|
776 | types: cTypes, | |
|
777 | blockKeywords: words(cBlockKeywords), | |
|
654 | 778 | atoms: words("null true false"), |
|
655 | 779 | hooks: {"#": cppHook}, |
|
656 | 780 | modeProps: {fold: ["brace", "include"]} |
@@ -658,28 +782,67 b' CodeMirror.defineMode("clike", function(' | |||
|
658 | 782 | |
|
659 | 783 | def("text/x-objectivec", { |
|
660 | 784 | name: "clike", |
|
661 | keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " + | |
|
662 | "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"), | |
|
663 | types: words(cTypes), | |
|
664 | atoms: words("YES NO NULL NILL ON OFF true false"), | |
|
785 | keywords: words(cKeywords + " " + objCKeywords), | |
|
786 | types: objCTypes, | |
|
787 | builtin: words(objCBuiltins), | |
|
788 | blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"), | |
|
789 | defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"), | |
|
790 | dontIndentStatements: /^@.*$/, | |
|
791 | typeFirstDefinitions: true, | |
|
792 | atoms: words("YES NO NULL Nil nil true false nullptr"), | |
|
793 | isReservedIdentifier: cIsReservedIdentifier, | |
|
665 | 794 | hooks: { |
|
666 | "@": function(stream) { | |
|
667 | stream.eatWhile(/[\w\$]/); | |
|
668 | return "keyword"; | |
|
669 | }, | |
|
795 | "#": cppHook, | |
|
796 | "*": pointerHook, | |
|
797 | }, | |
|
798 | modeProps: {fold: ["brace", "include"]} | |
|
799 | }); | |
|
800 | ||
|
801 | def("text/x-objectivec++", { | |
|
802 | name: "clike", | |
|
803 | keywords: words(cKeywords + " " + objCKeywords + " " + cppKeywords), | |
|
804 | types: objCTypes, | |
|
805 | builtin: words(objCBuiltins), | |
|
806 | blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized class try catch"), | |
|
807 | defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class class namespace"), | |
|
808 | dontIndentStatements: /^@.*$|^template$/, | |
|
809 | typeFirstDefinitions: true, | |
|
810 | atoms: words("YES NO NULL Nil nil true false nullptr"), | |
|
811 | isReservedIdentifier: cIsReservedIdentifier, | |
|
812 | hooks: { | |
|
670 | 813 | "#": cppHook, |
|
671 | indent: function(_state, ctx, textAfter) { | |
|
672 | if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented | |
|
814 | "*": pointerHook, | |
|
815 | "u": cpp11StringHook, | |
|
816 | "U": cpp11StringHook, | |
|
817 | "L": cpp11StringHook, | |
|
818 | "R": cpp11StringHook, | |
|
819 | "0": cpp14Literal, | |
|
820 | "1": cpp14Literal, | |
|
821 | "2": cpp14Literal, | |
|
822 | "3": cpp14Literal, | |
|
823 | "4": cpp14Literal, | |
|
824 | "5": cpp14Literal, | |
|
825 | "6": cpp14Literal, | |
|
826 | "7": cpp14Literal, | |
|
827 | "8": cpp14Literal, | |
|
828 | "9": cpp14Literal, | |
|
829 | token: function(stream, state, style) { | |
|
830 | if (style == "variable" && stream.peek() == "(" && | |
|
831 | (state.prevToken == ";" || state.prevToken == null || | |
|
832 | state.prevToken == "}") && | |
|
833 | cppLooksLikeConstructor(stream.current())) | |
|
834 | return "def"; | |
|
673 | 835 | } |
|
674 | 836 | }, |
|
675 | modeProps: {fold: "brace"} | |
|
837 | namespaceSeparator: "::", | |
|
838 | modeProps: {fold: ["brace", "include"]} | |
|
676 | 839 | }); |
|
677 | 840 | |
|
678 | 841 | def("text/x-squirrel", { |
|
679 | 842 | name: "clike", |
|
680 | 843 | keywords: words("base break clone continue const default delete enum extends function in class" + |
|
681 | 844 | " foreach local resume return this throw typeof yield constructor instanceof static"), |
|
682 |
types: |
|
|
845 | types: cTypes, | |
|
683 | 846 | blockKeywords: words("case catch class else for foreach if switch try while"), |
|
684 | 847 | defKeywords: words("function local class"), |
|
685 | 848 | typeFirstDefinitions: true, |
@@ -757,7 +920,7 b' CodeMirror.defineMode("clike", function(' | |||
|
757 | 920 | return "atom"; |
|
758 | 921 | }, |
|
759 | 922 | token: function(_stream, state, style) { |
|
760 |
if ((style == "variable" || style == " |
|
|
923 | if ((style == "variable" || style == "type") && | |
|
761 | 924 | state.prevToken == ".") { |
|
762 | 925 | return "variable-2"; |
|
763 | 926 | } |
@@ -1,15 +1,10 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
3 | ||
|
4 | /** | |
|
5 | * Author: Hans Engel | |
|
6 | * Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun) | |
|
7 | */ | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
8 | 3 | |
|
9 | 4 | (function(mod) { |
|
10 | if (typeof exports == "object" && typeof module == "object") // CommonJS | |
|
5 | if (typeof exports === "object" && typeof module === "object") // CommonJS | |
|
11 | 6 | mod(require("../../lib/codemirror")); |
|
12 | else if (typeof define == "function" && define.amd) // AMD | |
|
7 | else if (typeof define === "function" && define.amd) // AMD | |
|
13 | 8 | define(["../../lib/codemirror"], mod); |
|
14 | 9 | else // Plain browser env |
|
15 | 10 | mod(CodeMirror); |
@@ -17,233 +12,281 b'' | |||
|
17 | 12 | "use strict"; |
|
18 | 13 | |
|
19 | 14 | CodeMirror.defineMode("clojure", function (options) { |
|
20 | var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2", | |
|
21 | ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable"; | |
|
22 | var INDENT_WORD_SKIP = options.indentUnit || 2; | |
|
23 | var NORMAL_INDENT_UNIT = options.indentUnit || 2; | |
|
24 | ||
|
25 | function makeKeywords(str) { | |
|
26 | var obj = {}, words = str.split(" "); | |
|
27 | for (var i = 0; i < words.length; ++i) obj[words[i]] = true; | |
|
28 | return obj; | |
|
29 | } | |
|
30 | ||
|
31 | var atoms = makeKeywords("true false nil"); | |
|
32 | ||
|
33 | var keywords = makeKeywords( | |
|
34 | "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle"); | |
|
35 | ||
|
36 | var builtins = makeKeywords( | |
|
37 | "* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* *compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> ->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast byte byte-array bytes case cast char char-array char-escape-string char-name-string char? chars chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement concat cond condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? declare default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last drop-while empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot rand rand-int rand-nth range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote unquote-splicing update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of vector? when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap *default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! set-agent-send-off-executor! some-> some->>"); | |
|
38 | ||
|
39 | var indentKeys = makeKeywords( | |
|
40 | // Built-ins | |
|
41 | "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch " + | |
|
42 | ||
|
43 | // Binding forms | |
|
44 | "let letfn binding loop for doseq dotimes when-let if-let " + | |
|
45 | ||
|
46 | // Data structures | |
|
47 | "defstruct struct-map assoc " + | |
|
48 | ||
|
49 | // clojure.test | |
|
50 | "testing deftest " + | |
|
51 | ||
|
52 | // contrib | |
|
53 | "handler-case handle dotrace deftrace"); | |
|
54 | ||
|
55 | var tests = { | |
|
56 | digit: /\d/, | |
|
57 | digit_or_colon: /[\d:]/, | |
|
58 | hex: /[0-9a-f]/i, | |
|
59 | sign: /[+-]/, | |
|
60 | exponent: /e/i, | |
|
61 | keyword_char: /[^\s\(\[\;\)\]]/, | |
|
62 | symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/, | |
|
63 | block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/ | |
|
64 | }; | |
|
65 | ||
|
66 | function stateStack(indent, type, prev) { // represents a state stack object | |
|
67 | this.indent = indent; | |
|
68 | this.type = type; | |
|
69 | this.prev = prev; | |
|
70 | } | |
|
15 | var atoms = ["false", "nil", "true"]; | |
|
16 | var specialForms = [".", "catch", "def", "do", "if", "monitor-enter", | |
|
17 | "monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"]; | |
|
18 | var coreSymbols = ["*", "*'", "*1", "*2", "*3", "*agent*", | |
|
19 | "*allow-unresolved-vars*", "*assert*", "*clojure-version*", | |
|
20 | "*command-line-args*", "*compile-files*", "*compile-path*", | |
|
21 | "*compiler-options*", "*data-readers*", "*default-data-reader-fn*", "*e", | |
|
22 | "*err*", "*file*", "*flush-on-newline*", "*fn-loader*", "*in*", | |
|
23 | "*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*", | |
|
24 | "*print-level*", "*print-meta*", "*print-namespace-maps*", | |
|
25 | "*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*", | |
|
26 | "*suppress-read*", "*unchecked-math*", "*use-context-classloader*", | |
|
27 | "*verbose-defrecords*", "*warn-on-reflection*", "+", "+'", "-", "-'", | |
|
28 | "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode", | |
|
29 | "->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=", | |
|
30 | "=", "==", ">", ">=", "EMPTY-NODE", "Inst", "StackTraceElement->vec", | |
|
31 | "Throwable->map", "accessor", "aclone", "add-classpath", "add-watch", | |
|
32 | "agent", "agent-error", "agent-errors", "aget", "alength", "alias", | |
|
33 | "all-ns", "alter", "alter-meta!", "alter-var-root", "amap", "ancestors", | |
|
34 | "and", "any?", "apply", "areduce", "array-map", "as->", "aset", | |
|
35 | "aset-boolean", "aset-byte", "aset-char", "aset-double", "aset-float", | |
|
36 | "aset-int", "aset-long", "aset-short", "assert", "assoc", "assoc!", | |
|
37 | "assoc-in", "associative?", "atom", "await", "await-for", "await1", | |
|
38 | "bases", "bean", "bigdec", "bigint", "biginteger", "binding", "bit-and", | |
|
39 | "bit-and-not", "bit-clear", "bit-flip", "bit-not", "bit-or", "bit-set", | |
|
40 | "bit-shift-left", "bit-shift-right", "bit-test", "bit-xor", "boolean", | |
|
41 | "boolean-array", "boolean?", "booleans", "bound-fn", "bound-fn*", | |
|
42 | "bound?", "bounded-count", "butlast", "byte", "byte-array", "bytes", | |
|
43 | "bytes?", "case", "cast", "cat", "char", "char-array", | |
|
44 | "char-escape-string", "char-name-string", "char?", "chars", "chunk", | |
|
45 | "chunk-append", "chunk-buffer", "chunk-cons", "chunk-first", "chunk-next", | |
|
46 | "chunk-rest", "chunked-seq?", "class", "class?", "clear-agent-errors", | |
|
47 | "clojure-version", "coll?", "comment", "commute", "comp", "comparator", | |
|
48 | "compare", "compare-and-set!", "compile", "complement", "completing", | |
|
49 | "concat", "cond", "cond->", "cond->>", "condp", "conj", "conj!", "cons", | |
|
50 | "constantly", "construct-proxy", "contains?", "count", "counted?", | |
|
51 | "create-ns", "create-struct", "cycle", "dec", "dec'", "decimal?", | |
|
52 | "declare", "dedupe", "default-data-readers", "definline", "definterface", | |
|
53 | "defmacro", "defmethod", "defmulti", "defn", "defn-", "defonce", | |
|
54 | "defprotocol", "defrecord", "defstruct", "deftype", "delay", "delay?", | |
|
55 | "deliver", "denominator", "deref", "derive", "descendants", "destructure", | |
|
56 | "disj", "disj!", "dissoc", "dissoc!", "distinct", "distinct?", "doall", | |
|
57 | "dorun", "doseq", "dosync", "dotimes", "doto", "double", "double-array", | |
|
58 | "double?", "doubles", "drop", "drop-last", "drop-while", "eduction", | |
|
59 | "empty", "empty?", "ensure", "ensure-reduced", "enumeration-seq", | |
|
60 | "error-handler", "error-mode", "eval", "even?", "every-pred", "every?", | |
|
61 | "ex-data", "ex-info", "extend", "extend-protocol", "extend-type", | |
|
62 | "extenders", "extends?", "false?", "ffirst", "file-seq", "filter", | |
|
63 | "filterv", "find", "find-keyword", "find-ns", "find-protocol-impl", | |
|
64 | "find-protocol-method", "find-var", "first", "flatten", "float", | |
|
65 | "float-array", "float?", "floats", "flush", "fn", "fn?", "fnext", "fnil", | |
|
66 | "for", "force", "format", "frequencies", "future", "future-call", | |
|
67 | "future-cancel", "future-cancelled?", "future-done?", "future?", | |
|
68 | "gen-class", "gen-interface", "gensym", "get", "get-in", "get-method", | |
|
69 | "get-proxy-class", "get-thread-bindings", "get-validator", "group-by", | |
|
70 | "halt-when", "hash", "hash-combine", "hash-map", "hash-ordered-coll", | |
|
71 | "hash-set", "hash-unordered-coll", "ident?", "identical?", "identity", | |
|
72 | "if-let", "if-not", "if-some", "ifn?", "import", "in-ns", "inc", "inc'", | |
|
73 | "indexed?", "init-proxy", "inst-ms", "inst-ms*", "inst?", "instance?", | |
|
74 | "int", "int-array", "int?", "integer?", "interleave", "intern", | |
|
75 | "interpose", "into", "into-array", "ints", "io!", "isa?", "iterate", | |
|
76 | "iterator-seq", "juxt", "keep", "keep-indexed", "key", "keys", "keyword", | |
|
77 | "keyword?", "last", "lazy-cat", "lazy-seq", "let", "letfn", "line-seq", | |
|
78 | "list", "list*", "list?", "load", "load-file", "load-reader", | |
|
79 | "load-string", "loaded-libs", "locking", "long", "long-array", "longs", | |
|
80 | "loop", "macroexpand", "macroexpand-1", "make-array", "make-hierarchy", | |
|
81 | "map", "map-entry?", "map-indexed", "map?", "mapcat", "mapv", "max", | |
|
82 | "max-key", "memfn", "memoize", "merge", "merge-with", "meta", | |
|
83 | "method-sig", "methods", "min", "min-key", "mix-collection-hash", "mod", | |
|
84 | "munge", "name", "namespace", "namespace-munge", "nat-int?", "neg-int?", | |
|
85 | "neg?", "newline", "next", "nfirst", "nil?", "nnext", "not", "not-any?", | |
|
86 | "not-empty", "not-every?", "not=", "ns", "ns-aliases", "ns-imports", | |
|
87 | "ns-interns", "ns-map", "ns-name", "ns-publics", "ns-refers", | |
|
88 | "ns-resolve", "ns-unalias", "ns-unmap", "nth", "nthnext", "nthrest", | |
|
89 | "num", "number?", "numerator", "object-array", "odd?", "or", "parents", | |
|
90 | "partial", "partition", "partition-all", "partition-by", "pcalls", "peek", | |
|
91 | "persistent!", "pmap", "pop", "pop!", "pop-thread-bindings", "pos-int?", | |
|
92 | "pos?", "pr", "pr-str", "prefer-method", "prefers", | |
|
93 | "primitives-classnames", "print", "print-ctor", "print-dup", | |
|
94 | "print-method", "print-simple", "print-str", "printf", "println", | |
|
95 | "println-str", "prn", "prn-str", "promise", "proxy", | |
|
96 | "proxy-call-with-super", "proxy-mappings", "proxy-name", "proxy-super", | |
|
97 | "push-thread-bindings", "pvalues", "qualified-ident?", | |
|
98 | "qualified-keyword?", "qualified-symbol?", "quot", "rand", "rand-int", | |
|
99 | "rand-nth", "random-sample", "range", "ratio?", "rational?", | |
|
100 | "rationalize", "re-find", "re-groups", "re-matcher", "re-matches", | |
|
101 | "re-pattern", "re-seq", "read", "read-line", "read-string", | |
|
102 | "reader-conditional", "reader-conditional?", "realized?", "record?", | |
|
103 | "reduce", "reduce-kv", "reduced", "reduced?", "reductions", "ref", | |
|
104 | "ref-history-count", "ref-max-history", "ref-min-history", "ref-set", | |
|
105 | "refer", "refer-clojure", "reify", "release-pending-sends", "rem", | |
|
106 | "remove", "remove-all-methods", "remove-method", "remove-ns", | |
|
107 | "remove-watch", "repeat", "repeatedly", "replace", "replicate", "require", | |
|
108 | "reset!", "reset-meta!", "reset-vals!", "resolve", "rest", | |
|
109 | "restart-agent", "resultset-seq", "reverse", "reversible?", "rseq", | |
|
110 | "rsubseq", "run!", "satisfies?", "second", "select-keys", "send", | |
|
111 | "send-off", "send-via", "seq", "seq?", "seqable?", "seque", "sequence", | |
|
112 | "sequential?", "set", "set-agent-send-executor!", | |
|
113 | "set-agent-send-off-executor!", "set-error-handler!", "set-error-mode!", | |
|
114 | "set-validator!", "set?", "short", "short-array", "shorts", "shuffle", | |
|
115 | "shutdown-agents", "simple-ident?", "simple-keyword?", "simple-symbol?", | |
|
116 | "slurp", "some", "some->", "some->>", "some-fn", "some?", "sort", | |
|
117 | "sort-by", "sorted-map", "sorted-map-by", "sorted-set", "sorted-set-by", | |
|
118 | "sorted?", "special-symbol?", "spit", "split-at", "split-with", "str", | |
|
119 | "string?", "struct", "struct-map", "subs", "subseq", "subvec", "supers", | |
|
120 | "swap!", "swap-vals!", "symbol", "symbol?", "sync", "tagged-literal", | |
|
121 | "tagged-literal?", "take", "take-last", "take-nth", "take-while", "test", | |
|
122 | "the-ns", "thread-bound?", "time", "to-array", "to-array-2d", | |
|
123 | "trampoline", "transduce", "transient", "tree-seq", "true?", "type", | |
|
124 | "unchecked-add", "unchecked-add-int", "unchecked-byte", "unchecked-char", | |
|
125 | "unchecked-dec", "unchecked-dec-int", "unchecked-divide-int", | |
|
126 | "unchecked-double", "unchecked-float", "unchecked-inc", | |
|
127 | "unchecked-inc-int", "unchecked-int", "unchecked-long", | |
|
128 | "unchecked-multiply", "unchecked-multiply-int", "unchecked-negate", | |
|
129 | "unchecked-negate-int", "unchecked-remainder-int", "unchecked-short", | |
|
130 | "unchecked-subtract", "unchecked-subtract-int", "underive", "unquote", | |
|
131 | "unquote-splicing", "unreduced", "unsigned-bit-shift-right", "update", | |
|
132 | "update-in", "update-proxy", "uri?", "use", "uuid?", "val", "vals", | |
|
133 | "var-get", "var-set", "var?", "vary-meta", "vec", "vector", "vector-of", | |
|
134 | "vector?", "volatile!", "volatile?", "vreset!", "vswap!", "when", | |
|
135 | "when-first", "when-let", "when-not", "when-some", "while", | |
|
136 | "with-bindings", "with-bindings*", "with-in-str", "with-loading-context", | |
|
137 | "with-local-vars", "with-meta", "with-open", "with-out-str", | |
|
138 | "with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?", | |
|
139 | "zipmap"]; | |
|
140 | var haveBodyParameter = [ | |
|
141 | "->", "->>", "as->", "binding", "bound-fn", "case", "catch", "comment", | |
|
142 | "cond", "cond->", "cond->>", "condp", "def", "definterface", "defmethod", | |
|
143 | "defn", "defmacro", "defprotocol", "defrecord", "defstruct", "deftype", | |
|
144 | "do", "doseq", "dotimes", "doto", "extend", "extend-protocol", | |
|
145 | "extend-type", "fn", "for", "future", "if", "if-let", "if-not", "if-some", | |
|
146 | "let", "letfn", "locking", "loop", "ns", "proxy", "reify", "struct-map", | |
|
147 | "some->", "some->>", "try", "when", "when-first", "when-let", "when-not", | |
|
148 | "when-some", "while", "with-bindings", "with-bindings*", "with-in-str", | |
|
149 | "with-loading-context", "with-local-vars", "with-meta", "with-open", | |
|
150 | "with-out-str", "with-precision", "with-redefs", "with-redefs-fn"]; | |
|
71 | 151 | |
|
72 | function pushStack(state, indent, type) { | |
|
73 | state.indentStack = new stateStack(indent, type, state.indentStack); | |
|
74 | } | |
|
75 | ||
|
76 | function popStack(state) { | |
|
77 | state.indentStack = state.indentStack.prev; | |
|
78 | } | |
|
152 | CodeMirror.registerHelper("hintWords", "clojure", | |
|
153 | [].concat(atoms, specialForms, coreSymbols)); | |
|
79 | 154 | |
|
80 | function isNumber(ch, stream){ | |
|
81 | // hex | |
|
82 | if ( ch === '0' && stream.eat(/x/i) ) { | |
|
83 | stream.eatWhile(tests.hex); | |
|
84 | return true; | |
|
85 | } | |
|
155 | var atom = createLookupMap(atoms); | |
|
156 | var specialForm = createLookupMap(specialForms); | |
|
157 | var coreSymbol = createLookupMap(coreSymbols); | |
|
158 | var hasBodyParameter = createLookupMap(haveBodyParameter); | |
|
159 | var delimiter = /^(?:[\\\[\]\s"(),;@^`{}~]|$)/; | |
|
160 | var numberLiteral = /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/; | |
|
161 | var characterLiteral = /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/; | |
|
86 | 162 | |
|
87 | // leading sign | |
|
88 | if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) { | |
|
89 | stream.eat(tests.sign); | |
|
90 | ch = stream.next(); | |
|
91 | } | |
|
92 | ||
|
93 | if ( tests.digit.test(ch) ) { | |
|
94 | stream.eat(ch); | |
|
95 | stream.eatWhile(tests.digit); | |
|
163 | // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*/ | |
|
164 | // simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/ | |
|
165 | // qualified-symbol := (<simple-namespace>(<.><simple-namespace>)*</>)?<simple-symbol> | |
|
166 | var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/; | |
|
96 | 167 | |
|
97 | if ( '.' == stream.peek() ) { | |
|
98 | stream.eat('.'); | |
|
99 | stream.eatWhile(tests.digit); | |
|
100 | } else if ('/' == stream.peek() ) { | |
|
101 | stream.eat('/'); | |
|
102 | stream.eatWhile(tests.digit); | |
|
103 | } | |
|
104 | ||
|
105 | if ( stream.eat(tests.exponent) ) { | |
|
106 | stream.eat(tests.sign); | |
|
107 | stream.eatWhile(tests.digit); | |
|
108 | } | |
|
109 | ||
|
110 | return true; | |
|
111 | } | |
|
168 | function base(stream, state) { | |
|
169 | if (stream.eatSpace() || stream.eat(",")) return ["space", null]; | |
|
170 | if (stream.match(numberLiteral)) return [null, "number"]; | |
|
171 | if (stream.match(characterLiteral)) return [null, "string-2"]; | |
|
172 | if (stream.eat(/^"/)) return (state.tokenize = inString)(stream, state); | |
|
173 | if (stream.eat(/^[(\[{]/)) return ["open", "bracket"]; | |
|
174 | if (stream.eat(/^[)\]}]/)) return ["close", "bracket"]; | |
|
175 | if (stream.eat(/^;/)) {stream.skipToEnd(); return ["space", "comment"];} | |
|
176 | if (stream.eat(/^[#'@^`~]/)) return [null, "meta"]; | |
|
112 | 177 | |
|
113 | return false; | |
|
114 | } | |
|
178 | var matches = stream.match(qualifiedSymbol); | |
|
179 | var symbol = matches && matches[0]; | |
|
115 | 180 | |
|
116 | // Eat character that starts after backslash \ | |
|
117 | function eatCharacter(stream) { | |
|
118 |
|
|
|
119 | // Read special literals: backspace, newline, space, return. | |
|
120 | // Just read all lowercase letters. | |
|
121 | if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) { | |
|
122 | return; | |
|
123 | } | |
|
124 | // Read unicode character: \u1000 \uA0a1 | |
|
125 | if (first === "u") { | |
|
126 | stream.match(/[0-9a-z]{4}/i, true); | |
|
127 | } | |
|
181 | if (!symbol) { | |
|
182 | // advance stream by at least one character so we don't get stuck. | |
|
183 | stream.next(); | |
|
184 | stream.eatWhile(function (c) {return !is(c, delimiter);}); | |
|
185 | return [null, "error"]; | |
|
128 | 186 | } |
|
129 | 187 | |
|
130 | return { | |
|
131 | startState: function () { | |
|
132 | return { | |
|
133 | indentStack: null, | |
|
134 | indentation: 0, | |
|
135 | mode: false | |
|
136 | }; | |
|
137 | }, | |
|
188 | if (symbol === "comment" && state.lastToken === "(") | |
|
189 | return (state.tokenize = inComment)(stream, state); | |
|
190 | if (is(symbol, atom) || symbol.charAt(0) === ":") return ["symbol", "atom"]; | |
|
191 | if (is(symbol, specialForm) || is(symbol, coreSymbol)) return ["symbol", "keyword"]; | |
|
192 | if (state.lastToken === "(") return ["symbol", "builtin"]; // other operator | |
|
193 | ||
|
194 | return ["symbol", "variable"]; | |
|
195 | } | |
|
138 | 196 | |
|
139 |
|
|
|
140 | if (state.indentStack == null && stream.sol()) { | |
|
141 | // update indentation, but only if indentStack is empty | |
|
142 | state.indentation = stream.indentation(); | |
|
143 | } | |
|
197 | function inString(stream, state) { | |
|
198 | var escaped = false, next; | |
|
199 | ||
|
200 | while (next = stream.next()) { | |
|
201 | if (next === "\"" && !escaped) {state.tokenize = base; break;} | |
|
202 | escaped = !escaped && next === "\\"; | |
|
203 | } | |
|
204 | ||
|
205 | return [null, "string"]; | |
|
206 | } | |
|
144 | 207 | |
|
145 | // skip spaces | |
|
146 | if (state.mode != "string" && stream.eatSpace()) { | |
|
147 | return null; | |
|
148 | } | |
|
149 | var returnType = null; | |
|
208 | function inComment(stream, state) { | |
|
209 | var parenthesisCount = 1; | |
|
210 | var next; | |
|
150 | 211 | |
|
151 | switch(state.mode){ | |
|
152 | case "string": // multi-line string parsing mode | |
|
153 | var next, escaped = false; | |
|
154 | while ((next = stream.next()) != null) { | |
|
155 | if (next == "\"" && !escaped) { | |
|
212 | while (next = stream.next()) { | |
|
213 | if (next === ")") parenthesisCount--; | |
|
214 | if (next === "(") parenthesisCount++; | |
|
215 | if (parenthesisCount === 0) { | |
|
216 | stream.backUp(1); | |
|
217 | state.tokenize = base; | |
|
218 | break; | |
|
219 | } | |
|
220 | } | |
|
156 | 221 | |
|
157 | state.mode = false; | |
|
158 | break; | |
|
159 | } | |
|
160 | escaped = !escaped && next == "\\"; | |
|
161 | } | |
|
162 | returnType = STRING; // continue on in string mode | |
|
163 | break; | |
|
164 | default: // default parsing mode | |
|
165 | var ch = stream.next(); | |
|
222 | return ["space", "comment"]; | |
|
223 | } | |
|
224 | ||
|
225 | function createLookupMap(words) { | |
|
226 | var obj = {}; | |
|
227 | ||
|
228 | for (var i = 0; i < words.length; ++i) obj[words[i]] = true; | |
|
229 | ||
|
230 | return obj; | |
|
231 | } | |
|
166 | 232 | |
|
167 | if (ch == "\"") { | |
|
168 | state.mode = "string"; | |
|
169 | returnType = STRING; | |
|
170 | } else if (ch == "\\") { | |
|
171 | eatCharacter(stream); | |
|
172 | returnType = CHARACTER; | |
|
173 | } else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) { | |
|
174 | returnType = ATOM; | |
|
175 | } else if (ch == ";") { // comment | |
|
176 | stream.skipToEnd(); // rest of the line is a comment | |
|
177 | returnType = COMMENT; | |
|
178 | } else if (isNumber(ch,stream)){ | |
|
179 | returnType = NUMBER; | |
|
180 | } else if (ch == "(" || ch == "[" || ch == "{" ) { | |
|
181 | var keyWord = '', indentTemp = stream.column(), letter; | |
|
182 | /** | |
|
183 | Either | |
|
184 | (indent-word .. | |
|
185 | (non-indent-word .. | |
|
186 | (;something else, bracket, etc. | |
|
187 | */ | |
|
233 | function is(value, test) { | |
|
234 | if (test instanceof RegExp) return test.test(value); | |
|
235 | if (test instanceof Object) return test.propertyIsEnumerable(value); | |
|
236 | } | |
|
188 | 237 | |
|
189 | if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) { | |
|
190 | keyWord += letter; | |
|
191 | } | |
|
238 | return { | |
|
239 | startState: function () { | |
|
240 | return { | |
|
241 | ctx: {prev: null, start: 0, indentTo: 0}, | |
|
242 | lastToken: null, | |
|
243 | tokenize: base | |
|
244 | }; | |
|
245 | }, | |
|
246 | ||
|
247 | token: function (stream, state) { | |
|
248 | if (stream.sol() && (typeof state.ctx.indentTo !== "number")) | |
|
249 | state.ctx.indentTo = state.ctx.start + 1; | |
|
250 | ||
|
251 | var typeStylePair = state.tokenize(stream, state); | |
|
252 | var type = typeStylePair[0]; | |
|
253 | var style = typeStylePair[1]; | |
|
254 | var current = stream.current(); | |
|
192 | 255 | |
|
193 | if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) || | |
|
194 | tests.block_indent.test(keyWord))) { // indent-word | |
|
195 | pushStack(state, indentTemp + INDENT_WORD_SKIP, ch); | |
|
196 | } else { // non-indent word | |
|
197 | // we continue eating the spaces | |
|
198 | stream.eatSpace(); | |
|
199 | if (stream.eol() || stream.peek() == ";") { | |
|
200 | // nothing significant after | |
|
201 | // we restart indentation the user defined spaces after | |
|
202 | pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch); | |
|
203 | } else { | |
|
204 | pushStack(state, indentTemp + stream.current().length, ch); // else we match | |
|
205 | } | |
|
206 | } | |
|
207 | stream.backUp(stream.current().length - 1); // undo all the eating | |
|
256 | if (type !== "space") { | |
|
257 | if (state.lastToken === "(" && state.ctx.indentTo === null) { | |
|
258 | if (type === "symbol" && is(current, hasBodyParameter)) | |
|
259 | state.ctx.indentTo = state.ctx.start + options.indentUnit; | |
|
260 | else state.ctx.indentTo = "next"; | |
|
261 | } else if (state.ctx.indentTo === "next") { | |
|
262 | state.ctx.indentTo = stream.column(); | |
|
263 | } | |
|
264 | ||
|
265 | state.lastToken = current; | |
|
266 | } | |
|
208 | 267 | |
|
209 | returnType = BRACKET; | |
|
210 | } else if (ch == ")" || ch == "]" || ch == "}") { | |
|
211 | returnType = BRACKET; | |
|
212 | if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : (ch == "]" ? "[" :"{"))) { | |
|
213 | popStack(state); | |
|
214 | } | |
|
215 | } else if ( ch == ":" ) { | |
|
216 | stream.eatWhile(tests.symbol); | |
|
217 | return ATOM; | |
|
218 | } else { | |
|
219 | stream.eatWhile(tests.symbol); | |
|
268 | if (type === "open") | |
|
269 | state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null}; | |
|
270 | else if (type === "close") state.ctx = state.ctx.prev || state.ctx; | |
|
271 | ||
|
272 | return style; | |
|
273 | }, | |
|
220 | 274 | |
|
221 | if (keywords && keywords.propertyIsEnumerable(stream.current())) { | |
|
222 | returnType = KEYWORD; | |
|
223 | } else if (builtins && builtins.propertyIsEnumerable(stream.current())) { | |
|
224 | returnType = BUILTIN; | |
|
225 | } else if (atoms && atoms.propertyIsEnumerable(stream.current())) { | |
|
226 | returnType = ATOM; | |
|
227 | } else { | |
|
228 | returnType = VAR; | |
|
229 | } | |
|
230 | } | |
|
231 | } | |
|
275 | indent: function (state) { | |
|
276 | var i = state.ctx.indentTo; | |
|
232 | 277 | |
|
233 | return returnType; | |
|
234 |
|
|
|
278 | return (typeof i === "number") ? | |
|
279 | i : | |
|
280 | state.ctx.start + 1; | |
|
281 | }, | |
|
235 | 282 | |
|
236 | indent: function (state) { | |
|
237 | if (state.indentStack == null) return state.indentation; | |
|
238 | return state.indentStack.indent; | |
|
239 | }, | |
|
240 | ||
|
241 | closeBrackets: {pairs: "()[]{}\"\""}, | |
|
242 | lineComment: ";;" | |
|
243 | }; | |
|
283 | closeBrackets: {pairs: "()[]{}\"\""}, | |
|
284 | lineComment: ";;" | |
|
285 | }; | |
|
244 | 286 | }); |
|
245 | 287 | |
|
246 | 288 | CodeMirror.defineMIME("text/x-clojure", "clojure"); |
|
247 | 289 | CodeMirror.defineMIME("text/x-clojurescript", "clojure"); |
|
290 | CodeMirror.defineMIME("application/edn", "clojure"); | |
|
248 | 291 | |
|
249 | 292 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /** |
|
5 | 5 | * Author: Gautam Mehta |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /** |
|
5 | 5 | * Link to the project's GitHub page: |
@@ -349,6 +349,10 b' CodeMirror.defineMode("coffeescript", fu' | |||
|
349 | 349 | return external; |
|
350 | 350 | }); |
|
351 | 351 | |
|
352 | // IANA registered media type | |
|
353 | // https://www.iana.org/assignments/media-types/ | |
|
354 | CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript"); | |
|
355 | ||
|
352 | 356 | CodeMirror.defineMIME("text/x-coffeescript", "coffeescript"); |
|
353 | 357 | CodeMirror.defineMIME("text/coffeescript", "coffeescript"); |
|
354 | 358 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -43,11 +43,12 b' CodeMirror.defineMode("commonlisp", func' | |||
|
43 | 43 | else { stream.skipToEnd(); return "error"; } |
|
44 | 44 | } else if (ch == "#") { |
|
45 | 45 | var ch = stream.next(); |
|
46 |
if (ch == " |
|
|
46 | if (ch == "(") { type = "open"; return "bracket"; } | |
|
47 | 47 | else if (/[+\-=\.']/.test(ch)) return null; |
|
48 | 48 | else if (/\d/.test(ch) && stream.match(/^\d*#/)) return null; |
|
49 | 49 | else if (ch == "|") return (state.tokenize = inComment)(stream, state); |
|
50 | 50 | else if (ch == ":") { readSym(stream); return "meta"; } |
|
51 | else if (ch == "\\") { stream.next(); readSym(stream); return "string-2" } | |
|
51 | 52 | else return "error"; |
|
52 | 53 | } else { |
|
53 | 54 | var name = readSym(stream); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -29,26 +29,22 b'' | |||
|
29 | 29 | var types = /^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/; |
|
30 | 30 | var keywords = wordRegExp([ |
|
31 | 31 | "abstract", "alias", "as", "asm", "begin", "break", "case", "class", "def", "do", |
|
32 |
"else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if", |
|
|
32 | "else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if", | |
|
33 | 33 | "include", "instance_sizeof", "lib", "macro", "module", "next", "of", "out", "pointerof", |
|
34 | "private", "protected", "rescue", "return", "require", "sizeof", "struct", | |
|
35 | "super", "then", "type", "typeof", "union", "unless", "until", "when", "while", "with", | |
|
36 | "yield", "__DIR__", "__FILE__", "__LINE__" | |
|
34 | "private", "protected", "rescue", "return", "require", "select", "sizeof", "struct", | |
|
35 | "super", "then", "type", "typeof", "uninitialized", "union", "unless", "until", "when", "while", "with", | |
|
36 | "yield", "__DIR__", "__END_LINE__", "__FILE__", "__LINE__" | |
|
37 | 37 | ]); |
|
38 | 38 | var atomWords = wordRegExp(["true", "false", "nil", "self"]); |
|
39 | 39 | var indentKeywordsArray = [ |
|
40 | 40 | "def", "fun", "macro", |
|
41 | 41 | "class", "module", "struct", "lib", "enum", "union", |
|
42 | "if", "unless", "case", "while", "until", "begin", "then", | |
|
43 | "do", | |
|
44 | "for", "ifdef" | |
|
42 | "do", "for" | |
|
45 | 43 | ]; |
|
46 | 44 | var indentKeywords = wordRegExp(indentKeywordsArray); |
|
47 | var dedentKeywordsArray = [ | |
|
48 | "end", | |
|
49 | "else", "elsif", | |
|
50 | "rescue", "ensure" | |
|
51 | ]; | |
|
45 | var indentExpressionKeywordsArray = ["if", "unless", "case", "while", "until", "begin", "then"]; | |
|
46 | var indentExpressionKeywords = wordRegExp(indentExpressionKeywordsArray); | |
|
47 | var dedentKeywordsArray = ["end", "else", "elsif", "rescue", "ensure"]; | |
|
52 | 48 | var dedentKeywords = wordRegExp(dedentKeywordsArray); |
|
53 | 49 | var dedentPunctualsArray = ["\\)", "\\}", "\\]"]; |
|
54 | 50 | var dedentPunctuals = new RegExp("^(?:" + dedentPunctualsArray.join("|") + ")$"); |
@@ -90,12 +86,15 b'' | |||
|
90 | 86 | } else if (state.lastToken == ".") { |
|
91 | 87 | return "property"; |
|
92 | 88 | } else if (keywords.test(matched)) { |
|
93 |
if ( |
|
|
94 | if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0)) { | |
|
89 | if (indentKeywords.test(matched)) { | |
|
90 | if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0) && !(matched == "def" && state.lastToken == "abstract")) { | |
|
95 | 91 | state.blocks.push(matched); |
|
96 | 92 | state.currentIndent += 1; |
|
97 | 93 | } |
|
98 |
} else if ( |
|
|
94 | } else if ((state.lastStyle == "operator" || !state.lastStyle) && indentExpressionKeywords.test(matched)) { | |
|
95 | state.blocks.push(matched); | |
|
96 | state.currentIndent += 1; | |
|
97 | } else if (matched == "end") { | |
|
99 | 98 | state.blocks.pop(); |
|
100 | 99 | state.currentIndent -= 1; |
|
101 | 100 | } |
@@ -124,12 +123,6 b'' | |||
|
124 | 123 | return "variable-2"; |
|
125 | 124 | } |
|
126 | 125 | |
|
127 | // Global variables | |
|
128 | if (stream.eat("$")) { | |
|
129 | stream.eat(/[0-9]+|\?/) || stream.match(idents) || stream.match(types); | |
|
130 | return "variable-3"; | |
|
131 | } | |
|
132 | ||
|
133 | 126 | // Constants and types |
|
134 | 127 | if (stream.match(types)) { |
|
135 | 128 | return "tag"; |
@@ -165,6 +158,9 b'' | |||
|
165 | 158 | } else if (stream.match("%w")) { |
|
166 | 159 | embed = false; |
|
167 | 160 | delim = stream.next(); |
|
161 | } else if (stream.match("%q")) { | |
|
162 | embed = false; | |
|
163 | delim = stream.next(); | |
|
168 | 164 | } else { |
|
169 | 165 | if(delim = stream.match(/^%([^\w\s=])/)) { |
|
170 | 166 | delim = delim[1]; |
@@ -183,6 +179,11 b'' | |||
|
183 | 179 | return chain(tokenQuote(delim, style, embed), stream, state); |
|
184 | 180 | } |
|
185 | 181 | |
|
182 | // Here Docs | |
|
183 | if (matched = stream.match(/^<<-('?)([A-Z]\w*)\1/)) { | |
|
184 | return chain(tokenHereDoc(matched[2], !matched[1]), stream, state) | |
|
185 | } | |
|
186 | ||
|
186 | 187 | // Characters |
|
187 | 188 | if (stream.eat("'")) { |
|
188 | 189 | stream.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/); |
@@ -202,14 +203,14 b'' | |||
|
202 | 203 | return "number"; |
|
203 | 204 | } |
|
204 | 205 | |
|
205 | if (stream.eat(/\d/)) { | |
|
206 | if (stream.eat(/^\d/)) { | |
|
206 | 207 | stream.match(/^\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/); |
|
207 | 208 | return "number"; |
|
208 | 209 | } |
|
209 | 210 | |
|
210 | 211 | // Operators |
|
211 | 212 | if (stream.match(operators)) { |
|
212 |
stream.eat("="); // Operators can follow assig |
|
|
213 | stream.eat("="); // Operators can follow assign symbol. | |
|
213 | 214 | return "operator"; |
|
214 | 215 | } |
|
215 | 216 | |
@@ -339,7 +340,7 b'' | |||
|
339 | 340 | return style; |
|
340 | 341 | } |
|
341 | 342 | |
|
342 | escaped = ch == "\\"; | |
|
343 | escaped = embed && ch == "\\"; | |
|
343 | 344 | } else { |
|
344 | 345 | stream.next(); |
|
345 | 346 | escaped = false; |
@@ -350,12 +351,52 b'' | |||
|
350 | 351 | }; |
|
351 | 352 | } |
|
352 | 353 | |
|
354 | function tokenHereDoc(phrase, embed) { | |
|
355 | return function (stream, state) { | |
|
356 | if (stream.sol()) { | |
|
357 | stream.eatSpace() | |
|
358 | if (stream.match(phrase)) { | |
|
359 | state.tokenize.pop(); | |
|
360 | return "string"; | |
|
361 | } | |
|
362 | } | |
|
363 | ||
|
364 | var escaped = false; | |
|
365 | while (stream.peek()) { | |
|
366 | if (!escaped) { | |
|
367 | if (stream.match("{%", false)) { | |
|
368 | state.tokenize.push(tokenMacro("%", "%")); | |
|
369 | return "string"; | |
|
370 | } | |
|
371 | ||
|
372 | if (stream.match("{{", false)) { | |
|
373 | state.tokenize.push(tokenMacro("{", "}")); | |
|
374 | return "string"; | |
|
375 | } | |
|
376 | ||
|
377 | if (embed && stream.match("#{", false)) { | |
|
378 | state.tokenize.push(tokenNest("#{", "}", "meta")); | |
|
379 | return "string"; | |
|
380 | } | |
|
381 | ||
|
382 | escaped = embed && stream.next() == "\\"; | |
|
383 | } else { | |
|
384 | stream.next(); | |
|
385 | escaped = false; | |
|
386 | } | |
|
387 | } | |
|
388 | ||
|
389 | return "string"; | |
|
390 | } | |
|
391 | } | |
|
392 | ||
|
353 | 393 | return { |
|
354 | 394 | startState: function () { |
|
355 | 395 | return { |
|
356 | 396 | tokenize: [tokenBase], |
|
357 | 397 | currentIndent: 0, |
|
358 | 398 | lastToken: null, |
|
399 | lastStyle: null, | |
|
359 | 400 | blocks: [] |
|
360 | 401 | }; |
|
361 | 402 | }, |
@@ -366,6 +407,7 b'' | |||
|
366 | 407 | |
|
367 | 408 | if (style && style != "comment") { |
|
368 | 409 | state.lastToken = token; |
|
410 | state.lastStyle = style; | |
|
369 | 411 | } |
|
370 | 412 | |
|
371 | 413 | return style; |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -28,6 +28,7 b' CodeMirror.defineMode("css", function(co' | |||
|
28 | 28 | colorKeywords = parserConfig.colorKeywords || {}, |
|
29 | 29 | valueKeywords = parserConfig.valueKeywords || {}, |
|
30 | 30 | allowNested = parserConfig.allowNested, |
|
31 | lineComment = parserConfig.lineComment, | |
|
31 | 32 | supportsAtComponent = parserConfig.supportsAtComponent === true; |
|
32 | 33 | |
|
33 | 34 | var type, override; |
@@ -62,7 +63,7 b' CodeMirror.defineMode("css", function(co' | |||
|
62 | 63 | if (/[\d.]/.test(stream.peek())) { |
|
63 | 64 | stream.eatWhile(/[\w.%]/); |
|
64 | 65 | return ret("number", "unit"); |
|
65 |
} else if (stream.match(/^-[\w\\\-] |
|
|
66 | } else if (stream.match(/^-[\w\\\-]*/)) { | |
|
66 | 67 | stream.eatWhile(/[\w\\\-]/); |
|
67 | 68 | if (stream.match(/^\s*:/, false)) |
|
68 | 69 | return ret("variable-2", "variable-definition"); |
@@ -76,12 +77,11 b' CodeMirror.defineMode("css", function(co' | |||
|
76 | 77 | return ret("qualifier", "qualifier"); |
|
77 | 78 | } else if (/[:;{}\[\]\(\)]/.test(ch)) { |
|
78 | 79 | return ret(null, ch); |
|
79 |
} else if ( |
|
|
80 | (ch == "d" && stream.match("omain(")) || | |
|
81 | (ch == "r" && stream.match("egexp("))) { | |
|
82 | stream.backUp(1); | |
|
83 | state.tokenize = tokenParenthesized; | |
|
84 | return ret("property", "word"); | |
|
80 | } else if (stream.match(/[\w-.]+(?=\()/)) { | |
|
81 | if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) { | |
|
82 | state.tokenize = tokenParenthesized; | |
|
83 | } | |
|
84 | return ret("variable callee", "variable"); | |
|
85 | 85 | } else if (/[\w\\\-]/.test(ch)) { |
|
86 | 86 | stream.eatWhile(/[\w\\\-]/); |
|
87 | 87 | return ret("property", "word"); |
@@ -161,16 +161,16 b' CodeMirror.defineMode("css", function(co' | |||
|
161 | 161 | return pushContext(state, stream, "block"); |
|
162 | 162 | } else if (type == "}" && state.context.prev) { |
|
163 | 163 | return popContext(state); |
|
164 | } else if (supportsAtComponent && /@component/.test(type)) { | |
|
164 | } else if (supportsAtComponent && /@component/i.test(type)) { | |
|
165 | 165 | return pushContext(state, stream, "atComponentBlock"); |
|
166 | } else if (/^@(-moz-)?document$/.test(type)) { | |
|
166 | } else if (/^@(-moz-)?document$/i.test(type)) { | |
|
167 | 167 | return pushContext(state, stream, "documentTypes"); |
|
168 | } else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) { | |
|
168 | } else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) { | |
|
169 | 169 | return pushContext(state, stream, "atBlock"); |
|
170 | } else if (/^@(font-face|counter-style)/.test(type)) { | |
|
170 | } else if (/^@(font-face|counter-style)/i.test(type)) { | |
|
171 | 171 | state.stateArg = type; |
|
172 | 172 | return "restricted_atBlock_before"; |
|
173 | } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) { | |
|
173 | } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) { | |
|
174 | 174 | return "keyframes"; |
|
175 | 175 | } else if (type && type.charAt(0) == "@") { |
|
176 | 176 | return pushContext(state, stream, "at"); |
@@ -253,6 +253,8 b' CodeMirror.defineMode("css", function(co' | |||
|
253 | 253 | }; |
|
254 | 254 | |
|
255 | 255 | states.pseudo = function(type, stream, state) { |
|
256 | if (type == "meta") return "pseudo"; | |
|
257 | ||
|
256 | 258 | if (type == "word") { |
|
257 | 259 | override = "variable-3"; |
|
258 | 260 | return state.context.type; |
@@ -380,7 +382,8 b' CodeMirror.defineMode("css", function(co' | |||
|
380 | 382 | style = style[0]; |
|
381 | 383 | } |
|
382 | 384 | override = style; |
|
383 | state.state = states[state.state](type, stream, state); | |
|
385 | if (type != "comment") | |
|
386 | state.state = states[state.state](type, stream, state); | |
|
384 | 387 | return override; |
|
385 | 388 | }, |
|
386 | 389 | |
@@ -398,7 +401,6 b' CodeMirror.defineMode("css", function(co' | |||
|
398 | 401 | ch == "{" && (cx.type == "at" || cx.type == "atBlock")) { |
|
399 | 402 | // Dedent relative to current context. |
|
400 | 403 | indent = Math.max(0, cx.indent - indentUnit); |
|
401 | cx = cx.prev; | |
|
402 | 404 | } |
|
403 | 405 | } |
|
404 | 406 | return indent; |
@@ -407,6 +409,8 b' CodeMirror.defineMode("css", function(co' | |||
|
407 | 409 | electricChars: "}", |
|
408 | 410 | blockCommentStart: "/*", |
|
409 | 411 | blockCommentEnd: "*/", |
|
412 | blockCommentContinue: " * ", | |
|
413 | lineComment: lineComment, | |
|
410 | 414 | fold: "brace" |
|
411 | 415 | }; |
|
412 | 416 | }); |
@@ -414,7 +418,7 b' CodeMirror.defineMode("css", function(co' | |||
|
414 | 418 | function keySet(array) { |
|
415 | 419 | var keys = {}; |
|
416 | 420 | for (var i = 0; i < array.length; ++i) { |
|
417 | keys[array[i]] = true; | |
|
421 | keys[array[i].toLowerCase()] = true; | |
|
418 | 422 | } |
|
419 | 423 | return keys; |
|
420 | 424 | } |
@@ -468,7 +472,7 b' CodeMirror.defineMode("css", function(co' | |||
|
468 | 472 | "border-top-left-radius", "border-top-right-radius", "border-top-style", |
|
469 | 473 | "border-top-width", "border-width", "bottom", "box-decoration-break", |
|
470 | 474 | "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", |
|
471 | "caption-side", "clear", "clip", "color", "color-profile", "column-count", | |
|
475 | "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count", | |
|
472 | 476 | "column-fill", "column-gap", "column-rule", "column-rule-color", |
|
473 | 477 | "column-rule-style", "column-rule-width", "column-span", "column-width", |
|
474 | 478 | "columns", "content", "counter-increment", "counter-reset", "crop", "cue", |
@@ -484,19 +488,19 b' CodeMirror.defineMode("css", function(co' | |||
|
484 | 488 | "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", |
|
485 | 489 | "font-variant-ligatures", "font-variant-numeric", "font-variant-position", |
|
486 | 490 | "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", |
|
487 |
|
|
|
488 |
"grid-column-start", "grid-row", "grid-row-end", "grid-row- |
|
|
489 | "grid-template", "grid-template-areas", "grid-template-columns", | |
|
491 | "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap", | |
|
492 | "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", | |
|
493 | "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns", | |
|
490 | 494 | "grid-template-rows", "hanging-punctuation", "height", "hyphens", |
|
491 | 495 | "icon", "image-orientation", "image-rendering", "image-resolution", |
|
492 | "inline-box-align", "justify-content", "left", "letter-spacing", | |
|
496 | "inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing", | |
|
493 | 497 | "line-break", "line-height", "line-stacking", "line-stacking-ruby", |
|
494 | 498 | "line-stacking-shift", "line-stacking-strategy", "list-style", |
|
495 | 499 | "list-style-image", "list-style-position", "list-style-type", "margin", |
|
496 | 500 | "margin-bottom", "margin-left", "margin-right", "margin-top", |
|
497 |
|
|
|
501 | "marks", "marquee-direction", "marquee-loop", | |
|
498 | 502 | "marquee-play-count", "marquee-speed", "marquee-style", "max-height", |
|
499 | "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", | |
|
503 | "max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index", | |
|
500 | 504 | "nav-left", "nav-right", "nav-up", "object-fit", "object-position", |
|
501 | 505 | "opacity", "order", "orphans", "outline", |
|
502 | 506 | "outline-color", "outline-offset", "outline-style", "outline-width", |
@@ -504,7 +508,7 b' CodeMirror.defineMode("css", function(co' | |||
|
504 | 508 | "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", |
|
505 | 509 | "page", "page-break-after", "page-break-before", "page-break-inside", |
|
506 | 510 | "page-policy", "pause", "pause-after", "pause-before", "perspective", |
|
507 | "perspective-origin", "pitch", "pitch-range", "play-during", "position", | |
|
511 | "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position", | |
|
508 | 512 | "presentation-level", "punctuation-trim", "quotes", "region-break-after", |
|
509 | 513 | "region-break-before", "region-break-inside", "region-fragment", |
|
510 | 514 | "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", |
@@ -522,9 +526,9 b' CodeMirror.defineMode("css", function(co' | |||
|
522 | 526 | "text-wrap", "top", "transform", "transform-origin", "transform-style", |
|
523 | 527 | "transition", "transition-delay", "transition-duration", |
|
524 | 528 | "transition-property", "transition-timing-function", "unicode-bidi", |
|
525 | "vertical-align", "visibility", "voice-balance", "voice-duration", | |
|
529 | "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration", | |
|
526 | 530 | "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", |
|
527 | "voice-volume", "volume", "white-space", "widows", "width", "word-break", | |
|
531 | "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break", | |
|
528 | 532 | "word-spacing", "word-wrap", "z-index", |
|
529 | 533 | // SVG-specific |
|
530 | 534 | "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", |
@@ -589,7 +593,7 b' CodeMirror.defineMode("css", function(co' | |||
|
589 | 593 | "above", "absolute", "activeborder", "additive", "activecaption", "afar", |
|
590 | 594 | "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", |
|
591 | 595 | "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", |
|
592 | "arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page", | |
|
596 | "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", | |
|
593 | 597 | "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", |
|
594 | 598 | "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", |
|
595 | 599 | "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", |
@@ -598,10 +602,10 b' CodeMirror.defineMode("css", function(co' | |||
|
598 | 602 | "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch", |
|
599 | 603 | "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", |
|
600 | 604 | "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse", |
|
601 | "compact", "condensed", "contain", "content", | |
|
605 | "compact", "condensed", "contain", "content", "contents", | |
|
602 | 606 | "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop", |
|
603 | 607 | "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", |
|
604 | "decimal-leading-zero", "default", "default-button", "destination-atop", | |
|
608 | "decimal-leading-zero", "default", "default-button", "dense", "destination-atop", | |
|
605 | 609 | "destination-in", "destination-out", "destination-over", "devanagari", "difference", |
|
606 | 610 | "disc", "discard", "disclosure-closed", "disclosure-open", "document", |
|
607 | 611 | "dot-dash", "dot-dot-dash", |
@@ -615,13 +619,13 b' CodeMirror.defineMode("css", function(co' | |||
|
615 | 619 | "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", |
|
616 | 620 | "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed", |
|
617 | 621 | "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", |
|
618 | "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove", | |
|
622 | "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove", | |
|
619 | 623 | "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew", |
|
620 | 624 | "help", "hidden", "hide", "higher", "highlight", "highlighttext", |
|
621 | 625 | "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore", |
|
622 | 626 | "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", |
|
623 | 627 | "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis", |
|
624 | "inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert", | |
|
628 | "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert", | |
|
625 | 629 | "italic", "japanese-formal", "japanese-informal", "justify", "kannada", |
|
626 | 630 | "katakana", "katakana-iroha", "keep-all", "khmer", |
|
627 | 631 | "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal", |
@@ -641,7 +645,7 b' CodeMirror.defineMode("css", function(co' | |||
|
641 | 645 | "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize", |
|
642 | 646 | "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", |
|
643 | 647 | "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", |
|
644 | "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote", | |
|
648 | "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote", | |
|
645 | 649 | "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", |
|
646 | 650 | "outside", "outside-shape", "overlay", "overline", "padding", "padding-box", |
|
647 | 651 | "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter", |
@@ -653,17 +657,17 b' CodeMirror.defineMode("css", function(co' | |||
|
653 | 657 | "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", |
|
654 | 658 | "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running", |
|
655 | 659 | "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", |
|
656 | "scroll", "scrollbar", "se-resize", "searchfield", | |
|
660 | "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield", | |
|
657 | 661 | "searchfield-cancel-button", "searchfield-decoration", |
|
658 | "searchfield-results-button", "searchfield-results-decoration", | |
|
662 | "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end", | |
|
659 | 663 | "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama", |
|
660 | 664 | "simp-chinese-formal", "simp-chinese-informal", "single", |
|
661 | 665 | "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", |
|
662 | 666 | "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", |
|
663 | 667 | "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali", |
|
664 | "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "spell-out", "square", | |
|
668 | "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", | |
|
665 | 669 | "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", |
|
666 | "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table", | |
|
670 | "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", | |
|
667 | 671 | "table-caption", "table-cell", "table-column", "table-column-group", |
|
668 | 672 | "table-footer-group", "table-header-group", "table-row", "table-row-group", |
|
669 | 673 | "tamil", |
@@ -671,9 +675,9 b' CodeMirror.defineMode("css", function(co' | |||
|
671 | 675 | "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", |
|
672 | 676 | "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", |
|
673 | 677 | "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", |
|
674 | "trad-chinese-formal", "trad-chinese-informal", | |
|
678 | "trad-chinese-formal", "trad-chinese-informal", "transform", | |
|
675 | 679 | "translate", "translate3d", "translateX", "translateY", "translateZ", |
|
676 | "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", | |
|
680 | "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up", | |
|
677 | 681 | "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", |
|
678 | 682 | "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", |
|
679 | 683 | "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", |
@@ -730,6 +734,7 b' CodeMirror.defineMode("css", function(co' | |||
|
730 | 734 | valueKeywords: valueKeywords, |
|
731 | 735 | fontProperties: fontProperties, |
|
732 | 736 | allowNested: true, |
|
737 | lineComment: "//", | |
|
733 | 738 | tokenHooks: { |
|
734 | 739 | "/": function(stream, state) { |
|
735 | 740 | if (stream.eat("/")) { |
@@ -743,8 +748,8 b' CodeMirror.defineMode("css", function(co' | |||
|
743 | 748 | } |
|
744 | 749 | }, |
|
745 | 750 | ":": function(stream) { |
|
746 | if (stream.match(/\s*\{/)) | |
|
747 |
return [null, |
|
|
751 | if (stream.match(/\s*\{/, false)) | |
|
752 | return [null, null] | |
|
748 | 753 | return false; |
|
749 | 754 | }, |
|
750 | 755 | "$": function(stream) { |
@@ -772,6 +777,7 b' CodeMirror.defineMode("css", function(co' | |||
|
772 | 777 | valueKeywords: valueKeywords, |
|
773 | 778 | fontProperties: fontProperties, |
|
774 | 779 | allowNested: true, |
|
780 | lineComment: "//", | |
|
775 | 781 | tokenHooks: { |
|
776 | 782 | "/": function(stream, state) { |
|
777 | 783 | if (stream.eat("/")) { |
@@ -786,7 +792,7 b' CodeMirror.defineMode("css", function(co' | |||
|
786 | 792 | }, |
|
787 | 793 | "@": function(stream) { |
|
788 | 794 | if (stream.eat("{")) return [null, "interpolation"]; |
|
789 | if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false; | |
|
795 | if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false; | |
|
790 | 796 | stream.eatWhile(/[\w\\\-]/); |
|
791 | 797 | if (stream.match(/^\s*:/, false)) |
|
792 | 798 | return ["variable-2", "variable-definition"]; |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // By the Neo4j Team and contributors. |
|
5 | 5 | // https://github.com/neo4j-contrib/CodeMirror |
@@ -20,8 +20,12 b'' | |||
|
20 | 20 | CodeMirror.defineMode("cypher", function(config) { |
|
21 | 21 | var tokenBase = function(stream/*, state*/) { |
|
22 | 22 | var ch = stream.next(); |
|
23 |
if (ch === |
|
|
24 |
stream.match(/. |
|
|
23 | if (ch ==='"') { | |
|
24 | stream.match(/.*?"/); | |
|
25 | return "string"; | |
|
26 | } | |
|
27 | if (ch === "'") { | |
|
28 | stream.match(/.*?'/); | |
|
25 | 29 | return "string"; |
|
26 | 30 | } |
|
27 | 31 | if (/[{}\(\),\.;\[\]]/.test(ch)) { |
@@ -62,7 +66,7 b'' | |||
|
62 | 66 | var curPunc; |
|
63 | 67 | var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]); |
|
64 | 68 | var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]); |
|
65 | var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]); | |
|
69 | var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]); | |
|
66 | 70 | var operatorChars = /[*+\-<>=&|~%^]/; |
|
67 | 71 | |
|
68 | 72 | return { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -44,7 +44,7 b' CodeMirror.defineMode("d", function(conf' | |||
|
44 | 44 | } |
|
45 | 45 | if (ch == "/") { |
|
46 | 46 | if (stream.eat("+")) { |
|
47 | state.tokenize = tokenComment; | |
|
47 | state.tokenize = tokenNestedComment; | |
|
48 | 48 | return tokenNestedComment(stream, state); |
|
49 | 49 | } |
|
50 | 50 | if (stream.eat("*")) { |
@@ -182,7 +182,12 b' CodeMirror.defineMode("d", function(conf' | |||
|
182 | 182 | else return ctx.indented + (closing ? 0 : indentUnit); |
|
183 | 183 | }, |
|
184 | 184 | |
|
185 | electricChars: "{}" | |
|
185 | electricChars: "{}", | |
|
186 | blockCommentStart: "/*", | |
|
187 | blockCommentEnd: "*/", | |
|
188 | blockCommentContinue: " * ", | |
|
189 | lineComment: "//", | |
|
190 | fold: "brace" | |
|
186 | 191 | }; |
|
187 | 192 | }); |
|
188 | 193 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -12,10 +12,10 b'' | |||
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | 14 | var keywords = ("this super static final const abstract class extends external factory " + |
|
15 |
"implements get native |
|
|
16 | "assert break case continue default in return new deferred async await " + | |
|
15 | "implements mixin get native set typedef with enum throw rethrow " + | |
|
16 | "assert break case continue default in return new deferred async await covariant " + | |
|
17 | 17 | "try catch finally do else for if switch while import library export " + |
|
18 | "part of show hide is as").split(" "); | |
|
18 | "part of show hide is as extension on").split(" "); | |
|
19 | 19 | var blockKeywords = "try catch finally do else for if switch while".split(" "); |
|
20 | 20 | var atoms = "true false null".split(" "); |
|
21 | 21 | var builtins = "void bool num int double dynamic var String".split(" "); |
@@ -72,6 +72,21 b'' | |||
|
72 | 72 | return null; |
|
73 | 73 | } |
|
74 | 74 | return false; |
|
75 | }, | |
|
76 | ||
|
77 | "/": function(stream, state) { | |
|
78 | if (!stream.eat("*")) return false | |
|
79 | state.tokenize = tokenNestedComment(1) | |
|
80 | return state.tokenize(stream, state) | |
|
81 | }, | |
|
82 | token: function(stream, _, style) { | |
|
83 | if (style == "variable") { | |
|
84 | // Assume uppercase symbols are classes using variable-2 | |
|
85 | var isUpper = RegExp('^[_$]*[A-Z][a-zA-Z0-9_$]*$','g'); | |
|
86 | if (isUpper.test(stream.current())) { | |
|
87 | return 'variable-2'; | |
|
88 | } | |
|
89 | } | |
|
75 | 90 | } |
|
76 | 91 | } |
|
77 | 92 | }); |
@@ -121,6 +136,27 b'' | |||
|
121 | 136 | return "variable"; |
|
122 | 137 | } |
|
123 | 138 | |
|
139 | function tokenNestedComment(depth) { | |
|
140 | return function (stream, state) { | |
|
141 | var ch | |
|
142 | while (ch = stream.next()) { | |
|
143 | if (ch == "*" && stream.eat("/")) { | |
|
144 | if (depth == 1) { | |
|
145 | state.tokenize = null | |
|
146 | break | |
|
147 | } else { | |
|
148 | state.tokenize = tokenNestedComment(depth - 1) | |
|
149 | return state.tokenize(stream, state) | |
|
150 | } | |
|
151 | } else if (ch == "/" && stream.eat("*")) { | |
|
152 | state.tokenize = tokenNestedComment(depth + 1) | |
|
153 | return state.tokenize(stream, state) | |
|
154 | } | |
|
155 | } | |
|
156 | return "comment" | |
|
157 | } | |
|
158 | } | |
|
159 | ||
|
124 | 160 | CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins)); |
|
125 | 161 | |
|
126 | 162 | // This is needed to make loading through meta.js work. |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -66,11 +66,11 b'' | |||
|
66 | 66 | } |
|
67 | 67 | |
|
68 | 68 | // A string can be included in either single or double quotes (this is |
|
69 |
// the delim |
|
|
69 | // the delimiter). Mark everything as a string until the start delimiter | |
|
70 | 70 | // occurs again. |
|
71 |
function inString (delim |
|
|
71 | function inString (delimiter, previousTokenizer) { | |
|
72 | 72 | return function (stream, state) { |
|
73 |
if (!state.escapeNext && stream.eat(delim |
|
|
73 | if (!state.escapeNext && stream.eat(delimiter)) { | |
|
74 | 74 | state.tokenize = previousTokenizer; |
|
75 | 75 | } else { |
|
76 | 76 | if (state.escapeNext) { |
@@ -80,7 +80,7 b'' | |||
|
80 | 80 | var ch = stream.next(); |
|
81 | 81 | |
|
82 | 82 | // Take into account the backslash for escaping characters, such as |
|
83 |
// the string delim |
|
|
83 | // the string delimiter. | |
|
84 | 84 | if (ch == "\\") { |
|
85 | 85 | state.escapeNext = true; |
|
86 | 86 | } |
@@ -100,7 +100,7 b'' | |||
|
100 | 100 | return "null"; |
|
101 | 101 | } |
|
102 | 102 | |
|
103 | // Dot folowed by a non-word character should be considered an error. | |
|
103 | // Dot followed by a non-word character should be considered an error. | |
|
104 | 104 | if (stream.match(/\.\W+/)) { |
|
105 | 105 | return "error"; |
|
106 | 106 | } else if (stream.eat(".")) { |
@@ -119,7 +119,7 b'' | |||
|
119 | 119 | return "null"; |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | // Pipe folowed by a non-word character should be considered an error. | |
|
122 | // Pipe followed by a non-word character should be considered an error. | |
|
123 | 123 | if (stream.match(/\.\W+/)) { |
|
124 | 124 | return "error"; |
|
125 | 125 | } else if (stream.eat("|")) { |
@@ -199,7 +199,7 b'' | |||
|
199 | 199 | return "null"; |
|
200 | 200 | } |
|
201 | 201 | |
|
202 | // Dot folowed by a non-word character should be considered an error. | |
|
202 | // Dot followed by a non-word character should be considered an error. | |
|
203 | 203 | if (stream.match(/\.\W+/)) { |
|
204 | 204 | return "error"; |
|
205 | 205 | } else if (stream.eat(".")) { |
@@ -218,7 +218,7 b'' | |||
|
218 | 218 | return "null"; |
|
219 | 219 | } |
|
220 | 220 | |
|
221 | // Pipe folowed by a non-word character should be considered an error. | |
|
221 | // Pipe followed by a non-word character should be considered an error. | |
|
222 | 222 | if (stream.match(/\.\W+/)) { |
|
223 | 223 | return "error"; |
|
224 | 224 | } else if (stream.eat("|")) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -11,30 +11,64 b'' | |||
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | var from = "from"; | |
|
15 | var fromRegex = new RegExp("^(\\s*)\\b(" + from + ")\\b", "i"); | |
|
16 | ||
|
17 | var shells = ["run", "cmd", "entrypoint", "shell"]; | |
|
18 | var shellsAsArrayRegex = new RegExp("^(\\s*)(" + shells.join('|') + ")(\\s+\\[)", "i"); | |
|
19 | ||
|
20 | var expose = "expose"; | |
|
21 | var exposeRegex = new RegExp("^(\\s*)(" + expose + ")(\\s+)", "i"); | |
|
22 | ||
|
23 | var others = [ | |
|
24 | "arg", "from", "maintainer", "label", "env", | |
|
25 | "add", "copy", "volume", "user", | |
|
26 | "workdir", "onbuild", "stopsignal", "healthcheck", "shell" | |
|
27 | ]; | |
|
28 | ||
|
14 | 29 | // Collect all Dockerfile directives |
|
15 | var instructions = ["from", "maintainer", "run", "cmd", "expose", "env", | |
|
16 | "add", "copy", "entrypoint", "volume", "user", | |
|
17 | "workdir", "onbuild"], | |
|
30 | var instructions = [from, expose].concat(shells).concat(others), | |
|
18 | 31 | instructionRegex = "(" + instructions.join('|') + ")", |
|
19 | instructionOnlyLine = new RegExp(instructionRegex + "\\s*$", "i"), | |
|
20 | instructionWithArguments = new RegExp(instructionRegex + "(\\s+)", "i"); | |
|
32 | instructionOnlyLine = new RegExp("^(\\s*)" + instructionRegex + "(\\s*)(#.*)?$", "i"), | |
|
33 | instructionWithArguments = new RegExp("^(\\s*)" + instructionRegex + "(\\s+)", "i"); | |
|
21 | 34 | |
|
22 | 35 | CodeMirror.defineSimpleMode("dockerfile", { |
|
23 | 36 | start: [ |
|
24 | 37 | // Block comment: This is a line starting with a comment |
|
25 | 38 | { |
|
26 | regex: /#.*$/, | |
|
39 | regex: /^\s*#.*$/, | |
|
40 | sol: true, | |
|
27 | 41 | token: "comment" |
|
28 | 42 | }, |
|
43 | { | |
|
44 | regex: fromRegex, | |
|
45 | token: [null, "keyword"], | |
|
46 | sol: true, | |
|
47 | next: "from" | |
|
48 | }, | |
|
29 | 49 | // Highlight an instruction without any arguments (for convenience) |
|
30 | 50 | { |
|
31 | 51 | regex: instructionOnlyLine, |
|
32 | token: "variable-2" | |
|
52 | token: [null, "keyword", null, "error"], | |
|
53 | sol: true | |
|
54 | }, | |
|
55 | { | |
|
56 | regex: shellsAsArrayRegex, | |
|
57 | token: [null, "keyword", null], | |
|
58 | sol: true, | |
|
59 | next: "array" | |
|
60 | }, | |
|
61 | { | |
|
62 | regex: exposeRegex, | |
|
63 | token: [null, "keyword", null], | |
|
64 | sol: true, | |
|
65 | next: "expose" | |
|
33 | 66 | }, |
|
34 | 67 | // Highlight an instruction followed by arguments |
|
35 | 68 | { |
|
36 | 69 | regex: instructionWithArguments, |
|
37 |
token: [ |
|
|
70 | token: [null, "keyword", null], | |
|
71 | sol: true, | |
|
38 | 72 | next: "arguments" |
|
39 | 73 | }, |
|
40 | 74 | { |
@@ -42,26 +76,21 b'' | |||
|
42 | 76 | token: null |
|
43 | 77 | } |
|
44 | 78 | ], |
|
45 |
|
|
|
79 | from: [ | |
|
46 | 80 | { |
|
47 | // Line comment without instruction arguments is an error | |
|
48 | regex: /#.*$/, | |
|
49 | token: "error", | |
|
50 | next: "start" | |
|
51 | }, | |
|
52 | { | |
|
53 | regex: /[^#]+\\$/, | |
|
54 | token: null | |
|
55 | }, | |
|
56 | { | |
|
57 | // Match everything except for the inline comment | |
|
58 | regex: /[^#]+/, | |
|
81 | regex: /\s*$/, | |
|
59 | 82 | token: null, |
|
60 | 83 | next: "start" |
|
61 | 84 | }, |
|
62 | 85 | { |
|
63 | regex: /$/, | |
|
64 | token: null, | |
|
86 | // Line comment without instruction arguments is an error | |
|
87 | regex: /(\s*)(#.*)$/, | |
|
88 | token: [null, "error"], | |
|
89 | next: "start" | |
|
90 | }, | |
|
91 | { | |
|
92 | regex: /(\s*\S+\s+)(as)/i, | |
|
93 | token: [null, "keyword"], | |
|
65 | 94 | next: "start" |
|
66 | 95 | }, |
|
67 | 96 | // Fail safe return to start |
@@ -70,9 +99,112 b'' | |||
|
70 | 99 | next: "start" |
|
71 | 100 | } |
|
72 | 101 | ], |
|
73 | meta: { | |
|
74 | lineComment: "#" | |
|
102 | single: [ | |
|
103 | { | |
|
104 | regex: /(?:[^\\']|\\.)/, | |
|
105 | token: "string" | |
|
106 | }, | |
|
107 | { | |
|
108 | regex: /'/, | |
|
109 | token: "string", | |
|
110 | pop: true | |
|
111 | } | |
|
112 | ], | |
|
113 | double: [ | |
|
114 | { | |
|
115 | regex: /(?:[^\\"]|\\.)/, | |
|
116 | token: "string" | |
|
117 | }, | |
|
118 | { | |
|
119 | regex: /"/, | |
|
120 | token: "string", | |
|
121 | pop: true | |
|
122 | } | |
|
123 | ], | |
|
124 | array: [ | |
|
125 | { | |
|
126 | regex: /\]/, | |
|
127 | token: null, | |
|
128 | next: "start" | |
|
129 | }, | |
|
130 | { | |
|
131 | regex: /"(?:[^\\"]|\\.)*"?/, | |
|
132 | token: "string" | |
|
75 | 133 | } |
|
134 | ], | |
|
135 | expose: [ | |
|
136 | { | |
|
137 | regex: /\d+$/, | |
|
138 | token: "number", | |
|
139 | next: "start" | |
|
140 | }, | |
|
141 | { | |
|
142 | regex: /[^\d]+$/, | |
|
143 | token: null, | |
|
144 | next: "start" | |
|
145 | }, | |
|
146 | { | |
|
147 | regex: /\d+/, | |
|
148 | token: "number" | |
|
149 | }, | |
|
150 | { | |
|
151 | regex: /[^\d]+/, | |
|
152 | token: null | |
|
153 | }, | |
|
154 | // Fail safe return to start | |
|
155 | { | |
|
156 | token: null, | |
|
157 | next: "start" | |
|
158 | } | |
|
159 | ], | |
|
160 | arguments: [ | |
|
161 | { | |
|
162 | regex: /^\s*#.*$/, | |
|
163 | sol: true, | |
|
164 | token: "comment" | |
|
165 | }, | |
|
166 | { | |
|
167 | regex: /"(?:[^\\"]|\\.)*"?$/, | |
|
168 | token: "string", | |
|
169 | next: "start" | |
|
170 | }, | |
|
171 | { | |
|
172 | regex: /"/, | |
|
173 | token: "string", | |
|
174 | push: "double" | |
|
175 | }, | |
|
176 | { | |
|
177 | regex: /'(?:[^\\']|\\.)*'?$/, | |
|
178 | token: "string", | |
|
179 | next: "start" | |
|
180 | }, | |
|
181 | { | |
|
182 | regex: /'/, | |
|
183 | token: "string", | |
|
184 | push: "single" | |
|
185 | }, | |
|
186 | { | |
|
187 | regex: /[^#"']+[\\`]$/, | |
|
188 | token: null | |
|
189 | }, | |
|
190 | { | |
|
191 | regex: /[^#"']+$/, | |
|
192 | token: null, | |
|
193 | next: "start" | |
|
194 | }, | |
|
195 | { | |
|
196 | regex: /[^#"']+/, | |
|
197 | token: null | |
|
198 | }, | |
|
199 | // Fail safe return to start | |
|
200 | { | |
|
201 | token: null, | |
|
202 | next: "start" | |
|
203 | } | |
|
204 | ], | |
|
205 | meta: { | |
|
206 | lineComment: "#" | |
|
207 | } | |
|
76 | 208 | }); |
|
77 | 209 | |
|
78 | 210 | CodeMirror.defineMIME("text/x-dockerfile", "dockerfile"); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /* |
|
5 | 5 | DTD mode |
@@ -114,17 +114,17 b' CodeMirror.defineMode("dtd", function(co' | |||
|
114 | 114 | |
|
115 | 115 | if( textAfter.match(/\]\s+|\]/) )n=n-1; |
|
116 | 116 | else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){ |
|
117 |
if(textAfter.substr(0,1) === "<") |
|
|
118 |
else if( type == "doindent" && textAfter.length > 1 ) |
|
|
117 | if(textAfter.substr(0,1) === "<") {} | |
|
118 | else if( type == "doindent" && textAfter.length > 1 ) {} | |
|
119 | 119 | else if( type == "doindent")n--; |
|
120 |
else if( type == ">" && textAfter.length > 1) |
|
|
121 |
else if( type == "tag" && textAfter !== ">") |
|
|
120 | else if( type == ">" && textAfter.length > 1) {} | |
|
121 | else if( type == "tag" && textAfter !== ">") {} | |
|
122 | 122 | else if( type == "tag" && state.stack[state.stack.length-1] == "rule")n--; |
|
123 | 123 | else if( type == "tag")n++; |
|
124 | 124 | else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule" && type === ">")n--; |
|
125 |
else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule") |
|
|
125 | else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule") {} | |
|
126 | 126 | else if( textAfter.substr(0,1) !== "<" && textAfter.substr(0,1) === ">" )n=n-1; |
|
127 |
else if( textAfter === ">") |
|
|
127 | else if( textAfter === ">") {} | |
|
128 | 128 | else n=n-1; |
|
129 | 129 | //over rule them all |
|
130 | 130 | if(type == null || type == "]")n--; |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -11,6 +11,14 b'' | |||
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | function forEach(arr, f) { | |
|
15 | for (var i = 0; i < arr.length; i++) f(arr[i], i) | |
|
16 | } | |
|
17 | function some(arr, f) { | |
|
18 | for (var i = 0; i < arr.length; i++) if (f(arr[i], i)) return true | |
|
19 | return false | |
|
20 | } | |
|
21 | ||
|
14 | 22 | CodeMirror.defineMode("dylan", function(_config) { |
|
15 | 23 | // Words |
|
16 | 24 | var words = { |
@@ -136,13 +144,13 b' CodeMirror.defineMode("dylan", function(' | |||
|
136 | 144 | var wordLookup = {}; |
|
137 | 145 | var styleLookup = {}; |
|
138 | 146 | |
|
139 | [ | |
|
147 | forEach([ | |
|
140 | 148 | "keyword", |
|
141 | 149 | "definition", |
|
142 | 150 | "simpleDefinition", |
|
143 | 151 | "signalingCalls" |
|
144 |
] |
|
|
145 |
words[type] |
|
|
152 | ], function(type) { | |
|
153 | forEach(words[type], function(word) { | |
|
146 | 154 | wordLookup[word] = type; |
|
147 | 155 | styleLookup[word] = styles[type]; |
|
148 | 156 | }); |
@@ -169,15 +177,16 b' CodeMirror.defineMode("dylan", function(' | |||
|
169 | 177 | } else if (stream.eat("/")) { |
|
170 | 178 | stream.skipToEnd(); |
|
171 | 179 | return "comment"; |
|
172 | } else { | |
|
173 | stream.skipTo(" "); | |
|
174 | return "operator"; | |
|
175 | 180 | } |
|
181 | stream.backUp(1); | |
|
176 | 182 | } |
|
177 | 183 | // Decimal |
|
178 | else if (/\d/.test(ch)) { | |
|
179 | stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/); | |
|
180 | return "number"; | |
|
184 | else if (/[+\-\d\.]/.test(ch)) { | |
|
185 | if (stream.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i) || | |
|
186 | stream.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i) || | |
|
187 | stream.match(/^[+-]?\d+/)) { | |
|
188 | return "number"; | |
|
189 | } | |
|
181 | 190 | } |
|
182 | 191 | // Hash |
|
183 | 192 | else if (ch == "#") { |
@@ -186,7 +195,7 b' CodeMirror.defineMode("dylan", function(' | |||
|
186 | 195 | ch = stream.peek(); |
|
187 | 196 | if (ch == '"') { |
|
188 | 197 | stream.next(); |
|
189 |
return chain(stream, state, tokenString('"', "string |
|
|
198 | return chain(stream, state, tokenString('"', "string")); | |
|
190 | 199 | } |
|
191 | 200 | // Binary number |
|
192 | 201 | else if (ch == "b") { |
@@ -206,29 +215,73 b' CodeMirror.defineMode("dylan", function(' | |||
|
206 | 215 | stream.eatWhile(/[0-7]/); |
|
207 | 216 | return "number"; |
|
208 | 217 | } |
|
218 | // Token concatenation in macros | |
|
219 | else if (ch == '#') { | |
|
220 | stream.next(); | |
|
221 | return "punctuation"; | |
|
222 | } | |
|
223 | // Sequence literals | |
|
224 | else if ((ch == '[') || (ch == '(')) { | |
|
225 | stream.next(); | |
|
226 | return "bracket"; | |
|
209 | 227 | // Hash symbol |
|
210 | else { | |
|
228 | } else if (stream.match(/f|t|all-keys|include|key|next|rest/i)) { | |
|
229 | return "atom"; | |
|
230 | } else { | |
|
211 | 231 | stream.eatWhile(/[-a-zA-Z]/); |
|
212 |
return " |
|
|
232 | return "error"; | |
|
233 | } | |
|
234 | } else if (ch == "~") { | |
|
235 | stream.next(); | |
|
236 | ch = stream.peek(); | |
|
237 | if (ch == "=") { | |
|
238 | stream.next(); | |
|
239 | ch = stream.peek(); | |
|
240 | if (ch == "=") { | |
|
241 | stream.next(); | |
|
242 | return "operator"; | |
|
243 | } | |
|
244 | return "operator"; | |
|
213 | 245 | } |
|
246 | return "operator"; | |
|
247 | } else if (ch == ":") { | |
|
248 | stream.next(); | |
|
249 | ch = stream.peek(); | |
|
250 | if (ch == "=") { | |
|
251 | stream.next(); | |
|
252 | return "operator"; | |
|
253 | } else if (ch == ":") { | |
|
254 | stream.next(); | |
|
255 | return "punctuation"; | |
|
256 | } | |
|
257 | } else if ("[](){}".indexOf(ch) != -1) { | |
|
258 | stream.next(); | |
|
259 | return "bracket"; | |
|
260 | } else if (".,".indexOf(ch) != -1) { | |
|
261 | stream.next(); | |
|
262 | return "punctuation"; | |
|
214 | 263 | } else if (stream.match("end")) { |
|
215 | 264 | return "keyword"; |
|
216 | 265 | } |
|
217 | 266 | for (var name in patterns) { |
|
218 | 267 | if (patterns.hasOwnProperty(name)) { |
|
219 | 268 | var pattern = patterns[name]; |
|
220 |
if ((pattern instanceof Array && |
|
|
269 | if ((pattern instanceof Array && some(pattern, function(p) { | |
|
221 | 270 | return stream.match(p); |
|
222 | 271 | })) || stream.match(pattern)) |
|
223 | 272 | return patternStyles[name]; |
|
224 | 273 | } |
|
225 | 274 | } |
|
275 | if (/[+\-*\/^=<>&|]/.test(ch)) { | |
|
276 | stream.next(); | |
|
277 | return "operator"; | |
|
278 | } | |
|
226 | 279 | if (stream.match("define")) { |
|
227 | 280 | return "def"; |
|
228 | 281 | } else { |
|
229 | 282 | stream.eatWhile(/[\w\-]/); |
|
230 | 283 | // Keyword |
|
231 |
if (wordLookup |
|
|
284 | if (wordLookup.hasOwnProperty(stream.current())) { | |
|
232 | 285 | return styleLookup[stream.current()]; |
|
233 | 286 | } else if (stream.current().match(symbol)) { |
|
234 | 287 | return "variable"; |
@@ -240,29 +293,37 b' CodeMirror.defineMode("dylan", function(' | |||
|
240 | 293 | } |
|
241 | 294 | |
|
242 | 295 | function tokenComment(stream, state) { |
|
243 | var maybeEnd = false, | |
|
244 | ch; | |
|
296 | var maybeEnd = false, maybeNested = false, nestedCount = 0, ch; | |
|
245 | 297 | while ((ch = stream.next())) { |
|
246 | 298 | if (ch == "/" && maybeEnd) { |
|
247 | state.tokenize = tokenBase; | |
|
248 | break; | |
|
299 | if (nestedCount > 0) { | |
|
300 | nestedCount--; | |
|
301 | } else { | |
|
302 | state.tokenize = tokenBase; | |
|
303 | break; | |
|
304 | } | |
|
305 | } else if (ch == "*" && maybeNested) { | |
|
306 | nestedCount++; | |
|
249 | 307 | } |
|
250 | 308 | maybeEnd = (ch == "*"); |
|
309 | maybeNested = (ch == "/"); | |
|
251 | 310 | } |
|
252 | 311 | return "comment"; |
|
253 | 312 | } |
|
254 | 313 | |
|
255 | 314 | function tokenString(quote, style) { |
|
256 | 315 | return function(stream, state) { |
|
257 | var next, end = false; | |
|
316 | var escaped = false, next, end = false; | |
|
258 | 317 | while ((next = stream.next()) != null) { |
|
259 | if (next == quote) { | |
|
318 | if (next == quote && !escaped) { | |
|
260 | 319 | end = true; |
|
261 | 320 | break; |
|
262 | 321 | } |
|
322 | escaped = !escaped && next == "\\"; | |
|
263 | 323 | } |
|
264 | if (end) | |
|
324 | if (end || !escaped) { | |
|
265 | 325 | state.tokenize = tokenBase; |
|
326 | } | |
|
266 | 327 | return style; |
|
267 | 328 | }; |
|
268 | 329 | } |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -94,7 +94,7 b'' | |||
|
94 | 94 | |
|
95 | 95 | if (bracesMode !== null && (state.braced || peek === "{")) { |
|
96 | 96 | if (state.localState === null) |
|
97 |
state.localState = |
|
|
97 | state.localState = CodeMirror.startState(bracesMode); | |
|
98 | 98 | |
|
99 | 99 | var token = bracesMode.token(stream, state.localState), |
|
100 | 100 | text = stream.current(); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -70,7 +70,7 b'' | |||
|
70 | 70 | if (smallRE.test(ch)) { |
|
71 | 71 | var isDef = source.pos === 1; |
|
72 | 72 | source.eatWhile(idRE); |
|
73 |
return isDef ? " |
|
|
73 | return isDef ? "type" : "variable"; | |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | if (digitRE.test(ch)) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /*jshint unused:true, eqnull:true, curly:true, bitwise:true */ |
|
5 | 5 | /*jshint undef:true, latedef:true, trailing:true */ |
@@ -433,15 +433,16 b' CodeMirror.defineMode("erlang", function' | |||
|
433 | 433 | } |
|
434 | 434 | |
|
435 | 435 | function maybe_drop_post(s) { |
|
436 | if (!s.length) return s | |
|
436 | 437 | var last = s.length-1; |
|
437 | 438 | |
|
438 | 439 | if (s[last].type === "dot") { |
|
439 | 440 | return []; |
|
440 | 441 | } |
|
441 | if (s[last].type === "fun" && s[last-1].token === "fun") { | |
|
442 | if (last > 1 && s[last].type === "fun" && s[last-1].token === "fun") { | |
|
442 | 443 | return s.slice(0,last-1); |
|
443 | 444 | } |
|
444 |
switch (s[ |
|
|
445 | switch (s[last].token) { | |
|
445 | 446 | case "}": return d(s,{g:["{"]}); |
|
446 | 447 | case "]": return d(s,{i:["["]}); |
|
447 | 448 | case ")": return d(s,{i:["("]}); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // Factor syntax highlight - simple mode |
|
5 | 5 | // |
@@ -22,52 +22,54 b'' | |||
|
22 | 22 | {regex: /#?!.*/, token: "comment"}, |
|
23 | 23 | // strings """, multiline --> state |
|
24 | 24 | {regex: /"""/, token: "string", next: "string3"}, |
|
25 |
{regex: / |
|
|
25 | {regex: /(STRING:)(\s)/, token: ["keyword", null], next: "string2"}, | |
|
26 | {regex: /\S*?"/, token: "string", next: "string"}, | |
|
26 | 27 | // numbers: dec, hex, unicode, bin, fractional, complex |
|
27 |
{regex: /(?: |
|
|
28 | {regex: /(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\-?\d+.?\d*)(?=\s)/, token: "number"}, | |
|
28 | 29 | //{regex: /[+-]?/} //fractional |
|
29 | 30 | // definition: defining word, defined word, etc |
|
30 |
{regex: /(\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, " |
|
|
31 | {regex: /((?:GENERIC)|\:?\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "bracket"], next: "stack"}, | |
|
32 | // method definition: defining word, type, defined word, etc | |
|
33 | {regex: /(M\:)(\s+)(\S+)(\s+)(\S+)/, token: ["keyword", null, "def", null, "tag"]}, | |
|
31 | 34 | // vocabulary using --> state |
|
32 | 35 | {regex: /USING\:/, token: "keyword", next: "vocabulary"}, |
|
33 | 36 | // vocabulary definition/use |
|
34 |
{regex: /(USE\:|IN\:)(\s+)(\S+)/, token: ["keyword", null, " |
|
|
35 | // <constructors> | |
|
36 | {regex: /<\S+>/, token: "builtin"}, | |
|
37 | {regex: /(USE\:|IN\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "tag"]}, | |
|
38 | // definition: a defining word, defined word | |
|
39 | {regex: /(\S+\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "def"]}, | |
|
37 | 40 | // "keywords", incl. ; t f . [ ] { } defining words |
|
38 |
{regex: /;|t|f|if|\.|\[|\]|\ |
|
|
41 | {regex: /(?:;|\\|t|f|if|loop|while|until|do|PRIVATE>|<PRIVATE|\.|\S*\[|\]|\S*\{|\})(?=\s|$)/, token: "keyword"}, | |
|
42 | // <constructors> and the like | |
|
43 | {regex: /\S+[\)>\.\*\?]+(?=\s|$)/, token: "builtin"}, | |
|
44 | {regex: /[\)><]+\S+(?=\s|$)/, token: "builtin"}, | |
|
45 | // operators | |
|
46 | {regex: /(?:[\+\-\=\/\*<>])(?=\s|$)/, token: "keyword"}, | |
|
39 | 47 | // any id (?) |
|
40 | 48 | {regex: /\S+/, token: "variable"}, |
|
41 | ||
|
42 | { | |
|
43 | regex: /./, | |
|
44 | token: null | |
|
45 | } | |
|
49 | {regex: /\s+|./, token: null} | |
|
46 | 50 | ], |
|
47 | 51 | vocabulary: [ |
|
48 | 52 | {regex: /;/, token: "keyword", next: "start"}, |
|
49 |
{regex: /\S+/, token: " |
|
|
50 | { | |
|
51 | regex: /./, | |
|
52 | token: null | |
|
53 | } | |
|
53 | {regex: /\S+/, token: "tag"}, | |
|
54 | {regex: /\s+|./, token: null} | |
|
54 | 55 | ], |
|
55 | 56 | string: [ |
|
56 | 57 | {regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start"}, |
|
57 | 58 | {regex: /.*/, token: "string"} |
|
58 | 59 | ], |
|
60 | string2: [ | |
|
61 | {regex: /^;/, token: "keyword", next: "start"}, | |
|
62 | {regex: /.*/, token: "string"} | |
|
63 | ], | |
|
59 | 64 | string3: [ |
|
60 | 65 | {regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start"}, |
|
61 | 66 | {regex: /.*/, token: "string"} |
|
62 | 67 | ], |
|
63 | 68 | stack: [ |
|
64 |
{regex: /\)/, token: " |
|
|
65 |
{regex: /--/, token: " |
|
|
66 |
{regex: /\S+/, token: " |
|
|
67 | { | |
|
68 | regex: /./, | |
|
69 | token: null | |
|
70 | } | |
|
69 | {regex: /\)/, token: "bracket", next: "start"}, | |
|
70 | {regex: /--/, token: "bracket"}, | |
|
71 | {regex: /\S+/, token: "meta"}, | |
|
72 | {regex: /\s+|./, token: null} | |
|
71 | 73 | ], |
|
72 | 74 | // The meta property contains global information about the mode. It |
|
73 | 75 | // can contain properties like lineComment, which are supported by |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // Author: Aliaksei Chapyzhenka |
|
5 | 5 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -81,7 +81,7 b' CodeMirror.defineMode("gfm", function(co' | |||
|
81 | 81 | if (stream.sol() || state.ateSpace) { |
|
82 | 82 | state.ateSpace = false; |
|
83 | 83 | if (modeConfig.gitHubSpice !== false) { |
|
84 | if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) { | |
|
84 | if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/)) { | |
|
85 | 85 | // User/Project@SHA |
|
86 | 86 | // User@SHA |
|
87 | 87 | // SHA |
@@ -113,10 +113,9 b' CodeMirror.defineMode("gfm", function(co' | |||
|
113 | 113 | }; |
|
114 | 114 | |
|
115 | 115 | var markdownConfig = { |
|
116 | underscoresBreakWords: false, | |
|
117 | 116 | taskLists: true, |
|
118 | fencedCodeBlocks: '```', | |
|
119 | strikethrough: true | |
|
117 | strikethrough: true, | |
|
118 | emoji: true | |
|
120 | 119 | }; |
|
121 | 120 | for (var attr in modeConfig) { |
|
122 | 121 | markdownConfig[attr] = modeConfig[attr]; |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /* |
|
5 | 5 | Gherkin mode - http://www.cukes.info/ |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -23,12 +23,13 b' CodeMirror.defineMode("go", function(con' | |||
|
23 | 23 | "bool":true, "byte":true, "complex64":true, "complex128":true, |
|
24 | 24 | "float32":true, "float64":true, "int8":true, "int16":true, "int32":true, |
|
25 | 25 | "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true, |
|
26 | "uint64":true, "int":true, "uint":true, "uintptr":true | |
|
26 | "uint64":true, "int":true, "uint":true, "uintptr":true, "error": true, | |
|
27 | "rune":true | |
|
27 | 28 | }; |
|
28 | 29 | |
|
29 | 30 | var atoms = { |
|
30 | 31 | "true":true, "false":true, "iota":true, "nil":true, "append":true, |
|
31 | "cap":true, "close":true, "complex":true, "copy":true, "imag":true, | |
|
32 | "cap":true, "close":true, "complex":true, "copy":true, "delete":true, "imag":true, | |
|
32 | 33 | "len":true, "make":true, "new":true, "panic":true, "print":true, |
|
33 | 34 | "println":true, "real":true, "recover":true |
|
34 | 35 | }; |
@@ -154,14 +155,14 b' CodeMirror.defineMode("go", function(con' | |||
|
154 | 155 | else if (curPunc == "[") pushContext(state, stream.column(), "]"); |
|
155 | 156 | else if (curPunc == "(") pushContext(state, stream.column(), ")"); |
|
156 | 157 | else if (curPunc == "case") ctx.type = "case"; |
|
157 |
else if (curPunc == "}" && ctx.type == "}") |
|
|
158 | else if (curPunc == "}" && ctx.type == "}") popContext(state); | |
|
158 | 159 | else if (curPunc == ctx.type) popContext(state); |
|
159 | 160 | state.startOfLine = false; |
|
160 | 161 | return style; |
|
161 | 162 | }, |
|
162 | 163 | |
|
163 | 164 | indent: function(state, textAfter) { |
|
164 |
if (state.tokenize != tokenBase && state.tokenize != null) return |
|
|
165 | if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; | |
|
165 | 166 | var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); |
|
166 | 167 | if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) { |
|
167 | 168 | state.context.type = "}"; |
@@ -173,6 +174,7 b' CodeMirror.defineMode("go", function(con' | |||
|
173 | 174 | }, |
|
174 | 175 | |
|
175 | 176 | electricChars: "{}):", |
|
177 | closeBrackets: "()[]{}''\"\"``", | |
|
176 | 178 | fold: "brace", |
|
177 | 179 | blockCommentStart: "/*", |
|
178 | 180 | blockCommentEnd: "*/", |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -21,9 +21,9 b' CodeMirror.defineMode("groovy", function' | |||
|
21 | 21 | "abstract as assert boolean break byte case catch char class const continue def default " + |
|
22 | 22 | "do double else enum extends final finally float for goto if implements import in " + |
|
23 | 23 | "instanceof int interface long native new package private protected public return " + |
|
24 | "short static strictfp super switch synchronized threadsafe throw throws transient " + | |
|
24 | "short static strictfp super switch synchronized threadsafe throw throws trait transient " + | |
|
25 | 25 | "try void volatile while"); |
|
26 |
var blockKeywords = words("catch class do else finally for if switch try while |
|
|
26 | var blockKeywords = words("catch class def do else enum finally for if interface switch trait try while"); | |
|
27 | 27 | var standaloneKeywords = words("return break continue"); |
|
28 | 28 | var atoms = words("null true false this"); |
|
29 | 29 | |
@@ -210,7 +210,7 b' CodeMirror.defineMode("groovy", function' | |||
|
210 | 210 | }, |
|
211 | 211 | |
|
212 | 212 | indent: function(state, textAfter) { |
|
213 |
if (!state.tokenize[state.tokenize.length-1].isBase) return |
|
|
213 | if (!state.tokenize[state.tokenize.length-1].isBase) return CodeMirror.Pass; | |
|
214 | 214 | var firstChar = textAfter && textAfter.charAt(0), ctx = state.context; |
|
215 | 215 | if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) ctx = ctx.prev; |
|
216 | 216 | var closing = firstChar == ctx.type; |
@@ -221,7 +221,10 b' CodeMirror.defineMode("groovy", function' | |||
|
221 | 221 | |
|
222 | 222 | electricChars: "{}", |
|
223 | 223 | closeBrackets: {triples: "'\""}, |
|
224 | fold: "brace" | |
|
224 | fold: "brace", | |
|
225 | blockCommentStart: "/*", | |
|
226 | blockCommentEnd: "*/", | |
|
227 | lineComment: "//" | |
|
225 | 228 | }; |
|
226 | 229 | }); |
|
227 | 230 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -11,7 +11,7 b'' | |||
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | // full haml mode. This handled embeded ruby and html fragments too | |
|
14 | // full haml mode. This handled embedded ruby and html fragments too | |
|
15 | 15 | CodeMirror.defineMode("haml", function(config) { |
|
16 | 16 | var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"}); |
|
17 | 17 | var rubyMode = CodeMirror.getMode(config, "ruby"); |
@@ -98,8 +98,8 b'' | |||
|
98 | 98 | return { |
|
99 | 99 | // default to html mode |
|
100 | 100 | startState: function() { |
|
101 |
var htmlState = |
|
|
102 |
var rubyState = |
|
|
101 | var htmlState = CodeMirror.startState(htmlMode); | |
|
102 | var rubyState = CodeMirror.startState(rubyMode); | |
|
103 | 103 | return { |
|
104 | 104 | htmlState: htmlState, |
|
105 | 105 | rubyState: rubyState, |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -13,10 +13,14 b'' | |||
|
13 | 13 | |
|
14 | 14 | CodeMirror.defineSimpleMode("handlebars-tags", { |
|
15 | 15 | start: [ |
|
16 | { regex: /\{\{\{/, push: "handlebars_raw", token: "tag" }, | |
|
16 | 17 | { regex: /\{\{!--/, push: "dash_comment", token: "comment" }, |
|
17 | 18 | { regex: /\{\{!/, push: "comment", token: "comment" }, |
|
18 | 19 | { regex: /\{\{/, push: "handlebars", token: "tag" } |
|
19 | 20 | ], |
|
21 | handlebars_raw: [ | |
|
22 | { regex: /\}\}\}/, pop: true, token: "tag" }, | |
|
23 | ], | |
|
20 | 24 | handlebars: [ |
|
21 | 25 | { regex: /\}\}/, pop: true, token: "tag" }, |
|
22 | 26 | |
@@ -46,7 +50,11 b'' | |||
|
46 | 50 | comment: [ |
|
47 | 51 | { regex: /\}\}/, pop: true, token: "comment" }, |
|
48 | 52 | { regex: /./, token: "comment" } |
|
49 | ] | |
|
53 | ], | |
|
54 | meta: { | |
|
55 | blockCommentStart: "{{--", | |
|
56 | blockCommentEnd: "--}}" | |
|
57 | } | |
|
50 | 58 | }); |
|
51 | 59 | |
|
52 | 60 | CodeMirror.defineMode("handlebars", function(config, parserConfig) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function (mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -40,4 +40,4 b'' | |||
|
40 | 40 | }, "haskell") |
|
41 | 41 | |
|
42 | 42 | CodeMirror.defineMIME("text/x-literate-haskell", "haskell-literate") |
|
43 | }) | |
|
43 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -56,7 +56,7 b' CodeMirror.defineMode("haskell", functio' | |||
|
56 | 56 | if (source.eat('\'')) { |
|
57 | 57 | return "string"; |
|
58 | 58 | } |
|
59 | return "error"; | |
|
59 | return "string error"; | |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | if (ch == '"') { |
@@ -166,7 +166,7 b' CodeMirror.defineMode("haskell", functio' | |||
|
166 | 166 | } |
|
167 | 167 | } |
|
168 | 168 | setState(normal); |
|
169 | return "error"; | |
|
169 | return "string error"; | |
|
170 | 170 | } |
|
171 | 171 | |
|
172 | 172 | function stringGap(source, setState) { |
@@ -194,16 +194,17 b' CodeMirror.defineMode("haskell", functio' | |||
|
194 | 194 | "module", "newtype", "of", "then", "type", "where", "_"); |
|
195 | 195 | |
|
196 | 196 | setType("keyword")( |
|
197 |
"\.\.", ":", "::", "=", "\\" |
|
|
197 | "\.\.", ":", "::", "=", "\\", "<-", "->", "@", "~", "=>"); | |
|
198 | 198 | |
|
199 | 199 | setType("builtin")( |
|
200 |
"!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", |
|
|
201 |
"==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", |
|
|
200 | "!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<*", "<=", | |
|
201 | "<$>", "<*>", "=<<", "==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", | |
|
202 | "*>", "**"); | |
|
202 | 203 | |
|
203 | 204 | setType("builtin")( |
|
204 |
"Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", |
|
|
205 |
"False", "FilePath", "Float", "Floating", "Fractional", "Functor", |
|
|
206 | "IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left", | |
|
205 | "Applicative", "Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", | |
|
206 | "Eq", "False", "FilePath", "Float", "Floating", "Fractional", "Functor", | |
|
207 | "GT", "IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left", | |
|
207 | 208 | "Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read", |
|
208 | 209 | "ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS", |
|
209 | 210 | "String", "True"); |
@@ -223,7 +224,7 b' CodeMirror.defineMode("haskell", functio' | |||
|
223 | 224 | "lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map", |
|
224 | 225 | "mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound", |
|
225 | 226 | "minimum", "mod", "negate", "not", "notElem", "null", "odd", "or", |
|
226 | "otherwise", "pi", "pred", "print", "product", "properFraction", | |
|
227 | "otherwise", "pi", "pred", "print", "product", "properFraction", "pure", | |
|
227 | 228 | "putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile", |
|
228 | 229 | "readIO", "readList", "readLn", "readParen", "reads", "readsPrec", |
|
229 | 230 | "realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse", |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -485,7 +485,7 b' CodeMirror.defineMode("hxml", function (' | |||
|
485 | 485 | |
|
486 | 486 | if (state.inString == false && ch == "'") { |
|
487 | 487 | state.inString = true; |
|
488 |
|
|
|
488 | stream.next(); | |
|
489 | 489 | } |
|
490 | 490 | |
|
491 | 491 | if (state.inString == true) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -14,7 +14,16 b'' | |||
|
14 | 14 | "use strict"; |
|
15 | 15 | |
|
16 | 16 | CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { |
|
17 | var closeComment = parserConfig.closeComment || "--%>" | |
|
17 | 18 | return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), { |
|
19 | open: parserConfig.openComment || "<%--", | |
|
20 | close: closeComment, | |
|
21 | delimStyle: "comment", | |
|
22 | mode: {token: function(stream) { | |
|
23 | stream.skipTo(closeComment) || stream.skipToEnd() | |
|
24 | return "comment" | |
|
25 | }} | |
|
26 | }, { | |
|
18 | 27 | open: parserConfig.open || parserConfig.scriptStartRegex || "<%", |
|
19 | 28 | close: parserConfig.close || parserConfig.scriptEndRegex || "%>", |
|
20 | 29 | mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec) |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -14,7 +14,7 b'' | |||
|
14 | 14 | var defaultTags = { |
|
15 | 15 | script: [ |
|
16 | 16 | ["lang", /(javascript|babel)/i, "javascript"], |
|
17 | ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, "javascript"], | |
|
17 | ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"], | |
|
18 | 18 | ["type", /./, "text/plain"], |
|
19 | 19 | [null, null, "javascript"] |
|
20 | 20 | ], |
@@ -44,13 +44,9 b'' | |||
|
44 | 44 | return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"); |
|
45 | 45 | } |
|
46 | 46 | |
|
47 |
function getAttrValue( |
|
|
48 | var pos = stream.pos, match; | |
|
49 | while (pos >= 0 && stream.string.charAt(pos) !== "<") pos--; | |
|
50 | if (pos < 0) return pos; | |
|
51 | if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr))) | |
|
52 | return match[2]; | |
|
53 | return ""; | |
|
47 | function getAttrValue(text, attr) { | |
|
48 | var match = text.match(getAttrRegexp(attr)) | |
|
49 | return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "" | |
|
54 | 50 | } |
|
55 | 51 | |
|
56 | 52 | function getTagRegexp(tagName, anchored) { |
@@ -66,10 +62,10 b'' | |||
|
66 | 62 | } |
|
67 | 63 | } |
|
68 | 64 | |
|
69 |
function findMatchingMode(tagInfo, |
|
|
65 | function findMatchingMode(tagInfo, tagText) { | |
|
70 | 66 | for (var i = 0; i < tagInfo.length; i++) { |
|
71 | 67 | var spec = tagInfo[i]; |
|
72 |
if (!spec[0] || spec[1].test(getAttrValue( |
|
|
68 | if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2]; | |
|
73 | 69 | } |
|
74 | 70 | } |
|
75 | 71 | |
@@ -89,15 +85,17 b'' | |||
|
89 | 85 | tags.script.unshift(["type", configScript[i].matches, configScript[i].mode]) |
|
90 | 86 | |
|
91 | 87 | function html(stream, state) { |
|
92 | var tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase(); | |
|
93 | var tagInfo = tagName && tags.hasOwnProperty(tagName) && tags[tagName]; | |
|
94 | ||
|
95 | var style = htmlMode.token(stream, state.htmlState), modeSpec; | |
|
96 | ||
|
97 | if (tagInfo && /\btag\b/.test(style) && stream.current() === ">" && | |
|
98 | (modeSpec = findMatchingMode(tagInfo, stream))) { | |
|
99 | var mode = CodeMirror.getMode(config, modeSpec); | |
|
100 | var endTagA = getTagRegexp(tagName, true), endTag = getTagRegexp(tagName, false); | |
|
88 | var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName | |
|
89 | if (tag && !/[<>\s\/]/.test(stream.current()) && | |
|
90 | (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) && | |
|
91 | tags.hasOwnProperty(tagName)) { | |
|
92 | state.inTag = tagName + " " | |
|
93 | } else if (state.inTag && tag && />$/.test(stream.current())) { | |
|
94 | var inTag = /^([\S]+) (.*)/.exec(state.inTag) | |
|
95 | state.inTag = null | |
|
96 | var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2]) | |
|
97 | var mode = CodeMirror.getMode(config, modeSpec) | |
|
98 | var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false); | |
|
101 | 99 | state.token = function (stream, state) { |
|
102 | 100 | if (stream.match(endTagA, false)) { |
|
103 | 101 | state.token = html; |
@@ -107,15 +105,18 b'' | |||
|
107 | 105 | return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState)); |
|
108 | 106 | }; |
|
109 | 107 | state.localMode = mode; |
|
110 | state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "")); | |
|
108 | state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", "")); | |
|
109 | } else if (state.inTag) { | |
|
110 | state.inTag += stream.current() | |
|
111 | if (stream.eol()) state.inTag += " " | |
|
111 | 112 | } |
|
112 | 113 | return style; |
|
113 | 114 | }; |
|
114 | 115 | |
|
115 | 116 | return { |
|
116 | 117 | startState: function () { |
|
117 |
var state = |
|
|
118 | return {token: html, localMode: null, localState: null, htmlState: state}; | |
|
118 | var state = CodeMirror.startState(htmlMode); | |
|
119 | return {token: html, inTag: null, localMode: null, localState: null, htmlState: state}; | |
|
119 | 120 | }, |
|
120 | 121 | |
|
121 | 122 | copyState: function (state) { |
@@ -123,7 +124,8 b'' | |||
|
123 | 124 | if (state.localState) { |
|
124 | 125 | local = CodeMirror.copyState(state.localMode, state.localState); |
|
125 | 126 | } |
|
126 |
return {token: state.token, |
|
|
127 | return {token: state.token, inTag: state.inTag, | |
|
128 | localMode: state.localMode, localState: local, | |
|
127 | 129 | htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; |
|
128 | 130 | }, |
|
129 | 131 | |
@@ -131,11 +133,11 b'' | |||
|
131 | 133 | return state.token(stream, state); |
|
132 | 134 | }, |
|
133 | 135 | |
|
134 | indent: function (state, textAfter) { | |
|
136 | indent: function (state, textAfter, line) { | |
|
135 | 137 | if (!state.localMode || /^\s*<\//.test(textAfter)) |
|
136 | return htmlMode.indent(state.htmlState, textAfter); | |
|
138 | return htmlMode.indent(state.htmlState, textAfter, line); | |
|
137 | 139 | else if (state.localMode.indent) |
|
138 | return state.localMode.indent(state.localState, textAfter); | |
|
140 | return state.localMode.indent(state.localState, textAfter, line); | |
|
139 | 141 | else |
|
140 | 142 | return CodeMirror.Pass; |
|
141 | 143 | }, |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
This diff has been collapsed as it changes many lines, (526 lines changed) Show them Hide them | |||
@@ -1,7 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
3 | ||
|
4 | // TODO actually recognize syntax of TypeScript constructs | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
5 | 3 | |
|
6 | 4 | (function(mod) { |
|
7 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -13,11 +11,6 b'' | |||
|
13 | 11 | })(function(CodeMirror) { |
|
14 | 12 | "use strict"; |
|
15 | 13 | |
|
16 | function expressionAllowed(stream, state, backUp) { | |
|
17 | return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) || | |
|
18 | (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) | |
|
19 | } | |
|
20 | ||
|
21 | 14 | CodeMirror.defineMode("javascript", function(config, parserConfig) { |
|
22 | 15 | var indentUnit = config.indentUnit; |
|
23 | 16 | var statementIndent = parserConfig.statementIndent; |
@@ -30,54 +23,24 b' CodeMirror.defineMode("javascript", func' | |||
|
30 | 23 | |
|
31 | 24 | var keywords = function(){ |
|
32 | 25 | function kw(type) {return {type: type, style: "keyword"};} |
|
33 | var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); | |
|
26 | var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d"); | |
|
34 | 27 | var operator = kw("operator"), atom = {type: "atom", style: "atom"}; |
|
35 | 28 | |
|
36 | var jsKeywords = { | |
|
29 | return { | |
|
37 | 30 | "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, |
|
38 |
"return": |
|
|
39 | "var": kw("var"), "const": kw("var"), "let": kw("var"), | |
|
31 | "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C, | |
|
32 | "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"), | |
|
40 | 33 | "function": kw("function"), "catch": kw("catch"), |
|
41 | 34 | "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), |
|
42 | 35 | "in": operator, "typeof": operator, "instanceof": operator, |
|
43 | 36 | "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom, |
|
44 | 37 | "this": kw("this"), "class": kw("class"), "super": kw("atom"), |
|
45 | "yield": C, "export": kw("export"), "import": kw("import"), "extends": C | |
|
38 | "yield": C, "export": kw("export"), "import": kw("import"), "extends": C, | |
|
39 | "await": C | |
|
46 | 40 | }; |
|
47 | ||
|
48 | // Extend the 'normal' keywords with the TypeScript language extensions | |
|
49 | if (isTS) { | |
|
50 | var type = {type: "variable", style: "variable-3"}; | |
|
51 | var tsKeywords = { | |
|
52 | // object-like things | |
|
53 | "interface": kw("class"), | |
|
54 | "implements": C, | |
|
55 | "namespace": C, | |
|
56 | "module": kw("module"), | |
|
57 | "enum": kw("module"), | |
|
58 | ||
|
59 | // scope modifiers | |
|
60 | "public": kw("modifier"), | |
|
61 | "private": kw("modifier"), | |
|
62 | "protected": kw("modifier"), | |
|
63 | "abstract": kw("modifier"), | |
|
64 | ||
|
65 | // operators | |
|
66 | "as": operator, | |
|
67 | ||
|
68 | // types | |
|
69 | "string": type, "number": type, "boolean": type, "any": type | |
|
70 | }; | |
|
71 | ||
|
72 | for (var attr in tsKeywords) { | |
|
73 | jsKeywords[attr] = tsKeywords[attr]; | |
|
74 | } | |
|
75 | } | |
|
76 | ||
|
77 | return jsKeywords; | |
|
78 | 41 | }(); |
|
79 | 42 | |
|
80 | var isOperatorChar = /[+\-*&%=<>!?|~^]/; | |
|
43 | var isOperatorChar = /[+\-*&%=<>!?|~^@]/; | |
|
81 | 44 | var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/; |
|
82 | 45 | |
|
83 | 46 | function readRegexp(stream) { |
@@ -104,7 +67,7 b' CodeMirror.defineMode("javascript", func' | |||
|
104 | 67 | if (ch == '"' || ch == "'") { |
|
105 | 68 | state.tokenize = tokenString(ch); |
|
106 | 69 | return state.tokenize(stream, state); |
|
107 |
} else if (ch == "." && stream.match(/^\d |
|
|
70 | } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) { | |
|
108 | 71 | return ret("number", "number"); |
|
109 | 72 | } else if (ch == "." && stream.match("..")) { |
|
110 | 73 | return ret("spread", "meta"); |
@@ -112,17 +75,10 b' CodeMirror.defineMode("javascript", func' | |||
|
112 | 75 | return ret(ch); |
|
113 | 76 | } else if (ch == "=" && stream.eat(">")) { |
|
114 | 77 | return ret("=>", "operator"); |
|
115 |
} else if (ch == "0" && stream. |
|
|
116 | stream.eatWhile(/[\da-f]/i); | |
|
117 | return ret("number", "number"); | |
|
118 | } else if (ch == "0" && stream.eat(/o/i)) { | |
|
119 | stream.eatWhile(/[0-7]/i); | |
|
120 | return ret("number", "number"); | |
|
121 | } else if (ch == "0" && stream.eat(/b/i)) { | |
|
122 | stream.eatWhile(/[01]/i); | |
|
78 | } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) { | |
|
123 | 79 | return ret("number", "number"); |
|
124 | 80 | } else if (/\d/.test(ch)) { |
|
125 | stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); | |
|
81 | stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/); | |
|
126 | 82 | return ret("number", "number"); |
|
127 | 83 | } else if (ch == "/") { |
|
128 | 84 | if (stream.eat("*")) { |
@@ -133,10 +89,10 b' CodeMirror.defineMode("javascript", func' | |||
|
133 | 89 | return ret("comment", "comment"); |
|
134 | 90 | } else if (expressionAllowed(stream, state, 1)) { |
|
135 | 91 | readRegexp(stream); |
|
136 | stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/); | |
|
92 | stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/); | |
|
137 | 93 | return ret("regexp", "string-2"); |
|
138 | 94 | } else { |
|
139 |
stream.eat |
|
|
95 | stream.eat("="); | |
|
140 | 96 | return ret("operator", "operator", stream.current()); |
|
141 | 97 | } |
|
142 | 98 | } else if (ch == "`") { |
@@ -145,14 +101,31 b' CodeMirror.defineMode("javascript", func' | |||
|
145 | 101 | } else if (ch == "#") { |
|
146 | 102 | stream.skipToEnd(); |
|
147 | 103 | return ret("error", "error"); |
|
104 | } else if (ch == "<" && stream.match("!--") || ch == "-" && stream.match("->")) { | |
|
105 | stream.skipToEnd() | |
|
106 | return ret("comment", "comment") | |
|
148 | 107 | } else if (isOperatorChar.test(ch)) { |
|
149 | stream.eatWhile(isOperatorChar); | |
|
108 | if (ch != ">" || !state.lexical || state.lexical.type != ">") { | |
|
109 | if (stream.eat("=")) { | |
|
110 | if (ch == "!" || ch == "=") stream.eat("=") | |
|
111 | } else if (/[<>*+\-]/.test(ch)) { | |
|
112 | stream.eat(ch) | |
|
113 | if (ch == ">") stream.eat(ch) | |
|
114 | } | |
|
115 | } | |
|
150 | 116 | return ret("operator", "operator", stream.current()); |
|
151 | 117 | } else if (wordRE.test(ch)) { |
|
152 | 118 | stream.eatWhile(wordRE); |
|
153 | var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; | |
|
154 | return (known && state.lastType != ".") ? ret(known.type, known.style, word) : | |
|
155 | ret("variable", "variable", word); | |
|
119 | var word = stream.current() | |
|
120 | if (state.lastType != ".") { | |
|
121 | if (keywords.propertyIsEnumerable(word)) { | |
|
122 | var kw = keywords[word] | |
|
123 | return ret(kw.type, kw.style, word) | |
|
124 | } | |
|
125 | if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false)) | |
|
126 | return ret("async", "keyword", word) | |
|
127 | } | |
|
128 | return ret("variable", "variable", word) | |
|
156 | 129 | } |
|
157 | 130 | } |
|
158 | 131 | |
@@ -209,19 +182,28 b' CodeMirror.defineMode("javascript", func' | |||
|
209 | 182 | var arrow = stream.string.indexOf("=>", stream.start); |
|
210 | 183 | if (arrow < 0) return; |
|
211 | 184 | |
|
185 | if (isTS) { // Try to skip TypeScript return type declarations after the arguments | |
|
186 | var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow)) | |
|
187 | if (m) arrow = m.index | |
|
188 | } | |
|
189 | ||
|
212 | 190 | var depth = 0, sawSomething = false; |
|
213 | 191 | for (var pos = arrow - 1; pos >= 0; --pos) { |
|
214 | 192 | var ch = stream.string.charAt(pos); |
|
215 | 193 | var bracket = brackets.indexOf(ch); |
|
216 | 194 | if (bracket >= 0 && bracket < 3) { |
|
217 | 195 | if (!depth) { ++pos; break; } |
|
218 | if (--depth == 0) break; | |
|
196 | if (--depth == 0) { if (ch == "(") sawSomething = true; break; } | |
|
219 | 197 | } else if (bracket >= 3 && bracket < 6) { |
|
220 | 198 | ++depth; |
|
221 | 199 | } else if (wordRE.test(ch)) { |
|
222 | 200 | sawSomething = true; |
|
223 | } else if (/["'\/]/.test(ch)) { | |
|
224 | return; | |
|
201 | } else if (/["'\/`]/.test(ch)) { | |
|
202 | for (;; --pos) { | |
|
203 | if (pos == 0) return | |
|
204 | var next = stream.string.charAt(pos - 1) | |
|
205 | if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break } | |
|
206 | } | |
|
225 | 207 | } else if (sawSomething && !depth) { |
|
226 | 208 | ++pos; |
|
227 | 209 | break; |
@@ -283,35 +265,68 b' CodeMirror.defineMode("javascript", func' | |||
|
283 | 265 | pass.apply(null, arguments); |
|
284 | 266 | return true; |
|
285 | 267 | } |
|
268 | function inList(name, list) { | |
|
269 | for (var v = list; v; v = v.next) if (v.name == name) return true | |
|
270 | return false; | |
|
271 | } | |
|
286 | 272 | function register(varname) { |
|
287 | function inList(list) { | |
|
288 | for (var v = list; v; v = v.next) | |
|
289 | if (v.name == varname) return true; | |
|
290 | return false; | |
|
291 | } | |
|
292 | 273 | var state = cx.state; |
|
293 | 274 | cx.marked = "def"; |
|
294 | 275 | if (state.context) { |
|
295 | if (inList(state.localVars)) return; | |
|
296 | state.localVars = {name: varname, next: state.localVars}; | |
|
276 | if (state.lexical.info == "var" && state.context && state.context.block) { | |
|
277 | // FIXME function decls are also not block scoped | |
|
278 | var newContext = registerVarScoped(varname, state.context) | |
|
279 | if (newContext != null) { | |
|
280 | state.context = newContext | |
|
281 | return | |
|
282 | } | |
|
283 | } else if (!inList(varname, state.localVars)) { | |
|
284 | state.localVars = new Var(varname, state.localVars) | |
|
285 | return | |
|
286 | } | |
|
287 | } | |
|
288 | // Fall through means this is global | |
|
289 | if (parserConfig.globalVars && !inList(varname, state.globalVars)) | |
|
290 | state.globalVars = new Var(varname, state.globalVars) | |
|
291 | } | |
|
292 | function registerVarScoped(varname, context) { | |
|
293 | if (!context) { | |
|
294 | return null | |
|
295 | } else if (context.block) { | |
|
296 | var inner = registerVarScoped(varname, context.prev) | |
|
297 | if (!inner) return null | |
|
298 | if (inner == context.prev) return context | |
|
299 | return new Context(inner, context.vars, true) | |
|
300 | } else if (inList(varname, context.vars)) { | |
|
301 | return context | |
|
297 | 302 | } else { |
|
298 | if (inList(state.globalVars)) return; | |
|
299 | if (parserConfig.globalVars) | |
|
300 | state.globalVars = {name: varname, next: state.globalVars}; | |
|
303 | return new Context(context.prev, new Var(varname, context.vars), false) | |
|
301 | 304 | } |
|
302 | 305 | } |
|
303 | 306 | |
|
307 | function isModifier(name) { | |
|
308 | return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly" | |
|
309 | } | |
|
310 | ||
|
304 | 311 | // Combinators |
|
305 | 312 | |
|
306 | var defaultVars = {name: "this", next: {name: "arguments"}}; | |
|
313 | function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block } | |
|
314 | function Var(name, next) { this.name = name; this.next = next } | |
|
315 | ||
|
316 | var defaultVars = new Var("this", new Var("arguments", null)) | |
|
307 | 317 | function pushcontext() { |
|
308 |
cx.state.context = |
|
|
309 |
cx.state.localVars = defaultVars |
|
|
318 | cx.state.context = new Context(cx.state.context, cx.state.localVars, false) | |
|
319 | cx.state.localVars = defaultVars | |
|
320 | } | |
|
321 | function pushblockcontext() { | |
|
322 | cx.state.context = new Context(cx.state.context, cx.state.localVars, true) | |
|
323 | cx.state.localVars = null | |
|
310 | 324 | } |
|
311 | 325 | function popcontext() { |
|
312 |
cx.state.localVars = cx.state.context.vars |
|
|
313 |
cx.state.context = cx.state.context.prev |
|
|
326 | cx.state.localVars = cx.state.context.vars | |
|
327 | cx.state.context = cx.state.context.prev | |
|
314 | 328 | } |
|
329 | popcontext.lex = true | |
|
315 | 330 | function pushlex(type, info) { |
|
316 | 331 | var result = function() { |
|
317 | 332 | var state = cx.state, indent = state.indented; |
@@ -336,71 +351,99 b' CodeMirror.defineMode("javascript", func' | |||
|
336 | 351 | function expect(wanted) { |
|
337 | 352 | function exp(type) { |
|
338 | 353 | if (type == wanted) return cont(); |
|
339 | else if (wanted == ";") return pass(); | |
|
354 | else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass(); | |
|
340 | 355 | else return cont(exp); |
|
341 | 356 | }; |
|
342 | 357 | return exp; |
|
343 | 358 | } |
|
344 | 359 | |
|
345 | 360 | function statement(type, value) { |
|
346 |
if (type == "var") return cont(pushlex("vardef", value |
|
|
347 |
if (type == "keyword a") return cont(pushlex("form"), expr |
|
|
361 | if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex); | |
|
362 | if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex); | |
|
348 | 363 | if (type == "keyword b") return cont(pushlex("form"), statement, poplex); |
|
349 | if (type == "{") return cont(pushlex("}"), block, poplex); | |
|
364 | if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex); | |
|
365 | if (type == "debugger") return cont(expect(";")); | |
|
366 | if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext); | |
|
350 | 367 | if (type == ";") return cont(); |
|
351 | 368 | if (type == "if") { |
|
352 | 369 | if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) |
|
353 | 370 | cx.state.cc.pop()(); |
|
354 |
return cont(pushlex("form"), expr |
|
|
371 | return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse); | |
|
355 | 372 | } |
|
356 | 373 | if (type == "function") return cont(functiondef); |
|
357 | 374 | if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); |
|
358 | if (type == "variable") return cont(pushlex("stat"), maybelabel); | |
|
359 | if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), | |
|
360 | block, poplex, poplex); | |
|
375 | if (type == "class" || (isTS && value == "interface")) { | |
|
376 | cx.marked = "keyword" | |
|
377 | return cont(pushlex("form", type == "class" ? type : value), className, poplex) | |
|
378 | } | |
|
379 | if (type == "variable") { | |
|
380 | if (isTS && value == "declare") { | |
|
381 | cx.marked = "keyword" | |
|
382 | return cont(statement) | |
|
383 | } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) { | |
|
384 | cx.marked = "keyword" | |
|
385 | if (value == "enum") return cont(enumdef); | |
|
386 | else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";")); | |
|
387 | else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) | |
|
388 | } else if (isTS && value == "namespace") { | |
|
389 | cx.marked = "keyword" | |
|
390 | return cont(pushlex("form"), expression, statement, poplex) | |
|
391 | } else if (isTS && value == "abstract") { | |
|
392 | cx.marked = "keyword" | |
|
393 | return cont(statement) | |
|
394 | } else { | |
|
395 | return cont(pushlex("stat"), maybelabel); | |
|
396 | } | |
|
397 | } | |
|
398 | if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext, | |
|
399 | block, poplex, poplex, popcontext); | |
|
361 | 400 | if (type == "case") return cont(expression, expect(":")); |
|
362 | 401 | if (type == "default") return cont(expect(":")); |
|
363 |
if (type == "catch") return cont(pushlex("form"), pushcontext, |
|
|
364 | statement, poplex, popcontext); | |
|
365 | if (type == "class") return cont(pushlex("form"), className, poplex); | |
|
402 | if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext); | |
|
366 | 403 | if (type == "export") return cont(pushlex("stat"), afterExport, poplex); |
|
367 | 404 | if (type == "import") return cont(pushlex("stat"), afterImport, poplex); |
|
368 | if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex) | |
|
405 | if (type == "async") return cont(statement) | |
|
406 | if (value == "@") return cont(expression, statement) | |
|
369 | 407 | return pass(pushlex("stat"), expression, expect(";"), poplex); |
|
370 | 408 | } |
|
371 |
function |
|
|
372 | return expressionInner(type, false); | |
|
409 | function maybeCatchBinding(type) { | |
|
410 | if (type == "(") return cont(funarg, expect(")")) | |
|
411 | } | |
|
412 | function expression(type, value) { | |
|
413 | return expressionInner(type, value, false); | |
|
373 | 414 | } |
|
374 | function expressionNoComma(type) { | |
|
375 | return expressionInner(type, true); | |
|
415 | function expressionNoComma(type, value) { | |
|
416 | return expressionInner(type, value, true); | |
|
376 | 417 | } |
|
377 |
function |
|
|
418 | function parenExpr(type) { | |
|
419 | if (type != "(") return pass() | |
|
420 | return cont(pushlex(")"), expression, expect(")"), poplex) | |
|
421 | } | |
|
422 | function expressionInner(type, value, noComma) { | |
|
378 | 423 | if (cx.state.fatArrowAt == cx.stream.start) { |
|
379 | 424 | var body = noComma ? arrowBodyNoComma : arrowBody; |
|
380 |
if (type == "(") return cont(pushcontext, pushlex(")"), commasep( |
|
|
425 | if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext); | |
|
381 | 426 | else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext); |
|
382 | 427 | } |
|
383 | 428 | |
|
384 | 429 | var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; |
|
385 | 430 | if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); |
|
386 | 431 | if (type == "function") return cont(functiondef, maybeop); |
|
387 | if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression); | |
|
388 | if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop); | |
|
432 | if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); } | |
|
433 | if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression); | |
|
434 | if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop); | |
|
389 | 435 | if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); |
|
390 | 436 | if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop); |
|
391 | 437 | if (type == "{") return contCommasep(objprop, "}", null, maybeop); |
|
392 | 438 | if (type == "quasi") return pass(quasi, maybeop); |
|
393 | 439 | if (type == "new") return cont(maybeTarget(noComma)); |
|
440 | if (type == "import") return cont(expression); | |
|
394 | 441 | return cont(); |
|
395 | 442 | } |
|
396 | 443 | function maybeexpression(type) { |
|
397 | 444 | if (type.match(/[;\}\)\],]/)) return pass(); |
|
398 | 445 | return pass(expression); |
|
399 | 446 | } |
|
400 | function maybeexpressionNoComma(type) { | |
|
401 | if (type.match(/[;\}\)\],]/)) return pass(); | |
|
402 | return pass(expressionNoComma); | |
|
403 | } | |
|
404 | 447 | |
|
405 | 448 | function maybeoperatorComma(type, value) { |
|
406 | 449 | if (type == ",") return cont(expression); |
@@ -411,7 +454,9 b' CodeMirror.defineMode("javascript", func' | |||
|
411 | 454 | var expr = noComma == false ? expression : expressionNoComma; |
|
412 | 455 | if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); |
|
413 | 456 | if (type == "operator") { |
|
414 | if (/\+\+|--/.test(value)) return cont(me); | |
|
457 | if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me); | |
|
458 | if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false)) | |
|
459 | return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me); | |
|
415 | 460 | if (value == "?") return cont(expression, expect(":"), expr); |
|
416 | 461 | return cont(expr); |
|
417 | 462 | } |
@@ -420,6 +465,12 b' CodeMirror.defineMode("javascript", func' | |||
|
420 | 465 | if (type == "(") return contCommasep(expressionNoComma, ")", "call", me); |
|
421 | 466 | if (type == ".") return cont(property, me); |
|
422 | 467 | if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me); |
|
468 | if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) } | |
|
469 | if (type == "regexp") { | |
|
470 | cx.state.lastType = cx.marked = "operator" | |
|
471 | cx.stream.backUp(cx.stream.pos - cx.stream.start - 1) | |
|
472 | return cont(expr) | |
|
473 | } | |
|
423 | 474 | } |
|
424 | 475 | function quasi(type, value) { |
|
425 | 476 | if (type != "quasi") return pass(); |
@@ -444,6 +495,7 b' CodeMirror.defineMode("javascript", func' | |||
|
444 | 495 | function maybeTarget(noComma) { |
|
445 | 496 | return function(type) { |
|
446 | 497 | if (type == ".") return cont(noComma ? targetNoComma : target); |
|
498 | else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma) | |
|
447 | 499 | else return pass(noComma ? expressionNoComma : expression); |
|
448 | 500 | }; |
|
449 | 501 | } |
@@ -461,21 +513,33 b' CodeMirror.defineMode("javascript", func' | |||
|
461 | 513 | if (type == "variable") {cx.marked = "property"; return cont();} |
|
462 | 514 | } |
|
463 | 515 | function objprop(type, value) { |
|
464 | if (type == "variable" || cx.style == "keyword") { | |
|
516 | if (type == "async") { | |
|
517 | cx.marked = "property"; | |
|
518 | return cont(objprop); | |
|
519 | } else if (type == "variable" || cx.style == "keyword") { | |
|
465 | 520 | cx.marked = "property"; |
|
466 | 521 | if (value == "get" || value == "set") return cont(getterSetter); |
|
522 | var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params | |
|
523 | if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false))) | |
|
524 | cx.state.fatArrowAt = cx.stream.pos + m[0].length | |
|
467 | 525 | return cont(afterprop); |
|
468 | 526 | } else if (type == "number" || type == "string") { |
|
469 | 527 | cx.marked = jsonldMode ? "property" : (cx.style + " property"); |
|
470 | 528 | return cont(afterprop); |
|
471 | 529 | } else if (type == "jsonld-keyword") { |
|
472 | 530 | return cont(afterprop); |
|
473 |
} else if ( |
|
|
531 | } else if (isTS && isModifier(value)) { | |
|
532 | cx.marked = "keyword" | |
|
474 | 533 | return cont(objprop) |
|
475 | 534 | } else if (type == "[") { |
|
476 | return cont(expression, expect("]"), afterprop); | |
|
535 | return cont(expression, maybetype, expect("]"), afterprop); | |
|
477 | 536 | } else if (type == "spread") { |
|
478 | return cont(expression); | |
|
537 | return cont(expressionNoComma, afterprop); | |
|
538 | } else if (value == "*") { | |
|
539 | cx.marked = "keyword"; | |
|
540 | return cont(objprop); | |
|
541 | } else if (type == ":") { | |
|
542 | return pass(afterprop) | |
|
479 | 543 | } |
|
480 | 544 | } |
|
481 | 545 | function getterSetter(type) { |
@@ -487,18 +551,22 b' CodeMirror.defineMode("javascript", func' | |||
|
487 | 551 | if (type == ":") return cont(expressionNoComma); |
|
488 | 552 | if (type == "(") return pass(functiondef); |
|
489 | 553 | } |
|
490 | function commasep(what, end) { | |
|
491 | function proceed(type) { | |
|
492 | if (type == ",") { | |
|
554 | function commasep(what, end, sep) { | |
|
555 | function proceed(type, value) { | |
|
556 | if (sep ? sep.indexOf(type) > -1 : type == ",") { | |
|
493 | 557 | var lex = cx.state.lexical; |
|
494 | 558 | if (lex.info == "call") lex.pos = (lex.pos || 0) + 1; |
|
495 |
return cont( |
|
|
559 | return cont(function(type, value) { | |
|
560 | if (type == end || value == end) return pass() | |
|
561 | return pass(what) | |
|
562 | }, proceed); | |
|
496 | 563 | } |
|
497 | if (type == end) return cont(); | |
|
564 | if (type == end || value == end) return cont(); | |
|
565 | if (sep && sep.indexOf(";") > -1) return pass(what) | |
|
498 | 566 | return cont(expect(end)); |
|
499 | 567 | } |
|
500 | return function(type) { | |
|
501 | if (type == end) return cont(); | |
|
568 | return function(type, value) { | |
|
569 | if (type == end || value == end) return cont(); | |
|
502 | 570 | return pass(what, proceed); |
|
503 | 571 | }; |
|
504 | 572 | } |
@@ -511,23 +579,91 b' CodeMirror.defineMode("javascript", func' | |||
|
511 | 579 | if (type == "}") return cont(); |
|
512 | 580 | return pass(statement, block); |
|
513 | 581 | } |
|
514 | function maybetype(type) { | |
|
515 | if (isTS && type == ":") return cont(typedef); | |
|
582 | function maybetype(type, value) { | |
|
583 | if (isTS) { | |
|
584 | if (type == ":") return cont(typeexpr); | |
|
585 | if (value == "?") return cont(maybetype); | |
|
586 | } | |
|
587 | } | |
|
588 | function maybetypeOrIn(type, value) { | |
|
589 | if (isTS && (type == ":" || value == "in")) return cont(typeexpr) | |
|
590 | } | |
|
591 | function mayberettype(type) { | |
|
592 | if (isTS && type == ":") { | |
|
593 | if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr) | |
|
594 | else return cont(typeexpr) | |
|
595 | } | |
|
596 | } | |
|
597 | function isKW(_, value) { | |
|
598 | if (value == "is") { | |
|
599 | cx.marked = "keyword" | |
|
600 | return cont() | |
|
601 | } | |
|
602 | } | |
|
603 | function typeexpr(type, value) { | |
|
604 | if (value == "keyof" || value == "typeof" || value == "infer") { | |
|
605 | cx.marked = "keyword" | |
|
606 | return cont(value == "typeof" ? expressionNoComma : typeexpr) | |
|
607 | } | |
|
608 | if (type == "variable" || value == "void") { | |
|
609 | cx.marked = "type" | |
|
610 | return cont(afterType) | |
|
611 | } | |
|
612 | if (value == "|" || value == "&") return cont(typeexpr) | |
|
613 | if (type == "string" || type == "number" || type == "atom") return cont(afterType); | |
|
614 | if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) | |
|
615 | if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType) | |
|
616 | if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) | |
|
617 | if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) | |
|
516 | 618 | } |
|
517 |
function maybe |
|
|
518 |
if ( |
|
|
619 | function maybeReturnType(type) { | |
|
620 | if (type == "=>") return cont(typeexpr) | |
|
621 | } | |
|
622 | function typeprop(type, value) { | |
|
623 | if (type == "variable" || cx.style == "keyword") { | |
|
624 | cx.marked = "property" | |
|
625 | return cont(typeprop) | |
|
626 | } else if (value == "?" || type == "number" || type == "string") { | |
|
627 | return cont(typeprop) | |
|
628 | } else if (type == ":") { | |
|
629 | return cont(typeexpr) | |
|
630 | } else if (type == "[") { | |
|
631 | return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) | |
|
632 | } else if (type == "(") { | |
|
633 | return pass(functiondecl, typeprop) | |
|
634 | } | |
|
519 | 635 | } |
|
520 |
function type |
|
|
521 |
if (type == "variable") |
|
|
636 | function typearg(type, value) { | |
|
637 | if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg) | |
|
638 | if (type == ":") return cont(typeexpr) | |
|
639 | if (type == "spread") return cont(typearg) | |
|
640 | return pass(typeexpr) | |
|
522 | 641 | } |
|
523 |
function |
|
|
642 | function afterType(type, value) { | |
|
643 | if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) | |
|
644 | if (value == "|" || type == "." || value == "&") return cont(typeexpr) | |
|
645 | if (type == "[") return cont(typeexpr, expect("]"), afterType) | |
|
646 | if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) } | |
|
647 | if (value == "?") return cont(typeexpr, expect(":"), typeexpr) | |
|
648 | } | |
|
649 | function maybeTypeArgs(_, value) { | |
|
650 | if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) | |
|
651 | } | |
|
652 | function typeparam() { | |
|
653 | return pass(typeexpr, maybeTypeDefault) | |
|
654 | } | |
|
655 | function maybeTypeDefault(_, value) { | |
|
656 | if (value == "=") return cont(typeexpr) | |
|
657 | } | |
|
658 | function vardef(_, value) { | |
|
659 | if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)} | |
|
524 | 660 | return pass(pattern, maybetype, maybeAssign, vardefCont); |
|
525 | 661 | } |
|
526 | 662 | function pattern(type, value) { |
|
527 |
if ( |
|
|
663 | if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) } | |
|
528 | 664 | if (type == "variable") { register(value); return cont(); } |
|
529 | 665 | if (type == "spread") return cont(pattern); |
|
530 | if (type == "[") return contCommasep(pattern, "]"); | |
|
666 | if (type == "[") return contCommasep(eltpattern, "]"); | |
|
531 | 667 | if (type == "{") return contCommasep(proppattern, "}"); |
|
532 | 668 | } |
|
533 | 669 | function proppattern(type, value) { |
@@ -538,8 +674,12 b' CodeMirror.defineMode("javascript", func' | |||
|
538 | 674 | if (type == "variable") cx.marked = "property"; |
|
539 | 675 | if (type == "spread") return cont(pattern); |
|
540 | 676 | if (type == "}") return pass(); |
|
677 | if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern); | |
|
541 | 678 | return cont(expect(":"), pattern, maybeAssign); |
|
542 | 679 | } |
|
680 | function eltpattern() { | |
|
681 | return pass(pattern, maybeAssign) | |
|
682 | } | |
|
543 | 683 | function maybeAssign(_type, value) { |
|
544 | 684 | if (value == "=") return cont(expressionNoComma); |
|
545 | 685 | } |
@@ -549,73 +689,109 b' CodeMirror.defineMode("javascript", func' | |||
|
549 | 689 | function maybeelse(type, value) { |
|
550 | 690 | if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex); |
|
551 | 691 | } |
|
552 | function forspec(type) { | |
|
553 |
if ( |
|
|
692 | function forspec(type, value) { | |
|
693 | if (value == "await") return cont(forspec); | |
|
694 | if (type == "(") return cont(pushlex(")"), forspec1, poplex); | |
|
554 | 695 | } |
|
555 | 696 | function forspec1(type) { |
|
556 |
if (type == "var") return cont(vardef, |
|
|
557 |
if (type == " |
|
|
558 | if (type == "variable") return cont(formaybeinof); | |
|
559 | return pass(expression, expect(";"), forspec2); | |
|
560 | } | |
|
561 | function formaybeinof(_type, value) { | |
|
562 | if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); } | |
|
563 | return cont(maybeoperatorComma, forspec2); | |
|
697 | if (type == "var") return cont(vardef, forspec2); | |
|
698 | if (type == "variable") return cont(forspec2); | |
|
699 | return pass(forspec2) | |
|
564 | 700 | } |
|
565 | 701 | function forspec2(type, value) { |
|
566 |
if (type == " |
|
|
567 | if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); } | |
|
568 | return pass(expression, expect(";"), forspec3); | |
|
569 | } | |
|
570 | function forspec3(type) { | |
|
571 | if (type != ")") cont(expression); | |
|
702 | if (type == ")") return cont() | |
|
703 | if (type == ";") return cont(forspec2) | |
|
704 | if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) } | |
|
705 | return pass(expression, forspec2) | |
|
572 | 706 | } |
|
573 | 707 | function functiondef(type, value) { |
|
574 | 708 | if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} |
|
575 | 709 | if (type == "variable") {register(value); return cont(functiondef);} |
|
576 | if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext); | |
|
710 | if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext); | |
|
711 | if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef) | |
|
712 | } | |
|
713 | function functiondecl(type, value) { | |
|
714 | if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);} | |
|
715 | if (type == "variable") {register(value); return cont(functiondecl);} | |
|
716 | if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext); | |
|
717 | if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl) | |
|
577 | 718 | } |
|
578 |
function |
|
|
719 | function typename(type, value) { | |
|
720 | if (type == "keyword" || type == "variable") { | |
|
721 | cx.marked = "type" | |
|
722 | return cont(typename) | |
|
723 | } else if (value == "<") { | |
|
724 | return cont(pushlex(">"), commasep(typeparam, ">"), poplex) | |
|
725 | } | |
|
726 | } | |
|
727 | function funarg(type, value) { | |
|
728 | if (value == "@") cont(expression, funarg) | |
|
579 | 729 | if (type == "spread") return cont(funarg); |
|
580 | return pass(pattern, maybetype, maybedefault); | |
|
730 | if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); } | |
|
731 | if (isTS && type == "this") return cont(maybetype, maybeAssign) | |
|
732 | return pass(pattern, maybetype, maybeAssign); | |
|
733 | } | |
|
734 | function classExpression(type, value) { | |
|
735 | // Class expressions may have an optional name. | |
|
736 | if (type == "variable") return className(type, value); | |
|
737 | return classNameAfter(type, value); | |
|
581 | 738 | } |
|
582 | 739 | function className(type, value) { |
|
583 | 740 | if (type == "variable") {register(value); return cont(classNameAfter);} |
|
584 | 741 | } |
|
585 | 742 | function classNameAfter(type, value) { |
|
586 |
if (value == " |
|
|
743 | if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter) | |
|
744 | if (value == "extends" || value == "implements" || (isTS && type == ",")) { | |
|
745 | if (value == "implements") cx.marked = "keyword"; | |
|
746 | return cont(isTS ? typeexpr : expression, classNameAfter); | |
|
747 | } | |
|
587 | 748 | if (type == "{") return cont(pushlex("}"), classBody, poplex); |
|
588 | 749 | } |
|
589 | 750 | function classBody(type, value) { |
|
751 | if (type == "async" || | |
|
752 | (type == "variable" && | |
|
753 | (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) && | |
|
754 | cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) { | |
|
755 | cx.marked = "keyword"; | |
|
756 | return cont(classBody); | |
|
757 | } | |
|
590 | 758 | if (type == "variable" || cx.style == "keyword") { |
|
591 | if (value == "static") { | |
|
592 | cx.marked = "keyword"; | |
|
593 | return cont(classBody); | |
|
594 | } | |
|
595 | 759 | cx.marked = "property"; |
|
596 |
|
|
|
597 | return cont(functiondef, classBody); | |
|
760 | return cont(isTS ? classfield : functiondef, classBody); | |
|
598 | 761 | } |
|
762 | if (type == "number" || type == "string") return cont(isTS ? classfield : functiondef, classBody); | |
|
763 | if (type == "[") | |
|
764 | return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody) | |
|
599 | 765 | if (value == "*") { |
|
600 | 766 | cx.marked = "keyword"; |
|
601 | 767 | return cont(classBody); |
|
602 | 768 | } |
|
603 |
if (type == " |
|
|
769 | if (isTS && type == "(") return pass(functiondecl, classBody) | |
|
770 | if (type == ";" || type == ",") return cont(classBody); | |
|
604 | 771 | if (type == "}") return cont(); |
|
772 | if (value == "@") return cont(expression, classBody) | |
|
605 | 773 | } |
|
606 |
function class |
|
|
607 |
if ( |
|
|
608 | cx.marked = "property"; | |
|
609 | return cont(); | |
|
774 | function classfield(type, value) { | |
|
775 | if (value == "?") return cont(classfield) | |
|
776 | if (type == ":") return cont(typeexpr, maybeAssign) | |
|
777 | if (value == "=") return cont(expressionNoComma) | |
|
778 | var context = cx.state.lexical.prev, isInterface = context && context.info == "interface" | |
|
779 | return pass(isInterface ? functiondecl : functiondef) | |
|
610 | 780 | } |
|
611 |
function afterExport( |
|
|
781 | function afterExport(type, value) { | |
|
612 | 782 | if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } |
|
613 | 783 | if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); } |
|
784 | if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";")); | |
|
614 | 785 | return pass(statement); |
|
615 | 786 | } |
|
787 | function exportField(type, value) { | |
|
788 | if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); } | |
|
789 | if (type == "variable") return pass(expressionNoComma, exportField); | |
|
790 | } | |
|
616 | 791 | function afterImport(type) { |
|
617 | 792 | if (type == "string") return cont(); |
|
618 | return pass(importSpec, maybeFrom); | |
|
793 | if (type == "(") return pass(expression); | |
|
794 | return pass(importSpec, maybeMoreImports, maybeFrom); | |
|
619 | 795 | } |
|
620 | 796 | function importSpec(type, value) { |
|
621 | 797 | if (type == "{") return contCommasep(importSpec, "}"); |
@@ -623,6 +799,9 b' CodeMirror.defineMode("javascript", func' | |||
|
623 | 799 | if (value == "*") cx.marked = "keyword"; |
|
624 | 800 | return cont(maybeAs); |
|
625 | 801 | } |
|
802 | function maybeMoreImports(type) { | |
|
803 | if (type == ",") return cont(importSpec, maybeMoreImports) | |
|
804 | } | |
|
626 | 805 | function maybeAs(_type, value) { |
|
627 | 806 | if (value == "as") { cx.marked = "keyword"; return cont(importSpec); } |
|
628 | 807 | } |
@@ -631,16 +810,13 b' CodeMirror.defineMode("javascript", func' | |||
|
631 | 810 | } |
|
632 | 811 | function arrayLiteral(type) { |
|
633 | 812 | if (type == "]") return cont(); |
|
634 | return pass(expressionNoComma, maybeArrayComprehension); | |
|
635 | } | |
|
636 | function maybeArrayComprehension(type) { | |
|
637 | if (type == "for") return pass(comprehension, expect("]")); | |
|
638 | if (type == ",") return cont(commasep(maybeexpressionNoComma, "]")); | |
|
639 | 813 | return pass(commasep(expressionNoComma, "]")); |
|
640 | 814 | } |
|
641 |
function |
|
|
642 | if (type == "for") return cont(forspec, comprehension); | |
|
643 | if (type == "if") return cont(expression, comprehension); | |
|
815 | function enumdef() { | |
|
816 | return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex) | |
|
817 | } | |
|
818 | function enummember() { | |
|
819 | return pass(pattern, maybeAssign); | |
|
644 | 820 | } |
|
645 | 821 | |
|
646 | 822 | function isContinuedStatement(state, textAfter) { |
@@ -649,6 +825,12 b' CodeMirror.defineMode("javascript", func' | |||
|
649 | 825 | /[,.]/.test(textAfter.charAt(0)); |
|
650 | 826 | } |
|
651 | 827 | |
|
828 | function expressionAllowed(stream, state, backUp) { | |
|
829 | return state.tokenize == tokenBase && | |
|
830 | /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) || | |
|
831 | (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) | |
|
832 | } | |
|
833 | ||
|
652 | 834 | // Interface |
|
653 | 835 | |
|
654 | 836 | return { |
@@ -659,7 +841,7 b' CodeMirror.defineMode("javascript", func' | |||
|
659 | 841 | cc: [], |
|
660 | 842 | lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), |
|
661 | 843 | localVars: parserConfig.localVars, |
|
662 |
context: parserConfig.localVars && |
|
|
844 | context: parserConfig.localVars && new Context(null, null, false), | |
|
663 | 845 | indented: basecolumn || 0 |
|
664 | 846 | }; |
|
665 | 847 | if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") |
@@ -684,19 +866,23 b' CodeMirror.defineMode("javascript", func' | |||
|
684 | 866 | indent: function(state, textAfter) { |
|
685 | 867 | if (state.tokenize == tokenComment) return CodeMirror.Pass; |
|
686 | 868 | if (state.tokenize != tokenBase) return 0; |
|
687 |
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical |
|
|
869 | var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top | |
|
688 | 870 | // Kludge to prevent 'maybelse' from blocking lexical scope pops |
|
689 | 871 | if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { |
|
690 | 872 | var c = state.cc[i]; |
|
691 | 873 | if (c == poplex) lexical = lexical.prev; |
|
692 | 874 | else if (c != maybeelse) break; |
|
693 | 875 | } |
|
694 |
|
|
|
876 | while ((lexical.type == "stat" || lexical.type == "form") && | |
|
877 | (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) && | |
|
878 | (top == maybeoperatorComma || top == maybeoperatorNoComma) && | |
|
879 | !/^[,\.=+\-*:?[\(]/.test(textAfter)))) | |
|
880 | lexical = lexical.prev; | |
|
695 | 881 | if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat") |
|
696 | 882 | lexical = lexical.prev; |
|
697 | 883 | var type = lexical.type, closing = firstChar == type; |
|
698 | 884 | |
|
699 | if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0); | |
|
885 | if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0); | |
|
700 | 886 | else if (type == "form" && firstChar == "{") return lexical.indented; |
|
701 | 887 | else if (type == "form") return lexical.indented + indentUnit; |
|
702 | 888 | else if (type == "stat") |
@@ -710,6 +896,7 b' CodeMirror.defineMode("javascript", func' | |||
|
710 | 896 | electricInput: /^\s*(?:case .*?:|default:|\{|\})$/, |
|
711 | 897 | blockCommentStart: jsonMode ? null : "/*", |
|
712 | 898 | blockCommentEnd: jsonMode ? null : "*/", |
|
899 | blockCommentContinue: jsonMode ? null : " * ", | |
|
713 | 900 | lineComment: jsonMode ? null : "//", |
|
714 | 901 | fold: "brace", |
|
715 | 902 | closeBrackets: "()[]{}''\"\"``", |
@@ -719,6 +906,7 b' CodeMirror.defineMode("javascript", func' | |||
|
719 | 906 | jsonMode: jsonMode, |
|
720 | 907 | |
|
721 | 908 | expressionAllowed: expressionAllowed, |
|
909 | ||
|
722 | 910 | skipExpression: function(state) { |
|
723 | 911 | var top = state.cc[state.cc.length - 1] |
|
724 | 912 | if (top == expression || top == expressionNoComma) state.cc.pop() |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -107,7 +107,7 b'' | |||
|
107 | 107 | } |
|
108 | 108 | return "variable"; |
|
109 | 109 | } else if (stream.eat("{")) { |
|
110 |
if ( |
|
|
110 | if (stream.eat("#")) { | |
|
111 | 111 | state.incomment = true; |
|
112 | 112 | if(!stream.skipTo("#}")) { |
|
113 | 113 | stream.skipToEnd(); |
@@ -136,7 +136,11 b'' | |||
|
136 | 136 | }, |
|
137 | 137 | token: function (stream, state) { |
|
138 | 138 | return state.tokenize(stream, state); |
|
139 | } | |
|
139 | }, | |
|
140 | blockCommentStart: "{#", | |
|
141 | blockCommentEnd: "#}" | |
|
140 | 142 | }; |
|
141 | 143 | }); |
|
144 | ||
|
145 | CodeMirror.defineMIME("text/jinja2", "jinja2"); | |
|
142 | 146 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -25,14 +25,14 b'' | |||
|
25 | 25 | context.prev && copyContext(context.prev)) |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | CodeMirror.defineMode("jsx", function(config) { | |
|
29 | var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false}) | |
|
30 | var jsMode = CodeMirror.getMode(config, "javascript") | |
|
28 | CodeMirror.defineMode("jsx", function(config, modeConfig) { | |
|
29 | var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false, allowMissingTagName: true}) | |
|
30 | var jsMode = CodeMirror.getMode(config, modeConfig && modeConfig.base || "javascript") | |
|
31 | 31 | |
|
32 | 32 | function flatXMLIndent(state) { |
|
33 | 33 | var tagName = state.tagName |
|
34 | 34 | state.tagName = null |
|
35 | var result = xmlMode.indent(state, "") | |
|
35 | var result = xmlMode.indent(state, "", "") | |
|
36 | 36 | state.tagName = tagName |
|
37 | 37 | return result |
|
38 | 38 | } |
@@ -105,7 +105,7 b'' | |||
|
105 | 105 | function jsToken(stream, state, cx) { |
|
106 | 106 | if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) { |
|
107 | 107 | jsMode.skipExpression(cx.state) |
|
108 | state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), | |
|
108 | state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")), | |
|
109 | 109 | xmlMode, 0, state.context) |
|
110 | 110 | return null |
|
111 | 111 | } |
@@ -144,4 +144,5 b'' | |||
|
144 | 144 | }, "xml", "javascript") |
|
145 | 145 | |
|
146 | 146 | CodeMirror.defineMIME("text/jsx", "jsx") |
|
147 | }) | |
|
147 | CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}}) | |
|
148 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -11,61 +11,78 b'' | |||
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 |
CodeMirror.defineMode("julia", function( |
|
|
15 | var ERRORCLASS = 'error'; | |
|
16 | ||
|
17 | function wordRegexp(words) { | |
|
18 | return new RegExp("^((" + words.join(")|(") + "))\\b"); | |
|
14 | CodeMirror.defineMode("julia", function(config, parserConf) { | |
|
15 | function wordRegexp(words, end) { | |
|
16 | if (typeof end === "undefined") { end = "\\b"; } | |
|
17 | return new RegExp("^((" + words.join(")|(") + "))" + end); | |
|
19 | 18 | } |
|
20 | 19 | |
|
21 | var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b(?!\()|[\u2208\u2209](?!\()/; | |
|
20 | var octChar = "\\\\[0-7]{1,3}"; | |
|
21 | var hexChar = "\\\\x[A-Fa-f0-9]{1,2}"; | |
|
22 | var sChar = "\\\\[abefnrtv0%?'\"\\\\]"; | |
|
23 | var uChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])"; | |
|
24 | ||
|
25 | var operators = parserConf.operators || wordRegexp([ | |
|
26 | "[<>]:", "[<>=]=", "<<=?", ">>>?=?", "=>", "->", "\\/\\/", | |
|
27 | "[\\\\%*+\\-<>!=\\/^|&\\u00F7\\u22BB]=?", "\\?", "\\$", "~", ":", | |
|
28 | "\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2218", | |
|
29 | "\\u221A", "\\u221B", "\\u2229", "\\u222A", "\\u2260", "\\u2264", | |
|
30 | "\\u2265", "\\u2286", "\\u2288", "\\u228A", "\\u22C5", | |
|
31 | "\\b(in|isa)\\b(?!\.?\\()"], ""); | |
|
22 | 32 | var delimiters = parserConf.delimiters || /^[;,()[\]{}]/; |
|
23 |
var identifiers = parserConf.identifiers || |
|
|
24 | var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"]; | |
|
25 | var blockClosers = ["end", "else", "elseif", "catch", "finally"]; | |
|
26 | var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype']; | |
|
27 | var builtinList = ['true', 'false', 'nothing', 'NaN', 'Inf']; | |
|
33 | var identifiers = parserConf.identifiers || | |
|
34 | /^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/; | |
|
35 | ||
|
36 | var chars = wordRegexp([octChar, hexChar, sChar, uChar], "'"); | |
|
37 | ||
|
38 | var openersList = ["begin", "function", "type", "struct", "immutable", "let", | |
|
39 | "macro", "for", "while", "quote", "if", "else", "elseif", "try", | |
|
40 | "finally", "catch", "do"]; | |
|
28 | 41 | |
|
29 | //var stringPrefixes = new RegExp("^[br]?('|\")") | |
|
30 | var stringPrefixes = /^(`|'|"{3}|([brv]?"))/; | |
|
31 | var keywords = wordRegexp(keywordList); | |
|
32 | var builtins = wordRegexp(builtinList); | |
|
33 | var openers = wordRegexp(blockOpeners); | |
|
34 | var closers = wordRegexp(blockClosers); | |
|
35 | var macro = /^@[_A-Za-z][_A-Za-z0-9]*/; | |
|
36 | var symbol = /^:[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*!*/; | |
|
37 | var typeAnnotation = /^::[^.,;"{()=$\s]+({[^}]*}+)*/; | |
|
42 | var closersList = ["end", "else", "elseif", "catch", "finally"]; | |
|
43 | ||
|
44 | var keywordsList = ["if", "else", "elseif", "while", "for", "begin", "let", | |
|
45 | "end", "do", "try", "catch", "finally", "return", "break", "continue", | |
|
46 | "global", "local", "const", "export", "import", "importall", "using", | |
|
47 | "function", "where", "macro", "module", "baremodule", "struct", "type", | |
|
48 | "mutable", "immutable", "quote", "typealias", "abstract", "primitive", | |
|
49 | "bitstype"]; | |
|
50 | ||
|
51 | var builtinsList = ["true", "false", "nothing", "NaN", "Inf"]; | |
|
52 | ||
|
53 | CodeMirror.registerHelper("hintWords", "julia", keywordsList.concat(builtinsList)); | |
|
54 | ||
|
55 | var openers = wordRegexp(openersList); | |
|
56 | var closers = wordRegexp(closersList); | |
|
57 | var keywords = wordRegexp(keywordsList); | |
|
58 | var builtins = wordRegexp(builtinsList); | |
|
59 | ||
|
60 | var macro = /^@[_A-Za-z][\w]*/; | |
|
61 | var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/; | |
|
62 | var stringPrefixes = /^(`|([_A-Za-z\u00A1-\uFFFF]*"("")?))/; | |
|
38 | 63 | |
|
39 | 64 | function inArray(state) { |
|
40 | var ch = currentScope(state); | |
|
41 | if (ch == '[') { | |
|
42 | return true; | |
|
43 | } | |
|
44 | return false; | |
|
65 | return (state.nestedArrays > 0); | |
|
66 | } | |
|
67 | ||
|
68 | function inGenerator(state) { | |
|
69 | return (state.nestedGenerators > 0); | |
|
45 | 70 | } |
|
46 | 71 | |
|
47 | function currentScope(state) { | |
|
48 | if (state.scopes.length == 0) { | |
|
72 | function currentScope(state, n) { | |
|
73 | if (typeof(n) === "undefined") { n = 0; } | |
|
74 | if (state.scopes.length <= n) { | |
|
49 | 75 | return null; |
|
50 | 76 | } |
|
51 | return state.scopes[state.scopes.length - 1]; | |
|
77 | return state.scopes[state.scopes.length - (n + 1)]; | |
|
52 | 78 | } |
|
53 | 79 | |
|
54 | 80 | // tokenizers |
|
55 | 81 | function tokenBase(stream, state) { |
|
56 | //Handle multiline comments | |
|
57 |
if (stream.match(/^#= |
|
|
58 | state.scopes.push('#='); | |
|
59 | } | |
|
60 | if (currentScope(state) == '#=' && stream.match(/^=#/)) { | |
|
61 | state.scopes.pop(); | |
|
62 | return 'comment'; | |
|
63 | } | |
|
64 | if (state.scopes.indexOf('#=') >= 0) { | |
|
65 | if (!stream.match(/.*?(?=(#=|=#))/)) { | |
|
66 | stream.skipToEnd(); | |
|
67 | } | |
|
68 | return 'comment'; | |
|
82 | // Handle multiline comments | |
|
83 | if (stream.match(/^#=/, false)) { | |
|
84 | state.tokenize = tokenComment; | |
|
85 | return state.tokenize(stream, state); | |
|
69 | 86 | } |
|
70 | 87 | |
|
71 | 88 | // Handle scope changes |
@@ -74,14 +91,17 b' CodeMirror.defineMode("julia", function(' | |||
|
74 | 91 | leavingExpr = false; |
|
75 | 92 | } |
|
76 | 93 | state.leavingExpr = false; |
|
94 | ||
|
77 | 95 | if (leavingExpr) { |
|
78 | 96 | if (stream.match(/^'+/)) { |
|
79 |
return |
|
|
97 | return "operator"; | |
|
80 | 98 | } |
|
81 | 99 | } |
|
82 | 100 | |
|
83 |
if (stream.match(/ |
|
|
84 |
return |
|
|
101 | if (stream.match(/\.{4,}/)) { | |
|
102 | return "error"; | |
|
103 | } else if (stream.match(/\.{1,3}/)) { | |
|
104 | return "operator"; | |
|
85 | 105 | } |
|
86 | 106 | |
|
87 | 107 | if (stream.eatSpace()) { |
@@ -93,105 +113,101 b' CodeMirror.defineMode("julia", function(' | |||
|
93 | 113 | // Handle single line comments |
|
94 | 114 | if (ch === '#') { |
|
95 | 115 | stream.skipToEnd(); |
|
96 |
return |
|
|
116 | return "comment"; | |
|
97 | 117 | } |
|
98 | 118 | |
|
99 | 119 | if (ch === '[') { |
|
100 | 120 | state.scopes.push('['); |
|
121 | state.nestedArrays++; | |
|
101 | 122 | } |
|
102 | 123 | |
|
103 | var scope = currentScope(state); | |
|
124 | if (ch === '(') { | |
|
125 | state.scopes.push('('); | |
|
126 | state.nestedGenerators++; | |
|
127 | } | |
|
104 | 128 | |
|
105 |
if ( |
|
|
129 | if (inArray(state) && ch === ']') { | |
|
130 | if (currentScope(state) === "if") { state.scopes.pop(); } | |
|
131 | while (currentScope(state) === "for") { state.scopes.pop(); } | |
|
106 | 132 | state.scopes.pop(); |
|
133 | state.nestedArrays--; | |
|
107 | 134 | state.leavingExpr = true; |
|
108 | 135 | } |
|
109 | 136 | |
|
110 |
if ( |
|
|
137 | if (inGenerator(state) && ch === ')') { | |
|
138 | if (currentScope(state) === "if") { state.scopes.pop(); } | |
|
139 | while (currentScope(state) === "for") { state.scopes.pop(); } | |
|
111 | 140 | state.scopes.pop(); |
|
141 | state.nestedGenerators--; | |
|
112 | 142 | state.leavingExpr = true; |
|
113 | 143 | } |
|
114 | 144 | |
|
145 | if (inArray(state)) { | |
|
146 | if (state.lastToken == "end" && stream.match(/^:/)) { | |
|
147 | return "operator"; | |
|
148 | } | |
|
149 | if (stream.match(/^end/)) { | |
|
150 | return "number"; | |
|
151 | } | |
|
152 | } | |
|
153 | ||
|
115 | 154 | var match; |
|
116 |
if ( |
|
|
117 | state.scopes.push(match); | |
|
155 | if (match = stream.match(openers, false)) { | |
|
156 | state.scopes.push(match[0]); | |
|
118 | 157 | } |
|
119 | 158 | |
|
120 |
if ( |
|
|
159 | if (stream.match(closers, false)) { | |
|
121 | 160 | state.scopes.pop(); |
|
122 | 161 | } |
|
123 | 162 | |
|
124 | if (inArray(state)) { | |
|
125 | if (state.lastToken == 'end' && stream.match(/^:/)) { | |
|
126 | return 'operator'; | |
|
127 | } | |
|
128 | if (stream.match(/^end/)) { | |
|
129 | return 'number'; | |
|
130 | } | |
|
163 | // Handle type annotations | |
|
164 | if (stream.match(/^::(?![:\$])/)) { | |
|
165 | state.tokenize = tokenAnnotation; | |
|
166 | return state.tokenize(stream, state); | |
|
131 | 167 | } |
|
132 | 168 | |
|
133 | if (stream.match(/^=>/)) { | |
|
134 | return 'operator'; | |
|
169 | // Handle symbols | |
|
170 | if (!leavingExpr && stream.match(symbol) || | |
|
171 | stream.match(/:([<>]:|<<=?|>>>?=?|->|\/\/|\.{2,3}|[\.\\%*+\-<>!\/^|&]=?|[~\?\$])/)) { | |
|
172 | return "builtin"; | |
|
173 | } | |
|
174 | ||
|
175 | // Handle parametric types | |
|
176 | //if (stream.match(/^{[^}]*}(?=\()/)) { | |
|
177 | // return "builtin"; | |
|
178 | //} | |
|
179 | ||
|
180 | // Handle operators and Delimiters | |
|
181 | if (stream.match(operators)) { | |
|
182 | return "operator"; | |
|
135 | 183 | } |
|
136 | 184 | |
|
137 | 185 | // Handle Number Literals |
|
138 |
if (stream.match(/^ |
|
|
186 | if (stream.match(/^\.?\d/, false)) { | |
|
139 | 187 | var imMatcher = RegExp(/^im\b/); |
|
140 |
var |
|
|
188 | var numberLiteral = false; | |
|
141 | 189 | // Floats |
|
142 |
if (stream.match(/^\d*\.(?!\.) |
|
|
143 |
if (stream.match(/^ |
|
|
144 | if (stream.match(/^\.\d+/)) { floatLiteral = true; } | |
|
145 | if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { floatLiteral = true; } | |
|
146 | if (floatLiteral) { | |
|
147 | // Float literals may be "imaginary" | |
|
148 | stream.match(imMatcher); | |
|
149 | state.leavingExpr = true; | |
|
150 | return 'number'; | |
|
151 | } | |
|
190 | if (stream.match(/^(?:(?:\d[_\d]*)?\.(?!\.)(?:\d[_\d]*)?|\d[_\d]*\.(?!\.)(?:\d[_\d]*))?([Eef][\+\-]?[_\d]+)?/i)) { numberLiteral = true; } | |
|
191 | if (stream.match(/^0x\.[0-9a-f_]+p[\+\-]?[_\d]+/i)) { numberLiteral = true; } | |
|
152 | 192 | // Integers |
|
153 | var intLiteral = false; | |
|
154 | // Hex | |
|
155 |
if (stream.match(/^0 |
|
|
156 | // Binary | |
|
157 | if (stream.match(/^0b[01]+/i)) { intLiteral = true; } | |
|
158 | // Octal | |
|
159 | if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; } | |
|
160 | // Decimal | |
|
161 | if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { | |
|
162 | intLiteral = true; | |
|
163 | } | |
|
193 | if (stream.match(/^0x[0-9a-f_]+/i)) { numberLiteral = true; } // Hex | |
|
194 | if (stream.match(/^0b[01_]+/i)) { numberLiteral = true; } // Binary | |
|
195 | if (stream.match(/^0o[0-7_]+/i)) { numberLiteral = true; } // Octal | |
|
196 | if (stream.match(/^[1-9][_\d]*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal | |
|
164 | 197 | // Zero by itself with no other piece of number. |
|
165 |
if (stream.match(/^0(?![\dx])/i)) { |
|
|
166 |
if ( |
|
|
198 | if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; } | |
|
199 | if (numberLiteral) { | |
|
167 | 200 | // Integer literals may be "long" |
|
168 | 201 | stream.match(imMatcher); |
|
169 | 202 | state.leavingExpr = true; |
|
170 |
return |
|
|
203 | return "number"; | |
|
171 | 204 | } |
|
172 | 205 | } |
|
173 | 206 | |
|
174 | if (stream.match(/^<:/)) { | |
|
175 | return 'operator'; | |
|
176 | } | |
|
177 | ||
|
178 | if (stream.match(typeAnnotation)) { | |
|
179 | return 'builtin'; | |
|
180 | } | |
|
181 | ||
|
182 | // Handle symbols | |
|
183 | if (!leavingExpr && stream.match(symbol) || stream.match(/:\./)) { | |
|
184 | return 'builtin'; | |
|
185 | } | |
|
186 | ||
|
187 | // Handle parametric types | |
|
188 | if (stream.match(/^{[^}]*}(?=\()/)) { | |
|
189 | return 'builtin'; | |
|
190 | } | |
|
191 | ||
|
192 | // Handle operators and Delimiters | |
|
193 | if (stream.match(operators)) { | |
|
194 | return 'operator'; | |
|
207 | // Handle Chars | |
|
208 | if (stream.match(/^'/)) { | |
|
209 | state.tokenize = tokenChar; | |
|
210 | return state.tokenize(stream, state); | |
|
195 | 211 | } |
|
196 | 212 | |
|
197 | 213 | // Handle Strings |
@@ -201,7 +217,7 b' CodeMirror.defineMode("julia", function(' | |||
|
201 | 217 | } |
|
202 | 218 | |
|
203 | 219 | if (stream.match(macro)) { |
|
204 |
return |
|
|
220 | return "meta"; | |
|
205 | 221 | } |
|
206 | 222 | |
|
207 | 223 | if (stream.match(delimiters)) { |
@@ -209,41 +225,40 b' CodeMirror.defineMode("julia", function(' | |||
|
209 | 225 | } |
|
210 | 226 | |
|
211 | 227 | if (stream.match(keywords)) { |
|
212 |
return |
|
|
228 | return "keyword"; | |
|
213 | 229 | } |
|
214 | 230 | |
|
215 | 231 | if (stream.match(builtins)) { |
|
216 |
return |
|
|
232 | return "builtin"; | |
|
217 | 233 | } |
|
218 | 234 | |
|
219 | var isDefinition = state.isDefinition || | |
|
220 |
state.lastToken == |
|
|
221 |
state.lastToken == |
|
|
222 | state.lastToken == 'type' || | |
|
223 | state.lastToken == 'immutable'; | |
|
235 | var isDefinition = state.isDefinition || state.lastToken == "function" || | |
|
236 | state.lastToken == "macro" || state.lastToken == "type" || | |
|
237 | state.lastToken == "struct" || state.lastToken == "immutable"; | |
|
224 | 238 | |
|
225 | 239 | if (stream.match(identifiers)) { |
|
226 | 240 | if (isDefinition) { |
|
227 | 241 | if (stream.peek() === '.') { |
|
228 | 242 | state.isDefinition = true; |
|
229 |
return |
|
|
243 | return "variable"; | |
|
230 | 244 | } |
|
231 | 245 | state.isDefinition = false; |
|
232 |
return |
|
|
246 | return "def"; | |
|
233 | 247 | } |
|
234 | 248 | if (stream.match(/^({[^}]*})*\(/, false)) { |
|
235 | return callOrDef(stream, state); | |
|
249 | state.tokenize = tokenCallOrDef; | |
|
250 | return state.tokenize(stream, state); | |
|
236 | 251 | } |
|
237 | 252 | state.leavingExpr = true; |
|
238 |
return |
|
|
253 | return "variable"; | |
|
239 | 254 | } |
|
240 | 255 | |
|
241 | 256 | // Handle non-detected items |
|
242 | 257 | stream.next(); |
|
243 | return ERRORCLASS; | |
|
258 | return "error"; | |
|
244 | 259 | } |
|
245 | 260 | |
|
246 |
function |
|
|
261 | function tokenCallOrDef(stream, state) { | |
|
247 | 262 | var match = stream.match(/^(\(\s*)/); |
|
248 | 263 | if (match) { |
|
249 | 264 | if (state.firstParenPos < 0) |
@@ -255,13 +270,14 b' CodeMirror.defineMode("julia", function(' | |||
|
255 | 270 | state.scopes.pop(); |
|
256 | 271 | state.charsAdvanced += 1; |
|
257 | 272 | if (state.scopes.length <= state.firstParenPos) { |
|
258 | var isDefinition = stream.match(/^\s*?=(?!=)/, false); | |
|
273 | var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false); | |
|
259 | 274 | stream.backUp(state.charsAdvanced); |
|
260 | 275 | state.firstParenPos = -1; |
|
261 | 276 | state.charsAdvanced = 0; |
|
277 | state.tokenize = tokenBase; | |
|
262 | 278 | if (isDefinition) |
|
263 |
return |
|
|
264 |
return |
|
|
279 | return "def"; | |
|
280 | return "builtin"; | |
|
265 | 281 | } |
|
266 | 282 | } |
|
267 | 283 | // Unfortunately javascript does not support multiline strings, so we have |
@@ -269,48 +285,93 b' CodeMirror.defineMode("julia", function(' | |||
|
269 | 285 | // over two or more lines. |
|
270 | 286 | if (stream.match(/^$/g, false)) { |
|
271 | 287 | stream.backUp(state.charsAdvanced); |
|
272 |
while (state.scopes.length > state.firstParenPos |
|
|
288 | while (state.scopes.length > state.firstParenPos) | |
|
273 | 289 | state.scopes.pop(); |
|
274 | 290 | state.firstParenPos = -1; |
|
275 | 291 | state.charsAdvanced = 0; |
|
276 | return 'builtin'; | |
|
292 | state.tokenize = tokenBase; | |
|
293 | return "builtin"; | |
|
277 | 294 | } |
|
278 | 295 | state.charsAdvanced += stream.match(/^([^()]*)/)[1].length; |
|
279 |
return |
|
|
296 | return state.tokenize(stream, state); | |
|
297 | } | |
|
298 | ||
|
299 | function tokenAnnotation(stream, state) { | |
|
300 | stream.match(/.*?(?=,|;|{|}|\(|\)|=|$|\s)/); | |
|
301 | if (stream.match(/^{/)) { | |
|
302 | state.nestedParameters++; | |
|
303 | } else if (stream.match(/^}/) && state.nestedParameters > 0) { | |
|
304 | state.nestedParameters--; | |
|
305 | } | |
|
306 | if (state.nestedParameters > 0) { | |
|
307 | stream.match(/.*?(?={|})/) || stream.next(); | |
|
308 | } else if (state.nestedParameters == 0) { | |
|
309 | state.tokenize = tokenBase; | |
|
310 | } | |
|
311 | return "builtin"; | |
|
312 | } | |
|
313 | ||
|
314 | function tokenComment(stream, state) { | |
|
315 | if (stream.match(/^#=/)) { | |
|
316 | state.nestedComments++; | |
|
317 | } | |
|
318 | if (!stream.match(/.*?(?=(#=|=#))/)) { | |
|
319 | stream.skipToEnd(); | |
|
320 | } | |
|
321 | if (stream.match(/^=#/)) { | |
|
322 | state.nestedComments--; | |
|
323 | if (state.nestedComments == 0) | |
|
324 | state.tokenize = tokenBase; | |
|
325 | } | |
|
326 | return "comment"; | |
|
327 | } | |
|
328 | ||
|
329 | function tokenChar(stream, state) { | |
|
330 | var isChar = false, match; | |
|
331 | if (stream.match(chars)) { | |
|
332 | isChar = true; | |
|
333 | } else if (match = stream.match(/\\u([a-f0-9]{1,4})(?=')/i)) { | |
|
334 | var value = parseInt(match[1], 16); | |
|
335 | if (value <= 55295 || value >= 57344) { // (U+0,U+D7FF), (U+E000,U+FFFF) | |
|
336 | isChar = true; | |
|
337 | stream.next(); | |
|
338 | } | |
|
339 | } else if (match = stream.match(/\\U([A-Fa-f0-9]{5,8})(?=')/)) { | |
|
340 | var value = parseInt(match[1], 16); | |
|
341 | if (value <= 1114111) { // U+10FFFF | |
|
342 | isChar = true; | |
|
343 | stream.next(); | |
|
344 | } | |
|
345 | } | |
|
346 | if (isChar) { | |
|
347 | state.leavingExpr = true; | |
|
348 | state.tokenize = tokenBase; | |
|
349 | return "string"; | |
|
350 | } | |
|
351 | if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); } | |
|
352 | if (stream.match(/^'/)) { state.tokenize = tokenBase; } | |
|
353 | return "error"; | |
|
280 | 354 | } |
|
281 | 355 | |
|
282 | 356 | function tokenStringFactory(delimiter) { |
|
283 | while ('bruv'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) { | |
|
284 |
delimiter = |
|
|
357 | if (delimiter.substr(-3) === '"""') { | |
|
358 | delimiter = '"""'; | |
|
359 | } else if (delimiter.substr(-1) === '"') { | |
|
360 | delimiter = '"'; | |
|
285 | 361 | } |
|
286 | var singleline = delimiter == "'"; | |
|
287 | var OUTCLASS = 'string'; | |
|
288 | ||
|
289 | 362 | function tokenString(stream, state) { |
|
290 |
|
|
|
291 |
stream. |
|
|
292 |
if (stream. |
|
|
293 | stream.next(); | |
|
294 | if (singleline && stream.eol()) { | |
|
295 | return OUTCLASS; | |
|
296 | } | |
|
297 | } else if (stream.match(delimiter)) { | |
|
298 | state.tokenize = tokenBase; | |
|
299 | return OUTCLASS; | |
|
300 | } else { | |
|
301 | stream.eat(/['"]/); | |
|
302 | } | |
|
363 | if (stream.eat('\\')) { | |
|
364 | stream.next(); | |
|
365 | } else if (stream.match(delimiter)) { | |
|
366 | state.tokenize = tokenBase; | |
|
367 | state.leavingExpr = true; | |
|
368 | return "string"; | |
|
369 | } else { | |
|
370 | stream.eat(/[`"]/); | |
|
303 | 371 | } |
|
304 | if (singleline) { | |
|
305 | if (parserConf.singleLineStringErrors) { | |
|
306 | return ERRORCLASS; | |
|
307 | } else { | |
|
308 | state.tokenize = tokenBase; | |
|
309 | } | |
|
310 | } | |
|
311 | return OUTCLASS; | |
|
372 | stream.eatWhile(/[^\\`"]/); | |
|
373 | return "string"; | |
|
312 | 374 | } |
|
313 | tokenString.isString = true; | |
|
314 | 375 | return tokenString; |
|
315 | 376 | } |
|
316 | 377 | |
@@ -322,6 +383,10 b' CodeMirror.defineMode("julia", function(' | |||
|
322 | 383 | lastToken: null, |
|
323 | 384 | leavingExpr: false, |
|
324 | 385 | isDefinition: false, |
|
386 | nestedArrays: 0, | |
|
387 | nestedComments: 0, | |
|
388 | nestedGenerators: 0, | |
|
389 | nestedParameters: 0, | |
|
325 | 390 | charsAdvanced: 0, |
|
326 | 391 | firstParenPos: -1 |
|
327 | 392 | }; |
@@ -335,25 +400,25 b' CodeMirror.defineMode("julia", function(' | |||
|
335 | 400 | state.lastToken = current; |
|
336 | 401 | } |
|
337 | 402 | |
|
338 | // Handle '.' connected identifiers | |
|
339 | if (current === '.') { | |
|
340 | style = stream.match(identifiers, false) || stream.match(macro, false) || | |
|
341 | stream.match(/\(/, false) ? 'operator' : ERRORCLASS; | |
|
342 | } | |
|
343 | 403 | return style; |
|
344 | 404 | }, |
|
345 | 405 | |
|
346 | 406 | indent: function(state, textAfter) { |
|
347 | 407 | var delta = 0; |
|
348 | if (textAfter == "end" || textAfter == "]" || textAfter == "}" || textAfter == "else" || textAfter == "elseif" || textAfter == "catch" || textAfter == "finally") { | |
|
408 | if ( textAfter === ']' || textAfter === ')' || textAfter === "end" || | |
|
409 | textAfter === "else" || textAfter === "catch" || textAfter === "elseif" || | |
|
410 | textAfter === "finally" ) { | |
|
349 | 411 | delta = -1; |
|
350 | 412 | } |
|
351 |
return (state.scopes.length + delta) * |
|
|
413 | return (state.scopes.length + delta) * config.indentUnit; | |
|
352 | 414 | }, |
|
353 | 415 | |
|
416 | electricInput: /\b(end|else|catch|finally)\b/, | |
|
417 | blockCommentStart: "#=", | |
|
418 | blockCommentEnd: "=#", | |
|
354 | 419 | lineComment: "#", |
|
355 | fold: "indent", | |
|
356 | electricChars: "edlsifyh]}" | |
|
420 | closeBrackets: "()[]{}\"\"", | |
|
421 | fold: "indent" | |
|
357 | 422 | }; |
|
358 | 423 | return external; |
|
359 | 424 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /** |
|
5 | 5 | * Link to the project's GitHub page: |
@@ -50,7 +50,7 b'' | |||
|
50 | 50 | startState: function(){ |
|
51 | 51 | return { |
|
52 | 52 | next: 'start', |
|
53 | lastToken: null | |
|
53 | lastToken: {style: null, indent: 0, content: ""} | |
|
54 | 54 | }; |
|
55 | 55 | }, |
|
56 | 56 | token: function(stream, state){ |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's |
|
5 | 5 | // CodeMirror 1 mode. |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -13,8 +13,8 b'' | |||
|
13 | 13 | |
|
14 | 14 | CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { |
|
15 | 15 | |
|
16 |
var html |
|
|
17 | var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain"); | |
|
16 | var htmlMode = CodeMirror.getMode(cmCfg, "text/html"); | |
|
17 | var htmlModeMissing = htmlMode.name == "null" | |
|
18 | 18 | |
|
19 | 19 | function getMode(name) { |
|
20 | 20 | if (CodeMirror.findModeByName) { |
@@ -35,15 +35,6 b' CodeMirror.defineMode("markdown", functi' | |||
|
35 | 35 | if (modeCfg.maxBlockquoteDepth === undefined) |
|
36 | 36 | modeCfg.maxBlockquoteDepth = 0; |
|
37 | 37 | |
|
38 | // Should underscores in words open/close em/strong? | |
|
39 | if (modeCfg.underscoresBreakWords === undefined) | |
|
40 | modeCfg.underscoresBreakWords = true; | |
|
41 | ||
|
42 | // Use `fencedCodeBlocks` to configure fenced code blocks. false to | |
|
43 | // disable, string to specify a precise regexp that the fence should | |
|
44 | // match, and true to allow three or more backticks or tildes (as | |
|
45 | // per CommonMark). | |
|
46 | ||
|
47 | 38 | // Turn on task lists? ("- [ ] " and "- [x] ") |
|
48 | 39 | if (modeCfg.taskLists === undefined) modeCfg.taskLists = false; |
|
49 | 40 | |
@@ -51,12 +42,19 b' CodeMirror.defineMode("markdown", functi' | |||
|
51 | 42 | if (modeCfg.strikethrough === undefined) |
|
52 | 43 | modeCfg.strikethrough = false; |
|
53 | 44 | |
|
45 | if (modeCfg.emoji === undefined) | |
|
46 | modeCfg.emoji = false; | |
|
47 | ||
|
48 | if (modeCfg.fencedCodeBlockHighlighting === undefined) | |
|
49 | modeCfg.fencedCodeBlockHighlighting = true; | |
|
50 | ||
|
51 | if (modeCfg.xml === undefined) | |
|
52 | modeCfg.xml = true; | |
|
53 | ||
|
54 | 54 | // Allow token types to be overridden by user-provided token types. |
|
55 | 55 | if (modeCfg.tokenTypeOverrides === undefined) |
|
56 | 56 | modeCfg.tokenTypeOverrides = {}; |
|
57 | 57 | |
|
58 | var codeDepth = 0; | |
|
59 | ||
|
60 | 58 | var tokenTypes = { |
|
61 | 59 | header: "header", |
|
62 | 60 | code: "comment", |
@@ -65,7 +63,9 b' CodeMirror.defineMode("markdown", functi' | |||
|
65 | 63 | list2: "variable-3", |
|
66 | 64 | list3: "keyword", |
|
67 | 65 | hr: "hr", |
|
68 |
image: " |
|
|
66 | image: "image", | |
|
67 | imageAltText: "image-alt-text", | |
|
68 | imageMarker: "image-marker", | |
|
69 | 69 | formatting: "formatting", |
|
70 | 70 | linkInline: "link", |
|
71 | 71 | linkEmail: "link", |
@@ -73,7 +73,8 b' CodeMirror.defineMode("markdown", functi' | |||
|
73 | 73 | linkHref: "string", |
|
74 | 74 | em: "em", |
|
75 | 75 | strong: "strong", |
|
76 | strikethrough: "strikethrough" | |
|
76 | strikethrough: "strikethrough", | |
|
77 | emoji: "builtin" | |
|
77 | 78 | }; |
|
78 | 79 | |
|
79 | 80 | for (var tokenType in tokenTypes) { |
@@ -83,14 +84,15 b' CodeMirror.defineMode("markdown", functi' | |||
|
83 | 84 | } |
|
84 | 85 | |
|
85 | 86 | var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/ |
|
86 |
, |
|
|
87 | , olRE = /^[0-9]+([.)])\s+/ | |
|
88 | , taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE | |
|
87 | , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/ | |
|
88 | , taskListRE = /^\[(x| )\](?=\s)/i // Must follow listRE | |
|
89 | 89 | , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ |
|
90 | 90 | , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/ |
|
91 | , textRE = /^[^#!\[\]*_\\<>` "'(~]+/ | |
|
92 | , fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) + | |
|
93 | ")[ \\t]*([\\w+#]*)"); | |
|
91 | , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/ | |
|
92 | , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/ | |
|
93 | , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition | |
|
94 | , punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/ | |
|
95 | , expandedTab = " " // CommonMark specifies tab as 4 spaces | |
|
94 | 96 | |
|
95 | 97 | function switchInline(stream, state, f) { |
|
96 | 98 | state.f = state.inline = f; |
@@ -111,6 +113,8 b' CodeMirror.defineMode("markdown", functi' | |||
|
111 | 113 | function blankLine(state) { |
|
112 | 114 | // Reset linkTitle state |
|
113 | 115 | state.linkTitle = false; |
|
116 | state.linkHref = false; | |
|
117 | state.linkText = false; | |
|
114 | 118 | // Reset EM state |
|
115 | 119 | state.em = false; |
|
116 | 120 | // Reset STRONG state |
@@ -121,102 +125,154 b' CodeMirror.defineMode("markdown", functi' | |||
|
121 | 125 | state.quote = 0; |
|
122 | 126 | // Reset state.indentedCode |
|
123 | 127 | state.indentedCode = false; |
|
124 |
if ( |
|
|
125 | state.f = inlineNormal; | |
|
126 | state.block = blockNormal; | |
|
128 | if (state.f == htmlBlock) { | |
|
129 | var exit = htmlModeMissing | |
|
130 | if (!exit) { | |
|
131 | var inner = CodeMirror.innerMode(htmlMode, state.htmlState) | |
|
132 | exit = inner.mode.name == "xml" && inner.state.tagStart === null && | |
|
133 | (!inner.state.context && inner.state.tokenize.isInText) | |
|
134 | } | |
|
135 | if (exit) { | |
|
136 | state.f = inlineNormal; | |
|
137 | state.block = blockNormal; | |
|
138 | state.htmlState = null; | |
|
139 | } | |
|
127 | 140 | } |
|
128 | 141 | // Reset state.trailingSpace |
|
129 | 142 | state.trailingSpace = 0; |
|
130 | 143 | state.trailingSpaceNewLine = false; |
|
131 | 144 | // Mark this line as blank |
|
132 | 145 | state.prevLine = state.thisLine |
|
133 | state.thisLine = null | |
|
146 | state.thisLine = {stream: null} | |
|
134 | 147 | return null; |
|
135 | 148 | } |
|
136 | 149 | |
|
137 | 150 | function blockNormal(stream, state) { |
|
138 | ||
|
139 | var sol = stream.sol(); | |
|
140 | ||
|
141 |
var prevLineIs |
|
|
142 | prevLineIsIndentedCode = state.indentedCode; | |
|
151 | var firstTokenOnLine = stream.column() === state.indentation; | |
|
152 | var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream); | |
|
153 | var prevLineIsIndentedCode = state.indentedCode; | |
|
154 | var prevLineIsHr = state.prevLine.hr; | |
|
155 | var prevLineIsList = state.list !== false; | |
|
156 | var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3; | |
|
143 | 157 | |
|
144 | 158 | state.indentedCode = false; |
|
145 | 159 | |
|
146 | if (prevLineIsList) { | |
|
147 | if (state.indentationDiff >= 0) { // Continued list | |
|
148 | if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block | |
|
149 |
|
|
|
150 | } | |
|
160 | var lineIndentation = state.indentation; | |
|
161 | // compute once per line (on first token) | |
|
162 | if (state.indentationDiff === null) { | |
|
163 | state.indentationDiff = state.indentation; | |
|
164 | if (prevLineIsList) { | |
|
151 | 165 | state.list = null; |
|
152 | } else if (state.indentation > 0) { | |
|
153 | state.list = null; | |
|
154 | state.listDepth = Math.floor(state.indentation / 4); | |
|
155 | } else { // No longer a list | |
|
156 |
state.list |
|
|
157 |
state.list |
|
|
166 | // While this list item's marker's indentation is less than the deepest | |
|
167 | // list item's content's indentation,pop the deepest list item | |
|
168 | // indentation off the stack, and update block indentation state | |
|
169 | while (lineIndentation < state.listStack[state.listStack.length - 1]) { | |
|
170 | state.listStack.pop(); | |
|
171 | if (state.listStack.length) { | |
|
172 | state.indentation = state.listStack[state.listStack.length - 1]; | |
|
173 | // less than the first list's indent -> the line is no longer a list | |
|
174 | } else { | |
|
175 | state.list = false; | |
|
176 | } | |
|
177 | } | |
|
178 | if (state.list !== false) { | |
|
179 | state.indentationDiff = lineIndentation - state.listStack[state.listStack.length - 1] | |
|
180 | } | |
|
158 | 181 | } |
|
159 | 182 | } |
|
160 | 183 | |
|
184 | // not comprehensive (currently only for setext detection purposes) | |
|
185 | var allowsInlineContinuation = ( | |
|
186 | !prevLineLineIsEmpty && !prevLineIsHr && !state.prevLine.header && | |
|
187 | (!prevLineIsList || !prevLineIsIndentedCode) && | |
|
188 | !state.prevLine.fencedCodeEnd | |
|
189 | ); | |
|
190 | ||
|
191 | var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) && | |
|
192 | state.indentation <= maxNonCodeIndentation && stream.match(hrRE); | |
|
193 | ||
|
161 | 194 | var match = null; |
|
162 | if (state.indentationDiff >= 4) { | |
|
195 | if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || state.prevLine.fencedCodeEnd || | |
|
196 | state.prevLine.header || prevLineLineIsEmpty)) { | |
|
163 | 197 | stream.skipToEnd(); |
|
164 | if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) { | |
|
165 | state.indentation -= 4; | |
|
166 | state.indentedCode = true; | |
|
167 | return tokenTypes.code; | |
|
168 | } else { | |
|
169 | return null; | |
|
170 | } | |
|
198 | state.indentedCode = true; | |
|
199 | return tokenTypes.code; | |
|
171 | 200 | } else if (stream.eatSpace()) { |
|
172 | 201 | return null; |
|
173 | } else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) { | |
|
202 | } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) { | |
|
203 | state.quote = 0; | |
|
174 | 204 | state.header = match[1].length; |
|
205 | state.thisLine.header = true; | |
|
175 | 206 | if (modeCfg.highlightFormatting) state.formatting = "header"; |
|
176 | 207 | state.f = state.inline; |
|
177 | 208 | return getType(state); |
|
178 | } else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList && | |
|
179 | !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) { | |
|
180 | state.header = match[0].charAt(0) == '=' ? 1 : 2; | |
|
181 | if (modeCfg.highlightFormatting) state.formatting = "header"; | |
|
182 | state.f = state.inline; | |
|
183 | return getType(state); | |
|
184 | } else if (stream.eat('>')) { | |
|
185 | state.quote = sol ? 1 : state.quote + 1; | |
|
209 | } else if (state.indentation <= maxNonCodeIndentation && stream.eat('>')) { | |
|
210 | state.quote = firstTokenOnLine ? 1 : state.quote + 1; | |
|
186 | 211 | if (modeCfg.highlightFormatting) state.formatting = "quote"; |
|
187 | 212 | stream.eatSpace(); |
|
188 | 213 | return getType(state); |
|
189 | } else if (stream.peek() === '[') { | |
|
190 | return switchInline(stream, state, footnoteLink); | |
|
191 | } else if (stream.match(hrRE, true)) { | |
|
192 | state.hr = true; | |
|
193 | return tokenTypes.hr; | |
|
194 | } else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) { | |
|
195 | var listType = null; | |
|
196 | if (stream.match(ulRE, true)) { | |
|
197 | listType = 'ul'; | |
|
198 | } else { | |
|
199 | stream.match(olRE, true); | |
|
200 | listType = 'ol'; | |
|
201 | } | |
|
202 | state.indentation = stream.column() + stream.current().length; | |
|
214 | } else if (!isHr && !state.setext && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) { | |
|
215 | var listType = match[1] ? "ol" : "ul"; | |
|
216 | ||
|
217 | state.indentation = lineIndentation + stream.current().length; | |
|
203 | 218 | state.list = true; |
|
204 |
state. |
|
|
219 | state.quote = 0; | |
|
220 | ||
|
221 | // Add this list item's content's indentation to the stack | |
|
222 | state.listStack.push(state.indentation); | |
|
223 | // Reset inline styles which shouldn't propagate aross list items | |
|
224 | state.em = false; | |
|
225 | state.strong = false; | |
|
226 | state.code = false; | |
|
227 | state.strikethrough = false; | |
|
228 | ||
|
205 | 229 | if (modeCfg.taskLists && stream.match(taskListRE, false)) { |
|
206 | 230 | state.taskList = true; |
|
207 | 231 | } |
|
208 | 232 | state.f = state.inline; |
|
209 | 233 | if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; |
|
210 | 234 | return getType(state); |
|
211 |
} else if ( |
|
|
212 | state.fencedChars = match[1] | |
|
235 | } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) { | |
|
236 | state.quote = 0; | |
|
237 | state.fencedEndRE = new RegExp(match[1] + "+ *$"); | |
|
213 | 238 | // try switching mode |
|
214 | state.localMode = getMode(match[2]); | |
|
215 |
if (state.localMode) state.localState = state.localMode |
|
|
239 | state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]); | |
|
240 | if (state.localMode) state.localState = CodeMirror.startState(state.localMode); | |
|
216 | 241 | state.f = state.block = local; |
|
217 | 242 | if (modeCfg.highlightFormatting) state.formatting = "code-block"; |
|
218 |
state.code = |
|
|
243 | state.code = -1 | |
|
219 | 244 | return getType(state); |
|
245 | // SETEXT has lowest block-scope precedence after HR, so check it after | |
|
246 | // the others (code, blockquote, list...) | |
|
247 | } else if ( | |
|
248 | // if setext set, indicates line after ---/=== | |
|
249 | state.setext || ( | |
|
250 | // line before ---/=== | |
|
251 | (!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false && | |
|
252 | !state.code && !isHr && !linkDefRE.test(stream.string) && | |
|
253 | (match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE)) | |
|
254 | ) | |
|
255 | ) { | |
|
256 | if ( !state.setext ) { | |
|
257 | state.header = match[0].charAt(0) == '=' ? 1 : 2; | |
|
258 | state.setext = state.header; | |
|
259 | } else { | |
|
260 | state.header = state.setext; | |
|
261 | // has no effect on type so we can reset it now | |
|
262 | state.setext = 0; | |
|
263 | stream.skipToEnd(); | |
|
264 | if (modeCfg.highlightFormatting) state.formatting = "header"; | |
|
265 | } | |
|
266 | state.thisLine.header = true; | |
|
267 | state.f = state.inline; | |
|
268 | return getType(state); | |
|
269 | } else if (isHr) { | |
|
270 | stream.skipToEnd(); | |
|
271 | state.hr = true; | |
|
272 | state.thisLine.hr = true; | |
|
273 | return tokenTypes.hr; | |
|
274 | } else if (stream.peek() === '[') { | |
|
275 | return switchInline(stream, state, footnoteLink); | |
|
220 | 276 | } |
|
221 | 277 | |
|
222 | 278 | return switchInline(stream, state, state.inline); |
@@ -224,21 +280,35 b' CodeMirror.defineMode("markdown", functi' | |||
|
224 | 280 | |
|
225 | 281 | function htmlBlock(stream, state) { |
|
226 | 282 | var style = htmlMode.token(stream, state.htmlState); |
|
227 | if ((htmlFound && state.htmlState.tagStart === null && | |
|
228 | (!state.htmlState.context && state.htmlState.tokenize.isInText)) || | |
|
229 | (state.md_inside && stream.current().indexOf(">") > -1)) { | |
|
230 | state.f = inlineNormal; | |
|
231 | state.block = blockNormal; | |
|
232 |
state. |
|
|
283 | if (!htmlModeMissing) { | |
|
284 | var inner = CodeMirror.innerMode(htmlMode, state.htmlState) | |
|
285 | if ((inner.mode.name == "xml" && inner.state.tagStart === null && | |
|
286 | (!inner.state.context && inner.state.tokenize.isInText)) || | |
|
287 | (state.md_inside && stream.current().indexOf(">") > -1)) { | |
|
288 | state.f = inlineNormal; | |
|
289 | state.block = blockNormal; | |
|
290 | state.htmlState = null; | |
|
291 | } | |
|
233 | 292 | } |
|
234 | 293 | return style; |
|
235 | 294 | } |
|
236 | 295 | |
|
237 | 296 | function local(stream, state) { |
|
238 | if (state.fencedChars && stream.match(state.fencedChars, false)) { | |
|
297 | var currListInd = state.listStack[state.listStack.length - 1] || 0; | |
|
298 | var hasExitedList = state.indentation < currListInd; | |
|
299 | var maxFencedEndInd = currListInd + 3; | |
|
300 | if (state.fencedEndRE && state.indentation <= maxFencedEndInd && (hasExitedList || stream.match(state.fencedEndRE))) { | |
|
301 | if (modeCfg.highlightFormatting) state.formatting = "code-block"; | |
|
302 | var returnType; | |
|
303 | if (!hasExitedList) returnType = getType(state) | |
|
239 | 304 | state.localMode = state.localState = null; |
|
240 |
|
|
|
241 | return null; | |
|
305 | state.block = blockNormal; | |
|
306 | state.f = inlineNormal; | |
|
307 | state.fencedEndRE = null; | |
|
308 | state.code = 0 | |
|
309 | state.thisLine.fencedCodeEnd = true; | |
|
310 | if (hasExitedList) return switchBlock(stream, state, state.block); | |
|
311 | return returnType; | |
|
242 | 312 | } else if (state.localMode) { |
|
243 | 313 | return state.localMode.token(stream, state.localState); |
|
244 | 314 | } else { |
@@ -247,18 +317,6 b' CodeMirror.defineMode("markdown", functi' | |||
|
247 | 317 | } |
|
248 | 318 | } |
|
249 | 319 | |
|
250 | function leavingLocal(stream, state) { | |
|
251 | stream.match(state.fencedChars); | |
|
252 | state.block = blockNormal; | |
|
253 | state.f = inlineNormal; | |
|
254 | state.fencedChars = null; | |
|
255 | if (modeCfg.highlightFormatting) state.formatting = "code-block"; | |
|
256 | state.code = true; | |
|
257 | var returnType = getType(state); | |
|
258 | state.code = false; | |
|
259 | return returnType; | |
|
260 | } | |
|
261 | ||
|
262 | 320 | // Inline |
|
263 | 321 | function getType(state) { |
|
264 | 322 | var styles = []; |
@@ -302,8 +360,12 b' CodeMirror.defineMode("markdown", functi' | |||
|
302 | 360 | if (state.strong) { styles.push(tokenTypes.strong); } |
|
303 | 361 | if (state.em) { styles.push(tokenTypes.em); } |
|
304 | 362 | if (state.strikethrough) { styles.push(tokenTypes.strikethrough); } |
|
363 | if (state.emoji) { styles.push(tokenTypes.emoji); } | |
|
305 | 364 | if (state.linkText) { styles.push(tokenTypes.linkText); } |
|
306 | 365 | if (state.code) { styles.push(tokenTypes.code); } |
|
366 | if (state.image) { styles.push(tokenTypes.image); } | |
|
367 | if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); } | |
|
368 | if (state.imageMarker) { styles.push(tokenTypes.imageMarker); } | |
|
307 | 369 | } |
|
308 | 370 | |
|
309 | 371 | if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); } |
@@ -320,7 +382,7 b' CodeMirror.defineMode("markdown", functi' | |||
|
320 | 382 | } |
|
321 | 383 | |
|
322 | 384 | if (state.list !== false) { |
|
323 |
var listMod = (state.list |
|
|
385 | var listMod = (state.listStack.length - 1) % 3; | |
|
324 | 386 | if (!listMod) { |
|
325 | 387 | styles.push(tokenTypes.list1); |
|
326 | 388 | } else if (listMod === 1) { |
@@ -357,7 +419,7 b' CodeMirror.defineMode("markdown", functi' | |||
|
357 | 419 | } |
|
358 | 420 | |
|
359 | 421 | if (state.taskList) { |
|
360 |
var taskOpen = stream.match(taskListRE, true)[1] |
|
|
422 | var taskOpen = stream.match(taskListRE, true)[1] === " "; | |
|
361 | 423 | if (taskOpen) state.taskOpen = true; |
|
362 | 424 | else state.taskClosed = true; |
|
363 | 425 | if (modeCfg.highlightFormatting) state.formatting = "task"; |
@@ -373,20 +435,8 b' CodeMirror.defineMode("markdown", functi' | |||
|
373 | 435 | return getType(state); |
|
374 | 436 | } |
|
375 | 437 | |
|
376 | // Get sol() value now, before character is consumed | |
|
377 | var sol = stream.sol(); | |
|
378 | ||
|
379 | 438 | var ch = stream.next(); |
|
380 | 439 | |
|
381 | if (ch === '\\') { | |
|
382 | stream.next(); | |
|
383 | if (modeCfg.highlightFormatting) { | |
|
384 | var type = getType(state); | |
|
385 | var formattingEscape = tokenTypes.formatting + "-escape"; | |
|
386 | return type ? type + " " + formattingEscape : formattingEscape; | |
|
387 | } | |
|
388 | } | |
|
389 | ||
|
390 | 440 | // Matches link titles present on next line |
|
391 | 441 | if (state.linkTitle) { |
|
392 | 442 | state.linkTitle = false; |
@@ -394,7 +444,7 b' CodeMirror.defineMode("markdown", functi' | |||
|
394 | 444 | if (ch === '(') { |
|
395 | 445 | matchCh = ')'; |
|
396 | 446 | } |
|
397 |
matchCh = (matchCh+'').replace(/([.?*+^ |
|
|
447 | matchCh = (matchCh+'').replace(/([.?*+^\[\]\\(){}|-])/g, "\\$1"); | |
|
398 | 448 | var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh; |
|
399 | 449 | if (stream.match(new RegExp(regex), true)) { |
|
400 | 450 | return tokenTypes.linkHref; |
@@ -405,43 +455,67 b' CodeMirror.defineMode("markdown", functi' | |||
|
405 | 455 | if (ch === '`') { |
|
406 | 456 | var previousFormatting = state.formatting; |
|
407 | 457 | if (modeCfg.highlightFormatting) state.formatting = "code"; |
|
408 | var t = getType(state); | |
|
409 | var before = stream.pos; | |
|
410 | 458 | stream.eatWhile('`'); |
|
411 | var difference = 1 + stream.pos - before; | |
|
412 | if (!state.code) { | |
|
413 | codeDepth = difference; | |
|
414 | state.code = true; | |
|
415 | return getType(state); | |
|
459 | var count = stream.current().length | |
|
460 | if (state.code == 0 && (!state.quote || count == 1)) { | |
|
461 | state.code = count | |
|
462 | return getType(state) | |
|
463 | } else if (count == state.code) { // Must be exact | |
|
464 | var t = getType(state) | |
|
465 | state.code = 0 | |
|
466 | return t | |
|
416 | 467 | } else { |
|
417 | if (difference === codeDepth) { // Must be exact | |
|
418 | state.code = false; | |
|
419 | return t; | |
|
420 | } | |
|
421 | state.formatting = previousFormatting; | |
|
422 | return getType(state); | |
|
468 | state.formatting = previousFormatting | |
|
469 | return getType(state) | |
|
423 | 470 | } |
|
424 | 471 | } else if (state.code) { |
|
425 | 472 | return getType(state); |
|
426 | 473 | } |
|
427 | 474 | |
|
475 | if (ch === '\\') { | |
|
476 | stream.next(); | |
|
477 | if (modeCfg.highlightFormatting) { | |
|
478 | var type = getType(state); | |
|
479 | var formattingEscape = tokenTypes.formatting + "-escape"; | |
|
480 | return type ? type + " " + formattingEscape : formattingEscape; | |
|
481 | } | |
|
482 | } | |
|
483 | ||
|
428 | 484 | if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { |
|
429 | stream.match(/\[[^\]]*\]/); | |
|
430 |
state.i |
|
|
431 | return tokenTypes.image; | |
|
485 | state.imageMarker = true; | |
|
486 | state.image = true; | |
|
487 | if (modeCfg.highlightFormatting) state.formatting = "image"; | |
|
488 | return getType(state); | |
|
432 | 489 | } |
|
433 | 490 | |
|
434 |
if (ch === '[' && stream.match(/ |
|
|
491 | if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) { | |
|
492 | state.imageMarker = false; | |
|
493 | state.imageAltText = true | |
|
494 | if (modeCfg.highlightFormatting) state.formatting = "image"; | |
|
495 | return getType(state); | |
|
496 | } | |
|
497 | ||
|
498 | if (ch === ']' && state.imageAltText) { | |
|
499 | if (modeCfg.highlightFormatting) state.formatting = "image"; | |
|
500 | var type = getType(state); | |
|
501 | state.imageAltText = false; | |
|
502 | state.image = false; | |
|
503 | state.inline = state.f = linkHref; | |
|
504 | return type; | |
|
505 | } | |
|
506 | ||
|
507 | if (ch === '[' && !state.image) { | |
|
508 | if (state.linkText && stream.match(/^.*?\]/)) return getType(state) | |
|
435 | 509 | state.linkText = true; |
|
436 | 510 | if (modeCfg.highlightFormatting) state.formatting = "link"; |
|
437 | 511 | return getType(state); |
|
438 | 512 | } |
|
439 | 513 | |
|
440 |
if (ch === ']' && state.linkText |
|
|
514 | if (ch === ']' && state.linkText) { | |
|
441 | 515 | if (modeCfg.highlightFormatting) state.formatting = "link"; |
|
442 | 516 | var type = getType(state); |
|
443 | 517 | state.linkText = false; |
|
444 | state.inline = state.f = linkHref; | |
|
518 | state.inline = state.f = stream.match(/\(.*?\)| ?\[.*?\]/, false) ? linkHref : inlineNormal | |
|
445 | 519 | return type; |
|
446 | 520 | } |
|
447 | 521 | |
@@ -469,7 +543,7 b' CodeMirror.defineMode("markdown", functi' | |||
|
469 | 543 | return type + tokenTypes.linkEmail; |
|
470 | 544 | } |
|
471 | 545 | |
|
472 | if (ch === '<' && stream.match(/^(!--|\w)/, false)) { | |
|
546 | if (modeCfg.xml && ch === '<' && stream.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i, false)) { | |
|
473 | 547 | var end = stream.string.indexOf(">", stream.pos); |
|
474 | 548 | if (end != -1) { |
|
475 | 549 | var atts = stream.string.substring(stream.start, end); |
@@ -480,44 +554,37 b' CodeMirror.defineMode("markdown", functi' | |||
|
480 | 554 | return switchBlock(stream, state, htmlBlock); |
|
481 | 555 | } |
|
482 | 556 | |
|
483 | if (ch === '<' && stream.match(/^\/\w*?>/)) { | |
|
557 | if (modeCfg.xml && ch === '<' && stream.match(/^\/\w*?>/)) { | |
|
484 | 558 | state.md_inside = false; |
|
485 | 559 | return "tag"; |
|
486 | } | |
|
487 | ||
|
488 | var ignoreUnderscore = false; | |
|
489 | if (!modeCfg.underscoresBreakWords) { | |
|
490 | if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) { | |
|
491 | var prevPos = stream.pos - 2; | |
|
492 | if (prevPos >= 0) { | |
|
493 | var prevCh = stream.string.charAt(prevPos); | |
|
494 | if (prevCh !== '_' && prevCh.match(/(\w)/, false)) { | |
|
495 | ignoreUnderscore = true; | |
|
496 |
|
|
|
497 | } | |
|
560 | } else if (ch === "*" || ch === "_") { | |
|
561 | var len = 1, before = stream.pos == 1 ? " " : stream.string.charAt(stream.pos - 2) | |
|
562 | while (len < 3 && stream.eat(ch)) len++ | |
|
563 | var after = stream.peek() || " " | |
|
564 | // See http://spec.commonmark.org/0.27/#emphasis-and-strong-emphasis | |
|
565 | var leftFlanking = !/\s/.test(after) && (!punctuation.test(after) || /\s/.test(before) || punctuation.test(before)) | |
|
566 | var rightFlanking = !/\s/.test(before) && (!punctuation.test(before) || /\s/.test(after) || punctuation.test(after)) | |
|
567 | var setEm = null, setStrong = null | |
|
568 | if (len % 2) { // Em | |
|
569 | if (!state.em && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) | |
|
570 | setEm = true | |
|
571 | else if (state.em == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) | |
|
572 | setEm = false | |
|
498 | 573 | } |
|
499 | } | |
|
500 | if (ch === '*' || (ch === '_' && !ignoreUnderscore)) { | |
|
501 | if (sol && stream.peek() === ' ') { | |
|
502 | // Do nothing, surrounded by newline and space | |
|
503 | } else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG | |
|
504 | if (modeCfg.highlightFormatting) state.formatting = "strong"; | |
|
505 | var t = getType(state); | |
|
506 | state.strong = false; | |
|
507 | return t; | |
|
508 | } else if (!state.strong && stream.eat(ch)) { // Add STRONG | |
|
509 | state.strong = ch; | |
|
510 | if (modeCfg.highlightFormatting) state.formatting = "strong"; | |
|
511 | return getType(state); | |
|
512 | } else if (state.em === ch) { // Remove EM | |
|
513 | if (modeCfg.highlightFormatting) state.formatting = "em"; | |
|
514 | var t = getType(state); | |
|
515 | state.em = false; | |
|
516 | return t; | |
|
517 | } else if (!state.em) { // Add EM | |
|
518 | state.em = ch; | |
|
519 | if (modeCfg.highlightFormatting) state.formatting = "em"; | |
|
520 | return getType(state); | |
|
574 | if (len > 1) { // Strong | |
|
575 | if (!state.strong && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before))) | |
|
576 | setStrong = true | |
|
577 | else if (state.strong == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after))) | |
|
578 | setStrong = false | |
|
579 | } | |
|
580 | if (setStrong != null || setEm != null) { | |
|
581 | if (modeCfg.highlightFormatting) state.formatting = setEm == null ? "strong" : setStrong == null ? "em" : "strong em" | |
|
582 | if (setEm === true) state.em = ch | |
|
583 | if (setStrong === true) state.strong = ch | |
|
584 | var t = getType(state) | |
|
585 | if (setEm === false) state.em = false | |
|
586 | if (setStrong === false) state.strong = false | |
|
587 | return t | |
|
521 | 588 | } |
|
522 | 589 | } else if (ch === ' ') { |
|
523 | 590 | if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces |
@@ -552,8 +619,16 b' CodeMirror.defineMode("markdown", functi' | |||
|
552 | 619 | } |
|
553 | 620 | } |
|
554 | 621 | |
|
622 | if (modeCfg.emoji && ch === ":" && stream.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) { | |
|
623 | state.emoji = true; | |
|
624 | if (modeCfg.highlightFormatting) state.formatting = "emoji"; | |
|
625 | var retType = getType(state); | |
|
626 | state.emoji = false; | |
|
627 | return retType; | |
|
628 | } | |
|
629 | ||
|
555 | 630 | if (ch === ' ') { |
|
556 | if (stream.match(/ +$/, false)) { | |
|
631 | if (stream.match(/^ +$/, false)) { | |
|
557 | 632 | state.trailingSpace++; |
|
558 | 633 | } else if (state.trailingSpace) { |
|
559 | 634 | state.trailingSpaceNewLine = true; |
@@ -598,6 +673,11 b' CodeMirror.defineMode("markdown", functi' | |||
|
598 | 673 | return 'error'; |
|
599 | 674 | } |
|
600 | 675 | |
|
676 | var linkRE = { | |
|
677 | ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/, | |
|
678 | "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/ | |
|
679 | } | |
|
680 | ||
|
601 | 681 | function getLinkHrefInside(endChar) { |
|
602 | 682 | return function(stream, state) { |
|
603 | 683 | var ch = stream.next(); |
@@ -610,10 +690,7 b' CodeMirror.defineMode("markdown", functi' | |||
|
610 | 690 | return returnState; |
|
611 | 691 | } |
|
612 | 692 | |
|
613 |
|
|
|
614 | stream.backUp(1); | |
|
615 | } | |
|
616 | ||
|
693 | stream.match(linkRE[endChar]) | |
|
617 | 694 | state.linkHref = true; |
|
618 | 695 | return getType(state); |
|
619 | 696 | }; |
@@ -661,25 +738,13 b' CodeMirror.defineMode("markdown", functi' | |||
|
661 | 738 | return tokenTypes.linkHref + " url"; |
|
662 | 739 | } |
|
663 | 740 | |
|
664 | var savedInlineRE = []; | |
|
665 | function inlineRE(endChar) { | |
|
666 | if (!savedInlineRE[endChar]) { | |
|
667 | // Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741) | |
|
668 | endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); | |
|
669 | // Match any non-endChar, escaped character, as well as the closing | |
|
670 | // endChar. | |
|
671 | savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')'); | |
|
672 | } | |
|
673 | return savedInlineRE[endChar]; | |
|
674 | } | |
|
675 | ||
|
676 | 741 | var mode = { |
|
677 | 742 | startState: function() { |
|
678 | 743 | return { |
|
679 | 744 | f: blockNormal, |
|
680 | 745 | |
|
681 | prevLine: null, | |
|
682 | thisLine: null, | |
|
746 | prevLine: {stream: null}, | |
|
747 | thisLine: {stream: null}, | |
|
683 | 748 | |
|
684 | 749 | block: blockNormal, |
|
685 | 750 | htmlState: null, |
@@ -692,18 +757,21 b' CodeMirror.defineMode("markdown", functi' | |||
|
692 | 757 | linkText: false, |
|
693 | 758 | linkHref: false, |
|
694 | 759 | linkTitle: false, |
|
760 | code: 0, | |
|
695 | 761 | em: false, |
|
696 | 762 | strong: false, |
|
697 | 763 | header: 0, |
|
764 | setext: 0, | |
|
698 | 765 | hr: false, |
|
699 | 766 | taskList: false, |
|
700 | 767 | list: false, |
|
701 |
list |
|
|
768 | listStack: [], | |
|
702 | 769 | quote: 0, |
|
703 | 770 | trailingSpace: 0, |
|
704 | 771 | trailingSpaceNewLine: false, |
|
705 | 772 | strikethrough: false, |
|
706 | fencedChars: null | |
|
773 | emoji: false, | |
|
774 | fencedEndRE: null | |
|
707 | 775 | }; |
|
708 | 776 | }, |
|
709 | 777 | |
@@ -724,22 +792,26 b' CodeMirror.defineMode("markdown", functi' | |||
|
724 | 792 | inline: s.inline, |
|
725 | 793 | text: s.text, |
|
726 | 794 | formatting: false, |
|
795 | linkText: s.linkText, | |
|
727 | 796 | linkTitle: s.linkTitle, |
|
797 | linkHref: s.linkHref, | |
|
728 | 798 | code: s.code, |
|
729 | 799 | em: s.em, |
|
730 | 800 | strong: s.strong, |
|
731 | 801 | strikethrough: s.strikethrough, |
|
802 | emoji: s.emoji, | |
|
732 | 803 | header: s.header, |
|
804 | setext: s.setext, | |
|
733 | 805 | hr: s.hr, |
|
734 | 806 | taskList: s.taskList, |
|
735 | 807 | list: s.list, |
|
736 |
list |
|
|
808 | listStack: s.listStack.slice(0), | |
|
737 | 809 | quote: s.quote, |
|
738 | 810 | indentedCode: s.indentedCode, |
|
739 | 811 | trailingSpace: s.trailingSpace, |
|
740 | 812 | trailingSpaceNewLine: s.trailingSpaceNewLine, |
|
741 | 813 | md_inside: s.md_inside, |
|
742 |
fenced |
|
|
814 | fencedEndRE: s.fencedEndRE | |
|
743 | 815 | }; |
|
744 | 816 | }, |
|
745 | 817 | |
@@ -748,21 +820,17 b' CodeMirror.defineMode("markdown", functi' | |||
|
748 | 820 | // Reset state.formatting |
|
749 | 821 | state.formatting = false; |
|
750 | 822 | |
|
751 | if (stream != state.thisLine) { | |
|
752 | var forceBlankLine = state.header || state.hr; | |
|
753 | ||
|
754 | // Reset state.header and state.hr | |
|
823 | if (stream != state.thisLine.stream) { | |
|
755 | 824 | state.header = 0; |
|
756 | 825 | state.hr = false; |
|
757 | 826 | |
|
758 |
if (stream.match(/^\s*$/, true) |
|
|
827 | if (stream.match(/^\s*$/, true)) { | |
|
759 | 828 | blankLine(state); |
|
760 |
|
|
|
761 | state.prevLine = null | |
|
829 | return null; | |
|
762 | 830 | } |
|
763 | 831 | |
|
764 | 832 | state.prevLine = state.thisLine |
|
765 | state.thisLine = stream | |
|
833 | state.thisLine = {stream: stream} | |
|
766 | 834 | |
|
767 | 835 | // Reset state.taskList |
|
768 | 836 | state.taskList = false; |
@@ -771,14 +839,15 b' CodeMirror.defineMode("markdown", functi' | |||
|
771 | 839 | state.trailingSpace = 0; |
|
772 | 840 | state.trailingSpaceNewLine = false; |
|
773 | 841 | |
|
774 | state.f = state.block; | |
|
775 | var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length; | |
|
776 | var difference = Math.floor((indentation - state.indentation) / 4) * 4; | |
|
777 | if (difference > 4) difference = 4; | |
|
778 |
|
|
|
779 |
state.indentationDiff = |
|
|
780 | state.indentation = adjustedIndentation; | |
|
781 | if (indentation > 0) return null; | |
|
842 | if (!state.localState) { | |
|
843 | state.f = state.block; | |
|
844 | if (state.f != htmlBlock) { | |
|
845 | var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, expandedTab).length; | |
|
846 | state.indentation = indentation; | |
|
847 | state.indentationDiff = null; | |
|
848 | if (indentation > 0) return null; | |
|
849 | } | |
|
850 | } | |
|
782 | 851 | } |
|
783 | 852 | return state.f(stream, state); |
|
784 | 853 | }, |
@@ -789,15 +858,26 b' CodeMirror.defineMode("markdown", functi' | |||
|
789 | 858 | return {state: state, mode: mode}; |
|
790 | 859 | }, |
|
791 | 860 | |
|
861 | indent: function(state, textAfter, line) { | |
|
862 | if (state.block == htmlBlock && htmlMode.indent) return htmlMode.indent(state.htmlState, textAfter, line) | |
|
863 | if (state.localState && state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line) | |
|
864 | return CodeMirror.Pass | |
|
865 | }, | |
|
866 | ||
|
792 | 867 | blankLine: blankLine, |
|
793 | 868 | |
|
794 | 869 | getType: getType, |
|
795 | 870 | |
|
871 | blockCommentStart: "<!--", | |
|
872 | blockCommentEnd: "-->", | |
|
873 | closeBrackets: "()[]{}''\"\"``", | |
|
796 | 874 | fold: "markdown" |
|
797 | 875 | }; |
|
798 | 876 | return mode; |
|
799 | 877 | }, "xml"); |
|
800 | 878 | |
|
879 | CodeMirror.defineMIME("text/markdown", "markdown"); | |
|
880 | ||
|
801 | 881 | CodeMirror.defineMIME("text/x-markdown", "markdown"); |
|
802 | 882 | |
|
803 | 883 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // Mathematica mode copyright (c) 2015 by Calin Barbat |
|
5 | 5 | // Based on code by Patrick Scheibe (halirutan) |
@@ -71,12 +71,12 b" CodeMirror.defineMode('mathematica', fun" | |||
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | // usage |
|
74 |
if (stream.match(/([a-zA-Z\$] |
|
|
74 | if (stream.match(/([a-zA-Z\$][a-zA-Z0-9\$]*(?:`[a-zA-Z0-9\$]+)*::usage)/, true, false)) { | |
|
75 | 75 | return 'meta'; |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | // message |
|
79 |
if (stream.match(/([a-zA-Z\$] |
|
|
79 | if (stream.match(/([a-zA-Z\$][a-zA-Z0-9\$]*(?:`[a-zA-Z0-9\$]+)*::[a-zA-Z\$][a-zA-Z0-9\$]*):?/, true, false)) { | |
|
80 | 80 | return 'string-2'; |
|
81 | 81 | } |
|
82 | 82 | |
@@ -126,6 +126,7 b" CodeMirror.defineMode('mathematica', fun" | |||
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | // everything else is an error |
|
129 | stream.next(); // advance the stream. | |
|
129 | 130 | return 'error'; |
|
130 | 131 | } |
|
131 | 132 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -13,19 +13,19 b'' | |||
|
13 | 13 | |
|
14 | 14 | CodeMirror.modeInfo = [ |
|
15 | 15 | {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]}, |
|
16 | {name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]}, | |
|
16 | {name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"]}, | |
|
17 | 17 | {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]}, |
|
18 | 18 | {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, |
|
19 | 19 | {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]}, |
|
20 | {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]}, | |
|
20 | {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]}, | |
|
21 | 21 | {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]}, |
|
22 | 22 | {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]}, |
|
23 | {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]}, | |
|
24 | {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]}, | |
|
23 | {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp", "cs"]}, | |
|
24 | {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]}, | |
|
25 | 25 | {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]}, |
|
26 | 26 | {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]}, |
|
27 | 27 | {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/}, |
|
28 | {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, | |
|
28 | {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, | |
|
29 | 29 | {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]}, |
|
30 | 30 | {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]}, |
|
31 | 31 | {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]}, |
@@ -41,30 +41,33 b'' | |||
|
41 | 41 | {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]}, |
|
42 | 42 | {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"}, |
|
43 | 43 | {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]}, |
|
44 | {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]}, | |
|
44 | 45 | {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]}, |
|
45 | 46 | {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]}, |
|
46 | 47 | {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]}, |
|
47 | 48 | {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]}, |
|
48 | 49 | {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]}, |
|
50 | {name: "Esper", mime: "text/x-esper", mode: "sql"}, | |
|
49 | 51 | {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]}, |
|
52 | {name: "FCL", mime: "text/x-fcl", mode: "fcl"}, | |
|
50 | 53 | {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]}, |
|
51 | {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]}, | |
|
54 | {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90", "f95"]}, | |
|
52 | 55 | {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]}, |
|
53 | 56 | {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]}, |
|
54 | 57 | {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]}, |
|
55 | 58 | {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i}, |
|
56 | 59 | {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]}, |
|
57 | {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]}, | |
|
60 | {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/}, | |
|
58 | 61 | {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]}, |
|
59 | 62 | {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]}, |
|
60 | 63 | {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]}, |
|
61 | 64 | {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]}, |
|
62 | 65 | {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]}, |
|
63 | 66 | {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]}, |
|
64 | {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]}, | |
|
67 | {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm", "handlebars", "hbs"], alias: ["xhtml"]}, | |
|
65 | 68 | {name: "HTTP", mime: "message/http", mode: "http"}, |
|
66 | 69 | {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]}, |
|
67 |
{name: " |
|
|
70 | {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]}, | |
|
68 | 71 | {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]}, |
|
69 | 72 | {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]}, |
|
70 | 73 | {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"], |
@@ -72,7 +75,7 b'' | |||
|
72 | 75 | {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]}, |
|
73 | 76 | {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]}, |
|
74 | 77 | {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]}, |
|
75 |
{name: "Jinja2", mime: " |
|
|
78 | {name: "Jinja2", mime: "text/jinja2", mode: "jinja2", ext: ["j2", "jinja", "jinja2"]}, | |
|
76 | 79 | {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]}, |
|
77 | 80 | {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]}, |
|
78 | 81 | {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]}, |
@@ -81,75 +84,88 b'' | |||
|
81 | 84 | {name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]}, |
|
82 | 85 | {name: "mIRC", mime: "text/mirc", mode: "mirc"}, |
|
83 | 86 | {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"}, |
|
84 | {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]}, | |
|
87 | {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb", "wl", "wls"]}, | |
|
85 | 88 | {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]}, |
|
86 | {name: "MUMPS", mime: "text/x-mumps", mode: "mumps"}, | |
|
89 | {name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]}, | |
|
87 | 90 | {name: "MS SQL", mime: "text/x-mssql", mode: "sql"}, |
|
91 | {name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]}, | |
|
88 | 92 | {name: "MySQL", mime: "text/x-mysql", mode: "sql"}, |
|
89 | 93 | {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i}, |
|
90 | 94 | {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]}, |
|
91 | {name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]}, | |
|
92 | {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]}, | |
|
95 | {name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"], | |
|
96 | mode: "ntriples", ext: ["nt", "nq"]}, | |
|
97 | {name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m"], alias: ["objective-c", "objc"]}, | |
|
98 | {name: "Objective-C++", mime: "text/x-objectivec++", mode: "clike", ext: ["mm"], alias: ["objective-c++", "objc++"]}, | |
|
93 | 99 | {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]}, |
|
94 | 100 | {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]}, |
|
95 | 101 | {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]}, |
|
96 | 102 | {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]}, |
|
97 | 103 | {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]}, |
|
98 | 104 | {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]}, |
|
99 | {name: "PHP", mime: "application/x-httpd-php", mode: "php", ext: ["php", "php3", "php4", "php5", "phtml"]}, | |
|
105 | {name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]}, | |
|
100 | 106 | {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]}, |
|
101 | 107 | {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]}, |
|
102 | 108 | {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]}, |
|
109 | {name: "PostgreSQL", mime: "text/x-pgsql", mode: "sql"}, | |
|
110 | {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]}, | |
|
103 | 111 | {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]}, |
|
104 |
{name: "P |
|
|
112 | {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]}, | |
|
113 | {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/}, | |
|
105 | 114 | {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]}, |
|
106 | 115 | {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]}, |
|
107 | {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"], alias: ["rscript"]}, | |
|
116 | {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]}, | |
|
108 | 117 | {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]}, |
|
109 | 118 | {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"}, |
|
110 | 119 | {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]}, |
|
111 | 120 | {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]}, |
|
112 | 121 | {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]}, |
|
122 | {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]}, | |
|
113 | 123 | {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]}, |
|
114 | 124 | {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]}, |
|
115 | 125 | {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]}, |
|
116 | 126 | {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]}, |
|
117 | {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/}, | |
|
127 | {name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/}, | |
|
118 | 128 | {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]}, |
|
119 | 129 | {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]}, |
|
120 | 130 | {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]}, |
|
121 | 131 | {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]}, |
|
122 | 132 | {name: "Solr", mime: "text/x-solr", mode: "solr"}, |
|
133 | {name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"]}, | |
|
123 | 134 | {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]}, |
|
124 | 135 | {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]}, |
|
125 | 136 | {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]}, |
|
126 | 137 | {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]}, |
|
138 | {name: "SQLite", mime: "text/x-sqlite", mode: "sql"}, | |
|
127 | 139 | {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]}, |
|
140 | {name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]}, | |
|
128 | 141 | {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]}, |
|
129 | {name: "MariaDB", mime: "text/x-mariadb", mode: "sql"}, | |
|
130 | 142 | {name: "sTeX", mime: "text/x-stex", mode: "stex"}, |
|
131 | {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]}, | |
|
132 | {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]}, | |
|
143 | {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx", "tex"], alias: ["tex"]}, | |
|
144 | {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]}, | |
|
133 | 145 | {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]}, |
|
134 | 146 | {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]}, |
|
135 | 147 | {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"}, |
|
136 | 148 | {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"}, |
|
137 | 149 | {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]}, |
|
138 | 150 | {name: "Tornado", mime: "text/x-tornado", mode: "tornado"}, |
|
139 | {name: "troff", mime: "troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]}, | |
|
151 | {name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]}, | |
|
140 | 152 | {name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]}, |
|
141 | 153 | {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]}, |
|
142 | 154 | {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]}, |
|
143 | 155 | {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]}, |
|
156 | {name: "TypeScript-JSX", mime: "text/typescript-jsx", mode: "jsx", ext: ["tsx"], alias: ["tsx"]}, | |
|
144 | 157 | {name: "Twig", mime: "text/x-twig", mode: "twig"}, |
|
158 | {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]}, | |
|
145 | 159 | {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]}, |
|
146 | 160 | {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]}, |
|
147 | 161 | {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]}, |
|
148 | 162 | {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]}, |
|
149 | 163 | {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]}, |
|
150 | {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]}, | |
|
164 | {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]}, | |
|
165 | {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]}, | |
|
151 | 166 | {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]}, |
|
152 |
{name: "Y |
|
|
167 | {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]}, | |
|
168 | {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]}, | |
|
153 | 169 | {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}, |
|
154 | 170 | {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]}, |
|
155 | 171 | {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]}, |
@@ -169,6 +185,8 b'' | |||
|
169 | 185 | if (info.mimes) for (var j = 0; j < info.mimes.length; j++) |
|
170 | 186 | if (info.mimes[j] == mime) return info; |
|
171 | 187 | } |
|
188 | if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml") | |
|
189 | if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json") | |
|
172 | 190 | }; |
|
173 | 191 | |
|
174 | 192 | CodeMirror.findModeByExtension = function(ext) { |
@@ -36,7 +36,7 b' MIME_TO_EXT = {' | |||
|
36 | 36 | "application/x-ssp": {"exts": ["*.ssp"], "mode": ""}, |
|
37 | 37 | "application/x-troff": {"exts": ["*.[1234567]","*.man"], "mode": ""}, |
|
38 | 38 | "application/x-urbiscript": {"exts": ["*.u"], "mode": ""}, |
|
39 | "application/xml": {"exts": ["*.xml","*.xsl","*.rss","*.xslt","*.xsd","*.wsdl"], "mode": "xml"}, | |
|
39 | "application/xml": {"exts": ["*.xml","*.xsl","*.rss","*.xslt","*.xsd","*.wsdl","*.svg"], "mode": "xml"}, | |
|
40 | 40 | "application/xml+evoque": {"exts": ["*.xml"], "mode": ""}, |
|
41 | 41 | "application/xml-dtd": {"exts": ["*.dtd"], "mode": "dtd"}, |
|
42 | 42 | "application/xquery": {"exts": ["*.xqy","*.xquery","*.xq","*.xql","*.xqm","*.xy"], "mode": "xquery"}, |
@@ -48,7 +48,7 b' MIME_TO_EXT = {' | |||
|
48 | 48 | "text/coffeescript": {"exts": ["*.coffee"], "mode": ""}, |
|
49 | 49 | "text/css": {"exts": ["*.css"], "mode": "css"}, |
|
50 | 50 | "text/haxe": {"exts": ["*.hx"], "mode": ""}, |
|
51 | "text/html": {"exts": ["*.html","*.htm","*.xhtml","*.xslt"], "mode": "htmlmixed"}, | |
|
51 | "text/html": {"exts": ["*.html","*.htm","*.xhtml","*.xslt","*.handlebars","*.hbs"], "mode": "htmlmixed"}, | |
|
52 | 52 | "text/html+evoque": {"exts": ["*.html"], "mode": ""}, |
|
53 | 53 | "text/html+ruby": {"exts": ["*.rhtml"], "mode": ""}, |
|
54 | 54 | "text/idl": {"exts": ["*.pro"], "mode": ""}, |
@@ -80,7 +80,7 b' MIME_TO_EXT = {' | |||
|
80 | 80 | "text/x-c-objdump": {"exts": ["*.c-objdump"], "mode": ""}, |
|
81 | 81 | "text/x-ceylon": {"exts": ["*.ceylon"], "mode": ""}, |
|
82 | 82 | "text/x-chdr": {"exts": ["*.c","*.h","*.idc"], "mode": "clike"}, |
|
83 | "text/x-clojure": {"exts": ["*.clj"], "mode": "clojure"}, | |
|
83 | "text/x-clojure": {"exts": ["*.clj","*.cljc","*.cljx"], "mode": "clojure"}, | |
|
84 | 84 | "text/x-cmake": {"exts": ["*.cmake","CMakeLists.txt","*.cmake.in"], "mode": "cmake"}, |
|
85 | 85 | "text/x-cobol": {"exts": ["*.cob","*.COB","*.cpy","*.CPY"], "mode": "cobol"}, |
|
86 | 86 | "text/x-coffeescript": {"exts": ["*.coffee"], "mode": "coffeescript"}, |
@@ -89,7 +89,7 b' MIME_TO_EXT = {' | |||
|
89 | 89 | "text/x-cpp-objdump": {"exts": ["*.cpp-objdump","*.c++-objdump","*.cxx-objdump"], "mode": ""}, |
|
90 | 90 | "text/x-crocsrc": {"exts": ["*.croc"], "mode": ""}, |
|
91 | 91 | "text/x-csharp": {"exts": ["*.cs"], "mode": "clike"}, |
|
92 | "text/x-csrc": {"exts": ["*.c","*.h"], "mode": "clike"}, | |
|
92 | "text/x-csrc": {"exts": ["*.c","*.h","*.ino"], "mode": "clike"}, | |
|
93 | 93 | "text/x-cuda": {"exts": ["*.cu","*.cuh"], "mode": ""}, |
|
94 | 94 | "text/x-cython": {"exts": ["*.pyx","*.pxd","*.pxi"], "mode": "python"}, |
|
95 | 95 | "text/x-d": {"exts": ["*.d"], "mode": "d"}, |
@@ -110,7 +110,7 b' MIME_TO_EXT = {' | |||
|
110 | 110 | "text/x-factor": {"exts": ["*.factor"], "mode": "factor"}, |
|
111 | 111 | "text/x-fancysrc": {"exts": ["*.fy","*.fancypack"], "mode": ""}, |
|
112 | 112 | "text/x-felix": {"exts": ["*.flx","*.flxh"], "mode": ""}, |
|
113 | "text/x-fortran": {"exts": ["*.f","*.f90","*.F","*.F90","*.for","*.f77"], "mode": "fortran"}, | |
|
113 | "text/x-fortran": {"exts": ["*.f","*.f90","*.F","*.F90","*.for","*.f77","*.f95"], "mode": "fortran"}, | |
|
114 | 114 | "text/x-fsharp": {"exts": ["*.fs","*.fsi"], "mode": "mllike"}, |
|
115 | 115 | "text/x-gas": {"exts": ["*.s","*.S"], "mode": "gas"}, |
|
116 | 116 | "text/x-gfm": {"exts": ["*.md","*.MD"], "mode": "gfm"}, |
@@ -123,7 +123,7 b' MIME_TO_EXT = {' | |||
|
123 | 123 | "text/x-gosrc": {"exts": ["*.go"], "mode": ""}, |
|
124 | 124 | "text/x-gosu": {"exts": ["*.gs","*.gsx","*.gsp","*.vark"], "mode": ""}, |
|
125 | 125 | "text/x-gosu-template": {"exts": ["*.gst"], "mode": ""}, |
|
126 | "text/x-groovy": {"exts": ["*.groovy"], "mode": "groovy"}, | |
|
126 | "text/x-groovy": {"exts": ["*.groovy","*.gradle"], "mode": "groovy"}, | |
|
127 | 127 | "text/x-haml": {"exts": ["*.haml"], "mode": "haml"}, |
|
128 | 128 | "text/x-haskell": {"exts": ["*.hs"], "mode": "haskell"}, |
|
129 | 129 | "text/x-haxe": {"exts": ["*.hx"], "mode": "haxe"}, |
@@ -139,7 +139,7 b' MIME_TO_EXT = {' | |||
|
139 | 139 | "text/x-koka": {"exts": ["*.kk","*.kki"], "mode": ""}, |
|
140 | 140 | "text/x-kotlin": {"exts": ["*.kt"], "mode": "clike"}, |
|
141 | 141 | "text/x-lasso": {"exts": ["*.lasso","*.lasso[89]"], "mode": ""}, |
|
142 | "text/x-latex": {"exts": ["*.ltx","*.text"], "mode": "stex"}, | |
|
142 | "text/x-latex": {"exts": ["*.ltx","*.text","*.tex"], "mode": "stex"}, | |
|
143 | 143 | "text/x-less": {"exts": ["*.less"], "mode": "css"}, |
|
144 | 144 | "text/x-literate-haskell": {"exts": ["*.lhs"], "mode": "haskell-literate"}, |
|
145 | 145 | "text/x-livescript": {"exts": ["*.ls"], "mode": "livescript"}, |
@@ -173,13 +173,13 b' MIME_TO_EXT = {' | |||
|
173 | 173 | "text/x-openedge": {"exts": ["*.p","*.cls"], "mode": ""}, |
|
174 | 174 | "text/x-pascal": {"exts": ["*.pas","*.p"], "mode": "pascal"}, |
|
175 | 175 | "text/x-perl": {"exts": ["*.pl","*.pm"], "mode": "perl"}, |
|
176 | "text/x-php": {"exts": ["*.php","*.php[345]","*.inc"], "mode": "php"}, | |
|
176 | "text/x-php": {"exts": ["*.php","*.php[345]","*.inc","*.php3","*.php4","*.php5","*.php7","*.phtml"], "mode": "php"}, | |
|
177 | 177 | "text/x-pig": {"exts": ["*.pig"], "mode": "pig"}, |
|
178 | 178 | "text/x-povray": {"exts": ["*.pov","*.inc"], "mode": ""}, |
|
179 | 179 | "text/x-powershell": {"exts": ["*.ps1"], "mode": ""}, |
|
180 | 180 | "text/x-prolog": {"exts": ["*.prolog","*.pro","*.pl"], "mode": ""}, |
|
181 | 181 | "text/x-properties": {"exts": ["*.properties","*.ini","*.in"], "mode": "properties"}, |
|
182 | "text/x-python": {"exts": ["*.py","*.pyw","*.sc","SConstruct","SConscript","*.tac","*.sage"], "mode": "python"}, | |
|
182 | "text/x-python": {"exts": ["*.py","*.pyw","*.sc","SConstruct","SConscript","*.tac","*.sage","*.BUILD","*.bzl"], "mode": "python"}, | |
|
183 | 183 | "text/x-python-traceback": {"exts": ["*.pytb"], "mode": ""}, |
|
184 | 184 | "text/x-python3-traceback": {"exts": ["*.py3tb"], "mode": ""}, |
|
185 | 185 | "text/x-r-doc": {"exts": ["*.Rd"], "mode": ""}, |
@@ -187,7 +187,7 b' MIME_TO_EXT = {' | |||
|
187 | 187 | "text/x-rebol": {"exts": ["*.r","*.r3"], "mode": ""}, |
|
188 | 188 | "text/x-robotframework": {"exts": ["*.txt","*.robot"], "mode": ""}, |
|
189 | 189 | "text/x-rpm-spec": {"exts": ["*.spec"], "mode": "rpm"}, |
|
190 | "text/x-rsrc": {"exts": ["*.r"], "mode": "r"}, | |
|
190 | "text/x-rsrc": {"exts": ["*.r","*.R"], "mode": "r"}, | |
|
191 | 191 | "text/x-rst": {"exts": ["*.rst","*.rest"], "mode": "rst"}, |
|
192 | 192 | "text/x-ruby": {"exts": ["*.rb","*.rbw","Rakefile","*.rake","*.gemspec","*.rbx","*.duby"], "mode": "ruby"}, |
|
193 | 193 | "text/x-rustsrc": {"exts": ["*.rs","*.rc"], "mode": "rust"}, |
@@ -224,7 +224,7 b' MIME_TO_EXT = {' | |||
|
224 | 224 | "text/x-yaml": {"exts": ["*.yaml","*.yml"], "mode": "yaml"}, |
|
225 | 225 | "text/x-z80": {"exts": ["*.z80"], "mode": "z80"}, |
|
226 | 226 | "text/xml": {"exts": ["*.xml","*.xsl","*.rss","*.xslt","*.xsd","*.wsdl"], "mode": ""}, |
|
227 | "text/xquery": {"exts": ["*.xqy","*.xquery","*.xq","*.xql","*.xqm"], "mode": ""} | |
|
227 | "text/xquery": {"exts": ["*.xqy","*.xquery","*.xq","*.xql","*.xqm"], "mode": ""}, | |
|
228 | 228 | }; |
|
229 | 229 | |
|
230 | 230 | /* Special case for overriding mode by file extensions |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | //mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara |
|
5 | 5 | |
@@ -130,7 +130,7 b' CodeMirror.defineMode("mirc", function()' | |||
|
130 | 130 | } |
|
131 | 131 | } |
|
132 | 132 | else if (ch == "%") { |
|
133 |
stream.eatWhile(/[^, |
|
|
133 | stream.eatWhile(/[^,\s()]/); | |
|
134 | 134 | state.beforeParams = true; |
|
135 | 135 | return "string"; |
|
136 | 136 | } |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -13,31 +13,26 b'' | |||
|
13 | 13 | |
|
14 | 14 | CodeMirror.defineMode('mllike', function(_config, parserConfig) { |
|
15 | 15 | var words = { |
|
16 |
' |
|
|
17 | 'rec': 'keyword', | |
|
18 | 'in': 'keyword', | |
|
19 | 'of': 'keyword', | |
|
20 | 'and': 'keyword', | |
|
21 | 'if': 'keyword', | |
|
22 | 'then': 'keyword', | |
|
23 | 'else': 'keyword', | |
|
24 | 'for': 'keyword', | |
|
25 | 'to': 'keyword', | |
|
26 | 'while': 'keyword', | |
|
16 | 'as': 'keyword', | |
|
27 | 17 | 'do': 'keyword', |
|
28 |
' |
|
|
18 | 'else': 'keyword', | |
|
19 | 'end': 'keyword', | |
|
20 | 'exception': 'keyword', | |
|
29 | 21 | 'fun': 'keyword', |
|
30 |
'funct |
|
|
31 |
' |
|
|
22 | 'functor': 'keyword', | |
|
23 | 'if': 'keyword', | |
|
24 | 'in': 'keyword', | |
|
25 | 'include': 'keyword', | |
|
26 | 'let': 'keyword', | |
|
27 | 'of': 'keyword', | |
|
28 | 'open': 'keyword', | |
|
29 | 'rec': 'keyword', | |
|
30 | 'struct': 'keyword', | |
|
31 | 'then': 'keyword', | |
|
32 | 32 | 'type': 'keyword', |
|
33 |
' |
|
|
34 |
' |
|
|
35 |
'with': 'keyword' |
|
|
36 | 'try': 'keyword', | |
|
37 | 'open': 'builtin', | |
|
38 | 'ignore': 'builtin', | |
|
39 | 'begin': 'keyword', | |
|
40 | 'end': 'keyword' | |
|
33 | 'val': 'keyword', | |
|
34 | 'while': 'keyword', | |
|
35 | 'with': 'keyword' | |
|
41 | 36 | }; |
|
42 | 37 | |
|
43 | 38 | var extraWords = parserConfig.extraWords || {}; |
@@ -46,6 +41,9 b" CodeMirror.defineMode('mllike', function" | |||
|
46 | 41 | words[prop] = parserConfig.extraWords[prop]; |
|
47 | 42 | } |
|
48 | 43 | } |
|
44 | var hintWords = []; | |
|
45 | for (var k in words) { hintWords.push(k); } | |
|
46 | CodeMirror.registerHelper("hintWords", "mllike", hintWords); | |
|
49 | 47 | |
|
50 | 48 | function tokenBase(stream, state) { |
|
51 | 49 | var ch = stream.next(); |
@@ -54,6 +52,13 b" CodeMirror.defineMode('mllike', function" | |||
|
54 | 52 | state.tokenize = tokenString; |
|
55 | 53 | return state.tokenize(stream, state); |
|
56 | 54 | } |
|
55 | if (ch === '{') { | |
|
56 | if (stream.eat('|')) { | |
|
57 | state.longString = true; | |
|
58 | state.tokenize = tokenLongString; | |
|
59 | return state.tokenize(stream, state); | |
|
60 | } | |
|
61 | } | |
|
57 | 62 | if (ch === '(') { |
|
58 | 63 | if (stream.eat('*')) { |
|
59 | 64 | state.commentLevel++; |
@@ -61,7 +66,7 b" CodeMirror.defineMode('mllike', function" | |||
|
61 | 66 | return state.tokenize(stream, state); |
|
62 | 67 | } |
|
63 | 68 | } |
|
64 | if (ch === '~') { | |
|
69 | if (ch === '~' || ch === '?') { | |
|
65 | 70 | stream.eatWhile(/\w/); |
|
66 | 71 | return 'variable-2'; |
|
67 | 72 | } |
@@ -74,18 +79,32 b" CodeMirror.defineMode('mllike', function" | |||
|
74 | 79 | return 'comment'; |
|
75 | 80 | } |
|
76 | 81 | if (/\d/.test(ch)) { |
|
77 | stream.eatWhile(/[\d]/); | |
|
78 |
|
|
|
79 |
stream.eat |
|
|
82 | if (ch === '0' && stream.eat(/[bB]/)) { | |
|
83 | stream.eatWhile(/[01]/); | |
|
84 | } if (ch === '0' && stream.eat(/[xX]/)) { | |
|
85 | stream.eatWhile(/[0-9a-fA-F]/) | |
|
86 | } if (ch === '0' && stream.eat(/[oO]/)) { | |
|
87 | stream.eatWhile(/[0-7]/); | |
|
88 | } else { | |
|
89 | stream.eatWhile(/[\d_]/); | |
|
90 | if (stream.eat('.')) { | |
|
91 | stream.eatWhile(/[\d]/); | |
|
92 | } | |
|
93 | if (stream.eat(/[eE]/)) { | |
|
94 | stream.eatWhile(/[\d\-+]/); | |
|
95 | } | |
|
80 | 96 | } |
|
81 | 97 | return 'number'; |
|
82 | 98 | } |
|
83 | if ( /[+\-*&%=<>!?|]/.test(ch)) { | |
|
99 | if ( /[+\-*&%=<>!?|@\.~:]/.test(ch)) { | |
|
84 | 100 | return 'operator'; |
|
85 | 101 | } |
|
86 | stream.eatWhile(/\w/); | |
|
87 | var cur = stream.current(); | |
|
88 | return words.hasOwnProperty(cur) ? words[cur] : 'variable'; | |
|
102 | if (/[\w\xa1-\uffff]/.test(ch)) { | |
|
103 | stream.eatWhile(/[\w\xa1-\uffff]/); | |
|
104 | var cur = stream.current(); | |
|
105 | return words.hasOwnProperty(cur) ? words[cur] : 'variable'; | |
|
106 | } | |
|
107 | return null | |
|
89 | 108 | } |
|
90 | 109 | |
|
91 | 110 | function tokenString(stream, state) { |
@@ -116,8 +135,20 b" CodeMirror.defineMode('mllike', function" | |||
|
116 | 135 | return 'comment'; |
|
117 | 136 | } |
|
118 | 137 | |
|
138 | function tokenLongString(stream, state) { | |
|
139 | var prev, next; | |
|
140 | while (state.longString && (next = stream.next()) != null) { | |
|
141 | if (prev === '|' && next === '}') state.longString = false; | |
|
142 | prev = next; | |
|
143 | } | |
|
144 | if (!state.longString) { | |
|
145 | state.tokenize = tokenBase; | |
|
146 | } | |
|
147 | return 'string'; | |
|
148 | } | |
|
149 | ||
|
119 | 150 | return { |
|
120 | startState: function() {return {tokenize: tokenBase, commentLevel: 0};}, | |
|
151 | startState: function() {return {tokenize: tokenBase, commentLevel: 0, longString: false};}, | |
|
121 | 152 | token: function(stream, state) { |
|
122 | 153 | if (stream.eatSpace()) return null; |
|
123 | 154 | return state.tokenize(stream, state); |
@@ -132,14 +163,64 b" CodeMirror.defineMode('mllike', function" | |||
|
132 | 163 | CodeMirror.defineMIME('text/x-ocaml', { |
|
133 | 164 | name: 'mllike', |
|
134 | 165 | extraWords: { |
|
135 |
' |
|
|
166 | 'and': 'keyword', | |
|
167 | 'assert': 'keyword', | |
|
168 | 'begin': 'keyword', | |
|
169 | 'class': 'keyword', | |
|
170 | 'constraint': 'keyword', | |
|
171 | 'done': 'keyword', | |
|
172 | 'downto': 'keyword', | |
|
173 | 'external': 'keyword', | |
|
174 | 'function': 'keyword', | |
|
175 | 'initializer': 'keyword', | |
|
176 | 'lazy': 'keyword', | |
|
177 | 'match': 'keyword', | |
|
178 | 'method': 'keyword', | |
|
179 | 'module': 'keyword', | |
|
180 | 'mutable': 'keyword', | |
|
181 | 'new': 'keyword', | |
|
182 | 'nonrec': 'keyword', | |
|
183 | 'object': 'keyword', | |
|
184 | 'private': 'keyword', | |
|
185 | 'sig': 'keyword', | |
|
186 | 'to': 'keyword', | |
|
187 | 'try': 'keyword', | |
|
188 | 'value': 'keyword', | |
|
189 | 'virtual': 'keyword', | |
|
190 | 'when': 'keyword', | |
|
191 | ||
|
192 | // builtins | |
|
193 | 'raise': 'builtin', | |
|
194 | 'failwith': 'builtin', | |
|
195 | 'true': 'builtin', | |
|
196 | 'false': 'builtin', | |
|
197 | ||
|
198 | // Pervasives builtins | |
|
199 | 'asr': 'builtin', | |
|
200 | 'land': 'builtin', | |
|
201 | 'lor': 'builtin', | |
|
202 | 'lsl': 'builtin', | |
|
203 | 'lsr': 'builtin', | |
|
204 | 'lxor': 'builtin', | |
|
205 | 'mod': 'builtin', | |
|
206 | 'or': 'builtin', | |
|
207 | ||
|
208 | // More Pervasives | |
|
209 | 'raise_notrace': 'builtin', | |
|
136 | 210 | 'trace': 'builtin', |
|
137 | 211 | 'exit': 'builtin', |
|
138 | 212 | 'print_string': 'builtin', |
|
139 | 213 | 'print_endline': 'builtin', |
|
140 | 'true': 'atom', | |
|
141 |
|
|
|
142 | 'raise': 'keyword' | |
|
214 | ||
|
215 | 'int': 'type', | |
|
216 | 'float': 'type', | |
|
217 | 'bool': 'type', | |
|
218 | 'char': 'type', | |
|
219 | 'string': 'type', | |
|
220 | 'unit': 'type', | |
|
221 | ||
|
222 | // Modules | |
|
223 | 'List': 'builtin' | |
|
143 | 224 | } |
|
144 | 225 | }); |
|
145 | 226 | |
@@ -147,18 +228,21 b" CodeMirror.defineMIME('text/x-fsharp', {" | |||
|
147 | 228 | name: 'mllike', |
|
148 | 229 | extraWords: { |
|
149 | 230 | 'abstract': 'keyword', |
|
150 | 'as': 'keyword', | |
|
151 | 231 | 'assert': 'keyword', |
|
152 | 232 | 'base': 'keyword', |
|
233 | 'begin': 'keyword', | |
|
153 | 234 | 'class': 'keyword', |
|
154 | 235 | 'default': 'keyword', |
|
155 | 236 | 'delegate': 'keyword', |
|
237 | 'do!': 'keyword', | |
|
238 | 'done': 'keyword', | |
|
156 | 239 | 'downcast': 'keyword', |
|
157 | 240 | 'downto': 'keyword', |
|
158 | 241 | 'elif': 'keyword', |
|
159 | 'exception': 'keyword', | |
|
160 | 242 | 'extern': 'keyword', |
|
161 | 243 | 'finally': 'keyword', |
|
244 | 'for': 'keyword', | |
|
245 | 'function': 'keyword', | |
|
162 | 246 | 'global': 'keyword', |
|
163 | 247 | 'inherit': 'keyword', |
|
164 | 248 | 'inline': 'keyword', |
@@ -166,38 +250,108 b" CodeMirror.defineMIME('text/x-fsharp', {" | |||
|
166 | 250 | 'internal': 'keyword', |
|
167 | 251 | 'lazy': 'keyword', |
|
168 | 252 | 'let!': 'keyword', |
|
169 |
'm |
|
|
253 | 'match': 'keyword', | |
|
254 | 'member': 'keyword', | |
|
170 | 255 | 'module': 'keyword', |
|
256 | 'mutable': 'keyword', | |
|
171 | 257 | 'namespace': 'keyword', |
|
172 | 258 | 'new': 'keyword', |
|
173 | 259 | 'null': 'keyword', |
|
174 | 260 | 'override': 'keyword', |
|
175 | 261 | 'private': 'keyword', |
|
176 | 262 | 'public': 'keyword', |
|
263 | 'return!': 'keyword', | |
|
177 | 264 | 'return': 'keyword', |
|
178 | 'return!': 'keyword', | |
|
179 | 265 | 'select': 'keyword', |
|
180 | 266 | 'static': 'keyword', |
|
181 |
' |
|
|
267 | 'to': 'keyword', | |
|
268 | 'try': 'keyword', | |
|
182 | 269 | 'upcast': 'keyword', |
|
183 | 'use': 'keyword', | |
|
184 | 270 | 'use!': 'keyword', |
|
185 |
' |
|
|
271 | 'use': 'keyword', | |
|
272 | 'void': 'keyword', | |
|
186 | 273 | 'when': 'keyword', |
|
274 | 'yield!': 'keyword', | |
|
187 | 275 | 'yield': 'keyword', |
|
188 | 'yield!': 'keyword', | |
|
189 | 276 | |
|
277 | // Reserved words | |
|
278 | 'atomic': 'keyword', | |
|
279 | 'break': 'keyword', | |
|
280 | 'checked': 'keyword', | |
|
281 | 'component': 'keyword', | |
|
282 | 'const': 'keyword', | |
|
283 | 'constraint': 'keyword', | |
|
284 | 'constructor': 'keyword', | |
|
285 | 'continue': 'keyword', | |
|
286 | 'eager': 'keyword', | |
|
287 | 'event': 'keyword', | |
|
288 | 'external': 'keyword', | |
|
289 | 'fixed': 'keyword', | |
|
290 | 'method': 'keyword', | |
|
291 | 'mixin': 'keyword', | |
|
292 | 'object': 'keyword', | |
|
293 | 'parallel': 'keyword', | |
|
294 | 'process': 'keyword', | |
|
295 | 'protected': 'keyword', | |
|
296 | 'pure': 'keyword', | |
|
297 | 'sealed': 'keyword', | |
|
298 | 'tailcall': 'keyword', | |
|
299 | 'trait': 'keyword', | |
|
300 | 'virtual': 'keyword', | |
|
301 | 'volatile': 'keyword', | |
|
302 | ||
|
303 | // builtins | |
|
190 | 304 | 'List': 'builtin', |
|
191 | 305 | 'Seq': 'builtin', |
|
192 | 306 | 'Map': 'builtin', |
|
193 | 307 | 'Set': 'builtin', |
|
308 | 'Option': 'builtin', | |
|
194 | 309 | 'int': 'builtin', |
|
195 | 310 | 'string': 'builtin', |
|
196 | 'raise': 'builtin', | |
|
197 | 'failwith': 'builtin', | |
|
198 | 311 | 'not': 'builtin', |
|
199 | 312 | 'true': 'builtin', |
|
200 | 'false': 'builtin' | |
|
313 | 'false': 'builtin', | |
|
314 | ||
|
315 | 'raise': 'builtin', | |
|
316 | 'failwith': 'builtin' | |
|
317 | }, | |
|
318 | slashComments: true | |
|
319 | }); | |
|
320 | ||
|
321 | ||
|
322 | CodeMirror.defineMIME('text/x-sml', { | |
|
323 | name: 'mllike', | |
|
324 | extraWords: { | |
|
325 | 'abstype': 'keyword', | |
|
326 | 'and': 'keyword', | |
|
327 | 'andalso': 'keyword', | |
|
328 | 'case': 'keyword', | |
|
329 | 'datatype': 'keyword', | |
|
330 | 'fn': 'keyword', | |
|
331 | 'handle': 'keyword', | |
|
332 | 'infix': 'keyword', | |
|
333 | 'infixr': 'keyword', | |
|
334 | 'local': 'keyword', | |
|
335 | 'nonfix': 'keyword', | |
|
336 | 'op': 'keyword', | |
|
337 | 'orelse': 'keyword', | |
|
338 | 'raise': 'keyword', | |
|
339 | 'withtype': 'keyword', | |
|
340 | 'eqtype': 'keyword', | |
|
341 | 'sharing': 'keyword', | |
|
342 | 'sig': 'keyword', | |
|
343 | 'signature': 'keyword', | |
|
344 | 'structure': 'keyword', | |
|
345 | 'where': 'keyword', | |
|
346 | 'true': 'keyword', | |
|
347 | 'false': 'keyword', | |
|
348 | ||
|
349 | // types | |
|
350 | 'int': 'builtin', | |
|
351 | 'real': 'builtin', | |
|
352 | 'string': 'builtin', | |
|
353 | 'char': 'builtin', | |
|
354 | 'bool': 'builtin' | |
|
201 | 355 | }, |
|
202 | 356 | slashComments: true |
|
203 | 357 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // Modelica support for CodeMirror, copyright (c) by Lennart Ochel |
|
5 | 5 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // mode(s) for the sequence chart dsl's mscgen, xù and msgenny |
|
5 | 5 | // For more information on mscgen, see the site of the original author: |
@@ -23,6 +23,7 b'' | |||
|
23 | 23 | mscgen: { |
|
24 | 24 | "keywords" : ["msc"], |
|
25 | 25 | "options" : ["hscale", "width", "arcgradient", "wordwraparcs"], |
|
26 | "constants" : ["true", "false", "on", "off"], | |
|
26 | 27 | "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"], |
|
27 | 28 | "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists |
|
28 | 29 | "arcsWords" : ["note", "abox", "rbox", "box"], |
@@ -31,9 +32,10 b'' | |||
|
31 | 32 | "operators" : ["="] |
|
32 | 33 | }, |
|
33 | 34 | xu: { |
|
34 | "keywords" : ["msc"], | |
|
35 | "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], | |
|
36 | "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"], | |
|
35 | "keywords" : ["msc", "xu"], | |
|
36 | "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"], | |
|
37 | "constants" : ["true", "false", "on", "off", "auto"], | |
|
38 | "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip", "title", "deactivate", "activate", "activation"], | |
|
37 | 39 | "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists |
|
38 | 40 | "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"], |
|
39 | 41 | "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"], |
@@ -42,7 +44,8 b'' | |||
|
42 | 44 | }, |
|
43 | 45 | msgenny: { |
|
44 | 46 | "keywords" : null, |
|
45 | "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], | |
|
47 | "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"], | |
|
48 | "constants" : ["true", "false", "on", "off", "auto"], | |
|
46 | 49 | "attributes" : null, |
|
47 | 50 | "brackets" : ["\\{", "\\}"], |
|
48 | 51 | "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"], |
@@ -146,6 +149,9 b'' | |||
|
146 | 149 | if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true)) |
|
147 | 150 | return "operator"; |
|
148 | 151 | |
|
152 | if (!!pConfig.constants && pStream.match(wordRegexp(pConfig.constants), true, true)) | |
|
153 | return "variable"; | |
|
154 | ||
|
149 | 155 | /* attribute lists */ |
|
150 | 156 | if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) { |
|
151 | 157 | pConfig.inAttributeList = true; |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function() { |
|
5 | 5 | var mode = CodeMirror.getMode({indentUnit: 2}, "mscgen"); |
@@ -26,9 +26,18 b'' | |||
|
26 | 26 | |
|
27 | 27 | MT("xù/ msgenny keywords classify as 'base'", |
|
28 | 28 | "[base watermark]", |
|
29 | "[base wordwrapentities]", | |
|
29 | 30 | "[base alt loop opt ref else break par seq assert]" |
|
30 | 31 | ); |
|
31 | 32 | |
|
33 | MT("xù/ msgenny constants classify as 'base'", | |
|
34 | "[base auto]" | |
|
35 | ); | |
|
36 | ||
|
37 | MT("mscgen constants classify as 'variable'", | |
|
38 | "[variable true]", "[variable false]", "[variable on]", "[variable off]" | |
|
39 | ); | |
|
40 | ||
|
32 | 41 | MT("mscgen options classify as keyword", |
|
33 | 42 | "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" |
|
34 | 43 | ); |
@@ -63,7 +72,7 b'' | |||
|
63 | 72 | MT("a typical program", |
|
64 | 73 | "[comment # typical mscgen program]", |
|
65 | 74 | "[keyword msc][base ][bracket {]", |
|
66 |
"[keyword wordwraparcs][operator =][ |
|
|
75 | "[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", | |
|
67 | 76 | "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", |
|
68 | 77 | "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", |
|
69 | 78 | "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function() { |
|
5 | 5 | var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-msgenny"); |
@@ -20,9 +20,15 b'' | |||
|
20 | 20 | |
|
21 | 21 | MT("xù/ msgenny keywords classify as 'keyword'", |
|
22 | 22 | "[keyword watermark]", |
|
23 | "[keyword wordwrapentities]", | |
|
23 | 24 | "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" |
|
24 | 25 | ); |
|
25 | 26 | |
|
27 | MT("xù/ msgenny constants classify as 'variable'", | |
|
28 | "[variable auto]", | |
|
29 | "[variable true]", "[variable false]", "[variable on]", "[variable off]" | |
|
30 | ); | |
|
31 | ||
|
26 | 32 | MT("mscgen options classify as keyword", |
|
27 | 33 | "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" |
|
28 | 34 | ); |
@@ -56,7 +62,7 b'' | |||
|
56 | 62 | |
|
57 | 63 | MT("a typical program", |
|
58 | 64 | "[comment # typical msgenny program]", |
|
59 |
"[keyword wordwraparcs][operator =][ |
|
|
65 | "[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", | |
|
60 | 66 | "[base a : ][string \"Entity A\"][base ,]", |
|
61 | 67 | "[base b : Entity B,]", |
|
62 | 68 | "[base c : Entity C;]", |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function() { |
|
5 | 5 | var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-xu"); |
@@ -9,7 +9,13 b'' | |||
|
9 | 9 | "[keyword msc][bracket {]", |
|
10 | 10 | "[base ]", |
|
11 | 11 | "[bracket }]" |
|
12 |
|
|
|
12 | ); | |
|
13 | ||
|
14 | MT("empty chart", | |
|
15 | "[keyword xu][bracket {]", | |
|
16 | "[base ]", | |
|
17 | "[bracket }]" | |
|
18 | ); | |
|
13 | 19 | |
|
14 | 20 | MT("comments", |
|
15 | 21 | "[comment // a single line comment]", |
@@ -29,6 +35,11 b'' | |||
|
29 | 35 | "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" |
|
30 | 36 | ); |
|
31 | 37 | |
|
38 | MT("xù/ msgenny constants classify as 'variable'", | |
|
39 | "[variable auto]", | |
|
40 | "[variable true]", "[variable false]", "[variable on]", "[variable off]" | |
|
41 | ); | |
|
42 | ||
|
32 | 43 | MT("mscgen options classify as keyword", |
|
33 | 44 | "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" |
|
34 | 45 | ); |
@@ -49,7 +60,8 b'' | |||
|
49 | 60 | "[attribute id]","[attribute url]","[attribute idurl]", |
|
50 | 61 | "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]", |
|
51 | 62 | "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]", |
|
52 |
"[attribute arcskip] |
|
|
63 | "[attribute arcskip]","[attribute title]", | |
|
64 | "[attribute activate]","[attribute deactivate]","[attribute activation][bracket ]]]" | |
|
53 | 65 | ); |
|
54 | 66 | |
|
55 | 67 | MT("outside an attribute list, attributes classify as base", |
@@ -57,18 +69,18 b'' | |||
|
57 | 69 | "[base id]","[base url]","[base idurl]", |
|
58 | 70 | "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]", |
|
59 | 71 | "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]", |
|
60 | "[base arcskip]" | |
|
72 | "[base arcskip]", "[base title]" | |
|
61 | 73 | ); |
|
62 | 74 | |
|
63 | 75 | MT("a typical program", |
|
64 |
"[comment # typical |
|
|
65 |
"[keyword |
|
|
66 | "[keyword wordwraparcs][operator =][string \"true\"][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]", | |
|
76 | "[comment # typical xu program]", | |
|
77 | "[keyword xu][base ][bracket {]", | |
|
78 | "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30, ][keyword width][operator =][variable auto][base ;]", | |
|
67 | 79 | "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", |
|
68 | 80 | "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", |
|
69 | 81 | "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", |
|
70 | 82 | "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]", |
|
71 | "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]", | |
|
83 | "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][base , ][attribute title][operator =][string \"This is a title for this message\"][bracket ]]][base ;]", | |
|
72 | 84 | "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]", |
|
73 | 85 | "[bracket }]" |
|
74 | 86 | ); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /* |
|
5 | 5 | This MUMPS Language script was constructed using vbscript.js as a template. |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // Author: Jan T. Sott (http://github.com/idleberg) |
|
5 | 5 | |
@@ -24,20 +24,20 b' CodeMirror.defineSimpleMode("nsis",{' | |||
|
24 | 24 | { regex: /`(?:[^\\`]|\\.)*`?/, token: "string" }, |
|
25 | 25 | |
|
26 | 26 | // Compile Time Commands |
|
27 | {regex: /(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|finalize|getdllversion|system|tempfile|warning|verbose|define|undef|insertmacro|makensis|searchparse|searchreplace))\b/, token: "keyword"}, | |
|
27 | {regex: /^\s*(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|pragma|finalize|getdllversion|gettlbversion|system|tempfile|warning|verbose|define|undef|insertmacro|macro|macroend|makensis|searchparse|searchreplace))\b/, token: "keyword"}, | |
|
28 | 28 | |
|
29 | 29 | // Conditional Compilation |
|
30 | {regex: /(?:\!(if(?:n?def)?|ifmacron?def|macro))\b/, token: "keyword", indent: true}, | |
|
31 | {regex: /(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true}, | |
|
30 | {regex: /^\s*(?:\!(if(?:n?def)?|ifmacron?def|macro))\b/, token: "keyword", indent: true}, | |
|
31 | {regex: /^\s*(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true}, | |
|
32 | 32 | |
|
33 | 33 | // Runtime Commands |
|
34 |
{regex: / |
|
|
35 |
{regex: / |
|
|
36 |
{regex: / |
|
|
34 | {regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|Int64Cmp|Int64CmpU|Int64Fmt|IntCmp|IntCmpU|IntFmt|IntOp|IntPtrCmp|IntPtrCmpU|IntPtrOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEDllCharacteristics|PESubsysVer|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, | |
|
35 | {regex: /^\s*(?:Function|PageEx|Section(?:Group)?)\b/, token: "keyword", indent: true}, | |
|
36 | {regex: /^\s*(?:(Function|PageEx|Section(?:Group)?)End)\b/, token: "keyword", dedent: true}, | |
|
37 | 37 | |
|
38 | 38 | // Command Options |
|
39 | {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"}, | |
|
40 | {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|right|show|silent|silentlog|textonly|top|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"}, | |
|
39 | {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR(32|64)?|HKCU(32|64)?|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM(32|64)?|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"}, | |
|
40 | {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|false|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|off|on|right|show|silent|silentlog|textonly|top|true|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"}, | |
|
41 | 41 | |
|
42 | 42 | // LogicLib.nsh |
|
43 | 43 | {regex: /\$\{(?:And(?:If(?:Not)?|Unless)|Break|Case(?:Else)?|Continue|Default|Do(?:Until|While)?|Else(?:If(?:Not)?|Unless)?|End(?:If|Select|Switch)|Exit(?:Do|For|While)|For(?:Each)?|If(?:Cmd|Not(?:Then)?|Then)?|Loop(?:Until|While)?|Or(?:If(?:Not)?|Unless)|Select|Switch|Unless|While)\}/, token: "variable-2", indent: true}, |
@@ -71,13 +71,13 b' CodeMirror.defineSimpleMode("nsis",{' | |||
|
71 | 71 | {regex: /[-+\/*=<>!]+/, token: "operator"}, |
|
72 | 72 | |
|
73 | 73 | // Variable |
|
74 |
{regex: /\$ |
|
|
74 | {regex: /\$\w+/, token: "variable"}, | |
|
75 | 75 | |
|
76 | 76 | // Constant |
|
77 | {regex: /\${[\w]+}/,token: "variable-2"}, | |
|
77 | {regex: /\${[\w\.:-]+}/, token: "variable-2"}, | |
|
78 | 78 | |
|
79 | 79 | // Language String |
|
80 | {regex: /\$\([\w]+\)/,token: "variable-3"} | |
|
80 | {regex: /\$\([\w\.:-]+\)/, token: "variable-3"} | |
|
81 | 81 | ], |
|
82 | 82 | comment: [ |
|
83 | 83 | {regex: /.*?\*\//, token: "comment", next: "start"}, |
@@ -1,11 +1,11 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /********************************************************** |
|
5 | 5 | * This script provides syntax highlighting support for |
|
6 |
* the N |
|
|
7 |
* N |
|
|
8 |
* http://www.w3.org/TR/ |
|
|
6 | * the N-Triples format. | |
|
7 | * N-Triples format specification: | |
|
8 | * https://www.w3.org/TR/n-triples/ | |
|
9 | 9 | ***********************************************************/ |
|
10 | 10 | |
|
11 | 11 | /* |
@@ -181,6 +181,15 b' CodeMirror.defineMode("ntriples", functi' | |||
|
181 | 181 | }; |
|
182 | 182 | }); |
|
183 | 183 | |
|
184 | // define the registered Media Type for n-triples: | |
|
185 | // https://www.w3.org/TR/n-triples/#n-triples-mediatype | |
|
186 | CodeMirror.defineMIME("application/n-triples", "ntriples"); | |
|
187 | ||
|
188 | // N-Quads is based on the N-Triples format (so same highlighting works) | |
|
189 | // https://www.w3.org/TR/n-quads/ | |
|
190 | CodeMirror.defineMIME("application/n-quads", "ntriples"); | |
|
191 | ||
|
192 | // previously used, though technically incorrect media type for n-triples | |
|
184 | 193 | CodeMirror.defineMIME("text/n-triples", "ntriples"); |
|
185 | 194 | |
|
186 | 195 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -17,7 +17,7 b' CodeMirror.defineMode("octave", function' | |||
|
17 | 17 | } |
|
18 | 18 | |
|
19 | 19 | var singleOperators = new RegExp("^[\\+\\-\\*/&|\\^~<>!@'\\\\]"); |
|
20 | var singleDelimiters = new RegExp('^[\\(\\[\\{\\},:=;]'); | |
|
20 | var singleDelimiters = new RegExp('^[\\(\\[\\{\\},:=;\\.]'); | |
|
21 | 21 | var doubleOperators = new RegExp("^((==)|(~=)|(<=)|(>=)|(<<)|(>>)|(\\.[\\+\\-\\*/\\^\\\\]))"); |
|
22 | 22 | var doubleDelimiters = new RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))"); |
|
23 | 23 | var tripleDelimiters = new RegExp("^((>>=)|(<<=))"); |
@@ -90,8 +90,8 b' CodeMirror.defineMode("octave", function' | |||
|
90 | 90 | if (stream.match(wordRegexp(['nan','NaN','inf','Inf']))) { return 'number'; }; |
|
91 | 91 | |
|
92 | 92 | // Handle Strings |
|
93 | if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; } ; | |
|
94 | if (stream.match(/^'([^']|(''))*'/)) { return 'string'; } ; | |
|
93 | var m = stream.match(/^"(?:[^"]|"")*("|$)/) || stream.match(/^'(?:[^']|'')*('|$)/) | |
|
94 | if (m) { return m[1] ? 'string' : "string error"; } | |
|
95 | 95 | |
|
96 | 96 | // Handle words |
|
97 | 97 | if (stream.match(keywords)) { return 'keyword'; } ; |
@@ -126,7 +126,11 b' CodeMirror.defineMode("octave", function' | |||
|
126 | 126 | state.tokenize = tokenTranspose; |
|
127 | 127 | } |
|
128 | 128 | return style; |
|
129 | } | |
|
129 | }, | |
|
130 | ||
|
131 | lineComment: '%', | |
|
132 | ||
|
133 | fold: 'indent' | |
|
130 | 134 | }; |
|
131 | 135 | }); |
|
132 | 136 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -27,7 +27,7 b' CodeMirror.defineMode("oz", function (co' | |||
|
27 | 27 | |
|
28 | 28 | var atoms = wordRegexp(["true", "false", "nil", "unit"]); |
|
29 | 29 | var commonKeywords = wordRegexp(["andthen", "at", "attr", "declare", "feat", "from", "lex", |
|
30 | "mod", "mode", "orelse", "parser", "prod", "prop", "scanner", "self", "syn", "token"]); | |
|
30 | "mod", "div", "mode", "orelse", "parser", "prod", "prop", "scanner", "self", "syn", "token"]); | |
|
31 | 31 | var openingKeywords = wordRegexp(["local", "proc", "fun", "case", "class", "if", "cond", "or", "dis", |
|
32 | 32 | "choice", "not", "thread", "try", "raise", "lock", "for", "suchthat", "meth", "functor"]); |
|
33 | 33 | var middleKeywords = wordRegexp(middle); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -17,9 +17,21 b' CodeMirror.defineMode("pascal", function' | |||
|
17 | 17 | for (var i = 0; i < words.length; ++i) obj[words[i]] = true; |
|
18 | 18 | return obj; |
|
19 | 19 | } |
|
20 | var keywords = words("and array begin case const div do downto else end file for forward integer " + | |
|
21 | "boolean char function goto if in label mod nil not of or packed procedure " + | |
|
22 | "program record repeat set string then to type until var while with"); | |
|
20 | var keywords = words( | |
|
21 | "absolute and array asm begin case const constructor destructor div do " + | |
|
22 | "downto else end file for function goto if implementation in inherited " + | |
|
23 | "inline interface label mod nil not object of operator or packed procedure " + | |
|
24 | "program record reintroduce repeat self set shl shr string then to type " + | |
|
25 | "unit until uses var while with xor as class dispinterface except exports " + | |
|
26 | "finalization finally initialization inline is library on out packed " + | |
|
27 | "property raise resourcestring threadvar try absolute abstract alias " + | |
|
28 | "assembler bitpacked break cdecl continue cppdecl cvar default deprecated " + | |
|
29 | "dynamic enumerator experimental export external far far16 forward generic " + | |
|
30 | "helper implements index interrupt iocheck local message name near " + | |
|
31 | "nodefault noreturn nostackframe oldfpccall otherwise overload override " + | |
|
32 | "pascal platform private protected public published read register " + | |
|
33 | "reintroduce result safecall saveregisters softfloat specialize static " + | |
|
34 | "stdcall stored strict unaligned unimplemented varargs virtual write"); | |
|
23 | 35 | var atoms = {"null": true}; |
|
24 | 36 | |
|
25 | 37 | var isOperatorChar = /[+\-*&%=<>!?|\/]/; |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -24,7 +24,7 b' CodeMirror.defineMode("pegjs", function ' | |||
|
24 | 24 | inString: false, |
|
25 | 25 | stringType: null, |
|
26 | 26 | inComment: false, |
|
27 | inChracterClass: false, | |
|
27 | inCharacterClass: false, | |
|
28 | 28 | braced: 0, |
|
29 | 29 | lhs: true, |
|
30 | 30 | localState: null |
@@ -66,22 +66,22 b' CodeMirror.defineMode("pegjs", function ' | |||
|
66 | 66 | } |
|
67 | 67 | } |
|
68 | 68 | return "comment"; |
|
69 | } else if (state.inChracterClass) { | |
|
70 | while (state.inChracterClass && !stream.eol()) { | |
|
69 | } else if (state.inCharacterClass) { | |
|
70 | while (state.inCharacterClass && !stream.eol()) { | |
|
71 | 71 | if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) { |
|
72 | state.inChracterClass = false; | |
|
72 | state.inCharacterClass = false; | |
|
73 | 73 | } |
|
74 | 74 | } |
|
75 | 75 | } else if (stream.peek() === '[') { |
|
76 | 76 | stream.next(); |
|
77 | state.inChracterClass = true; | |
|
77 | state.inCharacterClass = true; | |
|
78 | 78 | return 'bracket'; |
|
79 | 79 | } else if (stream.match(/^\/\//)) { |
|
80 | 80 | stream.skipToEnd(); |
|
81 | 81 | return "comment"; |
|
82 | 82 | } else if (state.braced || stream.peek() === '{') { |
|
83 | 83 | if (state.localState === null) { |
|
84 |
state.localState = |
|
|
84 | state.localState = CodeMirror.startState(jsMode); | |
|
85 | 85 | } |
|
86 | 86 | var token = jsMode.token(stream, state.localState); |
|
87 | 87 | var text = stream.current(); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08) |
|
5 | 5 | // This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com) |
@@ -268,7 +268,7 b' CodeMirror.defineMode("perl",function(){' | |||
|
268 | 268 | chmod :1, // - changes the permissions on a list of files |
|
269 | 269 | chomp :1, // - remove a trailing record separator from a string |
|
270 | 270 | chop :1, // - remove the last character from a string |
|
271 | chown :1, // - change the owership on a list of files | |
|
271 | chown :1, // - change the ownership on a list of files | |
|
272 | 272 | chr :1, // - get character this number represents |
|
273 | 273 | chroot :1, // - make directory new root for path lookups |
|
274 | 274 | close :1, // - close file (or pipe or socket) handle |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -86,7 +86,7 b'' | |||
|
86 | 86 | "die echo empty exit eval include include_once isset list require require_once return " + |
|
87 | 87 | "print unset __halt_compiler self static parent yield insteadof finally"; |
|
88 | 88 | var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__"; |
|
89 | var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents file_put_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count"; | |
|
89 | var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents file_put_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists array_intersect_key array_combine array_column pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count"; | |
|
90 | 90 | CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" ")); |
|
91 | 91 | CodeMirror.registerHelper("wordChars", "php", /[\w$]/); |
|
92 | 92 | |
@@ -151,7 +151,7 b'' | |||
|
151 | 151 | }; |
|
152 | 152 | |
|
153 | 153 | CodeMirror.defineMode("php", function(config, parserConfig) { |
|
154 | var htmlMode = CodeMirror.getMode(config, "text/html"); | |
|
154 | var htmlMode = CodeMirror.getMode(config, (parserConfig && parserConfig.htmlMode) || "text/html"); | |
|
155 | 155 | var phpMode = CodeMirror.getMode(config, phpConfig); |
|
156 | 156 | |
|
157 | 157 | function dispatch(stream, state) { |
@@ -160,7 +160,7 b'' | |||
|
160 | 160 | if (!isPHP) { |
|
161 | 161 | if (stream.match(/^<\?\w*/)) { |
|
162 | 162 | state.curMode = phpMode; |
|
163 | if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "")) | |
|
163 | if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "", "")) | |
|
164 | 164 | state.curState = state.php; |
|
165 | 165 | return "meta"; |
|
166 | 166 | } |
@@ -213,11 +213,11 b'' | |||
|
213 | 213 | |
|
214 | 214 | token: dispatch, |
|
215 | 215 | |
|
216 | indent: function(state, textAfter) { | |
|
216 | indent: function(state, textAfter, line) { | |
|
217 | 217 | if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) || |
|
218 | 218 | (state.curMode == phpMode && /^\?>/.test(textAfter))) |
|
219 | return htmlMode.indent(state.html, textAfter); | |
|
220 | return state.curMode.indent(state.curState, textAfter); | |
|
219 | return htmlMode.indent(state.html, textAfter, line); | |
|
220 | return state.curMode.indent(state.curState, textAfter, line); | |
|
221 | 221 | }, |
|
222 | 222 | |
|
223 | 223 | blockCommentStart: "/*", |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /* |
|
5 | 5 | * Pig Latin Mode for CodeMirror 2 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -34,7 +34,7 b' CodeMirror.defineMode("properties", func' | |||
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | if (sol) { |
|
37 |
while(stream.eatSpace()) |
|
|
37 | while(stream.eatSpace()) {} | |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | var ch = stream.next(); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -126,7 +126,7 b' CodeMirror.defineMode("puppet", function' | |||
|
126 | 126 | if (word && words.hasOwnProperty(word)) { |
|
127 | 127 | // Negates the initial next() |
|
128 | 128 | stream.backUp(1); |
|
129 |
// |
|
|
129 | // rs move the stream | |
|
130 | 130 | stream.match(/[\w]+/); |
|
131 | 131 | // We want to process these words differently |
|
132 | 132 | // do to the importance they have in Puppet |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -32,13 +32,6 b'' | |||
|
32 | 32 | "sorted", "staticmethod", "str", "sum", "super", "tuple", |
|
33 | 33 | "type", "vars", "zip", "__import__", "NotImplemented", |
|
34 | 34 | "Ellipsis", "__debug__"]; |
|
35 | var py2 = {builtins: ["apply", "basestring", "buffer", "cmp", "coerce", "execfile", | |
|
36 | "file", "intern", "long", "raw_input", "reduce", "reload", | |
|
37 | "unichr", "unicode", "xrange", "False", "True", "None"], | |
|
38 | keywords: ["exec", "print"]}; | |
|
39 | var py3 = {builtins: ["ascii", "bytes", "exec", "print"], | |
|
40 | keywords: ["nonlocal", "False", "True", "None", "async", "await"]}; | |
|
41 | ||
|
42 | 35 | CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins)); |
|
43 | 36 | |
|
44 | 37 | function top(state) { |
@@ -48,51 +41,51 b'' | |||
|
48 | 41 | CodeMirror.defineMode("python", function(conf, parserConf) { |
|
49 | 42 | var ERRORCLASS = "error"; |
|
50 | 43 | |
|
51 |
var |
|
|
52 | var doubleOperators = parserConf.doubleOperators || /^([!<>]==|<>|<<|>>|\/\/|\*\*)/; | |
|
53 | var doubleDelimiters = parserConf.doubleDelimiters || /^(\+=|\-=|\*=|%=|\/=|&=|\|=|\^=)/; | |
|
54 | var tripleDelimiters = parserConf.tripleDelimiters || /^(\/\/=|>>=|<<=|\*\*=)/; | |
|
55 | ||
|
56 | if (parserConf.version && parseInt(parserConf.version, 10) == 3){ | |
|
57 | // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator | |
|
58 | var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/; | |
|
59 | var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/; | |
|
60 | } else { | |
|
61 | var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!]/; | |
|
62 | var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/; | |
|
63 | } | |
|
44 | var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.\\]/; | |
|
45 | // (Backwards-compatiblity with old, cumbersome config system) | |
|
46 | var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters, | |
|
47 | parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/] | |
|
48 | for (var i = 0; i < operators.length; i++) if (!operators[i]) operators.splice(i--, 1) | |
|
64 | 49 | |
|
65 | 50 | var hangingIndent = parserConf.hangingIndent || conf.indentUnit; |
|
66 | 51 | |
|
67 | 52 | var myKeywords = commonKeywords, myBuiltins = commonBuiltins; |
|
68 |
if(parserConf.extra_keywords != undefined) |
|
|
53 | if (parserConf.extra_keywords != undefined) | |
|
69 | 54 | myKeywords = myKeywords.concat(parserConf.extra_keywords); |
|
70 | } | |
|
71 |
if(parserConf.extra_builtins != undefined) |
|
|
55 | ||
|
56 | if (parserConf.extra_builtins != undefined) | |
|
72 | 57 | myBuiltins = myBuiltins.concat(parserConf.extra_builtins); |
|
73 | } | |
|
74 |
|
|
|
75 | myKeywords = myKeywords.concat(py3.keywords); | |
|
76 | myBuiltins = myBuiltins.concat(py3.builtins); | |
|
77 | var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i"); | |
|
58 | ||
|
59 | var py3 = !(parserConf.version && Number(parserConf.version) < 3) | |
|
60 | if (py3) { | |
|
61 | // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator | |
|
62 | var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/; | |
|
63 | myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]); | |
|
64 | myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]); | |
|
65 | var stringPrefixes = new RegExp("^(([rbuf]|(br)|(fr))?('{3}|\"{3}|['\"]))", "i"); | |
|
78 | 66 | } else { |
|
79 | myKeywords = myKeywords.concat(py2.keywords); | |
|
80 | myBuiltins = myBuiltins.concat(py2.builtins); | |
|
81 | var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); | |
|
67 | var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/; | |
|
68 | myKeywords = myKeywords.concat(["exec", "print"]); | |
|
69 | myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile", | |
|
70 | "file", "intern", "long", "raw_input", "reduce", "reload", | |
|
71 | "unichr", "unicode", "xrange", "False", "True", "None"]); | |
|
72 | var stringPrefixes = new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); | |
|
82 | 73 | } |
|
83 | 74 | var keywords = wordRegexp(myKeywords); |
|
84 | 75 | var builtins = wordRegexp(myBuiltins); |
|
85 | 76 | |
|
86 | 77 | // tokenizers |
|
87 | 78 | function tokenBase(stream, state) { |
|
79 | var sol = stream.sol() && state.lastToken != "\\" | |
|
80 | if (sol) state.indent = stream.indentation() | |
|
88 | 81 | // Handle scope changes |
|
89 |
if ( |
|
|
82 | if (sol && top(state).type == "py") { | |
|
90 | 83 | var scopeOffset = top(state).offset; |
|
91 | 84 | if (stream.eatSpace()) { |
|
92 | 85 | var lineOffset = stream.indentation(); |
|
93 | 86 | if (lineOffset > scopeOffset) |
|
94 |
pushScope( |
|
|
95 | else if (lineOffset < scopeOffset && dedent(stream, state)) | |
|
87 | pushPyScope(state); | |
|
88 | else if (lineOffset < scopeOffset && dedent(stream, state) && stream.peek() != "#") | |
|
96 | 89 | state.errorToken = true; |
|
97 | 90 | return null; |
|
98 | 91 | } else { |
@@ -108,20 +101,15 b'' | |||
|
108 | 101 | function tokenBaseInner(stream, state) { |
|
109 | 102 | if (stream.eatSpace()) return null; |
|
110 | 103 | |
|
111 | var ch = stream.peek(); | |
|
112 | ||
|
113 | 104 | // Handle Comments |
|
114 | if (ch == "#") { | |
|
115 | stream.skipToEnd(); | |
|
116 | return "comment"; | |
|
117 | } | |
|
105 | if (stream.match(/^#.*/)) return "comment"; | |
|
118 | 106 | |
|
119 | 107 | // Handle Number Literals |
|
120 | 108 | if (stream.match(/^[0-9\.]/, false)) { |
|
121 | 109 | var floatLiteral = false; |
|
122 | 110 | // Floats |
|
123 | if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } | |
|
124 | if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; } | |
|
111 | if (stream.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; } | |
|
112 | if (stream.match(/^[\d_]+\.\d*/)) { floatLiteral = true; } | |
|
125 | 113 | if (stream.match(/^\.\d+/)) { floatLiteral = true; } |
|
126 | 114 | if (floatLiteral) { |
|
127 | 115 | // Float literals may be "imaginary" |
@@ -131,13 +119,13 b'' | |||
|
131 | 119 | // Integers |
|
132 | 120 | var intLiteral = false; |
|
133 | 121 | // Hex |
|
134 | if (stream.match(/^0x[0-9a-f]+/i)) intLiteral = true; | |
|
122 | if (stream.match(/^0x[0-9a-f_]+/i)) intLiteral = true; | |
|
135 | 123 | // Binary |
|
136 | if (stream.match(/^0b[01]+/i)) intLiteral = true; | |
|
124 | if (stream.match(/^0b[01_]+/i)) intLiteral = true; | |
|
137 | 125 | // Octal |
|
138 | if (stream.match(/^0o[0-7]+/i)) intLiteral = true; | |
|
126 | if (stream.match(/^0o[0-7_]+/i)) intLiteral = true; | |
|
139 | 127 | // Decimal |
|
140 | if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { | |
|
128 | if (stream.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/)) { | |
|
141 | 129 | // Decimal literals may be "imaginary" |
|
142 | 130 | stream.eat(/J/i); |
|
143 | 131 | // TODO - Can you have imaginary longs? |
@@ -154,19 +142,20 b'' | |||
|
154 | 142 | |
|
155 | 143 | // Handle Strings |
|
156 | 144 | if (stream.match(stringPrefixes)) { |
|
157 | state.tokenize = tokenStringFactory(stream.current()); | |
|
158 | return state.tokenize(stream, state); | |
|
145 | var isFmtString = stream.current().toLowerCase().indexOf('f') !== -1; | |
|
146 | if (!isFmtString) { | |
|
147 | state.tokenize = tokenStringFactory(stream.current(), state.tokenize); | |
|
148 | return state.tokenize(stream, state); | |
|
149 | } else { | |
|
150 | state.tokenize = formatStringFactory(stream.current(), state.tokenize); | |
|
151 | return state.tokenize(stream, state); | |
|
152 | } | |
|
159 | 153 | } |
|
160 | 154 | |
|
161 | // Handle operators and Delimiters | |
|
162 | if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) | |
|
163 | return "punctuation"; | |
|
155 | for (var i = 0; i < operators.length; i++) | |
|
156 | if (stream.match(operators[i])) return "operator" | |
|
164 | 157 | |
|
165 | if (stream.match(doubleOperators) || stream.match(singleOperators)) | |
|
166 | return "operator"; | |
|
167 | ||
|
168 | if (stream.match(singleDelimiters)) | |
|
169 | return "punctuation"; | |
|
158 | if (stream.match(delimiters)) return "punctuation"; | |
|
170 | 159 | |
|
171 | 160 | if (state.lastToken == "." && stream.match(identifiers)) |
|
172 | 161 | return "property"; |
@@ -191,8 +180,69 b'' | |||
|
191 | 180 | return ERRORCLASS; |
|
192 | 181 | } |
|
193 | 182 | |
|
194 |
function t |
|
|
195 | while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) | |
|
183 | function formatStringFactory(delimiter, tokenOuter) { | |
|
184 | while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) | |
|
185 | delimiter = delimiter.substr(1); | |
|
186 | ||
|
187 | var singleline = delimiter.length == 1; | |
|
188 | var OUTCLASS = "string"; | |
|
189 | ||
|
190 | function tokenNestedExpr(depth) { | |
|
191 | return function(stream, state) { | |
|
192 | var inner = tokenBaseInner(stream, state) | |
|
193 | if (inner == "punctuation") { | |
|
194 | if (stream.current() == "{") { | |
|
195 | state.tokenize = tokenNestedExpr(depth + 1) | |
|
196 | } else if (stream.current() == "}") { | |
|
197 | if (depth > 1) state.tokenize = tokenNestedExpr(depth - 1) | |
|
198 | else state.tokenize = tokenString | |
|
199 | } | |
|
200 | } | |
|
201 | return inner | |
|
202 | } | |
|
203 | } | |
|
204 | ||
|
205 | function tokenString(stream, state) { | |
|
206 | while (!stream.eol()) { | |
|
207 | stream.eatWhile(/[^'"\{\}\\]/); | |
|
208 | if (stream.eat("\\")) { | |
|
209 | stream.next(); | |
|
210 | if (singleline && stream.eol()) | |
|
211 | return OUTCLASS; | |
|
212 | } else if (stream.match(delimiter)) { | |
|
213 | state.tokenize = tokenOuter; | |
|
214 | return OUTCLASS; | |
|
215 | } else if (stream.match('{{')) { | |
|
216 | // ignore {{ in f-str | |
|
217 | return OUTCLASS; | |
|
218 | } else if (stream.match('{', false)) { | |
|
219 | // switch to nested mode | |
|
220 | state.tokenize = tokenNestedExpr(0) | |
|
221 | if (stream.current()) return OUTCLASS; | |
|
222 | else return state.tokenize(stream, state) | |
|
223 | } else if (stream.match('}}')) { | |
|
224 | return OUTCLASS; | |
|
225 | } else if (stream.match('}')) { | |
|
226 | // single } in f-string is an error | |
|
227 | return ERRORCLASS; | |
|
228 | } else { | |
|
229 | stream.eat(/['"]/); | |
|
230 | } | |
|
231 | } | |
|
232 | if (singleline) { | |
|
233 | if (parserConf.singleLineStringErrors) | |
|
234 | return ERRORCLASS; | |
|
235 | else | |
|
236 | state.tokenize = tokenOuter; | |
|
237 | } | |
|
238 | return OUTCLASS; | |
|
239 | } | |
|
240 | tokenString.isString = true; | |
|
241 | return tokenString; | |
|
242 | } | |
|
243 | ||
|
244 | function tokenStringFactory(delimiter, tokenOuter) { | |
|
245 | while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) | |
|
196 | 246 | delimiter = delimiter.substr(1); |
|
197 | 247 | |
|
198 | 248 | var singleline = delimiter.length == 1; |
@@ -206,7 +256,7 b'' | |||
|
206 | 256 | if (singleline && stream.eol()) |
|
207 | 257 | return OUTCLASS; |
|
208 | 258 | } else if (stream.match(delimiter)) { |
|
209 |
state.tokenize = token |
|
|
259 | state.tokenize = tokenOuter; | |
|
210 | 260 | return OUTCLASS; |
|
211 | 261 | } else { |
|
212 | 262 | stream.eat(/['"]/); |
@@ -216,7 +266,7 b'' | |||
|
216 | 266 | if (parserConf.singleLineStringErrors) |
|
217 | 267 | return ERRORCLASS; |
|
218 | 268 | else |
|
219 |
state.tokenize = token |
|
|
269 | state.tokenize = tokenOuter; | |
|
220 | 270 | } |
|
221 | 271 | return OUTCLASS; |
|
222 | 272 | } |
@@ -224,21 +274,23 b'' | |||
|
224 | 274 | return tokenString; |
|
225 | 275 | } |
|
226 | 276 | |
|
227 |
function pushScope( |
|
|
228 | var offset = 0, align = null; | |
|
229 | if (type == "py") { | |
|
230 | while (top(state).type != "py") | |
|
231 | state.scopes.pop(); | |
|
232 |
|
|
|
233 | offset = top(state).offset + (type == "py" ? conf.indentUnit : hangingIndent); | |
|
234 | if (type != "py" && !stream.match(/^(\s|#.*)*$/, false)) | |
|
235 | align = stream.column() + 1; | |
|
236 | state.scopes.push({offset: offset, type: type, align: align}); | |
|
277 | function pushPyScope(state) { | |
|
278 | while (top(state).type != "py") state.scopes.pop() | |
|
279 | state.scopes.push({offset: top(state).offset + conf.indentUnit, | |
|
280 | type: "py", | |
|
281 | align: null}) | |
|
282 | } | |
|
283 | ||
|
284 | function pushBracketScope(stream, state, type) { | |
|
285 | var align = stream.match(/^([\s\[\{\(]|#.*)*$/, false) ? null : stream.column() + 1 | |
|
286 | state.scopes.push({offset: state.indent + hangingIndent, | |
|
287 | type: type, | |
|
288 | align: align}) | |
|
237 | 289 | } |
|
238 | 290 | |
|
239 | 291 | function dedent(stream, state) { |
|
240 | 292 | var indented = stream.indentation(); |
|
241 | while (top(state).offset > indented) { | |
|
293 | while (state.scopes.length > 1 && top(state).offset > indented) { | |
|
242 | 294 | if (top(state).type != "py") return true; |
|
243 | 295 | state.scopes.pop(); |
|
244 | 296 | } |
@@ -246,17 +298,16 b'' | |||
|
246 | 298 | } |
|
247 | 299 | |
|
248 | 300 | function tokenLexer(stream, state) { |
|
301 | if (stream.sol()) state.beginningOfLine = true; | |
|
302 | ||
|
249 | 303 | var style = state.tokenize(stream, state); |
|
250 | 304 | var current = stream.current(); |
|
251 | 305 | |
|
252 | 306 | // Handle decorators |
|
253 |
if (current == "@") |
|
|
254 | if(parserConf.version && parseInt(parserConf.version, 10) == 3){ | |
|
255 | return stream.match(identifiers, false) ? "meta" : "operator"; | |
|
256 | } else { | |
|
257 | return stream.match(identifiers, false) ? "meta" : ERRORCLASS; | |
|
258 | } | |
|
259 | } | |
|
307 | if (state.beginningOfLine && current == "@") | |
|
308 | return stream.match(identifiers, false) ? "meta" : py3 ? "operator" : ERRORCLASS; | |
|
309 | ||
|
310 | if (/\S/.test(current)) state.beginningOfLine = false; | |
|
260 | 311 | |
|
261 | 312 | if ((style == "variable" || style == "builtin") |
|
262 | 313 | && state.lastToken == "meta") |
@@ -268,16 +319,18 b'' | |||
|
268 | 319 | |
|
269 | 320 | if (current == "lambda") state.lambda = true; |
|
270 | 321 | if (current == ":" && !state.lambda && top(state).type == "py") |
|
271 |
pushScope( |
|
|
322 | pushPyScope(state); | |
|
272 | 323 | |
|
273 | var delimiter_index = current.length == 1 ? "[({".indexOf(current) : -1; | |
|
274 |
|
|
|
275 | pushScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1)); | |
|
324 | if (current.length == 1 && !/string|comment/.test(style)) { | |
|
325 | var delimiter_index = "[({".indexOf(current); | |
|
326 | if (delimiter_index != -1) | |
|
327 | pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1)); | |
|
276 | 328 | |
|
277 | delimiter_index = "])}".indexOf(current); | |
|
278 | if (delimiter_index != -1) { | |
|
279 |
if (top(state).type == current) state.scopes.pop() |
|
|
280 | else return ERRORCLASS; | |
|
329 | delimiter_index = "])}".indexOf(current); | |
|
330 | if (delimiter_index != -1) { | |
|
331 | if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent | |
|
332 | else return ERRORCLASS; | |
|
333 | } | |
|
281 | 334 | } |
|
282 | 335 | if (state.dedent > 0 && stream.eol() && top(state).type == "py") { |
|
283 | 336 | if (state.scopes.length > 1) state.scopes.pop(); |
@@ -292,6 +345,7 b'' | |||
|
292 | 345 | return { |
|
293 | 346 | tokenize: tokenBase, |
|
294 | 347 | scopes: [{offset: basecolumn || 0, type: "py", align: null}], |
|
348 | indent: basecolumn || 0, | |
|
295 | 349 | lastToken: null, |
|
296 | 350 | lambda: false, |
|
297 | 351 | dedent: 0 |
@@ -316,16 +370,14 b'' | |||
|
316 | 370 | if (state.tokenize != tokenBase) |
|
317 | 371 | return state.tokenize.isString ? CodeMirror.Pass : 0; |
|
318 | 372 | |
|
319 | var scope = top(state); | |
|
320 | var closing = textAfter && textAfter.charAt(0) == scope.type; | |
|
373 | var scope = top(state), closing = scope.type == textAfter.charAt(0) | |
|
321 | 374 | if (scope.align != null) |
|
322 |
return scope.align - (closing ? 1 : 0) |
|
|
323 | else if (closing && state.scopes.length > 1) | |
|
324 | return state.scopes[state.scopes.length - 2].offset; | |
|
375 | return scope.align - (closing ? 1 : 0) | |
|
325 | 376 | else |
|
326 |
return scope.offset |
|
|
377 | return scope.offset - (closing ? hangingIndent : 0) | |
|
327 | 378 | }, |
|
328 | 379 | |
|
380 | electricInput: /^\s*[\}\]\)]$/, | |
|
329 | 381 | closeBrackets: {triples: "'\""}, |
|
330 | 382 | lineComment: "#", |
|
331 | 383 | fold: "indent" |
@@ -339,8 +391,8 b'' | |||
|
339 | 391 | |
|
340 | 392 | CodeMirror.defineMIME("text/x-cython", { |
|
341 | 393 | name: "python", |
|
342 | extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+ | |
|
343 | "extern gil include nogil property public"+ | |
|
394 | extra_keywords: words("by cdef cimport cpdef ctypedef enum except "+ | |
|
395 | "extern gil include nogil property public "+ | |
|
344 | 396 | "readonly struct union DEF IF ELIF ELSE") |
|
345 | 397 | }); |
|
346 | 398 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -25,7 +25,7 b' CodeMirror.defineMode("q",function(confi' | |||
|
25 | 25 | return(state.tokenize=tokenLineComment)(stream,state); |
|
26 | 26 | else if(c=="\\"){ |
|
27 | 27 | if(stream.eol()||/\s/.test(stream.peek())) |
|
28 |
return stream.skipToEnd(),/^\\\s*$/.test(stream.current())?(state.tokenize=tokenCommentToEOF)(stream |
|
|
28 | return stream.skipToEnd(),/^\\\s*$/.test(stream.current())?(state.tokenize=tokenCommentToEOF)(stream):state.tokenize=tokenBase,"comment"; | |
|
29 | 29 | else |
|
30 | 30 | return state.tokenize=tokenBase,"builtin"; |
|
31 | 31 | } |
@@ -34,25 +34,25 b' CodeMirror.defineMode("q",function(confi' | |||
|
34 | 34 | if(c=='"') |
|
35 | 35 | return(state.tokenize=tokenString)(stream,state); |
|
36 | 36 | if(c=='`') |
|
37 |
return stream.eatWhile(/[A-Z |
|
|
37 | return stream.eatWhile(/[A-Za-z\d_:\/.]/),"symbol"; | |
|
38 | 38 | if(("."==c&&/\d/.test(stream.peek()))||/\d/.test(c)){ |
|
39 | 39 | var t=null; |
|
40 | 40 | stream.backUp(1); |
|
41 |
if(stream.match(/^\d{4}\.\d{2}(m|\.\d{2}([D |
|
|
41 | if(stream.match(/^\d{4}\.\d{2}(m|\.\d{2}([DT](\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)?)?)/) | |
|
42 | 42 | || stream.match(/^\d+D(\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)/) |
|
43 | 43 | || stream.match(/^\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?/) |
|
44 | 44 | || stream.match(/^\d+[ptuv]{1}/)) |
|
45 | 45 | t="temporal"; |
|
46 | 46 | else if(stream.match(/^0[NwW]{1}/) |
|
47 |
|| stream.match(/^0x[\d |
|
|
48 |
|| stream.match(/^[0 |
|
|
47 | || stream.match(/^0x[\da-fA-F]*/) | |
|
48 | || stream.match(/^[01]+[b]{1}/) | |
|
49 | 49 | || stream.match(/^\d+[chijn]{1}/) |
|
50 | 50 | || stream.match(/-?\d*(\.\d*)?(e[+\-]?\d+)?(e|f)?/)) |
|
51 | 51 | t="number"; |
|
52 | 52 | return(t&&(!(c=stream.peek())||E.test(c)))?t:(stream.next(),"error"); |
|
53 | 53 | } |
|
54 |
if(/[A-Z |
|
|
55 |
return stream.eatWhile(/[A-Z |
|
|
54 | if(/[A-Za-z]|\./.test(c)) | |
|
55 | return stream.eatWhile(/[A-Za-z._\d]/),keywords.test(stream.current())?"keyword":"variable"; | |
|
56 | 56 | if(/[|/&^!+:\\\-*%$=~#;@><\.,?_\']/.test(c)) |
|
57 | 57 | return null; |
|
58 | 58 | if(/[{}\(\[\]\)]/.test(c)) |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -11,16 +11,25 b'' | |||
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | CodeMirror.registerHelper("wordChars", "r", /[\w.]/); | |
|
15 | ||
|
14 | 16 | CodeMirror.defineMode("r", function(config) { |
|
15 |
function wordObj( |
|
|
16 | var words = str.split(" "), res = {}; | |
|
17 | function wordObj(words) { | |
|
18 | var res = {}; | |
|
17 | 19 | for (var i = 0; i < words.length; ++i) res[words[i]] = true; |
|
18 | 20 | return res; |
|
19 | 21 | } |
|
20 |
var |
|
|
21 |
var |
|
|
22 |
var |
|
|
23 |
var |
|
|
22 | var commonAtoms = ["NULL", "NA", "Inf", "NaN", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_", "TRUE", "FALSE"]; | |
|
23 | var commonBuiltins = ["list", "quote", "bquote", "eval", "return", "call", "parse", "deparse"]; | |
|
24 | var commonKeywords = ["if", "else", "repeat", "while", "function", "for", "in", "next", "break"]; | |
|
25 | var commonBlockKeywords = ["if", "else", "repeat", "while", "function", "for"]; | |
|
26 | ||
|
27 | CodeMirror.registerHelper("hintWords", "r", commonAtoms.concat(commonBuiltins, commonKeywords)); | |
|
28 | ||
|
29 | var atoms = wordObj(commonAtoms); | |
|
30 | var builtins = wordObj(commonBuiltins); | |
|
31 | var keywords = wordObj(commonKeywords); | |
|
32 | var blockkeywords = wordObj(commonBlockKeywords); | |
|
24 | 33 | var opChars = /[+\-*\/^<>=!&|~$:]/; |
|
25 | 34 | var curPunc; |
|
26 | 35 | |
@@ -42,6 +51,9 b' CodeMirror.defineMode("r", function(conf' | |||
|
42 | 51 | } else if (ch == "'" || ch == '"') { |
|
43 | 52 | state.tokenize = tokenString(ch); |
|
44 | 53 | return "string"; |
|
54 | } else if (ch == "`") { | |
|
55 | stream.match(/[^`]+`/); | |
|
56 | return "variable-3"; | |
|
45 | 57 | } else if (ch == "." && stream.match(/.[.\d]+/)) { |
|
46 | 58 | return "keyword"; |
|
47 | 59 | } else if (/[\w\.]/.test(ch) && ch != "_") { |
@@ -60,13 +72,17 b' CodeMirror.defineMode("r", function(conf' | |||
|
60 | 72 | return "variable"; |
|
61 | 73 | } else if (ch == "%") { |
|
62 | 74 | if (stream.skipTo("%")) stream.next(); |
|
63 | return "variable-2"; | |
|
64 | } else if (ch == "<" && stream.eat("-")) { | |
|
65 | return "arrow"; | |
|
75 | return "operator variable-2"; | |
|
76 | } else if ( | |
|
77 | (ch == "<" && stream.eat("-")) || | |
|
78 | (ch == "<" && stream.match("<-")) || | |
|
79 | (ch == "-" && stream.match(/>>?/)) | |
|
80 | ) { | |
|
81 | return "operator arrow"; | |
|
66 | 82 | } else if (ch == "=" && state.ctx.argList) { |
|
67 | 83 | return "arg-is"; |
|
68 | 84 | } else if (opChars.test(ch)) { |
|
69 | if (ch == "$") return "dollar"; | |
|
85 | if (ch == "$") return "operator dollar"; | |
|
70 | 86 | stream.eatWhile(opChars); |
|
71 | 87 | return "operator"; |
|
72 | 88 | } else if (/[\(\){}\[\];]/.test(ch)) { |
@@ -99,13 +115,23 b' CodeMirror.defineMode("r", function(conf' | |||
|
99 | 115 | }; |
|
100 | 116 | } |
|
101 | 117 | |
|
118 | var ALIGN_YES = 1, ALIGN_NO = 2, BRACELESS = 4 | |
|
119 | ||
|
102 | 120 | function push(state, type, stream) { |
|
103 | 121 | state.ctx = {type: type, |
|
104 | 122 | indent: state.indent, |
|
105 |
|
|
|
123 | flags: 0, | |
|
106 | 124 | column: stream.column(), |
|
107 | 125 | prev: state.ctx}; |
|
108 | 126 | } |
|
127 | function setFlag(state, flag) { | |
|
128 | var ctx = state.ctx | |
|
129 | state.ctx = {type: ctx.type, | |
|
130 | indent: ctx.indent, | |
|
131 | flags: ctx.flags | flag, | |
|
132 | column: ctx.column, | |
|
133 | prev: ctx.prev} | |
|
134 | } | |
|
109 | 135 | function pop(state) { |
|
110 | 136 | state.indent = state.ctx.indent; |
|
111 | 137 | state.ctx = state.ctx.prev; |
@@ -116,22 +142,22 b' CodeMirror.defineMode("r", function(conf' | |||
|
116 | 142 | return {tokenize: tokenBase, |
|
117 | 143 | ctx: {type: "top", |
|
118 | 144 | indent: -config.indentUnit, |
|
119 |
|
|
|
145 | flags: ALIGN_NO}, | |
|
120 | 146 | indent: 0, |
|
121 | 147 | afterIdent: false}; |
|
122 | 148 | }, |
|
123 | 149 | |
|
124 | 150 | token: function(stream, state) { |
|
125 | 151 | if (stream.sol()) { |
|
126 |
if (state.ctx. |
|
|
152 | if ((state.ctx.flags & 3) == 0) state.ctx.flags |= ALIGN_NO | |
|
153 | if (state.ctx.flags & BRACELESS) pop(state) | |
|
127 | 154 | state.indent = stream.indentation(); |
|
128 | 155 | } |
|
129 | 156 | if (stream.eatSpace()) return null; |
|
130 | 157 | var style = state.tokenize(stream, state); |
|
131 |
if (style != "comment" && state.ctx. |
|
|
158 | if (style != "comment" && (state.ctx.flags & ALIGN_NO) == 0) setFlag(state, ALIGN_YES) | |
|
132 | 159 | |
|
133 | var ctype = state.ctx.type; | |
|
134 | if ((curPunc == ";" || curPunc == "{" || curPunc == "}") && ctype == "block") pop(state); | |
|
160 | if ((curPunc == ";" || curPunc == "{" || curPunc == "}") && state.ctx.type == "block") pop(state); | |
|
135 | 161 | if (curPunc == "{") push(state, "}", stream); |
|
136 | 162 | else if (curPunc == "(") { |
|
137 | 163 | push(state, ")", stream); |
@@ -139,7 +165,8 b' CodeMirror.defineMode("r", function(conf' | |||
|
139 | 165 | } |
|
140 | 166 | else if (curPunc == "[") push(state, "]", stream); |
|
141 | 167 | else if (curPunc == "block") push(state, "block", stream); |
|
142 | else if (curPunc == ctype) pop(state); | |
|
168 | else if (curPunc == state.ctx.type) pop(state); | |
|
169 | else if (state.ctx.type == "block" && style != "comment") setFlag(state, BRACELESS) | |
|
143 | 170 | state.afterIdent = style == "variable" || style == "keyword"; |
|
144 | 171 | return style; |
|
145 | 172 | }, |
@@ -148,8 +175,9 b' CodeMirror.defineMode("r", function(conf' | |||
|
148 | 175 | if (state.tokenize != tokenBase) return 0; |
|
149 | 176 | var firstChar = textAfter && textAfter.charAt(0), ctx = state.ctx, |
|
150 | 177 | closing = firstChar == ctx.type; |
|
178 | if (ctx.flags & BRACELESS) ctx = ctx.prev | |
|
151 | 179 | if (ctx.type == "block") return ctx.indent + (firstChar == "{" ? 0 : config.indentUnit); |
|
152 |
else if (ctx. |
|
|
180 | else if (ctx.flags & ALIGN_YES) return ctx.column + (closing ? 0 : 1); | |
|
153 | 181 | else return ctx.indent + (closing ? 0 : config.indentUnit); |
|
154 | 182 | }, |
|
155 | 183 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -28,7 +28,8 b' CodeMirror.defineMode("ruby", function(c' | |||
|
28 | 28 | var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then", |
|
29 | 29 | "catch", "loop", "proc", "begin"]); |
|
30 | 30 | var dedentWords = wordObj(["end", "until"]); |
|
31 |
var |
|
|
31 | var opening = {"[": "]", "{": "}", "(": ")"}; | |
|
32 | var closing = {"]": "[", "}": "{", ")": "("}; | |
|
32 | 33 | var curPunc; |
|
33 | 34 | |
|
34 | 35 | function chain(newtok, stream, state) { |
@@ -46,22 +47,10 b' CodeMirror.defineMode("ruby", function(c' | |||
|
46 | 47 | if (ch == "`" || ch == "'" || ch == '"') { |
|
47 | 48 | return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state); |
|
48 | 49 | } else if (ch == "/") { |
|
49 | var currentIndex = stream.current().length; | |
|
50 | if (stream.skipTo("/")) { | |
|
51 | var search_till = stream.current().length; | |
|
52 | stream.backUp(stream.current().length - currentIndex); | |
|
53 | var balance = 0; // balance brackets | |
|
54 | while (stream.current().length < search_till) { | |
|
55 | var chchr = stream.next(); | |
|
56 | if (chchr == "(") balance += 1; | |
|
57 | else if (chchr == ")") balance -= 1; | |
|
58 | if (balance < 0) break; | |
|
59 | } | |
|
60 | stream.backUp(stream.current().length - currentIndex); | |
|
61 | if (balance == 0) | |
|
62 | return chain(readQuoted(ch, "string-2", true), stream, state); | |
|
63 | } | |
|
64 | return "operator"; | |
|
50 | if (regexpAhead(stream)) | |
|
51 | return chain(readQuoted(ch, "string-2", true), stream, state); | |
|
52 | else | |
|
53 | return "operator"; | |
|
65 | 54 | } else if (ch == "%") { |
|
66 | 55 | var style = "string", embed = true; |
|
67 | 56 | if (stream.eat("s")) style = "atom"; |
@@ -70,13 +59,13 b' CodeMirror.defineMode("ruby", function(c' | |||
|
70 | 59 | else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; } |
|
71 | 60 | var delim = stream.eat(/[^\w\s=]/); |
|
72 | 61 | if (!delim) return "operator"; |
|
73 |
if ( |
|
|
62 | if (opening.propertyIsEnumerable(delim)) delim = opening[delim]; | |
|
74 | 63 | return chain(readQuoted(delim, style, embed, true), stream, state); |
|
75 | 64 | } else if (ch == "#") { |
|
76 | 65 | stream.skipToEnd(); |
|
77 | 66 | return "comment"; |
|
78 |
} else if (ch == "<" && (m = stream.match(/^< |
|
|
79 | return chain(readHereDoc(m[1]), stream, state); | |
|
67 | } else if (ch == "<" && (m = stream.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) { | |
|
68 | return chain(readHereDoc(m[2], m[1]), stream, state); | |
|
80 | 69 | } else if (ch == "0") { |
|
81 | 70 | if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/); |
|
82 | 71 | else if (stream.eat("b")) stream.eatWhile(/[01]/); |
@@ -148,6 +137,28 b' CodeMirror.defineMode("ruby", function(c' | |||
|
148 | 137 | } |
|
149 | 138 | } |
|
150 | 139 | |
|
140 | function regexpAhead(stream) { | |
|
141 | var start = stream.pos, depth = 0, next, found = false, escaped = false | |
|
142 | while ((next = stream.next()) != null) { | |
|
143 | if (!escaped) { | |
|
144 | if ("[{(".indexOf(next) > -1) { | |
|
145 | depth++ | |
|
146 | } else if ("]})".indexOf(next) > -1) { | |
|
147 | depth-- | |
|
148 | if (depth < 0) break | |
|
149 | } else if (next == "/" && depth == 0) { | |
|
150 | found = true | |
|
151 | break | |
|
152 | } | |
|
153 | escaped = next == "\\" | |
|
154 | } else { | |
|
155 | escaped = false | |
|
156 | } | |
|
157 | } | |
|
158 | stream.backUp(stream.pos - start) | |
|
159 | return found | |
|
160 | } | |
|
161 | ||
|
151 | 162 | function tokenBaseUntilBrace(depth) { |
|
152 | 163 | if (!depth) depth = 1; |
|
153 | 164 | return function(stream, state) { |
@@ -206,8 +217,9 b' CodeMirror.defineMode("ruby", function(c' | |||
|
206 | 217 | return style; |
|
207 | 218 | }; |
|
208 | 219 | } |
|
209 | function readHereDoc(phrase) { | |
|
220 | function readHereDoc(phrase, mayIndent) { | |
|
210 | 221 | return function(stream, state) { |
|
222 | if (mayIndent) stream.eatSpace() | |
|
211 | 223 | if (stream.match(phrase)) state.tokenize.pop(); |
|
212 | 224 | else stream.skipToEnd(); |
|
213 | 225 | return "string"; |
@@ -266,17 +278,18 b' CodeMirror.defineMode("ruby", function(c' | |||
|
266 | 278 | }, |
|
267 | 279 | |
|
268 | 280 | indent: function(state, textAfter) { |
|
269 |
if (state.tokenize[state.tokenize.length-1] != tokenBase) return |
|
|
281 | if (state.tokenize[state.tokenize.length-1] != tokenBase) return CodeMirror.Pass; | |
|
270 | 282 | var firstChar = textAfter && textAfter.charAt(0); |
|
271 | 283 | var ct = state.context; |
|
272 |
var clos |
|
|
284 | var closed = ct.type == closing[firstChar] || | |
|
273 | 285 | ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter); |
|
274 |
return ct.indented + (clos |
|
|
286 | return ct.indented + (closed ? 0 : config.indentUnit) + | |
|
275 | 287 | (state.continuedLine ? config.indentUnit : 0); |
|
276 | 288 | }, |
|
277 | 289 | |
|
278 | electricInput: /^\s*(?:end|rescue|\})$/, | |
|
279 | lineComment: "#" | |
|
290 | electricInput: /^\s*(?:end|rescue|elsif|else|\})$/, | |
|
291 | lineComment: "#", | |
|
292 | fold: "indent" | |
|
280 | 293 | }; |
|
281 | 294 | }); |
|
282 | 295 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -68,4 +68,5 b' CodeMirror.defineSimpleMode("rust",{' | |||
|
68 | 68 | |
|
69 | 69 | |
|
70 | 70 | CodeMirror.defineMIME("text/x-rustsrc", "rust"); |
|
71 | CodeMirror.defineMIME("text/rust", "rust"); | |
|
71 | 72 | }); |
@@ -1,17 +1,23 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
|
6 | mod(require("../../lib/codemirror")); | |
|
6 | mod(require("../../lib/codemirror"), require("../css/css")); | |
|
7 | 7 | else if (typeof define == "function" && define.amd) // AMD |
|
8 | define(["../../lib/codemirror"], mod); | |
|
8 | define(["../../lib/codemirror", "../css/css"], mod); | |
|
9 | 9 | else // Plain browser env |
|
10 | 10 | mod(CodeMirror); |
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | 14 | CodeMirror.defineMode("sass", function(config) { |
|
15 | var cssMode = CodeMirror.mimeModes["text/css"]; | |
|
16 | var propertyKeywords = cssMode.propertyKeywords || {}, | |
|
17 | colorKeywords = cssMode.colorKeywords || {}, | |
|
18 | valueKeywords = cssMode.valueKeywords || {}, | |
|
19 | fontProperties = cssMode.fontProperties || {}; | |
|
20 | ||
|
15 | 21 | function tokenRegexp(words) { |
|
16 | 22 | return new RegExp("^" + words.join("|")); |
|
17 | 23 | } |
@@ -25,6 +31,12 b' CodeMirror.defineMode("sass", function(c' | |||
|
25 | 31 | |
|
26 | 32 | var pseudoElementsRegexp = /^::?[a-zA-Z_][\w\-]*/; |
|
27 | 33 | |
|
34 | var word; | |
|
35 | ||
|
36 | function isEndLine(stream) { | |
|
37 | return !stream.peek() || stream.match(/\s+$/, false); | |
|
38 | } | |
|
39 | ||
|
28 | 40 | function urlTokens(stream, state) { |
|
29 | 41 | var ch = stream.peek(); |
|
30 | 42 | |
@@ -76,6 +88,9 b' CodeMirror.defineMode("sass", function(c' | |||
|
76 | 88 | |
|
77 | 89 | if (endingString) { |
|
78 | 90 | if (nextChar !== quote && greedy) { stream.next(); } |
|
91 | if (isEndLine(stream)) { | |
|
92 | state.cursorHalf = 0; | |
|
93 | } | |
|
79 | 94 | state.tokenizer = tokenBase; |
|
80 | 95 | return "string"; |
|
81 | 96 | } else if (nextChar === "#" && peekChar === "{") { |
@@ -147,14 +162,20 b' CodeMirror.defineMode("sass", function(c' | |||
|
147 | 162 | // first half i.e. before : for key-value pairs |
|
148 | 163 | // including selectors |
|
149 | 164 | |
|
165 | if (ch === "-") { | |
|
166 | if (stream.match(/^-\w+-/)) { | |
|
167 | return "meta"; | |
|
168 | } | |
|
169 | } | |
|
170 | ||
|
150 | 171 | if (ch === ".") { |
|
151 | 172 | stream.next(); |
|
152 | 173 | if (stream.match(/^[\w-]+/)) { |
|
153 | 174 | indent(state); |
|
154 |
return " |
|
|
175 | return "qualifier"; | |
|
155 | 176 | } else if (stream.peek() === "#") { |
|
156 | 177 | indent(state); |
|
157 |
return " |
|
|
178 | return "tag"; | |
|
158 | 179 | } |
|
159 | 180 | } |
|
160 | 181 | |
@@ -163,11 +184,11 b' CodeMirror.defineMode("sass", function(c' | |||
|
163 | 184 | // ID selectors |
|
164 | 185 | if (stream.match(/^[\w-]+/)) { |
|
165 | 186 | indent(state); |
|
166 |
return " |
|
|
187 | return "builtin"; | |
|
167 | 188 | } |
|
168 | 189 | if (stream.peek() === "#") { |
|
169 | 190 | indent(state); |
|
170 |
return " |
|
|
191 | return "tag"; | |
|
171 | 192 | } |
|
172 | 193 | } |
|
173 | 194 | |
@@ -220,37 +241,48 b' CodeMirror.defineMode("sass", function(c' | |||
|
220 | 241 | // Indent Directives |
|
221 | 242 | if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) { |
|
222 | 243 | indent(state); |
|
223 |
return " |
|
|
244 | return "def"; | |
|
224 | 245 | } |
|
225 | 246 | |
|
226 | 247 | // Other Directives |
|
227 | 248 | if (ch === "@") { |
|
228 | 249 | stream.next(); |
|
229 | 250 | stream.eatWhile(/[\w-]/); |
|
230 |
return " |
|
|
251 | return "def"; | |
|
231 | 252 | } |
|
232 | 253 | |
|
233 | 254 | if (stream.eatWhile(/[\w-]/)){ |
|
234 | 255 | if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){ |
|
235 | return "property"; | |
|
256 | word = stream.current().toLowerCase(); | |
|
257 | var prop = state.prevProp + "-" + word; | |
|
258 | if (propertyKeywords.hasOwnProperty(prop)) { | |
|
259 | return "property"; | |
|
260 | } else if (propertyKeywords.hasOwnProperty(word)) { | |
|
261 | state.prevProp = word; | |
|
262 | return "property"; | |
|
263 | } else if (fontProperties.hasOwnProperty(word)) { | |
|
264 | return "property"; | |
|
265 | } | |
|
266 | return "tag"; | |
|
236 | 267 | } |
|
237 | 268 | else if(stream.match(/ *:/,false)){ |
|
238 | 269 | indent(state); |
|
239 | 270 | state.cursorHalf = 1; |
|
240 | return "atom"; | |
|
271 | state.prevProp = stream.current().toLowerCase(); | |
|
272 | return "property"; | |
|
241 | 273 | } |
|
242 | 274 | else if(stream.match(/ *,/,false)){ |
|
243 |
return " |
|
|
275 | return "tag"; | |
|
244 | 276 | } |
|
245 | 277 | else{ |
|
246 | 278 | indent(state); |
|
247 |
return " |
|
|
279 | return "tag"; | |
|
248 | 280 | } |
|
249 | 281 | } |
|
250 | 282 | |
|
251 | 283 | if(ch === ":"){ |
|
252 | 284 | if (stream.match(pseudoElementsRegexp)){ // could be a pseudo-element |
|
253 |
return " |
|
|
285 | return "variable-3"; | |
|
254 | 286 | } |
|
255 | 287 | stream.next(); |
|
256 | 288 | state.cursorHalf=1; |
@@ -264,7 +296,7 b' CodeMirror.defineMode("sass", function(c' | |||
|
264 | 296 | stream.next(); |
|
265 | 297 | // Hex numbers |
|
266 | 298 | if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){ |
|
267 |
if( |
|
|
299 | if (isEndLine(stream)) { | |
|
268 | 300 | state.cursorHalf = 0; |
|
269 | 301 | } |
|
270 | 302 | return "number"; |
@@ -273,7 +305,7 b' CodeMirror.defineMode("sass", function(c' | |||
|
273 | 305 | |
|
274 | 306 | // Numbers |
|
275 | 307 | if (stream.match(/^-?[0-9\.]+/)){ |
|
276 |
if( |
|
|
308 | if (isEndLine(stream)) { | |
|
277 | 309 | state.cursorHalf = 0; |
|
278 | 310 | } |
|
279 | 311 | return "number"; |
@@ -281,14 +313,14 b' CodeMirror.defineMode("sass", function(c' | |||
|
281 | 313 | |
|
282 | 314 | // Units |
|
283 | 315 | if (stream.match(/^(px|em|in)\b/)){ |
|
284 |
if( |
|
|
316 | if (isEndLine(stream)) { | |
|
285 | 317 | state.cursorHalf = 0; |
|
286 | 318 | } |
|
287 | 319 | return "unit"; |
|
288 | 320 | } |
|
289 | 321 | |
|
290 | 322 | if (stream.match(keywordsRegexp)){ |
|
291 |
if( |
|
|
323 | if (isEndLine(stream)) { | |
|
292 | 324 | state.cursorHalf = 0; |
|
293 | 325 | } |
|
294 | 326 | return "keyword"; |
@@ -296,7 +328,7 b' CodeMirror.defineMode("sass", function(c' | |||
|
296 | 328 | |
|
297 | 329 | if (stream.match(/^url/) && stream.peek() === "(") { |
|
298 | 330 | state.tokenizer = urlTokens; |
|
299 |
if( |
|
|
331 | if (isEndLine(stream)) { | |
|
300 | 332 | state.cursorHalf = 0; |
|
301 | 333 | } |
|
302 | 334 | return "atom"; |
@@ -306,23 +338,21 b' CodeMirror.defineMode("sass", function(c' | |||
|
306 | 338 | if (ch === "$") { |
|
307 | 339 | stream.next(); |
|
308 | 340 | stream.eatWhile(/[\w-]/); |
|
309 |
if( |
|
|
341 | if (isEndLine(stream)) { | |
|
310 | 342 | state.cursorHalf = 0; |
|
311 | 343 | } |
|
312 |
return "variable- |
|
|
344 | return "variable-2"; | |
|
313 | 345 | } |
|
314 | 346 | |
|
315 | 347 | // bang character for !important, !default, etc. |
|
316 | 348 | if (ch === "!") { |
|
317 | 349 | stream.next(); |
|
318 | if(!stream.peek()){ | |
|
319 | state.cursorHalf = 0; | |
|
320 | } | |
|
350 | state.cursorHalf = 0; | |
|
321 | 351 | return stream.match(/^[\w]+/) ? "keyword": "operator"; |
|
322 | 352 | } |
|
323 | 353 | |
|
324 | 354 | if (stream.match(opRegexp)){ |
|
325 |
if( |
|
|
355 | if (isEndLine(stream)) { | |
|
326 | 356 | state.cursorHalf = 0; |
|
327 | 357 | } |
|
328 | 358 | return "operator"; |
@@ -330,14 +360,24 b' CodeMirror.defineMode("sass", function(c' | |||
|
330 | 360 | |
|
331 | 361 | // attributes |
|
332 | 362 | if (stream.eatWhile(/[\w-]/)) { |
|
333 |
if( |
|
|
363 | if (isEndLine(stream)) { | |
|
334 | 364 | state.cursorHalf = 0; |
|
335 | 365 | } |
|
336 | return "attribute"; | |
|
366 | word = stream.current().toLowerCase(); | |
|
367 | if (valueKeywords.hasOwnProperty(word)) { | |
|
368 | return "atom"; | |
|
369 | } else if (colorKeywords.hasOwnProperty(word)) { | |
|
370 | return "keyword"; | |
|
371 | } else if (propertyKeywords.hasOwnProperty(word)) { | |
|
372 | state.prevProp = stream.current().toLowerCase(); | |
|
373 | return "property"; | |
|
374 | } else { | |
|
375 | return "tag"; | |
|
376 | } | |
|
337 | 377 | } |
|
338 | 378 | |
|
339 | 379 | //stream.eatSpace(); |
|
340 |
if( |
|
|
380 | if (isEndLine(stream)) { | |
|
341 | 381 | state.cursorHalf = 0; |
|
342 | 382 | return null; |
|
343 | 383 | } |
@@ -407,7 +447,7 b' CodeMirror.defineMode("sass", function(c' | |||
|
407 | 447 | return state.scopes[0].offset; |
|
408 | 448 | } |
|
409 | 449 | }; |
|
410 | }); | |
|
450 | }, "css"); | |
|
411 | 451 | |
|
412 | 452 | CodeMirror.defineMIME("text/x-sass", "sass"); |
|
413 | 453 |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /** |
|
5 | 5 | * Author: Koh Zi Han, based on implementation by Koh Zi Chun |
@@ -73,7 +73,8 b' CodeMirror.defineMode("scheme", function' | |||
|
73 | 73 | indentStack: null, |
|
74 | 74 | indentation: 0, |
|
75 | 75 | mode: false, |
|
76 | sExprComment: false | |
|
76 | sExprComment: false, | |
|
77 | sExprQuote: false | |
|
77 | 78 | }; |
|
78 | 79 | }, |
|
79 | 80 | |
@@ -121,7 +122,7 b' CodeMirror.defineMode("scheme", function' | |||
|
121 | 122 | state.sExprComment = 0; |
|
122 | 123 | }else{ |
|
123 | 124 | // if not we just comment the entire of the next token |
|
124 |
stream.eatWhile(/[^ |
|
|
125 | stream.eatWhile(/[^\s\(\)\[\]]/); // eat symbol atom | |
|
125 | 126 | returnType = COMMENT; |
|
126 | 127 | break; |
|
127 | 128 | } |
@@ -133,7 +134,15 b' CodeMirror.defineMode("scheme", function' | |||
|
133 | 134 | returnType = STRING; |
|
134 | 135 | |
|
135 | 136 | } else if (ch == "'") { |
|
136 | returnType = ATOM; | |
|
137 | if (stream.peek() == "(" || stream.peek() == "["){ | |
|
138 | if (typeof state.sExprQuote != "number") { | |
|
139 | state.sExprQuote = 0; | |
|
140 | } // else already in a quoted expression | |
|
141 | returnType = ATOM; | |
|
142 | } else { | |
|
143 | stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/); | |
|
144 | returnType = ATOM; | |
|
145 | } | |
|
137 | 146 | } else if (ch == '#') { |
|
138 | 147 | if (stream.eat("|")) { // Multi-line comment |
|
139 | 148 | state.mode = "comment"; // toggle to comment mode |
@@ -209,6 +218,7 b' CodeMirror.defineMode("scheme", function' | |||
|
209 | 218 | stream.backUp(stream.current().length - 1); // undo all the eating |
|
210 | 219 | |
|
211 | 220 | if(typeof state.sExprComment == "number") state.sExprComment++; |
|
221 | if(typeof state.sExprQuote == "number") state.sExprQuote++; | |
|
212 | 222 | |
|
213 | 223 | returnType = BRACKET; |
|
214 | 224 | } else if (ch == ")" || ch == "]") { |
@@ -222,16 +232,22 b' CodeMirror.defineMode("scheme", function' | |||
|
222 | 232 | state.sExprComment = false; // turn off s-expr commenting mode |
|
223 | 233 | } |
|
224 | 234 | } |
|
235 | if(typeof state.sExprQuote == "number"){ | |
|
236 | if(--state.sExprQuote == 0){ | |
|
237 | returnType = ATOM; // final closing bracket | |
|
238 | state.sExprQuote = false; // turn off s-expr quote mode | |
|
239 | } | |
|
240 | } | |
|
225 | 241 | } |
|
226 | 242 | } else { |
|
227 |
stream.eatWhile(/[\w |
|
|
243 | stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/); | |
|
228 | 244 | |
|
229 | 245 | if (keywords && keywords.propertyIsEnumerable(stream.current())) { |
|
230 | 246 | returnType = BUILTIN; |
|
231 | 247 | } else returnType = "variable"; |
|
232 | 248 | } |
|
233 | 249 | } |
|
234 | return (typeof state.sExprComment == "number") ? COMMENT : returnType; | |
|
250 | return (typeof state.sExprComment == "number") ? COMMENT : ((typeof state.sExprQuote == "number") ? ATOM : returnType); | |
|
235 | 251 | }, |
|
236 | 252 | |
|
237 | 253 | indent: function (state) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -14,26 +14,27 b'' | |||
|
14 | 14 | CodeMirror.defineMode('shell', function() { |
|
15 | 15 | |
|
16 | 16 | var words = {}; |
|
17 |
function define(style, |
|
|
18 | var split = string.split(' '); | |
|
19 | for(var i = 0; i < split.length; i++) { | |
|
20 | words[split[i]] = style; | |
|
17 | function define(style, dict) { | |
|
18 | for(var i = 0; i < dict.length; i++) { | |
|
19 | words[dict[i]] = style; | |
|
21 | 20 | } |
|
22 | 21 | }; |
|
23 | 22 | |
|
24 | // Atoms | |
|
25 | define('atom', 'true false'); | |
|
26 | ||
|
27 | // Keywords | |
|
28 | define('keyword', 'if then do else elif while until for in esac fi fin ' + | |
|
29 | 'fil done exit set unset export function'); | |
|
23 | var commonAtoms = ["true", "false"]; | |
|
24 | var commonKeywords = ["if", "then", "do", "else", "elif", "while", "until", "for", "in", "esac", "fi", | |
|
25 | "fin", "fil", "done", "exit", "set", "unset", "export", "function"]; | |
|
26 | var commonCommands = ["ab", "awk", "bash", "beep", "cat", "cc", "cd", "chown", "chmod", "chroot", "clear", | |
|
27 | "cp", "curl", "cut", "diff", "echo", "find", "gawk", "gcc", "get", "git", "grep", "hg", "kill", "killall", | |
|
28 | "ln", "ls", "make", "mkdir", "openssl", "mv", "nc", "nl", "node", "npm", "ping", "ps", "restart", "rm", | |
|
29 | "rmdir", "sed", "service", "sh", "shopt", "shred", "source", "sort", "sleep", "ssh", "start", "stop", | |
|
30 | "su", "sudo", "svn", "tee", "telnet", "top", "touch", "vi", "vim", "wall", "wc", "wget", "who", "write", | |
|
31 | "yes", "zsh"]; | |
|
30 | 32 | |
|
31 | // Commands | |
|
32 | define('builtin', 'ab awk bash beep cat cc cd chown chmod chroot clear cp ' + | |
|
33 | 'curl cut diff echo find gawk gcc get git grep kill killall ln ls make ' + | |
|
34 | 'mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh ' + | |
|
35 | 'shopt shred source sort sleep ssh start stop su sudo tee telnet top ' + | |
|
36 | 'touch vi vim wall wc wget who write yes zsh'); | |
|
33 | CodeMirror.registerHelper("hintWords", "shell", commonAtoms.concat(commonKeywords, commonCommands)); | |
|
34 | ||
|
35 | define('atom', commonAtoms); | |
|
36 | define('keyword', commonKeywords); | |
|
37 | define('builtin', commonCommands); | |
|
37 | 38 | |
|
38 | 39 | function tokenBase(stream, state) { |
|
39 | 40 | if (stream.eatSpace()) return null; |
@@ -46,7 +47,7 b" CodeMirror.defineMode('shell', function(" | |||
|
46 | 47 | return null; |
|
47 | 48 | } |
|
48 | 49 | if (ch === '\'' || ch === '"' || ch === '`') { |
|
49 | state.tokens.unshift(tokenString(ch)); | |
|
50 | state.tokens.unshift(tokenString(ch, ch === "`" ? "quote" : "string")); | |
|
50 | 51 | return tokenize(stream, state); |
|
51 | 52 | } |
|
52 | 53 | if (ch === '#') { |
@@ -81,41 +82,49 b" CodeMirror.defineMode('shell', function(" | |||
|
81 | 82 | return words.hasOwnProperty(cur) ? words[cur] : null; |
|
82 | 83 | } |
|
83 | 84 | |
|
84 | function tokenString(quote) { | |
|
85 | function tokenString(quote, style) { | |
|
86 | var close = quote == "(" ? ")" : quote == "{" ? "}" : quote | |
|
85 | 87 | return function(stream, state) { |
|
86 |
var next |
|
|
88 | var next, escaped = false; | |
|
87 | 89 | while ((next = stream.next()) != null) { |
|
88 |
if (next === |
|
|
89 | end = true; | |
|
90 | if (next === close && !escaped) { | |
|
91 | state.tokens.shift(); | |
|
90 | 92 | break; |
|
91 | } | |
|
92 | if (next === '$' && !escaped && quote !== '\'') { | |
|
93 | } else if (next === '$' && !escaped && quote !== "'" && stream.peek() != close) { | |
|
93 | 94 | escaped = true; |
|
94 | 95 | stream.backUp(1); |
|
95 | 96 | state.tokens.unshift(tokenDollar); |
|
96 | 97 | break; |
|
98 | } else if (!escaped && quote !== close && next === quote) { | |
|
99 | state.tokens.unshift(tokenString(quote, style)) | |
|
100 | return tokenize(stream, state) | |
|
101 | } else if (!escaped && /['"]/.test(next) && !/['"]/.test(quote)) { | |
|
102 | state.tokens.unshift(tokenStringStart(next, "string")); | |
|
103 | stream.backUp(1); | |
|
104 | break; | |
|
97 | 105 | } |
|
98 | 106 | escaped = !escaped && next === '\\'; |
|
99 | 107 | } |
|
100 | if (end || !escaped) { | |
|
101 | state.tokens.shift(); | |
|
102 | } | |
|
103 | return (quote === '`' || quote === ')' ? 'quote' : 'string'); | |
|
108 | return style; | |
|
104 | 109 | }; |
|
105 | 110 | }; |
|
106 | 111 | |
|
112 | function tokenStringStart(quote, style) { | |
|
113 | return function(stream, state) { | |
|
114 | state.tokens[0] = tokenString(quote, style) | |
|
115 | stream.next() | |
|
116 | return tokenize(stream, state) | |
|
117 | } | |
|
118 | } | |
|
119 | ||
|
107 | 120 | var tokenDollar = function(stream, state) { |
|
108 | 121 | if (state.tokens.length > 1) stream.eat('$'); |
|
109 |
var ch = stream.next() |
|
|
110 | if (ch === '{') hungry = /[^}]/; | |
|
111 | if (ch === '(') { | |
|
112 | state.tokens[0] = tokenString(')'); | |
|
122 | var ch = stream.next() | |
|
123 | if (/['"({]/.test(ch)) { | |
|
124 | state.tokens[0] = tokenString(ch, ch == "(" ? "quote" : ch == "{" ? "def" : "string"); | |
|
113 | 125 | return tokenize(stream, state); |
|
114 | 126 | } |
|
115 |
if (!/\d/.test(ch)) |
|
|
116 | stream.eatWhile(hungry); | |
|
117 | stream.eat('}'); | |
|
118 | } | |
|
127 | if (!/\d/.test(ch)) stream.eatWhile(/\w/); | |
|
119 | 128 | state.tokens.shift(); |
|
120 | 129 | return 'def'; |
|
121 | 130 | }; |
@@ -129,11 +138,15 b" CodeMirror.defineMode('shell', function(" | |||
|
129 | 138 | token: function(stream, state) { |
|
130 | 139 | return tokenize(stream, state); |
|
131 | 140 | }, |
|
141 | closeBrackets: "()[]{}''\"\"``", | |
|
132 | 142 | lineComment: '#', |
|
133 | 143 | fold: "brace" |
|
134 | 144 | }; |
|
135 | 145 | }); |
|
136 | 146 | |
|
137 | 147 | CodeMirror.defineMIME('text/x-sh', 'shell'); |
|
148 | // Apache uses a slightly different Media Type for Shell scripts | |
|
149 | // http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types | |
|
150 | CodeMirror.defineMIME('application/x-sh', 'shell'); | |
|
138 | 151 | |
|
139 | 152 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -170,7 +170,7 b' CodeMirror.defineMode("sieve", function(' | |||
|
170 | 170 | if (stream.eatSpace()) |
|
171 | 171 | return null; |
|
172 | 172 | |
|
173 |
return (state.tokenize || tokenBase)(stream, state); |
|
|
173 | return (state.tokenize || tokenBase)(stream, state); | |
|
174 | 174 | }, |
|
175 | 175 | |
|
176 | 176 | indent: function(state, _textAfter) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | // Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh |
|
5 | 5 | |
@@ -165,7 +165,7 b'' | |||
|
165 | 165 | }; |
|
166 | 166 | return function(stream, state) { |
|
167 | 167 | rubyState = state.rubyState; |
|
168 |
state.rubyState = |
|
|
168 | state.rubyState = CodeMirror.startState(rubyMode); | |
|
169 | 169 | state.tokenize = runSplat; |
|
170 | 170 | return ruby(stream, state); |
|
171 | 171 | }; |
@@ -317,7 +317,7 b'' | |||
|
317 | 317 | |
|
318 | 318 | function startSubMode(mode, state) { |
|
319 | 319 | var subMode = getMode(mode); |
|
320 |
var subState = |
|
|
320 | var subState = CodeMirror.startState(subMode); | |
|
321 | 321 | |
|
322 | 322 | state.subMode = subMode; |
|
323 | 323 | state.subState = subState; |
@@ -507,8 +507,8 b'' | |||
|
507 | 507 | var mode = { |
|
508 | 508 | // default to html mode |
|
509 | 509 | startState: function() { |
|
510 |
var htmlState = |
|
|
511 |
var rubyState = |
|
|
510 | var htmlState = CodeMirror.startState(htmlMode); | |
|
511 | var rubyState = CodeMirror.startState(rubyMode); | |
|
512 | 512 | return { |
|
513 | 513 | htmlState: htmlState, |
|
514 | 514 | rubyState: rubyState, |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /** |
|
5 | 5 | * Smarty 2 and 3 mode. |
@@ -210,9 +210,9 b'' | |||
|
210 | 210 | state.last = last; |
|
211 | 211 | return style; |
|
212 | 212 | }, |
|
213 | indent: function(state, text) { | |
|
213 | indent: function(state, text, line) { | |
|
214 | 214 | if (state.tokenize == tokenTop && baseMode.indent) |
|
215 | return baseMode.indent(state.base, text); | |
|
215 | return baseMode.indent(state.base, text, line); | |
|
216 | 216 | else |
|
217 | 217 | return CodeMirror.Pass; |
|
218 | 218 | }, |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -14,12 +14,12 b'' | |||
|
14 | 14 | CodeMirror.defineMode("solr", function() { |
|
15 | 15 | "use strict"; |
|
16 | 16 | |
|
17 |
var isStringChar = /[^\s\|\!\+\-\*\?\~\^\&\:\(\)\[\]\{\}\ |
|
|
17 | var isStringChar = /[^\s\|\!\+\-\*\?\~\^\&\:\(\)\[\]\{\}\"\\]/; | |
|
18 | 18 | var isOperatorChar = /[\|\!\+\-\*\?\~\^\&]/; |
|
19 | 19 | var isOperatorString = /^(OR|AND|NOT|TO)$/i; |
|
20 | 20 | |
|
21 | 21 | function isNumber(word) { |
|
22 |
return parseFloat(word |
|
|
22 | return parseFloat(word).toString() === word; | |
|
23 | 23 | } |
|
24 | 24 | |
|
25 | 25 | function tokenString(quote) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -11,9 +11,45 b'' | |||
|
11 | 11 | })(function(CodeMirror) { |
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | var indentingTags = ["template", "literal", "msg", "fallbackmsg", "let", "if", "elseif", | |
|
15 | "else", "switch", "case", "default", "foreach", "ifempty", "for", | |
|
16 | "call", "param", "deltemplate", "delcall", "log"]; | |
|
14 | var paramData = { noEndTag: true, soyState: "param-def" }; | |
|
15 | var tags = { | |
|
16 | "alias": { noEndTag: true }, | |
|
17 | "delpackage": { noEndTag: true }, | |
|
18 | "namespace": { noEndTag: true, soyState: "namespace-def" }, | |
|
19 | "@param": paramData, | |
|
20 | "@param?": paramData, | |
|
21 | "@inject": paramData, | |
|
22 | "@inject?": paramData, | |
|
23 | "@state": paramData, | |
|
24 | "@state?": paramData, | |
|
25 | "template": { soyState: "templ-def", variableScope: true}, | |
|
26 | "literal": { }, | |
|
27 | "msg": {}, | |
|
28 | "fallbackmsg": { noEndTag: true, reduceIndent: true}, | |
|
29 | "select": {}, | |
|
30 | "plural": {}, | |
|
31 | "let": { soyState: "var-def" }, | |
|
32 | "if": {}, | |
|
33 | "elseif": { noEndTag: true, reduceIndent: true}, | |
|
34 | "else": { noEndTag: true, reduceIndent: true}, | |
|
35 | "switch": {}, | |
|
36 | "case": { noEndTag: true, reduceIndent: true}, | |
|
37 | "default": { noEndTag: true, reduceIndent: true}, | |
|
38 | "foreach": { variableScope: true, soyState: "var-def" }, | |
|
39 | "ifempty": { noEndTag: true, reduceIndent: true}, | |
|
40 | "for": { variableScope: true, soyState: "var-def" }, | |
|
41 | "call": { soyState: "templ-ref" }, | |
|
42 | "param": { soyState: "param-ref"}, | |
|
43 | "print": { noEndTag: true }, | |
|
44 | "deltemplate": { soyState: "templ-def", variableScope: true}, | |
|
45 | "delcall": { soyState: "templ-ref" }, | |
|
46 | "log": {}, | |
|
47 | "element": { variableScope: true }, | |
|
48 | }; | |
|
49 | ||
|
50 | var indentingTags = Object.keys(tags).filter(function(tag) { | |
|
51 | return !tags[tag].noEndTag || tags[tag].reduceIndent; | |
|
52 | }); | |
|
17 | 53 | |
|
18 | 54 | CodeMirror.defineMode("soy", function(config) { |
|
19 | 55 | var textMode = CodeMirror.getMode(config, "text/plain"); |
@@ -22,6 +58,7 b'' | |||
|
22 | 58 | attributes: textMode, |
|
23 | 59 | text: textMode, |
|
24 | 60 | uri: textMode, |
|
61 | trusted_resource_uri: textMode, | |
|
25 | 62 | css: CodeMirror.getMode(config, "text/css"), |
|
26 | 63 | js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit}) |
|
27 | 64 | }; |
@@ -31,6 +68,12 b'' | |||
|
31 | 68 | } |
|
32 | 69 | |
|
33 | 70 | function tokenUntil(stream, state, untilRegExp) { |
|
71 | if (stream.sol()) { | |
|
72 | for (var indent = 0; indent < state.indent; indent++) { | |
|
73 | if (!stream.eat(/\s/)) break; | |
|
74 | } | |
|
75 | if (indent) return null; | |
|
76 | } | |
|
34 | 77 | var oldString = stream.string; |
|
35 | 78 | var match = untilRegExp.exec(oldString.substr(stream.pos)); |
|
36 | 79 | if (match) { |
@@ -39,33 +82,82 b'' | |||
|
39 | 82 | stream.string = oldString.substr(0, stream.pos + match.index); |
|
40 | 83 | } |
|
41 | 84 | var result = stream.hideFirstChars(state.indent, function() { |
|
42 |
r |
|
|
85 | var localState = last(state.localStates); | |
|
86 | return localState.mode.token(stream, localState.state); | |
|
43 | 87 | }); |
|
44 | 88 | stream.string = oldString; |
|
45 | 89 | return result; |
|
46 | 90 | } |
|
47 | 91 | |
|
92 | function contains(list, element) { | |
|
93 | while (list) { | |
|
94 | if (list.element === element) return true; | |
|
95 | list = list.next; | |
|
96 | } | |
|
97 | return false; | |
|
98 | } | |
|
99 | ||
|
100 | function prepend(list, element) { | |
|
101 | return { | |
|
102 | element: element, | |
|
103 | next: list | |
|
104 | }; | |
|
105 | } | |
|
106 | ||
|
107 | function popcontext(state) { | |
|
108 | if (!state.context) return; | |
|
109 | if (state.context.scope) { | |
|
110 | state.variables = state.context.scope; | |
|
111 | } | |
|
112 | state.context = state.context.previousContext; | |
|
113 | } | |
|
114 | ||
|
115 | // Reference a variable `name` in `list`. | |
|
116 | // Let `loose` be truthy to ignore missing identifiers. | |
|
117 | function ref(list, name, loose) { | |
|
118 | return contains(list, name) ? "variable-2" : (loose ? "variable" : "variable-2 error"); | |
|
119 | } | |
|
120 | ||
|
121 | // Data for an open soy tag. | |
|
122 | function Context(previousContext, tag, scope) { | |
|
123 | this.previousContext = previousContext; | |
|
124 | this.tag = tag; | |
|
125 | this.kind = null; | |
|
126 | this.scope = scope; | |
|
127 | } | |
|
128 | ||
|
48 | 129 | return { |
|
49 | 130 | startState: function() { |
|
50 | 131 | return { |
|
51 | kind: [], | |
|
52 | kindTag: [], | |
|
53 | 132 | soyState: [], |
|
133 | templates: null, | |
|
134 | variables: prepend(null, 'ij'), | |
|
135 | scopes: null, | |
|
54 | 136 | indent: 0, |
|
55 | localMode: modes.html, | |
|
56 | localState: CodeMirror.startState(modes.html) | |
|
137 | quoteKind: null, | |
|
138 | context: null, | |
|
139 | localStates: [{ | |
|
140 | mode: modes.html, | |
|
141 | state: CodeMirror.startState(modes.html) | |
|
142 | }] | |
|
57 | 143 | }; |
|
58 | 144 | }, |
|
59 | 145 | |
|
60 | 146 | copyState: function(state) { |
|
61 | 147 | return { |
|
62 | 148 | tag: state.tag, // Last seen Soy tag. |
|
63 | kind: state.kind.concat([]), // Values of kind="" attributes. | |
|
64 | kindTag: state.kindTag.concat([]), // Opened tags with kind="" attributes. | |
|
65 | 149 | soyState: state.soyState.concat([]), |
|
150 | templates: state.templates, | |
|
151 | variables: state.variables, | |
|
152 | context: state.context, | |
|
66 | 153 | indent: state.indent, // Indentation of the following line. |
|
67 |
|
|
|
68 | localState: CodeMirror.copyState(state.localMode, state.localState) | |
|
154 | quoteKind: state.quoteKind, | |
|
155 | localStates: state.localStates.map(function(localState) { | |
|
156 | return { | |
|
157 | mode: localState.mode, | |
|
158 | state: CodeMirror.copyState(localState.mode, localState.state) | |
|
159 | }; | |
|
160 | }) | |
|
69 | 161 | }; |
|
70 | 162 | }, |
|
71 | 163 | |
@@ -79,36 +171,159 b'' | |||
|
79 | 171 | } else { |
|
80 | 172 | stream.skipToEnd(); |
|
81 | 173 | } |
|
174 | if (!state.context || !state.context.scope) { | |
|
175 | var paramRe = /@param\??\s+(\S+)/g; | |
|
176 | var current = stream.current(); | |
|
177 | for (var match; (match = paramRe.exec(current)); ) { | |
|
178 | state.variables = prepend(state.variables, match[1]); | |
|
179 | } | |
|
180 | } | |
|
82 | 181 | return "comment"; |
|
83 | 182 | |
|
84 |
case " |
|
|
85 |
|
|
|
86 | state.indent -= 2 * config.indentUnit; | |
|
183 | case "string": | |
|
184 | var match = stream.match(/^.*?(["']|\\[\s\S])/); | |
|
185 | if (!match) { | |
|
186 | stream.skipToEnd(); | |
|
187 | } else if (match[1] == state.quoteKind) { | |
|
188 | state.quoteKind = null; | |
|
189 | state.soyState.pop(); | |
|
190 | } | |
|
191 | return "string"; | |
|
192 | } | |
|
193 | ||
|
194 | if (!state.soyState.length || last(state.soyState) != "literal") { | |
|
195 | if (stream.match(/^\/\*/)) { | |
|
196 | state.soyState.push("comment"); | |
|
197 | return "comment"; | |
|
198 | } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { | |
|
199 | return "comment"; | |
|
200 | } | |
|
201 | } | |
|
202 | ||
|
203 | switch (last(state.soyState)) { | |
|
204 | case "templ-def": | |
|
205 | if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) { | |
|
206 | state.templates = prepend(state.templates, match[1]); | |
|
207 | state.soyState.pop(); | |
|
208 | return "def"; | |
|
209 | } | |
|
210 | stream.next(); | |
|
211 | return null; | |
|
212 | ||
|
213 | case "templ-ref": | |
|
214 | if (match = stream.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/)) { | |
|
87 | 215 | state.soyState.pop(); |
|
88 | return "variable-2"; | |
|
216 | // If the first character is '.', it can only be a local template. | |
|
217 | if (match[0][0] == '.') { | |
|
218 | return "variable-2" | |
|
219 | } | |
|
220 | // Otherwise | |
|
221 | return "variable"; | |
|
222 | } | |
|
223 | stream.next(); | |
|
224 | return null; | |
|
225 | ||
|
226 | case "namespace-def": | |
|
227 | if (match = stream.match(/^\.?([\w\.]+)/)) { | |
|
228 | state.soyState.pop(); | |
|
229 | return "variable"; | |
|
230 | } | |
|
231 | stream.next(); | |
|
232 | return null; | |
|
233 | ||
|
234 | case "param-def": | |
|
235 | if (match = stream.match(/^\w+/)) { | |
|
236 | state.variables = prepend(state.variables, match[0]); | |
|
237 | state.soyState.pop(); | |
|
238 | state.soyState.push("param-type"); | |
|
239 | return "def"; | |
|
240 | } | |
|
241 | stream.next(); | |
|
242 | return null; | |
|
243 | ||
|
244 | case "param-ref": | |
|
245 | if (match = stream.match(/^\w+/)) { | |
|
246 | state.soyState.pop(); | |
|
247 | return "property"; | |
|
248 | } | |
|
249 | stream.next(); | |
|
250 | return null; | |
|
251 | ||
|
252 | case "param-type": | |
|
253 | if (stream.peek() == "}") { | |
|
254 | state.soyState.pop(); | |
|
255 | return null; | |
|
256 | } | |
|
257 | if (stream.eatWhile(/^([\w]+|[?])/)) { | |
|
258 | return "type"; | |
|
259 | } | |
|
260 | stream.next(); | |
|
261 | return null; | |
|
262 | ||
|
263 | case "var-def": | |
|
264 | if (match = stream.match(/^\$([\w]+)/)) { | |
|
265 | state.variables = prepend(state.variables, match[1]); | |
|
266 | state.soyState.pop(); | |
|
267 | return "def"; | |
|
89 | 268 | } |
|
90 | 269 | stream.next(); |
|
91 | 270 | return null; |
|
92 | 271 | |
|
93 | 272 | case "tag": |
|
273 | var endTag = state.tag[0] == "/"; | |
|
274 | var tagName = endTag ? state.tag.substring(1) : state.tag; | |
|
275 | var tag = tags[tagName]; | |
|
94 | 276 | if (stream.match(/^\/?}/)) { |
|
95 | if (state.tag == "/template" || state.tag == "/deltemplate") state.indent = 0; | |
|
96 | else state.indent -= (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1) * config.indentUnit; | |
|
277 | var selfClosed = stream.current() == "/}"; | |
|
278 | if (selfClosed && !endTag) { | |
|
279 | popcontext(state); | |
|
280 | } | |
|
281 | if (state.tag == "/template" || state.tag == "/deltemplate") { | |
|
282 | state.variables = prepend(null, 'ij'); | |
|
283 | state.indent = 0; | |
|
284 | } else { | |
|
285 | state.indent -= config.indentUnit * | |
|
286 | (selfClosed || indentingTags.indexOf(state.tag) == -1 ? 2 : 1); | |
|
287 | } | |
|
97 | 288 | state.soyState.pop(); |
|
98 | 289 | return "keyword"; |
|
99 | 290 | } else if (stream.match(/^([\w?]+)(?==)/)) { |
|
100 | if (stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) { | |
|
291 | if (state.context && state.context.tag == tagName && stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) { | |
|
101 | 292 | var kind = match[1]; |
|
102 |
state.kind |
|
|
103 | state.kindTag.push(state.tag); | |
|
104 | state.localMode = modes[kind] || modes.html; | |
|
105 | state.localState = CodeMirror.startState(state.localMode); | |
|
293 | state.context.kind = kind; | |
|
294 | var mode = modes[kind] || modes.html; | |
|
295 | var localState = last(state.localStates); | |
|
296 | if (localState.mode.indent) { | |
|
297 | state.indent += localState.mode.indent(localState.state, "", ""); | |
|
298 | } | |
|
299 | state.localStates.push({ | |
|
300 | mode: mode, | |
|
301 | state: CodeMirror.startState(mode) | |
|
302 | }); | |
|
106 | 303 | } |
|
107 | 304 | return "attribute"; |
|
108 |
} else if (stream.match(/ |
|
|
305 | } else if (match = stream.match(/([\w]+)(?=\()/)) { | |
|
306 | return "variable callee"; | |
|
307 | } else if (match = stream.match(/^["']/)) { | |
|
109 | 308 | state.soyState.push("string"); |
|
309 | state.quoteKind = match; | |
|
110 | 310 | return "string"; |
|
111 | 311 | } |
|
312 | if (stream.match(/(null|true|false)(?!\w)/) || | |
|
313 | stream.match(/0x([0-9a-fA-F]{2,})/) || | |
|
314 | stream.match(/-?([0-9]*[.])?[0-9]+(e[0-9]*)?/)) { | |
|
315 | return "atom"; | |
|
316 | } | |
|
317 | if (stream.match(/(\||[+\-*\/%]|[=!]=|\?:|[<>]=?)/)) { | |
|
318 | // Tokenize filter, binary, null propagator, and equality operators. | |
|
319 | return "operator"; | |
|
320 | } | |
|
321 | if (match = stream.match(/^\$([\w]+)/)) { | |
|
322 | return ref(state.variables, match[1]); | |
|
323 | } | |
|
324 | if (match = stream.match(/^\w+/)) { | |
|
325 | return /^(?:as|and|or|not|in)$/.test(match[0]) ? "keyword" : null; | |
|
326 | } | |
|
112 | 327 | stream.next(); |
|
113 | 328 | return null; |
|
114 | 329 | |
@@ -119,40 +334,59 b'' | |||
|
119 | 334 | return this.token(stream, state); |
|
120 | 335 | } |
|
121 | 336 | return tokenUntil(stream, state, /\{\/literal}/); |
|
122 | ||
|
123 | case "string": | |
|
124 | if (stream.match(/^.*?"/)) { | |
|
125 | state.soyState.pop(); | |
|
126 | } else { | |
|
127 | stream.skipToEnd(); | |
|
128 | } | |
|
129 | return "string"; | |
|
130 | 337 | } |
|
131 | 338 | |
|
132 |
if (stream.match(/^\ |
|
|
133 | state.soyState.push("comment"); | |
|
134 | return "comment"; | |
|
135 | } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { | |
|
136 | return "comment"; | |
|
137 | } else if (stream.match(/^\{\$[\w?]*/)) { | |
|
138 | state.indent += 2 * config.indentUnit; | |
|
139 | state.soyState.push("variable"); | |
|
140 | return "variable-2"; | |
|
141 | } else if (stream.match(/^\{literal}/)) { | |
|
339 | if (stream.match(/^\{literal}/)) { | |
|
142 | 340 | state.indent += config.indentUnit; |
|
143 | 341 | state.soyState.push("literal"); |
|
342 | state.context = new Context(state.context, "literal", state.variables); | |
|
144 | 343 | return "keyword"; |
|
145 | } else if (match = stream.match(/^\{([\/@\\]?[\w?]*)/)) { | |
|
146 | if (match[1] != "/switch") | |
|
147 | state.indent += (/^(\/|(else|elseif|case|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit; | |
|
344 | ||
|
345 | // A tag-keyword must be followed by whitespace, comment or a closing tag. | |
|
346 | } else if (match = stream.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)) { | |
|
347 | var prevTag = state.tag; | |
|
148 | 348 | state.tag = match[1]; |
|
149 | if (state.tag == "/" + last(state.kindTag)) { | |
|
150 | // We found the tag that opened the current kind="". | |
|
151 | state.kind.pop(); | |
|
152 | state.kindTag.pop(); | |
|
153 | state.localMode = modes[last(state.kind)] || modes.html; | |
|
154 | state.localState = CodeMirror.startState(state.localMode); | |
|
349 | var endTag = state.tag[0] == "/"; | |
|
350 | var indentingTag = !!tags[state.tag]; | |
|
351 | var tagName = endTag ? state.tag.substring(1) : state.tag; | |
|
352 | var tag = tags[tagName]; | |
|
353 | if (state.tag != "/switch") | |
|
354 | state.indent += ((endTag || tag && tag.reduceIndent) && prevTag != "switch" ? 1 : 2) * config.indentUnit; | |
|
355 | ||
|
356 | state.soyState.push("tag"); | |
|
357 | var tagError = false; | |
|
358 | if (tag) { | |
|
359 | if (!endTag) { | |
|
360 | if (tag.soyState) state.soyState.push(tag.soyState); | |
|
361 | } | |
|
362 | // If a new tag, open a new context. | |
|
363 | if (!tag.noEndTag && (indentingTag || !endTag)) { | |
|
364 | state.context = new Context(state.context, state.tag, tag.variableScope ? state.variables : null); | |
|
365 | // Otherwise close the current context. | |
|
366 | } else if (endTag) { | |
|
367 | if (!state.context || state.context.tag != tagName) { | |
|
368 | tagError = true; | |
|
369 | } else if (state.context) { | |
|
370 | if (state.context.kind) { | |
|
371 | state.localStates.pop(); | |
|
372 | var localState = last(state.localStates); | |
|
373 | if (localState.mode.indent) { | |
|
374 | state.indent -= localState.mode.indent(localState.state, "", ""); | |
|
375 | } | |
|
376 | } | |
|
377 | popcontext(state); | |
|
378 | } | |
|
379 | } | |
|
380 | } else if (endTag) { | |
|
381 | // Assume all tags with a closing tag are defined in the config. | |
|
382 | tagError = true; | |
|
155 | 383 | } |
|
384 | return (tagError ? "error " : "") + "keyword"; | |
|
385 | ||
|
386 | // Not a tag-keyword; it's an implicit print tag. | |
|
387 | } else if (stream.eat('{')) { | |
|
388 | state.tag = "print"; | |
|
389 | state.indent += 2 * config.indentUnit; | |
|
156 | 390 | state.soyState.push("tag"); |
|
157 | 391 | return "keyword"; |
|
158 | 392 | } |
@@ -160,7 +394,7 b'' | |||
|
160 | 394 | return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); |
|
161 | 395 | }, |
|
162 | 396 | |
|
163 | indent: function(state, textAfter) { | |
|
397 | indent: function(state, textAfter, line) { | |
|
164 | 398 | var indent = state.indent, top = last(state.soyState); |
|
165 | 399 | if (top == "comment") return CodeMirror.Pass; |
|
166 | 400 | |
@@ -172,14 +406,16 b'' | |||
|
172 | 406 | if (state.tag != "switch" && /^\{(case|default)\b/.test(textAfter)) indent -= config.indentUnit; |
|
173 | 407 | if (/^\{\/switch\b/.test(textAfter)) indent -= config.indentUnit; |
|
174 | 408 | } |
|
175 | if (indent && state.localMode.indent) | |
|
176 | indent += state.localMode.indent(state.localState, textAfter); | |
|
409 | var localState = last(state.localStates); | |
|
410 | if (indent && localState.mode.indent) { | |
|
411 | indent += localState.mode.indent(localState.state, textAfter, line); | |
|
412 | } | |
|
177 | 413 | return indent; |
|
178 | 414 | }, |
|
179 | 415 | |
|
180 | 416 | innerMode: function(state) { |
|
181 | 417 | if (state.soyState.length && last(state.soyState) != "literal") return null; |
|
182 |
else return |
|
|
418 | else return last(state.localStates); | |
|
183 | 419 | }, |
|
184 | 420 | |
|
185 | 421 | electricInput: /^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/, |
@@ -187,12 +423,15 b'' | |||
|
187 | 423 | blockCommentStart: "/*", |
|
188 | 424 | blockCommentEnd: "*/", |
|
189 | 425 | blockCommentContinue: " * ", |
|
426 | useInnerComments: false, | |
|
190 | 427 | fold: "indent" |
|
191 | 428 | }; |
|
192 | 429 | }, "htmlmixed"); |
|
193 | 430 | |
|
194 |
CodeMirror.registerHelper(" |
|
|
195 | ["delpackage", "namespace", "alias", "print", "css", "debugger"])); | |
|
431 | CodeMirror.registerHelper("wordChars", "soy", /[\w$]/); | |
|
432 | ||
|
433 | CodeMirror.registerHelper("hintWords", "soy", Object.keys(tags).concat( | |
|
434 | ["css", "debugger"])); | |
|
196 | 435 | |
|
197 | 436 | CodeMirror.defineMIME("text/x-soy", "soy"); |
|
198 | 437 | }); |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -25,7 +25,7 b' CodeMirror.defineMode("sparql", function' | |||
|
25 | 25 | "strbefore", "strafter", "year", "month", "day", "hours", "minutes", "seconds", |
|
26 | 26 | "timezone", "tz", "now", "uuid", "struuid", "md5", "sha1", "sha256", "sha384", |
|
27 | 27 | "sha512", "coalesce", "if", "strlang", "strdt", "isnumeric", "regex", "exists", |
|
28 | "isblank", "isliteral", "a"]); | |
|
28 | "isblank", "isliteral", "a", "bind"]); | |
|
29 | 29 | var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe", |
|
30 | 30 | "ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional", |
|
31 | 31 | "graph", "by", "asc", "desc", "as", "having", "undef", "values", "group", |
@@ -41,7 +41,7 b' CodeMirror.defineMode("sparql", function' | |||
|
41 | 41 | if(ch == "?" && stream.match(/\s/, false)){ |
|
42 | 42 | return "operator"; |
|
43 | 43 | } |
|
44 | stream.match(/^[\w\d]*/); | |
|
44 | stream.match(/^[A-Za-z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][A-Za-z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*/); | |
|
45 | 45 | return "variable-2"; |
|
46 | 46 | } |
|
47 | 47 | else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) { |
@@ -135,7 +135,11 b' CodeMirror.defineMode("sparql", function' | |||
|
135 | 135 | else if (curPunc == "{") pushContext(state, "}", stream.column()); |
|
136 | 136 | else if (/[\]\}\)]/.test(curPunc)) { |
|
137 | 137 | while (state.context && state.context.type == "pattern") popContext(state); |
|
138 |
if (state.context && curPunc == state.context.type) |
|
|
138 | if (state.context && curPunc == state.context.type) { | |
|
139 | popContext(state); | |
|
140 | if (curPunc == "}" && state.context && state.context.type == "pattern") | |
|
141 | popContext(state); | |
|
142 | } | |
|
139 | 143 | } |
|
140 | 144 | else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state); |
|
141 | 145 | else if (/atom|string|variable/.test(style) && state.context) { |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -70,7 +70,10 b'' | |||
|
70 | 70 | return "operator"; |
|
71 | 71 | case "\\": |
|
72 | 72 | if (stream.match(/\\[a-z]+/)) return "string-2"; |
|
73 |
else |
|
|
73 | else { | |
|
74 | stream.next(); | |
|
75 | return "atom"; | |
|
76 | } | |
|
74 | 77 | case ".": |
|
75 | 78 | case ",": |
|
76 | 79 | case ";": |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | (function(mod) { |
|
5 | 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
@@ -12,16 +12,17 b'' | |||
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | 14 | CodeMirror.defineMode("sql", function(config, parserConfig) { |
|
15 | "use strict"; | |
|
16 | ||
|
17 | 15 | var client = parserConfig.client || {}, |
|
18 | 16 | atoms = parserConfig.atoms || {"false": true, "true": true, "null": true}, |
|
19 |
builtin = parserConfig.builtin || |
|
|
20 |
keywords = parserConfig.keywords || |
|
|
21 | operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/, | |
|
17 | builtin = parserConfig.builtin || set(defaultBuiltin), | |
|
18 | keywords = parserConfig.keywords || set(sqlKeywords), | |
|
19 | operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^\/]/, | |
|
22 | 20 | support = parserConfig.support || {}, |
|
23 | 21 | hooks = parserConfig.hooks || {}, |
|
24 |
dateSQL = parserConfig.dateSQL || {"date" : true, "time" : true, "timestamp" : true} |
|
|
22 | dateSQL = parserConfig.dateSQL || {"date" : true, "time" : true, "timestamp" : true}, | |
|
23 | backslashStringEscapes = parserConfig.backslashStringEscapes !== false, | |
|
24 | brackets = parserConfig.brackets || /^[\{}\(\)\[\]]/, | |
|
25 | punctuation = parserConfig.punctuation || /^[;.,:]/ | |
|
25 | 26 | |
|
26 | 27 | function tokenBase(stream, state) { |
|
27 | 28 | var ch = stream.next(); |
@@ -32,13 +33,13 b' CodeMirror.defineMode("sql", function(co' | |||
|
32 | 33 | if (result !== false) return result; |
|
33 | 34 | } |
|
34 | 35 | |
|
35 |
if (support.hexNumber |
|
|
36 | if (support.hexNumber && | |
|
36 | 37 | ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) |
|
37 | 38 | || (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/))) { |
|
38 | 39 | // hex |
|
39 | 40 | // ref: http://dev.mysql.com/doc/refman/5.5/en/hexadecimal-literals.html |
|
40 | 41 | return "number"; |
|
41 |
} else if (support.binaryNumber |
|
|
42 | } else if (support.binaryNumber && | |
|
42 | 43 | (((ch == "b" || ch == "B") && stream.match(/^'[01]+'/)) |
|
43 | 44 | || (ch == "0" && stream.match(/^b[01]+/)))) { |
|
44 | 45 | // bitstring |
@@ -47,8 +48,8 b' CodeMirror.defineMode("sql", function(co' | |||
|
47 | 48 | } else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) { |
|
48 | 49 | // numbers |
|
49 | 50 | // ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html |
|
50 |
|
|
|
51 |
support.decimallessFloat |
|
|
51 | stream.match(/^[0-9]*(\.[0-9]+)?([eE][-+]?[0-9]+)?/); | |
|
52 | support.decimallessFloat && stream.match(/^\.(?!\.)/); | |
|
52 | 53 | return "number"; |
|
53 | 54 | } else if (ch == "?" && (stream.eatSpace() || stream.eol() || stream.eat(";"))) { |
|
54 | 55 | // placeholders |
@@ -58,15 +59,12 b' CodeMirror.defineMode("sql", function(co' | |||
|
58 | 59 | // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html |
|
59 | 60 | state.tokenize = tokenLiteral(ch); |
|
60 | 61 | return state.tokenize(stream, state); |
|
61 |
} else if ((((support.nCharCast |
|
|
62 |
|| (support.charsetCast |
|
|
62 | } else if ((((support.nCharCast && (ch == "n" || ch == "N")) | |
|
63 | || (support.charsetCast && ch == "_" && stream.match(/[a-z][a-z0-9]*/i))) | |
|
63 | 64 | && (stream.peek() == "'" || stream.peek() == '"'))) { |
|
64 | 65 | // charset casting: _utf8'str', N'str', n'str' |
|
65 | 66 | // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html |
|
66 | 67 | return "keyword"; |
|
67 | } else if (/^[\(\),\;\[\]]/.test(ch)) { | |
|
68 | // no highlightning | |
|
69 | return null; | |
|
70 | 68 | } else if (support.commentSlashSlash && ch == "/" && stream.eat("/")) { |
|
71 | 69 | // 1-line comment |
|
72 | 70 | stream.skipToEnd(); |
@@ -80,22 +78,29 b' CodeMirror.defineMode("sql", function(co' | |||
|
80 | 78 | } else if (ch == "/" && stream.eat("*")) { |
|
81 | 79 | // multi-line comments |
|
82 | 80 | // ref: https://kb.askmonty.org/en/comment-syntax/ |
|
83 | state.tokenize = tokenComment; | |
|
81 | state.tokenize = tokenComment(1); | |
|
84 | 82 | return state.tokenize(stream, state); |
|
85 | 83 | } else if (ch == ".") { |
|
86 | 84 | // .1 for 0.1 |
|
87 |
if (support.zerolessFloat |
|
|
85 | if (support.zerolessFloat && stream.match(/^(?:\d+(?:e[+-]?\d+)?)/i)) | |
|
88 | 86 | return "number"; |
|
89 | } | |
|
87 | if (stream.match(/^\.+/)) | |
|
88 | return null | |
|
90 | 89 | // .table_name (ODBC) |
|
91 | 90 | // // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html |
|
92 |
if (support.ODBCdotTable |
|
|
91 | if (support.ODBCdotTable && stream.match(/^[\w\d_]+/)) | |
|
93 | 92 | return "variable-2"; |
|
94 | } | |
|
95 | 93 | } else if (operatorChars.test(ch)) { |
|
96 | 94 | // operators |
|
97 | 95 | stream.eatWhile(operatorChars); |
|
98 |
return |
|
|
96 | return "operator"; | |
|
97 | } else if (brackets.test(ch)) { | |
|
98 | // brackets | |
|
99 | return "bracket"; | |
|
100 | } else if (punctuation.test(ch)) { | |
|
101 | // punctuation | |
|
102 | stream.eatWhile(punctuation); | |
|
103 | return "punctuation"; | |
|
99 | 104 | } else if (ch == '{' && |
|
100 | 105 | (stream.match(/^( )*(d|D|t|T|ts|TS)( )*'[^']*'( )*}/) || stream.match(/^( )*(d|D|t|T|ts|TS)( )*"[^"]*"( )*}/))) { |
|
101 | 106 | // dates (weird ODBC syntax) |
@@ -125,25 +130,20 b' CodeMirror.defineMode("sql", function(co' | |||
|
125 | 130 | state.tokenize = tokenBase; |
|
126 | 131 | break; |
|
127 | 132 | } |
|
128 | escaped = !escaped && ch == "\\"; | |
|
133 | escaped = backslashStringEscapes && !escaped && ch == "\\"; | |
|
129 | 134 | } |
|
130 | 135 | return "string"; |
|
131 | 136 | }; |
|
132 | 137 | } |
|
133 |
function tokenComment( |
|
|
134 | while (true) { | |
|
135 | if (stream.skipTo("*")) { | |
|
136 |
stream. |
|
|
137 | if (stream.eat("/")) { | |
|
138 |
state.tokenize = token |
|
|
139 | break; | |
|
140 | } | |
|
141 | } else { | |
|
142 | stream.skipToEnd(); | |
|
143 | break; | |
|
144 | } | |
|
138 | function tokenComment(depth) { | |
|
139 | return function(stream, state) { | |
|
140 | var m = stream.match(/^.*?(\/\*|\*\/)/) | |
|
141 | if (!m) stream.skipToEnd() | |
|
142 | else if (m[1] == "/*") state.tokenize = tokenComment(depth + 1) | |
|
143 | else if (depth > 1) state.tokenize = tokenComment(depth - 1) | |
|
144 | else state.tokenize = tokenBase | |
|
145 | return "comment" | |
|
145 | 146 | } |
|
146 | return "comment"; | |
|
147 | 147 | } |
|
148 | 148 | |
|
149 | 149 | function pushContext(stream, state, type) { |
@@ -170,7 +170,7 b' CodeMirror.defineMode("sql", function(co' | |||
|
170 | 170 | if (state.context && state.context.align == null) |
|
171 | 171 | state.context.align = false; |
|
172 | 172 | } |
|
173 | if (stream.eatSpace()) return null; | |
|
173 | if (state.tokenize == tokenBase && stream.eatSpace()) return null; | |
|
174 | 174 | |
|
175 | 175 | var style = state.tokenize(stream, state); |
|
176 | 176 | if (style == "comment") return style; |
@@ -198,13 +198,11 b' CodeMirror.defineMode("sql", function(co' | |||
|
198 | 198 | |
|
199 | 199 | blockCommentStart: "/*", |
|
200 | 200 | blockCommentEnd: "*/", |
|
201 |
lineComment: support.commentSlashSlash ? "//" : support.commentHash ? "#" : |
|
|
201 | lineComment: support.commentSlashSlash ? "//" : support.commentHash ? "#" : "--", | |
|
202 | closeBrackets: "()[]{}''\"\"``" | |
|
202 | 203 | }; |
|
203 | 204 | }); |
|
204 | 205 | |
|
205 | (function() { | |
|
206 | "use strict"; | |
|
207 | ||
|
208 | 206 | // `identifier` |
|
209 | 207 | function hookIdentifier(stream) { |
|
210 | 208 | // MySQL/MariaDB identifiers |
@@ -217,6 +215,19 b' CodeMirror.defineMode("sql", function(co' | |||
|
217 | 215 | return stream.eatWhile(/\w/) ? "variable-2" : null; |
|
218 | 216 | } |
|
219 | 217 | |
|
218 | // "identifier" | |
|
219 | function hookIdentifierDoublequote(stream) { | |
|
220 | // Standard SQL /SQLite identifiers | |
|
221 | // ref: http://web.archive.org/web/20160813185132/http://savage.net.au/SQL/sql-99.bnf.html#delimited%20identifier | |
|
222 | // ref: http://sqlite.org/lang_keywords.html | |
|
223 | var ch; | |
|
224 | while ((ch = stream.next()) != null) { | |
|
225 | if (ch == "\"" && !stream.eat("\"")) return "variable-2"; | |
|
226 | } | |
|
227 | stream.backUp(stream.current().length - 1); | |
|
228 | return stream.eatWhile(/\w/) ? "variable-2" : null; | |
|
229 | } | |
|
230 | ||
|
220 | 231 | // variable token |
|
221 | 232 | function hookVar(stream) { |
|
222 | 233 | // variables |
@@ -257,7 +268,7 b' CodeMirror.defineMode("sql", function(co' | |||
|
257 | 268 | } |
|
258 | 269 | |
|
259 | 270 | // these keywords are used by all SQL dialects (however, a mode can still overwrite it) |
|
260 | var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where limit"; | |
|
271 | var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where limit "; | |
|
261 | 272 | |
|
262 | 273 | // turn a space-separated list into an array |
|
263 | 274 | function set(str) { |
@@ -266,24 +277,28 b' CodeMirror.defineMode("sql", function(co' | |||
|
266 | 277 | return obj; |
|
267 | 278 | } |
|
268 | 279 | |
|
280 | var defaultBuiltin = "bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric" | |
|
281 | ||
|
269 | 282 | // A generic SQL Mode. It's not a standard, it just try to support what is generally supported |
|
270 | 283 | CodeMirror.defineMIME("text/x-sql", { |
|
271 | 284 | name: "sql", |
|
272 | 285 | keywords: set(sqlKeywords + "begin"), |
|
273 | builtin: set("bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric"), | |
|
286 | builtin: set(defaultBuiltin), | |
|
274 | 287 | atoms: set("false true null unknown"), |
|
275 | operatorChars: /^[*+\-%<>!=]/, | |
|
276 | 288 | dateSQL: set("date time timestamp"), |
|
277 | 289 | support: set("ODBCdotTable doubleQuote binaryNumber hexNumber") |
|
278 | 290 | }); |
|
279 | 291 | |
|
280 | 292 | CodeMirror.defineMIME("text/x-mssql", { |
|
281 | 293 | name: "sql", |
|
282 | client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"), | |
|
283 | keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare"), | |
|
294 | client: set("$partition binary_checksum checksum connectionproperty context_info current_request_id error_line error_message error_number error_procedure error_severity error_state formatmessage get_filestream_transaction_context getansinull host_id host_name isnull isnumeric min_active_rowversion newid newsequentialid rowcount_big xact_state object_id"), | |
|
295 | keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare exec go if use index holdlock nolock nowait paglock readcommitted readcommittedlock readpast readuncommitted repeatableread rowlock serializable snapshot tablock tablockx updlock with"), | |
|
284 | 296 | builtin: set("bigint numeric bit smallint decimal smallmoney int tinyint money float real char varchar text nchar nvarchar ntext binary varbinary image cursor timestamp hierarchyid uniqueidentifier sql_variant xml table "), |
|
285 | atoms: set("false true null unknown"), | |
|
286 | operatorChars: /^[*+\-%<>!=]/, | |
|
297 | atoms: set("is not null like and or in left right between inner outer join all any some cross unpivot pivot exists"), | |
|
298 | operatorChars: /^[*+\-%<>!=^\&|\/]/, | |
|
299 | brackets: /^[\{}\(\)]/, | |
|
300 | punctuation: /^[;.,:/]/, | |
|
301 | backslashStringEscapes: false, | |
|
287 | 302 | dateSQL: set("date datetimeoffset datetime2 smalldatetime datetime time"), |
|
288 | 303 | hooks: { |
|
289 | 304 | "@": hookVar |
@@ -322,6 +337,36 b' CodeMirror.defineMode("sql", function(co' | |||
|
322 | 337 | } |
|
323 | 338 | }); |
|
324 | 339 | |
|
340 | // provided by the phpLiteAdmin project - phpliteadmin.org | |
|
341 | CodeMirror.defineMIME("text/x-sqlite", { | |
|
342 | name: "sql", | |
|
343 | // commands of the official SQLite client, ref: https://www.sqlite.org/cli.html#dotcmd | |
|
344 | client: set("auth backup bail binary changes check clone databases dbinfo dump echo eqp exit explain fullschema headers help import imposter indexes iotrace limit lint load log mode nullvalue once open output print prompt quit read restore save scanstats schema separator session shell show stats system tables testcase timeout timer trace vfsinfo vfslist vfsname width"), | |
|
345 | // ref: http://sqlite.org/lang_keywords.html | |
|
346 | keywords: set(sqlKeywords + "abort action add after all analyze attach autoincrement before begin cascade case cast check collate column commit conflict constraint cross current_date current_time current_timestamp database default deferrable deferred detach each else end escape except exclusive exists explain fail for foreign full glob if ignore immediate index indexed initially inner instead intersect isnull key left limit match natural no notnull null of offset outer plan pragma primary query raise recursive references regexp reindex release rename replace restrict right rollback row savepoint temp temporary then to transaction trigger unique using vacuum view virtual when with without"), | |
|
347 | // SQLite is weakly typed, ref: http://sqlite.org/datatype3.html. This is just a list of some common types. | |
|
348 | builtin: set("bool boolean bit blob decimal double float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text clob bigint int int2 int8 integer float double char varchar date datetime year unsigned signed numeric real"), | |
|
349 | // ref: http://sqlite.org/syntax/literal-value.html | |
|
350 | atoms: set("null current_date current_time current_timestamp"), | |
|
351 | // ref: http://sqlite.org/lang_expr.html#binaryops | |
|
352 | operatorChars: /^[*+\-%<>!=&|/~]/, | |
|
353 | // SQLite is weakly typed, ref: http://sqlite.org/datatype3.html. This is just a list of some common types. | |
|
354 | dateSQL: set("date time timestamp datetime"), | |
|
355 | support: set("decimallessFloat zerolessFloat"), | |
|
356 | identifierQuote: "\"", //ref: http://sqlite.org/lang_keywords.html | |
|
357 | hooks: { | |
|
358 | // bind-parameters ref:http://sqlite.org/lang_expr.html#varparam | |
|
359 | "@": hookVar, | |
|
360 | ":": hookVar, | |
|
361 | "?": hookVar, | |
|
362 | "$": hookVar, | |
|
363 | // The preferred way to escape Identifiers is using double quotes, ref: http://sqlite.org/lang_keywords.html | |
|
364 | "\"": hookIdentifierDoublequote, | |
|
365 | // there is also support for backtics, ref: http://sqlite.org/lang_keywords.html | |
|
366 | "`": hookIdentifier | |
|
367 | } | |
|
368 | }); | |
|
369 | ||
|
325 | 370 | // the query language used by Apache Cassandra is called CQL, but this mime type |
|
326 | 371 | // is called Cassandra to avoid confusion with Contextual Query Language |
|
327 | 372 | CodeMirror.defineMIME("text/x-cassandra", { |
@@ -341,8 +386,8 b' CodeMirror.defineMode("sql", function(co' | |||
|
341 | 386 | name: "sql", |
|
342 | 387 | client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"), |
|
343 | 388 | keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"), |
|
344 |
builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least leng |
|
|
345 | operatorChars: /^[*+\-%<>!=~]/, | |
|
389 | builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least length lengthb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim serial sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid unlogged upper user userenv varchar varchar2 variance varying vsize xml"), | |
|
390 | operatorChars: /^[*\/+\-%<>!=~]/, | |
|
346 | 391 | dateSQL: set("date time timestamp"), |
|
347 | 392 | support: set("doubleQuote nCharCast zerolessFloat binaryNumber hexNumber") |
|
348 | 393 | }); |
@@ -350,15 +395,73 b' CodeMirror.defineMode("sql", function(co' | |||
|
350 | 395 | // Created to support specific hive keywords |
|
351 | 396 | CodeMirror.defineMIME("text/x-hive", { |
|
352 | 397 | name: "sql", |
|
353 |
keywords: set("select alter $elem$ $key$ $value$ add after all analyze and archive as asc before between binary both bucket buckets by cascade case cast change cluster clustered clusterstatus collection column columns comment compute concatenate continue create cross cursor data database databases dbproperties deferred delete delimited desc describe directory disable distinct distribute drop else enable end escaped exclusive exists explain export extended external f |
|
|
354 | builtin: set("bool boolean long timestamp tinyint smallint bigint int float double date datetime unsigned string array struct map uniontype"), | |
|
398 | keywords: set("select alter $elem$ $key$ $value$ add after all analyze and archive as asc before between binary both bucket buckets by cascade case cast change cluster clustered clusterstatus collection column columns comment compute concatenate continue create cross cursor data database databases dbproperties deferred delete delimited desc describe directory disable distinct distribute drop else enable end escaped exclusive exists explain export extended external fetch fields fileformat first format formatted from full function functions grant group having hold_ddltime idxproperties if import in index indexes inpath inputdriver inputformat insert intersect into is items join keys lateral left like limit lines load local location lock locks mapjoin materialized minus msck no_drop nocompress not of offline on option or order out outer outputdriver outputformat overwrite partition partitioned partitions percent plus preserve procedure purge range rcfile read readonly reads rebuild recordreader recordwriter recover reduce regexp rename repair replace restrict revoke right rlike row schema schemas semi sequencefile serde serdeproperties set shared show show_database sort sorted ssl statistics stored streamtable table tables tablesample tblproperties temporary terminated textfile then tmp to touch transform trigger unarchive undo union uniquejoin unlock update use using utc utc_tmestamp view when where while with admin authorization char compact compactions conf cube current current_date current_timestamp day decimal defined dependency directories elem_type exchange file following for grouping hour ignore inner interval jar less logical macro minute month more none noscan over owner partialscan preceding pretty principals protection reload rewrite role roles rollup rows second server sets skewed transactions truncate unbounded unset uri user values window year"), | |
|
399 | builtin: set("bool boolean long timestamp tinyint smallint bigint int float double date datetime unsigned string array struct map uniontype key_type utctimestamp value_type varchar"), | |
|
355 | 400 | atoms: set("false true null unknown"), |
|
356 | 401 | operatorChars: /^[*+\-%<>!=]/, |
|
357 | 402 | dateSQL: set("date timestamp"), |
|
358 | 403 | support: set("ODBCdotTable doubleQuote binaryNumber hexNumber") |
|
359 | 404 | }); |
|
360 | }()); | |
|
405 | ||
|
406 | CodeMirror.defineMIME("text/x-pgsql", { | |
|
407 | name: "sql", | |
|
408 | client: set("source"), | |
|
409 | // For PostgreSQL - https://www.postgresql.org/docs/11/sql-keywords-appendix.html | |
|
410 | // For pl/pgsql lang - https://github.com/postgres/postgres/blob/REL_11_2/src/pl/plpgsql/src/pl_scanner.c | |
|
411 | keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate alias all allocate also alter always analyse analyze and any are array array_agg array_max_cardinality as asc asensitive assert assertion assignment asymmetric at atomic attach attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli between bigint binary bit bit_length blob blocked bom boolean both breadth by c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain char char_length character character_length character_set_catalog character_set_name character_set_schema characteristics characters check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column column_name columns command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constant constraint constraint_catalog constraint_name constraint_schema constraints constructor contains content continue control conversion convert copy corr corresponding cost count covar_pop covar_samp create cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datatype date datetime_interval_code datetime_interval_precision day db deallocate debug dec decimal declare default defaults deferrable deferred defined definer degree delete delimiter delimiters dense_rank depends depth deref derived desc describe descriptor detach detail deterministic diagnostics dictionary disable discard disconnect dispatch distinct dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain double drop dump dynamic dynamic_function dynamic_function_code each element else elseif elsif empty enable encoding encrypted end end_frame end_partition endexec enforced enum equals errcode error escape event every except exception exclude excluding exclusive exec execute exists exit exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreach foreign fortran forward found frame_row free freeze from fs full function functions fusion g general generated get global go goto grant granted greatest group grouping groups handler having header hex hierarchy hint hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import in include including increment indent index indexes indicator info inherit inherits initially inline inner inout input insensitive insert instance instantiable instead int integer integrity intersect intersection interval into invoker is isnull isolation join k key key_member key_type label lag language large last last_value lateral lead leading leakproof least left length level library like like_regex limit link listen ln load local localtime localtimestamp location locator lock locked log logged loop lower m map mapping match matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized not nothing notice notify notnull nowait nth_value ntile null nullable nullif nulls number numeric object occurrences_regex octet_length octets of off offset oids old on only open operator option options or order ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parallel parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password path percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding precision prepare prepared preserve primary print_strict_params prior privileges procedural procedure procedures program public publication query quote raise range rank read reads real reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict result result_oid return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns reverse revoke right role rollback rollup routine routine_catalog routine_name routine_schema routines row row_count row_number rows rowtype rule savepoint scale schema schema_name schemas scope scope_catalog scope_name scope_schema scroll search second section security select selective self sensitive sequence sequences serializable server server_name session session_user set setof sets share show similar simple size skip slice smallint snapshot some source space specific specific_name specifictype sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable stacked standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time system_user t table table_name tables tablesample tablespace temp template temporary text then ties time timestamp timezone_hour timezone_minute to token top_level_count trailing transaction transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted union unique unknown unlink unlisten unlogged unnamed unnest until untyped update upper uri usage use_column use_variable user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of values var_pop var_samp varbinary varchar variable_conflict variadic varying verbose version versioning view views volatile warning when whenever where while whitespace width_bucket window with within without work wrapper write xml xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes zone"), | |
|
412 | // https://www.postgresql.org/docs/11/datatype.html | |
|
413 | builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr macaddr8 money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"), | |
|
414 | atoms: set("false true null unknown"), | |
|
415 | operatorChars: /^[*\/+\-%<>!=&|^\/#@?~]/, | |
|
416 | dateSQL: set("date time timestamp"), | |
|
417 | support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast") | |
|
418 | }); | |
|
419 | ||
|
420 | // Google's SQL-like query language, GQL | |
|
421 | CodeMirror.defineMIME("text/x-gql", { | |
|
422 | name: "sql", | |
|
423 | keywords: set("ancestor and asc by contains desc descendant distinct from group has in is limit offset on order select superset where"), | |
|
424 | atoms: set("false true"), | |
|
425 | builtin: set("blob datetime first key __key__ string integer double boolean null"), | |
|
426 | operatorChars: /^[*+\-%<>!=]/ | |
|
427 | }); | |
|
361 | 428 | |
|
429 | // Greenplum | |
|
430 | CodeMirror.defineMIME("text/x-gpsql", { | |
|
431 | name: "sql", | |
|
432 | client: set("source"), | |
|
433 | //https://github.com/greenplum-db/gpdb/blob/master/src/include/parser/kwlist.h | |
|
434 | keywords: set("abort absolute access action active add admin after aggregate all also alter always analyse analyze and any array as asc assertion assignment asymmetric at authorization backward before begin between bigint binary bit boolean both by cache called cascade cascaded case cast chain char character characteristics check checkpoint class close cluster coalesce codegen collate column comment commit committed concurrency concurrently configuration connection constraint constraints contains content continue conversion copy cost cpu_rate_limit create createdb createexttable createrole createuser cross csv cube current current_catalog current_date current_role current_schema current_time current_timestamp current_user cursor cycle data database day deallocate dec decimal declare decode default defaults deferrable deferred definer delete delimiter delimiters deny desc dictionary disable discard distinct distributed do document domain double drop dxl each else enable encoding encrypted end enum errors escape every except exchange exclude excluding exclusive execute exists explain extension external extract false family fetch fields filespace fill filter first float following for force foreign format forward freeze from full function global grant granted greatest group group_id grouping handler hash having header hold host hour identity if ignore ilike immediate immutable implicit in including inclusive increment index indexes inherit inherits initially inline inner inout input insensitive insert instead int integer intersect interval into invoker is isnull isolation join key language large last leading least left level like limit list listen load local localtime localtimestamp location lock log login mapping master match maxvalue median merge minute minvalue missing mode modifies modify month move name names national natural nchar new newline next no nocreatedb nocreateexttable nocreaterole nocreateuser noinherit nologin none noovercommit nosuperuser not nothing notify notnull nowait null nullif nulls numeric object of off offset oids old on only operator option options or order ordered others out outer over overcommit overlaps overlay owned owner parser partial partition partitions passing password percent percentile_cont percentile_disc placing plans position preceding precision prepare prepared preserve primary prior privileges procedural procedure protocol queue quote randomly range read readable reads real reassign recheck recursive ref references reindex reject relative release rename repeatable replace replica reset resource restart restrict returning returns revoke right role rollback rollup rootpartition row rows rule savepoint scatter schema scroll search second security segment select sequence serializable session session_user set setof sets share show similar simple smallint some split sql stable standalone start statement statistics stdin stdout storage strict strip subpartition subpartitions substring superuser symmetric sysid system table tablespace temp template temporary text then threshold ties time timestamp to trailing transaction treat trigger trim true truncate trusted type unbounded uncommitted unencrypted union unique unknown unlisten until update user using vacuum valid validation validator value values varchar variadic varying verbose version view volatile web when where whitespace window with within without work writable write xml xmlattributes xmlconcat xmlelement xmlexists xmlforest xmlparse xmlpi xmlroot xmlserialize year yes zone"), | |
|
435 | builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float float8 inet integer int int4 interval json jsonb line lseg macaddr macaddr8 money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"), | |
|
436 | atoms: set("false true null unknown"), | |
|
437 | operatorChars: /^[*+\-%<>!=&|^\/#@?~]/, | |
|
438 | dateSQL: set("date time timestamp"), | |
|
439 | support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast") | |
|
440 | }); | |
|
441 | ||
|
442 | // Spark SQL | |
|
443 | CodeMirror.defineMIME("text/x-sparksql", { | |
|
444 | name: "sql", | |
|
445 | keywords: set("add after all alter analyze and anti archive array as asc at between bucket buckets by cache cascade case cast change clear cluster clustered codegen collection column columns comment commit compact compactions compute concatenate cost create cross cube current current_date current_timestamp database databases datata dbproperties defined delete delimited deny desc describe dfs directories distinct distribute drop else end escaped except exchange exists explain export extended external false fields fileformat first following for format formatted from full function functions global grant group grouping having if ignore import in index indexes inner inpath inputformat insert intersect interval into is items join keys last lateral lazy left like limit lines list load local location lock locks logical macro map minus msck natural no not null nulls of on optimize option options or order out outer outputformat over overwrite partition partitioned partitions percent preceding principals purge range recordreader recordwriter recover reduce refresh regexp rename repair replace reset restrict revoke right rlike role roles rollback rollup row rows schema schemas select semi separated serde serdeproperties set sets show skewed sort sorted start statistics stored stratify struct table tables tablesample tblproperties temp temporary terminated then to touch transaction transactions transform true truncate unarchive unbounded uncache union unlock unset use using values view when where window with"), | |
|
446 | builtin: set("tinyint smallint int bigint boolean float double string binary timestamp decimal array map struct uniontype delimited serde sequencefile textfile rcfile inputformat outputformat"), | |
|
447 | atoms: set("false true null"), | |
|
448 | operatorChars: /^[*\/+\-%<>!=~&|^]/, | |
|
449 | dateSQL: set("date time timestamp"), | |
|
450 | support: set("ODBCdotTable doubleQuote zerolessFloat") | |
|
451 | }); | |
|
452 | ||
|
453 | // Esper | |
|
454 | CodeMirror.defineMIME("text/x-esper", { | |
|
455 | name: "sql", | |
|
456 | client: set("source"), | |
|
457 | // http://www.espertech.com/esper/release-5.5.0/esper-reference/html/appendix_keywords.html | |
|
458 | keywords: set("alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where limit after all and as at asc avedev avg between by case cast coalesce count create current_timestamp day days delete define desc distinct else end escape events every exists false first from full group having hour hours in inner insert instanceof into irstream is istream join last lastweekday left limit like max match_recognize matches median measures metadatasql min minute minutes msec millisecond milliseconds not null offset on or order outer output partition pattern prev prior regexp retain-union retain-intersection right rstream sec second seconds select set some snapshot sql stddev sum then true unidirectional until update variable weekday when where window"), | |
|
459 | builtin: {}, | |
|
460 | atoms: set("false true null"), | |
|
461 | operatorChars: /^[*+\-%<>!=&|^\/#@?~]/, | |
|
462 | dateSQL: set("time"), | |
|
463 | support: set("decimallessFloat zerolessFloat binaryNumber hexNumber") | |
|
464 | }); | |
|
362 | 465 | }); |
|
363 | 466 | |
|
364 | 467 | /* |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE | |
|
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE | |
|
3 | 3 | |
|
4 | 4 | /* |
|
5 | 5 | * Author: Constantin Jucovschi (c.jucovschi@jacobs-university.de) |
@@ -16,7 +16,7 b'' | |||
|
16 | 16 | })(function(CodeMirror) { |
|
17 | 17 | "use strict"; |
|
18 | 18 | |
|
19 | CodeMirror.defineMode("stex", function() { | |
|
19 | CodeMirror.defineMode("stex", function(_config, parserConfig) { | |
|
20 | 20 | "use strict"; |
|
21 | 21 | |
|
22 | 22 | function pushCommand(state, command) { |
@@ -78,6 +78,14 b'' | |||
|
78 | 78 | plugins["begin"] = addPluginPattern("begin", "tag", ["atom"]); |
|
79 | 79 | plugins["end"] = addPluginPattern("end", "tag", ["atom"]); |
|
80 | 80 | |
|
81 | plugins["label" ] = addPluginPattern("label" , "tag", ["atom"]); | |
|
82 | plugins["ref" ] = addPluginPattern("ref" , "tag", ["atom"]); | |
|
83 | plugins["eqref" ] = addPluginPattern("eqref" , "tag", ["atom"]); | |
|
84 | plugins["cite" ] = addPluginPattern("cite" , "tag", ["atom"]); | |
|
85 | plugins["bibitem" ] = addPluginPattern("bibitem" , "tag", ["atom"]); | |
|
86 | plugins["Bibitem" ] = addPluginPattern("Bibitem" , "tag", ["atom"]); | |
|
87 | plugins["RBibitem" ] = addPluginPattern("RBibitem" , "tag", ["atom"]); | |
|
88 | ||
|
81 | 89 | plugins["DEFAULT"] = function () { |
|
82 | 90 | this.name = "DEFAULT"; |
|
83 | 91 | this.style = "tag"; |
@@ -117,6 +125,10 b'' | |||
|
117 | 125 | setState(state, function(source, state){ return inMathMode(source, state, "\\]"); }); |
|
118 | 126 | return "keyword"; |
|
119 | 127 | } |
|
128 | if (source.match("\\(")) { | |
|
129 | setState(state, function(source, state){ return inMathMode(source, state, "\\)"); }); | |
|
130 | return "keyword"; | |
|
131 | } | |
|
120 | 132 | if (source.match("$$")) { |
|
121 | 133 | setState(state, function(source, state){ return inMathMode(source, state, "$$"); }); |
|
122 | 134 | return "keyword"; |
@@ -161,7 +173,7 b'' | |||
|
161 | 173 | if (source.eatSpace()) { |
|
162 | 174 | return null; |
|
163 | 175 | } |
|
164 | if (source.match(endModeSeq)) { | |
|
176 | if (endModeSeq && source.match(endModeSeq)) { | |
|
165 | 177 | setState(state, normal); |
|
166 | 178 | return "keyword"; |
|
167 | 179 | } |
@@ -223,9 +235,10 b'' | |||
|
223 | 235 | |
|
224 | 236 | return { |
|
225 | 237 | startState: function() { |
|
238 | var f = parserConfig.inMathMode ? function(source, state){ return inMathMode(source, state); } : normal; | |
|
226 | 239 | return { |
|
227 | 240 | cmdState: [], |
|
228 |
f: |
|
|
241 | f: f | |
|
229 | 242 | }; |
|
230 | 243 | }, |
|
231 | 244 | copyState: function(s) { |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now