mode-asl.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. };
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. ace.define("ace/mode/asl_highlight_rules",[], function(require, exports, module) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  46. var ASLHighlightRules = function() {
  47. var keywords = (
  48. "Default|DefinitionBlock|Device|Method|Else|ElseIf|For|Function|If|Include|Method|Return|" +
  49. "Scope|Switch|Case|While|Break|BreakPoint|Continue|NoOp|Wait"
  50. );
  51. var keywordOperators = (
  52. "Add|And|Decrement|Divide|Increment|Index|LAnd|LEqual|LGreater|LGreaterEqual|" +
  53. "LLess|LLessEqual|LNot|LNotEqual|LOr|Mod|Multiply|NAnd|NOr|Not|Or|RefOf|Revision|" +
  54. "ShiftLeft|ShiftRight|Subtract|XOr|DerefOf"
  55. );
  56. var buildinFunctions = (
  57. "AccessAs|Acquire|Alias|BankField|Buffer|Concatenate|ConcatenateResTemplate|" +
  58. "CondRefOf|Connection|CopyObject|CreateBitField|CreateByteField|CreateDWordField|" +
  59. "CreateField|CreateQWordField|CreateWordField|DataTableRegion|Debug|" +
  60. "DMA|DWordIO|DWordMemory|DWordSpace|EisaId|EISAID|EndDependentFn|Event|ExtendedIO|" +
  61. "ExtendedMemory|ExtendedSpace|External|Fatal|Field|FindSetLeftBit|FindSetRightBit|" +
  62. "FixedDMA|FixedIO|Fprintf|FromBCD|GpioInt|GpioIo|I2CSerialBusV2|IndexField|" +
  63. "Interrupt|IO|IRQ|IRQNoFlags|Load|LoadTable|Match|Memory32|Memory32Fixed|" +
  64. "Mid|Mutex|Name|Notify|Offset|ObjectType|OperationRegion|Package|PowerResource|Printf|" +
  65. "QWordIO|QWordMemory|QWordSpace|RawDataBuffer|Register|Release|Reset|ResourceTemplate|" +
  66. "Signal|SizeOf|Sleep|SPISerialBusV2|Stall|StartDependentFn|StartDependentFnNoPri|" +
  67. "Store|ThermalZone|Timer|ToBCD|ToBuffer|ToDecimalString|ToInteger|ToPLD|ToString|" +
  68. "ToUUID|UARTSerialBusV2|Unicode|Unload|VendorLong|VendorShort|WordBusNumber|WordIO|" +
  69. "WordSpace"
  70. );
  71. var flags = (
  72. "AttribQuick|AttribSendReceive|AttribByte|AttribBytes|AttribRawBytes|" +
  73. "AttribRawProcessBytes|AttribWord|AttribBlock|AttribProcessCall|AttribBlockProcessCall|" +
  74. "AnyAcc|ByteAcc|WordAcc|DWordAcc|QWordAcc|BufferAcc|" +
  75. "AddressRangeMemory|AddressRangeReserved|AddressRangeNVS|AddressRangeACPI|" +
  76. "RegionSpaceKeyword|FFixedHW|PCC|" +
  77. "AddressingMode7Bit|AddressingMode10Bit|" +
  78. "DataBitsFive|DataBitsSix|DataBitsSeven|DataBitsEight|DataBitsNine|" +
  79. "BusMaster|NotBusMaster|" +
  80. "ClockPhaseFirst|ClockPhaseSecond|ClockPolarityLow|ClockPolarityHigh|" +
  81. "SubDecode|PosDecode|" +
  82. "BigEndianing|LittleEndian|" +
  83. "FlowControlNone|FlowControlXon|FlowControlHardware|" +
  84. "Edge|Level|ActiveHigh|ActiveLow|ActiveBoth|Decode16|Decode10|" +
  85. "IoRestrictionNone|IoRestrictionInputOnly|IoRestrictionOutputOnly|" +
  86. "IoRestrictionNoneAndPreserve|Lock|NoLock|MTR|MEQ|MLE|MLT|MGE|MGT|" +
  87. "MaxFixed|MaxNotFixed|Cacheable|WriteCombining|Prefetchable|NonCacheable|" +
  88. "MinFixed|MinNotFixed|" +
  89. "ParityTypeNone|ParityTypeSpace|ParityTypeMark|ParityTypeOdd|ParityTypeEven|" +
  90. "PullDefault|PullUp|PullDown|PullNone|PolarityHigh|PolarityLow|" +
  91. "ISAOnlyRanges|NonISAOnlyRanges|EntireRange|ReadWrite|ReadOnly|" +
  92. "UserDefRegionSpace|SystemIO|SystemMemory|PCI_Config|EmbeddedControl|" +
  93. "SMBus|SystemCMOS|PciBarTarget|IPMI|GeneralPurposeIO|GenericSerialBus|" +
  94. "ResourceConsumer|ResourceProducer|Serialized|NotSerialized|" +
  95. "Shared|Exclusive|SharedAndWake|ExclusiveAndWake|ControllerInitiated|DeviceInitiated|" +
  96. "StopBitsZero|StopBitsOne|StopBitsOnePlusHalf|StopBitsTwo|" +
  97. "Width8Bit|Width16Bit|Width32Bit|Width64Bit|Width128Bit|Width256Bit|" +
  98. "SparseTranslation|DenseTranslation|TypeTranslation|TypeStatic|" +
  99. "Preserve|WriteAsOnes|WriteAsZeros|Transfer8|Transfer16|Transfer8_16|" +
  100. "ThreeWireMode|FourWireMode"
  101. );
  102. var storageTypes = (
  103. "UnknownObj|IntObj|StrObj|BuffObj|PkgObj|FieldUnitObj|DeviceObj|" +
  104. "EventObj|MethodObj|MutexObj|OpRegionObj|PowerResObj|ProcessorObj|" +
  105. "ThermalZoneObj|BuffFieldObj|DDBHandleObj"
  106. );
  107. var buildinConstants = (
  108. "__FILE__|__PATH__|__LINE__|__DATE__|__IASL__"
  109. );
  110. var deprecated = (
  111. "Memory24|Processor"
  112. );
  113. var keywordMapper = this.createKeywordMapper({
  114. "keyword": keywords,
  115. "keyword.operator": keywordOperators,
  116. "function.buildin": buildinFunctions,
  117. "constant.language": buildinConstants,
  118. "storage.type": storageTypes,
  119. "constant.character": flags,
  120. "invalid.deprecated": deprecated
  121. }, "identifier");
  122. this.$rules = {
  123. "start" : [
  124. {
  125. token : "comment",
  126. regex : "\\/\\/.*$"
  127. },
  128. DocCommentHighlightRules.getStartRule("doc-start"),
  129. {
  130. token : "comment", // multi line comment
  131. regex : "\\/\\*",
  132. next : "comment"
  133. },
  134. DocCommentHighlightRules.getStartRule("doc-start"),
  135. {
  136. token : "comment", // ignored fields / comments
  137. regex : "\\\[",
  138. next : "ignoredfield"
  139. }, {
  140. token : "variable",
  141. regex : "\\Local[0-7]|\\Arg[0-6]"
  142. }, {
  143. token : "keyword", // pre-compiler directives
  144. regex : "#\\s*(?:define|elif|else|endif|error|if|ifdef|ifndef|include|includebuffer|line|pragma|undef|warning)\\b",
  145. next : "directive"
  146. }, {
  147. token : "string", // single line
  148. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  149. }, {
  150. token : "constant.character", // single line
  151. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  152. }, {
  153. token : "constant.numeric", // hex
  154. regex : /0[xX][0-9a-fA-F]+\b/
  155. }, {
  156. token : "constant.numeric",
  157. regex : /(One(s)?|Zero|True|False|[0-9]+)\b/
  158. }, {
  159. token : keywordMapper,
  160. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  161. }, {
  162. token : "keyword.operator",
  163. regex : "/|!|\\$|%|&|\\||\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|\\^|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\|="
  164. }, {
  165. token : "lparen",
  166. regex : "[[({]"
  167. }, {
  168. token : "rparen",
  169. regex : "[\\])}]"
  170. }, {
  171. token : "text",
  172. regex : "\\s+"
  173. }
  174. ],
  175. "comment" : [
  176. {
  177. token : "comment", // closing comment
  178. regex : "\\*\\/",
  179. next : "start"
  180. }, {
  181. defaultToken : "comment"
  182. }
  183. ],
  184. "ignoredfield" : [
  185. {
  186. token : "comment", // closing ignored fields / comments
  187. regex : "\\\]",
  188. next : "start"
  189. }, {
  190. defaultToken : "comment"
  191. }
  192. ],
  193. "directive" : [
  194. {
  195. token : "constant.other.multiline",
  196. regex : /\\/
  197. },
  198. {
  199. token : "constant.other.multiline",
  200. regex : /.*\\/
  201. },
  202. {
  203. token : "constant.other",
  204. regex : "\\s*<.+?>*s",
  205. next : "start"
  206. },
  207. {
  208. token : "constant.other", // single line
  209. regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]*s',
  210. next : "start"
  211. },
  212. {
  213. token : "constant.other", // single line
  214. regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
  215. next : "start"
  216. },
  217. {
  218. token : "constant.other",
  219. regex : /[^\\\/]+/,
  220. next : "start"
  221. }
  222. ]
  223. };
  224. this.embedRules(DocCommentHighlightRules, "doc-",
  225. [ DocCommentHighlightRules.getEndRule("start") ]);
  226. };
  227. oop.inherits(ASLHighlightRules, TextHighlightRules);
  228. exports.ASLHighlightRules = ASLHighlightRules;
  229. });
  230. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  231. "use strict";
  232. var oop = require("../../lib/oop");
  233. var Range = require("../../range").Range;
  234. var BaseFoldMode = require("./fold_mode").FoldMode;
  235. var FoldMode = exports.FoldMode = function(commentRegex) {
  236. if (commentRegex) {
  237. this.foldingStartMarker = new RegExp(
  238. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  239. );
  240. this.foldingStopMarker = new RegExp(
  241. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  242. );
  243. }
  244. };
  245. oop.inherits(FoldMode, BaseFoldMode);
  246. (function() {
  247. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  248. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  249. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  250. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  251. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  252. this._getFoldWidgetBase = this.getFoldWidget;
  253. this.getFoldWidget = function(session, foldStyle, row) {
  254. var line = session.getLine(row);
  255. if (this.singleLineBlockCommentRe.test(line)) {
  256. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  257. return "";
  258. }
  259. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  260. if (!fw && this.startRegionRe.test(line))
  261. return "start"; // lineCommentRegionStart
  262. return fw;
  263. };
  264. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  265. var line = session.getLine(row);
  266. if (this.startRegionRe.test(line))
  267. return this.getCommentRegionBlock(session, line, row);
  268. var match = line.match(this.foldingStartMarker);
  269. if (match) {
  270. var i = match.index;
  271. if (match[1])
  272. return this.openingBracketBlock(session, match[1], row, i);
  273. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  274. if (range && !range.isMultiLine()) {
  275. if (forceMultiline) {
  276. range = this.getSectionRange(session, row);
  277. } else if (foldStyle != "all")
  278. range = null;
  279. }
  280. return range;
  281. }
  282. if (foldStyle === "markbegin")
  283. return;
  284. var match = line.match(this.foldingStopMarker);
  285. if (match) {
  286. var i = match.index + match[0].length;
  287. if (match[1])
  288. return this.closingBracketBlock(session, match[1], row, i);
  289. return session.getCommentFoldRange(row, i, -1);
  290. }
  291. };
  292. this.getSectionRange = function(session, row) {
  293. var line = session.getLine(row);
  294. var startIndent = line.search(/\S/);
  295. var startRow = row;
  296. var startColumn = line.length;
  297. row = row + 1;
  298. var endRow = row;
  299. var maxRow = session.getLength();
  300. while (++row < maxRow) {
  301. line = session.getLine(row);
  302. var indent = line.search(/\S/);
  303. if (indent === -1)
  304. continue;
  305. if (startIndent > indent)
  306. break;
  307. var subRange = this.getFoldWidgetRange(session, "all", row);
  308. if (subRange) {
  309. if (subRange.start.row <= startRow) {
  310. break;
  311. } else if (subRange.isMultiLine()) {
  312. row = subRange.end.row;
  313. } else if (startIndent == indent) {
  314. break;
  315. }
  316. }
  317. endRow = row;
  318. }
  319. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  320. };
  321. this.getCommentRegionBlock = function(session, line, row) {
  322. var startColumn = line.search(/\s*$/);
  323. var maxRow = session.getLength();
  324. var startRow = row;
  325. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  326. var depth = 1;
  327. while (++row < maxRow) {
  328. line = session.getLine(row);
  329. var m = re.exec(line);
  330. if (!m) continue;
  331. if (m[1]) depth--;
  332. else depth++;
  333. if (!depth) break;
  334. }
  335. var endRow = row;
  336. if (endRow > startRow) {
  337. return new Range(startRow, startColumn, endRow, line.length);
  338. }
  339. };
  340. }).call(FoldMode.prototype);
  341. });
  342. ace.define("ace/mode/asl",[], function (require, exports, module) {
  343. "use strict";
  344. var oop = require("../lib/oop");
  345. var TextMode = require("./text").Mode;
  346. var ASLHighlightRules = require("./asl_highlight_rules").ASLHighlightRules;
  347. var FoldMode = require("./folding/cstyle").FoldMode;
  348. var Mode = function () {
  349. this.HighlightRules = ASLHighlightRules;
  350. this.foldingRules = new FoldMode();
  351. this.$behaviour = this.$defaultBehaviour;
  352. };
  353. oop.inherits(Mode, TextMode);
  354. (function () {
  355. this.$id = "ace/mode/asl";
  356. }).call(Mode.prototype);
  357. exports.Mode = Mode;
  358. });
  359. (function() {
  360. ace.require(["ace/mode/asl"], function(m) {
  361. if (typeof module == "object" && typeof exports == "object" && module) {
  362. module.exports = m;
  363. }
  364. });
  365. })();