| 1 |
ace.define("ace/mode/pig_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){ |
| 2 |
"use strict"; |
| 3 |
var oop = require("../lib/oop"); |
| 4 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 5 |
var PigHighlightRules = function () { |
| 6 |
this.$rules = { |
| 7 |
start: [{ |
| 8 |
token: "comment.block.pig", |
| 9 |
regex: /\/\*/, |
| 10 |
push: [{ |
| 11 |
token: "comment.block.pig", |
| 12 |
regex: /\*\//, |
| 13 |
next: "pop" |
| 14 |
}, { |
| 15 |
defaultToken: "comment.block.pig" |
| 16 |
}] |
| 17 |
}, { |
| 18 |
token: "comment.line.double-dash.asciidoc", |
| 19 |
regex: /--.*$/ |
| 20 |
}, { |
| 21 |
token: "keyword.control.pig", |
| 22 |
regex: /\b(?:ASSERT|LOAD|STORE|DUMP|FILTER|DISTINCT|FOREACH|GENERATE|STREAM|JOIN|COGROUP|GROUP|CROSS|ORDER|LIMIT|UNION|SPLIT|DESCRIBE|EXPLAIN|ILLUSTRATE|AS|BY|INTO|USING|LIMIT|PARALLEL|OUTER|INNER|DEFAULT|LEFT|SAMPLE|RANK|CUBE|ALL|KILL|QUIT|MAPREDUCE|ASC|DESC|THROUGH|SHIP|CACHE|DECLARE|CASE|WHEN|THEN|END|IN|PARTITION|FULL|IMPORT|IF|ONSCHEMA|INPUT|OUTPUT)\b/, |
| 23 |
caseInsensitive: true |
| 24 |
}, { |
| 25 |
token: "storage.datatypes.pig", |
| 26 |
regex: /\b(?:int|long|float|double|chararray|bytearray|boolean|datetime|biginteger|bigdecimal|tuple|bag|map)\b/, |
| 27 |
caseInsensitive: true |
| 28 |
}, { |
| 29 |
token: "support.function.storage.pig", |
| 30 |
regex: /\b(?:PigStorage|BinStorage|BinaryStorage|PigDump|HBaseStorage|JsonLoader|JsonStorage|AvroStorage|TextLoader|PigStreaming|TrevniStorage|AccumuloStorage)\b/ |
| 31 |
}, { |
| 32 |
token: "support.function.udf.pig", |
| 33 |
regex: /\b(?:DIFF|TOBAG|TOMAP|TOP|TOTUPLE|RANDOM|FLATTEN|flatten|CUBE|ROLLUP|IsEmpty|ARITY|PluckTuple|SUBTRACT|BagToString)\b/ |
| 34 |
}, { |
| 35 |
token: "support.function.udf.math.pig", |
| 36 |
regex: /\b(?:ABS|ACOS|ASIN|ATAN|CBRT|CEIL|COS|COSH|EXP|FLOOR|LOG|LOG10|ROUND|ROUND_TO|SIN|SINH|SQRT|TAN|TANH|AVG|COUNT|COUNT_STAR|MAX|MIN|SUM|COR|COV)\b/ |
| 37 |
}, { |
| 38 |
token: "support.function.udf.string.pig", |
| 39 |
regex: /\b(?:CONCAT|INDEXOF|LAST_INDEX_OF|LCFIRST|LOWER|REGEX_EXTRACT|REGEX_EXTRACT_ALL|REPLACE|SIZE|STRSPLIT|SUBSTRING|TOKENIZE|TRIM|UCFIRST|UPPER|LTRIM|RTRIM|ENDSWITH|STARTSWITH|TRIM)\b/ |
| 40 |
}, { |
| 41 |
token: "support.function.udf.datetime.pig", |
| 42 |
regex: /\b(?:AddDuration|CurrentTime|DaysBetween|GetDay|GetHour|GetMilliSecond|GetMinute|GetMonth|GetSecond|GetWeek|GetWeekYear|GetYear|HoursBetween|MilliSecondsBetween|MinutesBetween|MonthsBetween|SecondsBetween|SubtractDuration|ToDate|WeeksBetween|YearsBetween|ToMilliSeconds|ToString|ToUnixTime)\b/ |
| 43 |
}, { |
| 44 |
token: "support.function.command.pig", |
| 45 |
regex: /\b(?:cat|cd|copyFromLocal|copyToLocal|cp|ls|mkdir|mv|pwd|rm)\b/ |
| 46 |
}, { |
| 47 |
token: "variable.pig", |
| 48 |
regex: /\$[a_zA-Z0-9_]+/ |
| 49 |
}, { |
| 50 |
token: "constant.language.pig", |
| 51 |
regex: /\b(?:NULL|true|false|stdin|stdout|stderr)\b/, |
| 52 |
caseInsensitive: true |
| 53 |
}, { |
| 54 |
token: "constant.numeric.pig", |
| 55 |
regex: /\b\d+(?:\.\d+)?\b/ |
| 56 |
}, { |
| 57 |
token: "keyword.operator.comparison.pig", |
| 58 |
regex: /!=|==|<|>|<=|>=|\b(?:MATCHES|IS|OR|AND|NOT)\b/, |
| 59 |
caseInsensitive: true |
| 60 |
}, { |
| 61 |
token: "keyword.operator.arithmetic.pig", |
| 62 |
regex: /\+|\-|\*|\/|\%|\?|:|::|\.\.|#/ |
| 63 |
}, { |
| 64 |
token: "string.quoted.double.pig", |
| 65 |
regex: /"/, |
| 66 |
push: [{ |
| 67 |
token: "string.quoted.double.pig", |
| 68 |
regex: /"/, |
| 69 |
next: "pop" |
| 70 |
}, { |
| 71 |
token: "constant.character.escape.pig", |
| 72 |
regex: /\\./ |
| 73 |
}, { |
| 74 |
defaultToken: "string.quoted.double.pig" |
| 75 |
}] |
| 76 |
}, { |
| 77 |
token: "string.quoted.single.pig", |
| 78 |
regex: /'/, |
| 79 |
push: [{ |
| 80 |
token: "string.quoted.single.pig", |
| 81 |
regex: /'/, |
| 82 |
next: "pop" |
| 83 |
}, { |
| 84 |
token: "constant.character.escape.pig", |
| 85 |
regex: /\\./ |
| 86 |
}, { |
| 87 |
defaultToken: "string.quoted.single.pig" |
| 88 |
}] |
| 89 |
}, { |
| 90 |
todo: { |
| 91 |
token: [ |
| 92 |
"text", |
| 93 |
"keyword.parameter.pig", |
| 94 |
"text", |
| 95 |
"storage.type.parameter.pig" |
| 96 |
], |
| 97 |
regex: /^(\s*)(set)(\s+)(\S+)/, |
| 98 |
caseInsensitive: true, |
| 99 |
push: [{ |
| 100 |
token: "text", |
| 101 |
regex: /$/, |
| 102 |
next: "pop" |
| 103 |
}, { |
| 104 |
include: "$self" |
| 105 |
}] |
| 106 |
} |
| 107 |
}, { |
| 108 |
token: [ |
| 109 |
"text", |
| 110 |
"keyword.alias.pig", |
| 111 |
"text", |
| 112 |
"storage.type.alias.pig" |
| 113 |
], |
| 114 |
regex: /(\s*)(DEFINE|DECLARE|REGISTER)(\s+)(\S+)/, |
| 115 |
caseInsensitive: true, |
| 116 |
push: [{ |
| 117 |
token: "text", |
| 118 |
regex: /;?$/, |
| 119 |
next: "pop" |
| 120 |
}] |
| 121 |
}] |
| 122 |
}; |
| 123 |
this.normalizeRules(); |
| 124 |
}; |
| 125 |
PigHighlightRules.metaData = { |
| 126 |
fileTypes: ["pig"], |
| 127 |
name: "Pig", |
| 128 |
scopeName: "source.pig" |
| 129 |
}; |
| 130 |
oop.inherits(PigHighlightRules, TextHighlightRules); |
| 131 |
exports.PigHighlightRules = PigHighlightRules; |
| 132 |
|
| 133 |
}); |
| 134 |
|
| 135 |
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict"; |
| 136 |
var oop = require("../../lib/oop"); |
| 137 |
var Range = require("../../range").Range; |
| 138 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 139 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 140 |
if (commentRegex) { |
| 141 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 142 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 143 |
} |
| 144 |
}; |
| 145 |
oop.inherits(FoldMode, BaseFoldMode); |
| 146 |
(function () { |
| 147 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 148 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 149 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 150 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 151 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 152 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 153 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 154 |
var line = session.getLine(row); |
| 155 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 156 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 157 |
return ""; |
| 158 |
} |
| 159 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 160 |
if (!fw && this.startRegionRe.test(line)) |
| 161 |
return "start"; |
| 162 |
return fw; |
| 163 |
}; |
| 164 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 165 |
var line = session.getLine(row); |
| 166 |
if (this.startRegionRe.test(line)) |
| 167 |
return this.getCommentRegionBlock(session, line, row); |
| 168 |
var match = line.match(this.foldingStartMarker); |
| 169 |
if (match) { |
| 170 |
var i = match.index; |
| 171 |
if (match[1]) |
| 172 |
return this.openingBracketBlock(session, match[1], row, i); |
| 173 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 174 |
if (range && !range.isMultiLine()) { |
| 175 |
if (forceMultiline) { |
| 176 |
range = this.getSectionRange(session, row); |
| 177 |
} |
| 178 |
else if (foldStyle != "all") |
| 179 |
range = null; |
| 180 |
} |
| 181 |
return range; |
| 182 |
} |
| 183 |
if (foldStyle === "markbegin") |
| 184 |
return; |
| 185 |
var match = line.match(this.foldingStopMarker); |
| 186 |
if (match) { |
| 187 |
var i = match.index + match[0].length; |
| 188 |
if (match[1]) |
| 189 |
return this.closingBracketBlock(session, match[1], row, i); |
| 190 |
return session.getCommentFoldRange(row, i, -1); |
| 191 |
} |
| 192 |
}; |
| 193 |
this.getSectionRange = function (session, row) { |
| 194 |
var line = session.getLine(row); |
| 195 |
var startIndent = line.search(/\S/); |
| 196 |
var startRow = row; |
| 197 |
var startColumn = line.length; |
| 198 |
row = row + 1; |
| 199 |
var endRow = row; |
| 200 |
var maxRow = session.getLength(); |
| 201 |
while (++row < maxRow) { |
| 202 |
line = session.getLine(row); |
| 203 |
var indent = line.search(/\S/); |
| 204 |
if (indent === -1) |
| 205 |
continue; |
| 206 |
if (startIndent > indent) |
| 207 |
break; |
| 208 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 209 |
if (subRange) { |
| 210 |
if (subRange.start.row <= startRow) { |
| 211 |
break; |
| 212 |
} |
| 213 |
else if (subRange.isMultiLine()) { |
| 214 |
row = subRange.end.row; |
| 215 |
} |
| 216 |
else if (startIndent == indent) { |
| 217 |
break; |
| 218 |
} |
| 219 |
} |
| 220 |
endRow = row; |
| 221 |
} |
| 222 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 223 |
}; |
| 224 |
this.getCommentRegionBlock = function (session, line, row) { |
| 225 |
var startColumn = line.search(/\s*$/); |
| 226 |
var maxRow = session.getLength(); |
| 227 |
var startRow = row; |
| 228 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 229 |
var depth = 1; |
| 230 |
while (++row < maxRow) { |
| 231 |
line = session.getLine(row); |
| 232 |
var m = re.exec(line); |
| 233 |
if (!m) |
| 234 |
continue; |
| 235 |
if (m[1]) |
| 236 |
depth--; |
| 237 |
else |
| 238 |
depth++; |
| 239 |
if (!depth) |
| 240 |
break; |
| 241 |
} |
| 242 |
var endRow = row; |
| 243 |
if (endRow > startRow) { |
| 244 |
return new Range(startRow, startColumn, endRow, line.length); |
| 245 |
} |
| 246 |
}; |
| 247 |
}).call(FoldMode.prototype); |
| 248 |
|
| 249 |
}); |
| 250 |
|
| 251 |
ace.define("ace/mode/pig",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/pig_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){ |
| 252 |
|
| 253 |
|
| 254 |
"use strict"; |
| 255 |
var oop = require("../lib/oop"); |
| 256 |
var TextMode = require("./text").Mode; |
| 257 |
var PigHighlightRules = require("./pig_highlight_rules").PigHighlightRules; |
| 258 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 259 |
var Mode = function () { |
| 260 |
this.HighlightRules = PigHighlightRules; |
| 261 |
this.foldingRules = new FoldMode(); |
| 262 |
}; |
| 263 |
oop.inherits(Mode, TextMode); |
| 264 |
(function () { |
| 265 |
this.lineCommentStart = "--"; |
| 266 |
this.blockComment = { start: "/*", end: "*/" }; |
| 267 |
this.$id = "ace/mode/pig"; |
| 268 |
}).call(Mode.prototype); |
| 269 |
exports.Mode = Mode; |
| 270 |
|
| 271 |
}); (function() { |
| 272 |
ace.require(["ace/mode/pig"], function(m) { |
| 273 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 274 |
module.exports = m; |
| 275 |
} |
| 276 |
}); |
| 277 |
})(); |
| 278 |
|