mode-asl.js 16 KB

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