ace-oqc 1.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/package.json +7 -0
  2. package/src-noconflict/ace.js +21402 -0
  3. package/src-noconflict/ext-beautify.js +331 -0
  4. package/src-noconflict/ext-elastic_tabstops_lite.js +277 -0
  5. package/src-noconflict/ext-emmet.js +1331 -0
  6. package/src-noconflict/ext-error_marker.js +9 -0
  7. package/src-noconflict/ext-keybinding_menu.js +193 -0
  8. package/src-noconflict/ext-language_tools.js +2166 -0
  9. package/src-noconflict/ext-linking.js +64 -0
  10. package/src-noconflict/ext-modelist.js +248 -0
  11. package/src-noconflict/ext-options.js +799 -0
  12. package/src-noconflict/ext-prompt.js +2806 -0
  13. package/src-noconflict/ext-rtl.js +122 -0
  14. package/src-noconflict/ext-searchbox.js +514 -0
  15. package/src-noconflict/ext-settings_menu.js +820 -0
  16. package/src-noconflict/ext-spellcheck.js +73 -0
  17. package/src-noconflict/ext-split.js +207 -0
  18. package/src-noconflict/ext-static_highlight.js +229 -0
  19. package/src-noconflict/ext-statusbar.js +56 -0
  20. package/src-noconflict/ext-textarea.js +430 -0
  21. package/src-noconflict/ext-themelist.js +67 -0
  22. package/src-noconflict/ext-whitespace.js +213 -0
  23. package/src-noconflict/keybinding-emacs.js +1169 -0
  24. package/src-noconflict/keybinding-sublime.js +422 -0
  25. package/src-noconflict/keybinding-vim.js +6198 -0
  26. package/src-noconflict/mode-abap.js +221 -0
  27. package/src-noconflict/mode-abc.js +271 -0
  28. package/src-noconflict/mode-actionscript.js +275 -0
  29. package/src-noconflict/mode-ada.js +137 -0
  30. package/src-noconflict/mode-apache_conf.js +363 -0
  31. package/src-noconflict/mode-apex.js +457 -0
  32. package/src-noconflict/mode-applescript.js +278 -0
  33. package/src-noconflict/mode-aql.js +102 -0
  34. package/src-noconflict/mode-asciidoc.js +349 -0
  35. package/src-noconflict/mode-asl.js +422 -0
  36. package/src-noconflict/mode-assembly_x86.js +193 -0
  37. package/src-noconflict/mode-autohotkey.js +244 -0
  38. package/src-noconflict/mode-batchfile.js +230 -0
  39. package/src-noconflict/mode-c9search.js +293 -0
  40. package/src-noconflict/mode-c_cpp.js +503 -0
  41. package/src-noconflict/mode-cirru.js +210 -0
  42. package/src-noconflict/mode-clojure.js +315 -0
  43. package/src-noconflict/mode-cobol.js +101 -0
  44. package/src-noconflict/mode-coffee.js +400 -0
  45. package/src-noconflict/mode-coldfusion.js +2596 -0
  46. package/src-noconflict/mode-crystal.js +642 -0
  47. package/src-noconflict/mode-csharp.js +502 -0
  48. package/src-noconflict/mode-csound_document.js +4105 -0
  49. package/src-noconflict/mode-csound_orchestra.js +3035 -0
  50. package/src-noconflict/mode-csound_score.js +462 -0
  51. package/src-noconflict/mode-csp.js +59 -0
  52. package/src-noconflict/mode-css.js +720 -0
  53. package/src-noconflict/mode-curly.js +2564 -0
  54. package/src-noconflict/mode-d.js +520 -0
  55. package/src-noconflict/mode-dart.js +715 -0
  56. package/src-noconflict/mode-diff.js +147 -0
  57. package/src-noconflict/mode-django.js +2595 -0
  58. package/src-noconflict/mode-dockerfile.js +500 -0
  59. package/src-noconflict/mode-dot.js +417 -0
  60. package/src-noconflict/mode-drools.js +498 -0
  61. package/src-noconflict/mode-edifact.js +166 -0
  62. package/src-noconflict/mode-eiffel.js +135 -0
  63. package/src-noconflict/mode-ejs.js +3533 -0
  64. package/src-noconflict/mode-elixir.js +501 -0
  65. package/src-noconflict/mode-elm.js +306 -0
  66. package/src-noconflict/mode-erlang.js +1010 -0
  67. package/src-noconflict/mode-forth.js +297 -0
  68. package/src-noconflict/mode-fortran.js +430 -0
  69. package/src-noconflict/mode-fsharp.js +316 -0
  70. package/src-noconflict/mode-fsl.js +259 -0
  71. package/src-noconflict/mode-ftl.js +1193 -0
  72. package/src-noconflict/mode-gcode.js +93 -0
  73. package/src-noconflict/mode-gherkin.js +168 -0
  74. package/src-noconflict/mode-gitignore.js +59 -0
  75. package/src-noconflict/mode-glsl.js +580 -0
  76. package/src-noconflict/mode-gobstones.js +1090 -0
  77. package/src-noconflict/mode-golang.js +413 -0
  78. package/src-noconflict/mode-graphqlschema.js +214 -0
  79. package/src-noconflict/mode-groovy.js +989 -0
  80. package/src-noconflict/mode-haml.js +1873 -0
  81. package/src-noconflict/mode-handlebars.js +2622 -0
  82. package/src-noconflict/mode-haskell.js +380 -0
  83. package/src-noconflict/mode-haskell_cabal.js +141 -0
  84. package/src-noconflict/mode-haxe.js +386 -0
  85. package/src-noconflict/mode-hjson.js +353 -0
  86. package/src-noconflict/mode-html.js +2509 -0
  87. package/src-noconflict/mode-html_elixir.js +3088 -0
  88. package/src-noconflict/mode-html_ruby.js +3550 -0
  89. package/src-noconflict/mode-ini.js +162 -0
  90. package/src-noconflict/mode-io.js +248 -0
  91. package/src-noconflict/mode-jack.js +346 -0
  92. package/src-noconflict/mode-jade.js +2025 -0
  93. package/src-noconflict/mode-java.js +1038 -0
  94. package/src-noconflict/mode-javascript.js +798 -0
  95. package/src-noconflict/mode-json.js +329 -0
  96. package/src-noconflict/mode-jsoniq.js +2632 -0
  97. package/src-noconflict/mode-jsp.js +1433 -0
  98. package/src-noconflict/mode-jssm.js +325 -0
  99. package/src-noconflict/mode-jsx.js +411 -0
  100. package/src-noconflict/mode-julia.js +303 -0
  101. package/src-noconflict/mode-kotlin.js +797 -0
  102. package/src-noconflict/mode-latex.js +296 -0
  103. package/src-noconflict/mode-less.js +839 -0
  104. package/src-noconflict/mode-liquid.js +2742 -0
  105. package/src-noconflict/mode-lisp.js +112 -0
  106. package/src-noconflict/mode-livescript.js +279 -0
  107. package/src-noconflict/mode-logiql.js +317 -0
  108. package/src-noconflict/mode-logtalk.js +352 -0
  109. package/src-noconflict/mode-lsl.js +343 -0
  110. package/src-noconflict/mode-lua.js +452 -0
  111. package/src-noconflict/mode-luapage.js +3028 -0
  112. package/src-noconflict/mode-lucene.js +154 -0
  113. package/src-noconflict/mode-makefile.js +412 -0
  114. package/src-noconflict/mode-markdown.js +3194 -0
  115. package/src-noconflict/mode-mask.js +1803 -0
  116. package/src-noconflict/mode-matlab.js +263 -0
  117. package/src-noconflict/mode-maze.js +292 -0
  118. package/src-noconflict/mode-mel.js +263 -0
  119. package/src-noconflict/mode-mixal.js +122 -0
  120. package/src-noconflict/mode-mushcode.js +681 -0
  121. package/src-noconflict/mode-mysql.js +167 -0
  122. package/src-noconflict/mode-nginx.js +298 -0
  123. package/src-noconflict/mode-nim.js +363 -0
  124. package/src-noconflict/mode-nix.js +647 -0
  125. package/src-noconflict/mode-nsis.js +312 -0
  126. package/src-noconflict/mode-objectivec.js +740 -0
  127. package/src-noconflict/mode-ocaml.js +421 -0
  128. package/src-noconflict/mode-pascal.js +223 -0
  129. package/src-noconflict/mode-perl.js +381 -0
  130. package/src-noconflict/mode-pgsql.js +1743 -0
  131. package/src-noconflict/mode-php.js +13110 -0
  132. package/src-noconflict/mode-php_laravel_blade.js +13311 -0
  133. package/src-noconflict/mode-pig.js +310 -0
  134. package/src-noconflict/mode-plain_text.js +32 -0
  135. package/src-noconflict/mode-powershell.js +418 -0
  136. package/src-noconflict/mode-praat.js +478 -0
  137. package/src-noconflict/mode-prolog.js +371 -0
  138. package/src-noconflict/mode-properties.js +80 -0
  139. package/src-noconflict/mode-protobuf.js +593 -0
  140. package/src-noconflict/mode-puppet.js +368 -0
  141. package/src-noconflict/mode-python.js +508 -0
  142. package/src-noconflict/mode-r.js +312 -0
  143. package/src-noconflict/mode-razor.js +2875 -0
  144. package/src-noconflict/mode-rdoc.js +243 -0
  145. package/src-noconflict/mode-red.js +450 -0
  146. package/src-noconflict/mode-redshift.js +360 -0
  147. package/src-noconflict/mode-rhtml.js +2808 -0
  148. package/src-noconflict/mode-rst.js +257 -0
  149. package/src-noconflict/mode-ruby.js +1003 -0
  150. package/src-noconflict/mode-rust.js +282 -0
  151. package/src-noconflict/mode-sass.js +529 -0
  152. package/src-noconflict/mode-scad.js +414 -0
  153. package/src-noconflict/mode-scala.js +984 -0
  154. package/src-noconflict/mode-scheme.js +232 -0
  155. package/src-noconflict/mode-scss.js +873 -0
  156. package/src-noconflict/mode-sh.js +449 -0
  157. package/src-noconflict/mode-sjs.js +1015 -0
  158. package/src-noconflict/mode-slim.js +5240 -0
  159. package/src-noconflict/mode-smarty.js +2635 -0
  160. package/src-noconflict/mode-snippets.js +207 -0
  161. package/src-noconflict/mode-soy_template.js +2848 -0
  162. package/src-noconflict/mode-space.js +167 -0
  163. package/src-noconflict/mode-sparql.js +320 -0
  164. package/src-noconflict/mode-sql.js +271 -0
  165. package/src-noconflict/mode-sqlserver.js +445 -0
  166. package/src-noconflict/mode-stylus.js +472 -0
  167. package/src-noconflict/mode-svg.js +1582 -0
  168. package/src-noconflict/mode-swift.js +395 -0
  169. package/src-noconflict/mode-tcl.js +387 -0
  170. package/src-noconflict/mode-terraform.js +400 -0
  171. package/src-noconflict/mode-tex.js +160 -0
  172. package/src-noconflict/mode-text.js +9 -0
  173. package/src-noconflict/mode-textile.js +150 -0
  174. package/src-noconflict/mode-toml.js +153 -0
  175. package/src-noconflict/mode-tsx.js +888 -0
  176. package/src-noconflict/mode-turtle.js +296 -0
  177. package/src-noconflict/mode-twig.js +2693 -0
  178. package/src-noconflict/mode-typescript.js +869 -0
  179. package/src-noconflict/mode-vala.js +677 -0
  180. package/src-noconflict/mode-vbscript.js +635 -0
  181. package/src-noconflict/mode-velocity.js +2792 -0
  182. package/src-noconflict/mode-verilog.js +118 -0
  183. package/src-noconflict/mode-vhdl.js +116 -0
  184. package/src-noconflict/mode-visualforce.js +2640 -0
  185. package/src-noconflict/mode-wollok.js +914 -0
  186. package/src-noconflict/mode-xml.js +676 -0
  187. package/src-noconflict/mode-xquery.js +2644 -0
  188. package/src-noconflict/mode-yaml.js +330 -0
  189. package/src-noconflict/mode-zeek.js +539 -0
  190. package/src-noconflict/qurator-mode.js +120 -0
  191. package/src-noconflict/qurator-worker.js +91 -0
  192. package/src-noconflict/snippets/abap.js +9 -0
  193. package/src-noconflict/snippets/abc.js +45 -0
  194. package/src-noconflict/snippets/actionscript.js +171 -0
  195. package/src-noconflict/snippets/ada.js +9 -0
  196. package/src-noconflict/snippets/apache_conf.js +9 -0
  197. package/src-noconflict/snippets/apex.js +9 -0
  198. package/src-noconflict/snippets/applescript.js +9 -0
  199. package/src-noconflict/snippets/aql.js +9 -0
  200. package/src-noconflict/snippets/asciidoc.js +9 -0
  201. package/src-noconflict/snippets/asl.js +9 -0
  202. package/src-noconflict/snippets/assembly_x86.js +9 -0
  203. package/src-noconflict/snippets/autohotkey.js +9 -0
  204. package/src-noconflict/snippets/batchfile.js +9 -0
  205. package/src-noconflict/snippets/c9search.js +9 -0
  206. package/src-noconflict/snippets/c_cpp.js +145 -0
  207. package/src-noconflict/snippets/cirru.js +9 -0
  208. package/src-noconflict/snippets/clojure.js +104 -0
  209. package/src-noconflict/snippets/cobol.js +9 -0
  210. package/src-noconflict/snippets/coffee.js +109 -0
  211. package/src-noconflict/snippets/coldfusion.js +9 -0
  212. package/src-noconflict/snippets/crystal.js +9 -0
  213. package/src-noconflict/snippets/csharp.js +9 -0
  214. package/src-noconflict/snippets/csound_document.js +24 -0
  215. package/src-noconflict/snippets/csound_orchestra.js +61 -0
  216. package/src-noconflict/snippets/csound_score.js +9 -0
  217. package/src-noconflict/snippets/csp.js +9 -0
  218. package/src-noconflict/snippets/css.js +981 -0
  219. package/src-noconflict/snippets/curly.js +9 -0
  220. package/src-noconflict/snippets/d.js +9 -0
  221. package/src-noconflict/snippets/dart.js +97 -0
  222. package/src-noconflict/snippets/diff.js +25 -0
  223. package/src-noconflict/snippets/django.js +122 -0
  224. package/src-noconflict/snippets/dockerfile.js +9 -0
  225. package/src-noconflict/snippets/dot.js +9 -0
  226. package/src-noconflict/snippets/drools.js +33 -0
  227. package/src-noconflict/snippets/edifact.js +254 -0
  228. package/src-noconflict/snippets/eiffel.js +9 -0
  229. package/src-noconflict/snippets/ejs.js +9 -0
  230. package/src-noconflict/snippets/elixir.js +9 -0
  231. package/src-noconflict/snippets/elm.js +9 -0
  232. package/src-noconflict/snippets/erlang.js +174 -0
  233. package/src-noconflict/snippets/forth.js +9 -0
  234. package/src-noconflict/snippets/fortran.js +9 -0
  235. package/src-noconflict/snippets/fsharp.js +9 -0
  236. package/src-noconflict/snippets/fsl.js +14 -0
  237. package/src-noconflict/snippets/ftl.js +9 -0
  238. package/src-noconflict/snippets/gcode.js +9 -0
  239. package/src-noconflict/snippets/gherkin.js +9 -0
  240. package/src-noconflict/snippets/gitignore.js +9 -0
  241. package/src-noconflict/snippets/glsl.js +9 -0
  242. package/src-noconflict/snippets/gobstones.js +1718 -0
  243. package/src-noconflict/snippets/golang.js +9 -0
  244. package/src-noconflict/snippets/graphqlschema.js +46 -0
  245. package/src-noconflict/snippets/groovy.js +9 -0
  246. package/src-noconflict/snippets/haml.js +34 -0
  247. package/src-noconflict/snippets/handlebars.js +9 -0
  248. package/src-noconflict/snippets/haskell.js +96 -0
  249. package/src-noconflict/snippets/haskell_cabal.js +9 -0
  250. package/src-noconflict/snippets/haxe.js +9 -0
  251. package/src-noconflict/snippets/hjson.js +9 -0
  252. package/src-noconflict/snippets/html.js +867 -0
  253. package/src-noconflict/snippets/html_elixir.js +9 -0
  254. package/src-noconflict/snippets/html_ruby.js +9 -0
  255. package/src-noconflict/snippets/ini.js +9 -0
  256. package/src-noconflict/snippets/io.js +76 -0
  257. package/src-noconflict/snippets/jack.js +9 -0
  258. package/src-noconflict/snippets/jade.js +9 -0
  259. package/src-noconflict/snippets/java.js +254 -0
  260. package/src-noconflict/snippets/javascript.js +209 -0
  261. package/src-noconflict/snippets/json.js +9 -0
  262. package/src-noconflict/snippets/jsoniq.js +75 -0
  263. package/src-noconflict/snippets/jsp.js +113 -0
  264. package/src-noconflict/snippets/jssm.js +9 -0
  265. package/src-noconflict/snippets/jsx.js +9 -0
  266. package/src-noconflict/snippets/julia.js +9 -0
  267. package/src-noconflict/snippets/kotlin.js +9 -0
  268. package/src-noconflict/snippets/latex.js +9 -0
  269. package/src-noconflict/snippets/less.js +9 -0
  270. package/src-noconflict/snippets/liquid.js +895 -0
  271. package/src-noconflict/snippets/lisp.js +9 -0
  272. package/src-noconflict/snippets/livescript.js +9 -0
  273. package/src-noconflict/snippets/logiql.js +9 -0
  274. package/src-noconflict/snippets/logtalk.js +9 -0
  275. package/src-noconflict/snippets/lsl.js +1246 -0
  276. package/src-noconflict/snippets/lua.js +35 -0
  277. package/src-noconflict/snippets/luapage.js +9 -0
  278. package/src-noconflict/snippets/lucene.js +9 -0
  279. package/src-noconflict/snippets/makefile.js +18 -0
  280. package/src-noconflict/snippets/markdown.js +102 -0
  281. package/src-noconflict/snippets/mask.js +9 -0
  282. package/src-noconflict/snippets/matlab.js +9 -0
  283. package/src-noconflict/snippets/maze.js +23 -0
  284. package/src-noconflict/snippets/mel.js +9 -0
  285. package/src-noconflict/snippets/mixal.js +9 -0
  286. package/src-noconflict/snippets/mushcode.js +9 -0
  287. package/src-noconflict/snippets/mysql.js +9 -0
  288. package/src-noconflict/snippets/nginx.js +9 -0
  289. package/src-noconflict/snippets/nim.js +9 -0
  290. package/src-noconflict/snippets/nix.js +9 -0
  291. package/src-noconflict/snippets/nsis.js +9 -0
  292. package/src-noconflict/snippets/objectivec.js +9 -0
  293. package/src-noconflict/snippets/ocaml.js +9 -0
  294. package/src-noconflict/snippets/pascal.js +9 -0
  295. package/src-noconflict/snippets/perl.js +361 -0
  296. package/src-noconflict/snippets/pgsql.js +9 -0
  297. package/src-noconflict/snippets/php.js +397 -0
  298. package/src-noconflict/snippets/php_laravel_blade.js +9 -0
  299. package/src-noconflict/snippets/pig.js +9 -0
  300. package/src-noconflict/snippets/plain_text.js +9 -0
  301. package/src-noconflict/snippets/powershell.js +9 -0
  302. package/src-noconflict/snippets/praat.js +9 -0
  303. package/src-noconflict/snippets/prolog.js +9 -0
  304. package/src-noconflict/snippets/properties.js +9 -0
  305. package/src-noconflict/snippets/protobuf.js +9 -0
  306. package/src-noconflict/snippets/puppet.js +9 -0
  307. package/src-noconflict/snippets/python.js +172 -0
  308. package/src-noconflict/snippets/r.js +135 -0
  309. package/src-noconflict/snippets/razor.js +17 -0
  310. package/src-noconflict/snippets/rdoc.js +9 -0
  311. package/src-noconflict/snippets/red.js +9 -0
  312. package/src-noconflict/snippets/redshift.js +9 -0
  313. package/src-noconflict/snippets/rhtml.js +9 -0
  314. package/src-noconflict/snippets/rst.js +36 -0
  315. package/src-noconflict/snippets/ruby.js +942 -0
  316. package/src-noconflict/snippets/rust.js +9 -0
  317. package/src-noconflict/snippets/sass.js +9 -0
  318. package/src-noconflict/snippets/scad.js +9 -0
  319. package/src-noconflict/snippets/scala.js +9 -0
  320. package/src-noconflict/snippets/scheme.js +9 -0
  321. package/src-noconflict/snippets/scss.js +9 -0
  322. package/src-noconflict/snippets/sh.js +97 -0
  323. package/src-noconflict/snippets/sjs.js +9 -0
  324. package/src-noconflict/snippets/slim.js +9 -0
  325. package/src-noconflict/snippets/smarty.js +9 -0
  326. package/src-noconflict/snippets/snippets.js +23 -0
  327. package/src-noconflict/snippets/soy_template.js +9 -0
  328. package/src-noconflict/snippets/space.js +9 -0
  329. package/src-noconflict/snippets/sparql.js +9 -0
  330. package/src-noconflict/snippets/sql.js +40 -0
  331. package/src-noconflict/snippets/sqlserver.js +83 -0
  332. package/src-noconflict/snippets/stylus.js +9 -0
  333. package/src-noconflict/snippets/svg.js +9 -0
  334. package/src-noconflict/snippets/swift.js +9 -0
  335. package/src-noconflict/snippets/tcl.js +106 -0
  336. package/src-noconflict/snippets/terraform.js +9 -0
  337. package/src-noconflict/snippets/tex.js +204 -0
  338. package/src-noconflict/snippets/text.js +9 -0
  339. package/src-noconflict/snippets/textile.js +44 -0
  340. package/src-noconflict/snippets/toml.js +9 -0
  341. package/src-noconflict/snippets/tsx.js +9 -0
  342. package/src-noconflict/snippets/turtle.js +9 -0
  343. package/src-noconflict/snippets/twig.js +9 -0
  344. package/src-noconflict/snippets/typescript.js +9 -0
  345. package/src-noconflict/snippets/vala.js +200 -0
  346. package/src-noconflict/snippets/vbscript.js +9 -0
  347. package/src-noconflict/snippets/velocity.js +43 -0
  348. package/src-noconflict/snippets/verilog.js +9 -0
  349. package/src-noconflict/snippets/vhdl.js +9 -0
  350. package/src-noconflict/snippets/visualforce.js +9 -0
  351. package/src-noconflict/snippets/wollok.js +98 -0
  352. package/src-noconflict/snippets/xml.js +9 -0
  353. package/src-noconflict/snippets/xquery.js +75 -0
  354. package/src-noconflict/snippets/yaml.js +9 -0
  355. package/src-noconflict/snippets/zeek.js +9 -0
  356. package/src-noconflict/theme-ambiance.js +185 -0
  357. package/src-noconflict/theme-chaos.js +163 -0
  358. package/src-noconflict/theme-chrome.js +135 -0
  359. package/src-noconflict/theme-clouds.js +102 -0
  360. package/src-noconflict/theme-clouds_midnight.js +103 -0
  361. package/src-noconflict/theme-cobalt.js +120 -0
  362. package/src-noconflict/theme-crimson_editor.js +125 -0
  363. package/src-noconflict/theme-dawn.js +115 -0
  364. package/src-noconflict/theme-dracula.js +135 -0
  365. package/src-noconflict/theme-dreamweaver.js +148 -0
  366. package/src-noconflict/theme-eclipse.js +105 -0
  367. package/src-noconflict/theme-github.js +110 -0
  368. package/src-noconflict/theme-gob.js +119 -0
  369. package/src-noconflict/theme-gruvbox.js +89 -0
  370. package/src-noconflict/theme-idle_fingers.js +103 -0
  371. package/src-noconflict/theme-iplastic.js +128 -0
  372. package/src-noconflict/theme-katzenmilch.js +128 -0
  373. package/src-noconflict/theme-kr_theme.js +111 -0
  374. package/src-noconflict/theme-kuroir.js +68 -0
  375. package/src-noconflict/theme-merbivore.js +102 -0
  376. package/src-noconflict/theme-merbivore_soft.js +103 -0
  377. package/src-noconflict/theme-mono_industrial.js +114 -0
  378. package/src-noconflict/theme-monokai.js +112 -0
  379. package/src-noconflict/theme-pastel_on_dark.js +115 -0
  380. package/src-noconflict/theme-solarized_dark.js +95 -0
  381. package/src-noconflict/theme-solarized_light.js +98 -0
  382. package/src-noconflict/theme-sqlserver.js +145 -0
  383. package/src-noconflict/theme-terminal.js +121 -0
  384. package/src-noconflict/theme-textmate.js +137 -0
  385. package/src-noconflict/theme-tomorrow.js +115 -0
  386. package/src-noconflict/theme-tomorrow_night.js +115 -0
  387. package/src-noconflict/theme-tomorrow_night_blue.js +113 -0
  388. package/src-noconflict/theme-tomorrow_night_bright.js +128 -0
  389. package/src-noconflict/theme-tomorrow_night_eighties.js +115 -0
  390. package/src-noconflict/theme-twilight.js +116 -0
  391. package/src-noconflict/theme-vibrant_ink.js +101 -0
  392. package/src-noconflict/theme-xcode.js +95 -0
  393. package/src-noconflict/worker-coffee.js +1470 -0
  394. package/src-noconflict/worker-css.js +9000 -0
  395. package/src-noconflict/worker-html.js +10922 -0
  396. package/src-noconflict/worker-javascript.js +15001 -0
  397. package/src-noconflict/worker-json.js +1715 -0
  398. package/src-noconflict/worker-lua.js +3608 -0
  399. package/src-noconflict/worker-php.js +3687 -0
  400. package/src-noconflict/worker-xml.js +3208 -0
  401. package/src-noconflict/worker-xquery.js +57668 -0
@@ -0,0 +1,3608 @@
1
+ "no use strict";
2
+ !(function(window) {
3
+ if (typeof window.window != "undefined" && window.document)
4
+ return;
5
+ if (window.require && window.define)
6
+ return;
7
+
8
+ if (!window.console) {
9
+ window.console = function() {
10
+ var msgs = Array.prototype.slice.call(arguments, 0);
11
+ postMessage({type: "log", data: msgs});
12
+ };
13
+ window.console.error =
14
+ window.console.warn =
15
+ window.console.log =
16
+ window.console.trace = window.console;
17
+ }
18
+ window.window = window;
19
+ window.ace = window;
20
+
21
+ window.onerror = function(message, file, line, col, err) {
22
+ postMessage({type: "error", data: {
23
+ message: message,
24
+ data: err.data,
25
+ file: file,
26
+ line: line,
27
+ col: col,
28
+ stack: err.stack
29
+ }});
30
+ };
31
+
32
+ window.normalizeModule = function(parentId, moduleName) {
33
+ // normalize plugin requires
34
+ if (moduleName.indexOf("!") !== -1) {
35
+ var chunks = moduleName.split("!");
36
+ return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
37
+ }
38
+ // normalize relative requires
39
+ if (moduleName.charAt(0) == ".") {
40
+ var base = parentId.split("/").slice(0, -1).join("/");
41
+ moduleName = (base ? base + "/" : "") + moduleName;
42
+
43
+ while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
44
+ var previous = moduleName;
45
+ moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
46
+ }
47
+ }
48
+
49
+ return moduleName;
50
+ };
51
+
52
+ window.require = function require(parentId, id) {
53
+ if (!id) {
54
+ id = parentId;
55
+ parentId = null;
56
+ }
57
+ if (!id.charAt)
58
+ throw new Error("worker.js require() accepts only (parentId, id) as arguments");
59
+
60
+ id = window.normalizeModule(parentId, id);
61
+
62
+ var module = window.require.modules[id];
63
+ if (module) {
64
+ if (!module.initialized) {
65
+ module.initialized = true;
66
+ module.exports = module.factory().exports;
67
+ }
68
+ return module.exports;
69
+ }
70
+
71
+ if (!window.require.tlns)
72
+ return console.log("unable to load " + id);
73
+
74
+ var path = resolveModuleId(id, window.require.tlns);
75
+ if (path.slice(-3) != ".js") path += ".js";
76
+
77
+ window.require.id = id;
78
+ window.require.modules[id] = {}; // prevent infinite loop on broken modules
79
+ importScripts(path);
80
+ return window.require(parentId, id);
81
+ };
82
+ function resolveModuleId(id, paths) {
83
+ var testPath = id, tail = "";
84
+ while (testPath) {
85
+ var alias = paths[testPath];
86
+ if (typeof alias == "string") {
87
+ return alias + tail;
88
+ } else if (alias) {
89
+ return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
90
+ } else if (alias === false) {
91
+ return "";
92
+ }
93
+ var i = testPath.lastIndexOf("/");
94
+ if (i === -1) break;
95
+ tail = testPath.substr(i) + tail;
96
+ testPath = testPath.slice(0, i);
97
+ }
98
+ return id;
99
+ }
100
+ window.require.modules = {};
101
+ window.require.tlns = {};
102
+
103
+ window.define = function(id, deps, factory) {
104
+ if (arguments.length == 2) {
105
+ factory = deps;
106
+ if (typeof id != "string") {
107
+ deps = id;
108
+ id = window.require.id;
109
+ }
110
+ } else if (arguments.length == 1) {
111
+ factory = id;
112
+ deps = [];
113
+ id = window.require.id;
114
+ }
115
+
116
+ if (typeof factory != "function") {
117
+ window.require.modules[id] = {
118
+ exports: factory,
119
+ initialized: true
120
+ };
121
+ return;
122
+ }
123
+
124
+ if (!deps.length)
125
+ // If there is no dependencies, we inject "require", "exports" and
126
+ // "module" as dependencies, to provide CommonJS compatibility.
127
+ deps = ["require", "exports", "module"];
128
+
129
+ var req = function(childId) {
130
+ return window.require(id, childId);
131
+ };
132
+
133
+ window.require.modules[id] = {
134
+ exports: {},
135
+ factory: function() {
136
+ var module = this;
137
+ var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
138
+ switch (dep) {
139
+ // Because "require", "exports" and "module" aren't actual
140
+ // dependencies, we must handle them seperately.
141
+ case "require": return req;
142
+ case "exports": return module.exports;
143
+ case "module": return module;
144
+ // But for all other dependencies, we can just go ahead and
145
+ // require them.
146
+ default: return req(dep);
147
+ }
148
+ }));
149
+ if (returnExports)
150
+ module.exports = returnExports;
151
+ return module;
152
+ }
153
+ };
154
+ };
155
+ window.define.amd = {};
156
+ require.tlns = {};
157
+ window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
158
+ for (var i in topLevelNamespaces)
159
+ require.tlns[i] = topLevelNamespaces[i];
160
+ };
161
+
162
+ window.initSender = function initSender() {
163
+
164
+ var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
165
+ var oop = window.require("ace/lib/oop");
166
+
167
+ var Sender = function() {};
168
+
169
+ (function() {
170
+
171
+ oop.implement(this, EventEmitter);
172
+
173
+ this.callback = function(data, callbackId) {
174
+ postMessage({
175
+ type: "call",
176
+ id: callbackId,
177
+ data: data
178
+ });
179
+ };
180
+
181
+ this.emit = function(name, data) {
182
+ postMessage({
183
+ type: "event",
184
+ name: name,
185
+ data: data
186
+ });
187
+ };
188
+
189
+ }).call(Sender.prototype);
190
+
191
+ return new Sender();
192
+ };
193
+
194
+ var main = window.main = null;
195
+ var sender = window.sender = null;
196
+
197
+ window.onmessage = function(e) {
198
+ var msg = e.data;
199
+ if (msg.event && sender) {
200
+ sender._signal(msg.event, msg.data);
201
+ }
202
+ else if (msg.command) {
203
+ if (main[msg.command])
204
+ main[msg.command].apply(main, msg.args);
205
+ else if (window[msg.command])
206
+ window[msg.command].apply(window, msg.args);
207
+ else
208
+ throw new Error("Unknown command:" + msg.command);
209
+ }
210
+ else if (msg.init) {
211
+ window.initBaseUrls(msg.tlns);
212
+ sender = window.sender = window.initSender();
213
+ var clazz = require(msg.module)[msg.classname];
214
+ main = window.main = new clazz(sender);
215
+ }
216
+ };
217
+ })(this);
218
+
219
+ ace.define("ace/lib/oop",[], function(require, exports, module) {
220
+ "use strict";
221
+
222
+ exports.inherits = function(ctor, superCtor) {
223
+ ctor.super_ = superCtor;
224
+ ctor.prototype = Object.create(superCtor.prototype, {
225
+ constructor: {
226
+ value: ctor,
227
+ enumerable: false,
228
+ writable: true,
229
+ configurable: true
230
+ }
231
+ });
232
+ };
233
+
234
+ exports.mixin = function(obj, mixin) {
235
+ for (var key in mixin) {
236
+ obj[key] = mixin[key];
237
+ }
238
+ return obj;
239
+ };
240
+
241
+ exports.implement = function(proto, mixin) {
242
+ exports.mixin(proto, mixin);
243
+ };
244
+
245
+ });
246
+
247
+ ace.define("ace/range",[], function(require, exports, module) {
248
+ "use strict";
249
+ var comparePoints = function(p1, p2) {
250
+ return p1.row - p2.row || p1.column - p2.column;
251
+ };
252
+ var Range = function(startRow, startColumn, endRow, endColumn) {
253
+ this.start = {
254
+ row: startRow,
255
+ column: startColumn
256
+ };
257
+
258
+ this.end = {
259
+ row: endRow,
260
+ column: endColumn
261
+ };
262
+ };
263
+
264
+ (function() {
265
+ this.isEqual = function(range) {
266
+ return this.start.row === range.start.row &&
267
+ this.end.row === range.end.row &&
268
+ this.start.column === range.start.column &&
269
+ this.end.column === range.end.column;
270
+ };
271
+ this.toString = function() {
272
+ return ("Range: [" + this.start.row + "/" + this.start.column +
273
+ "] -> [" + this.end.row + "/" + this.end.column + "]");
274
+ };
275
+
276
+ this.contains = function(row, column) {
277
+ return this.compare(row, column) == 0;
278
+ };
279
+ this.compareRange = function(range) {
280
+ var cmp,
281
+ end = range.end,
282
+ start = range.start;
283
+
284
+ cmp = this.compare(end.row, end.column);
285
+ if (cmp == 1) {
286
+ cmp = this.compare(start.row, start.column);
287
+ if (cmp == 1) {
288
+ return 2;
289
+ } else if (cmp == 0) {
290
+ return 1;
291
+ } else {
292
+ return 0;
293
+ }
294
+ } else if (cmp == -1) {
295
+ return -2;
296
+ } else {
297
+ cmp = this.compare(start.row, start.column);
298
+ if (cmp == -1) {
299
+ return -1;
300
+ } else if (cmp == 1) {
301
+ return 42;
302
+ } else {
303
+ return 0;
304
+ }
305
+ }
306
+ };
307
+ this.comparePoint = function(p) {
308
+ return this.compare(p.row, p.column);
309
+ };
310
+ this.containsRange = function(range) {
311
+ return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
312
+ };
313
+ this.intersects = function(range) {
314
+ var cmp = this.compareRange(range);
315
+ return (cmp == -1 || cmp == 0 || cmp == 1);
316
+ };
317
+ this.isEnd = function(row, column) {
318
+ return this.end.row == row && this.end.column == column;
319
+ };
320
+ this.isStart = function(row, column) {
321
+ return this.start.row == row && this.start.column == column;
322
+ };
323
+ this.setStart = function(row, column) {
324
+ if (typeof row == "object") {
325
+ this.start.column = row.column;
326
+ this.start.row = row.row;
327
+ } else {
328
+ this.start.row = row;
329
+ this.start.column = column;
330
+ }
331
+ };
332
+ this.setEnd = function(row, column) {
333
+ if (typeof row == "object") {
334
+ this.end.column = row.column;
335
+ this.end.row = row.row;
336
+ } else {
337
+ this.end.row = row;
338
+ this.end.column = column;
339
+ }
340
+ };
341
+ this.inside = function(row, column) {
342
+ if (this.compare(row, column) == 0) {
343
+ if (this.isEnd(row, column) || this.isStart(row, column)) {
344
+ return false;
345
+ } else {
346
+ return true;
347
+ }
348
+ }
349
+ return false;
350
+ };
351
+ this.insideStart = function(row, column) {
352
+ if (this.compare(row, column) == 0) {
353
+ if (this.isEnd(row, column)) {
354
+ return false;
355
+ } else {
356
+ return true;
357
+ }
358
+ }
359
+ return false;
360
+ };
361
+ this.insideEnd = function(row, column) {
362
+ if (this.compare(row, column) == 0) {
363
+ if (this.isStart(row, column)) {
364
+ return false;
365
+ } else {
366
+ return true;
367
+ }
368
+ }
369
+ return false;
370
+ };
371
+ this.compare = function(row, column) {
372
+ if (!this.isMultiLine()) {
373
+ if (row === this.start.row) {
374
+ return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
375
+ }
376
+ }
377
+
378
+ if (row < this.start.row)
379
+ return -1;
380
+
381
+ if (row > this.end.row)
382
+ return 1;
383
+
384
+ if (this.start.row === row)
385
+ return column >= this.start.column ? 0 : -1;
386
+
387
+ if (this.end.row === row)
388
+ return column <= this.end.column ? 0 : 1;
389
+
390
+ return 0;
391
+ };
392
+ this.compareStart = function(row, column) {
393
+ if (this.start.row == row && this.start.column == column) {
394
+ return -1;
395
+ } else {
396
+ return this.compare(row, column);
397
+ }
398
+ };
399
+ this.compareEnd = function(row, column) {
400
+ if (this.end.row == row && this.end.column == column) {
401
+ return 1;
402
+ } else {
403
+ return this.compare(row, column);
404
+ }
405
+ };
406
+ this.compareInside = function(row, column) {
407
+ if (this.end.row == row && this.end.column == column) {
408
+ return 1;
409
+ } else if (this.start.row == row && this.start.column == column) {
410
+ return -1;
411
+ } else {
412
+ return this.compare(row, column);
413
+ }
414
+ };
415
+ this.clipRows = function(firstRow, lastRow) {
416
+ if (this.end.row > lastRow)
417
+ var end = {row: lastRow + 1, column: 0};
418
+ else if (this.end.row < firstRow)
419
+ var end = {row: firstRow, column: 0};
420
+
421
+ if (this.start.row > lastRow)
422
+ var start = {row: lastRow + 1, column: 0};
423
+ else if (this.start.row < firstRow)
424
+ var start = {row: firstRow, column: 0};
425
+
426
+ return Range.fromPoints(start || this.start, end || this.end);
427
+ };
428
+ this.extend = function(row, column) {
429
+ var cmp = this.compare(row, column);
430
+
431
+ if (cmp == 0)
432
+ return this;
433
+ else if (cmp == -1)
434
+ var start = {row: row, column: column};
435
+ else
436
+ var end = {row: row, column: column};
437
+
438
+ return Range.fromPoints(start || this.start, end || this.end);
439
+ };
440
+
441
+ this.isEmpty = function() {
442
+ return (this.start.row === this.end.row && this.start.column === this.end.column);
443
+ };
444
+ this.isMultiLine = function() {
445
+ return (this.start.row !== this.end.row);
446
+ };
447
+ this.clone = function() {
448
+ return Range.fromPoints(this.start, this.end);
449
+ };
450
+ this.collapseRows = function() {
451
+ if (this.end.column == 0)
452
+ return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
453
+ else
454
+ return new Range(this.start.row, 0, this.end.row, 0);
455
+ };
456
+ this.toScreenRange = function(session) {
457
+ var screenPosStart = session.documentToScreenPosition(this.start);
458
+ var screenPosEnd = session.documentToScreenPosition(this.end);
459
+
460
+ return new Range(
461
+ screenPosStart.row, screenPosStart.column,
462
+ screenPosEnd.row, screenPosEnd.column
463
+ );
464
+ };
465
+ this.moveBy = function(row, column) {
466
+ this.start.row += row;
467
+ this.start.column += column;
468
+ this.end.row += row;
469
+ this.end.column += column;
470
+ };
471
+
472
+ }).call(Range.prototype);
473
+ Range.fromPoints = function(start, end) {
474
+ return new Range(start.row, start.column, end.row, end.column);
475
+ };
476
+ Range.comparePoints = comparePoints;
477
+
478
+ Range.comparePoints = function(p1, p2) {
479
+ return p1.row - p2.row || p1.column - p2.column;
480
+ };
481
+
482
+
483
+ exports.Range = Range;
484
+ });
485
+
486
+ ace.define("ace/apply_delta",[], function(require, exports, module) {
487
+ "use strict";
488
+
489
+ function throwDeltaError(delta, errorText){
490
+ console.log("Invalid Delta:", delta);
491
+ throw "Invalid Delta: " + errorText;
492
+ }
493
+
494
+ function positionInDocument(docLines, position) {
495
+ return position.row >= 0 && position.row < docLines.length &&
496
+ position.column >= 0 && position.column <= docLines[position.row].length;
497
+ }
498
+
499
+ function validateDelta(docLines, delta) {
500
+ if (delta.action != "insert" && delta.action != "remove")
501
+ throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
502
+ if (!(delta.lines instanceof Array))
503
+ throwDeltaError(delta, "delta.lines must be an Array");
504
+ if (!delta.start || !delta.end)
505
+ throwDeltaError(delta, "delta.start/end must be an present");
506
+ var start = delta.start;
507
+ if (!positionInDocument(docLines, delta.start))
508
+ throwDeltaError(delta, "delta.start must be contained in document");
509
+ var end = delta.end;
510
+ if (delta.action == "remove" && !positionInDocument(docLines, end))
511
+ throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
512
+ var numRangeRows = end.row - start.row;
513
+ var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
514
+ if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
515
+ throwDeltaError(delta, "delta.range must match delta lines");
516
+ }
517
+
518
+ exports.applyDelta = function(docLines, delta, doNotValidate) {
519
+
520
+ var row = delta.start.row;
521
+ var startColumn = delta.start.column;
522
+ var line = docLines[row] || "";
523
+ switch (delta.action) {
524
+ case "insert":
525
+ var lines = delta.lines;
526
+ if (lines.length === 1) {
527
+ docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
528
+ } else {
529
+ var args = [row, 1].concat(delta.lines);
530
+ docLines.splice.apply(docLines, args);
531
+ docLines[row] = line.substring(0, startColumn) + docLines[row];
532
+ docLines[row + delta.lines.length - 1] += line.substring(startColumn);
533
+ }
534
+ break;
535
+ case "remove":
536
+ var endColumn = delta.end.column;
537
+ var endRow = delta.end.row;
538
+ if (row === endRow) {
539
+ docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
540
+ } else {
541
+ docLines.splice(
542
+ row, endRow - row + 1,
543
+ line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
544
+ );
545
+ }
546
+ break;
547
+ }
548
+ };
549
+ });
550
+
551
+ ace.define("ace/lib/event_emitter",[], function(require, exports, module) {
552
+ "use strict";
553
+
554
+ var EventEmitter = {};
555
+ var stopPropagation = function() { this.propagationStopped = true; };
556
+ var preventDefault = function() { this.defaultPrevented = true; };
557
+
558
+ EventEmitter._emit =
559
+ EventEmitter._dispatchEvent = function(eventName, e) {
560
+ this._eventRegistry || (this._eventRegistry = {});
561
+ this._defaultHandlers || (this._defaultHandlers = {});
562
+
563
+ var listeners = this._eventRegistry[eventName] || [];
564
+ var defaultHandler = this._defaultHandlers[eventName];
565
+ if (!listeners.length && !defaultHandler)
566
+ return;
567
+
568
+ if (typeof e != "object" || !e)
569
+ e = {};
570
+
571
+ if (!e.type)
572
+ e.type = eventName;
573
+ if (!e.stopPropagation)
574
+ e.stopPropagation = stopPropagation;
575
+ if (!e.preventDefault)
576
+ e.preventDefault = preventDefault;
577
+
578
+ listeners = listeners.slice();
579
+ for (var i=0; i<listeners.length; i++) {
580
+ listeners[i](e, this);
581
+ if (e.propagationStopped)
582
+ break;
583
+ }
584
+
585
+ if (defaultHandler && !e.defaultPrevented)
586
+ return defaultHandler(e, this);
587
+ };
588
+
589
+
590
+ EventEmitter._signal = function(eventName, e) {
591
+ var listeners = (this._eventRegistry || {})[eventName];
592
+ if (!listeners)
593
+ return;
594
+ listeners = listeners.slice();
595
+ for (var i=0; i<listeners.length; i++)
596
+ listeners[i](e, this);
597
+ };
598
+
599
+ EventEmitter.once = function(eventName, callback) {
600
+ var _self = this;
601
+ this.on(eventName, function newCallback() {
602
+ _self.off(eventName, newCallback);
603
+ callback.apply(null, arguments);
604
+ });
605
+ if (!callback) {
606
+ return new Promise(function(resolve) {
607
+ callback = resolve;
608
+ });
609
+ }
610
+ };
611
+
612
+
613
+ EventEmitter.setDefaultHandler = function(eventName, callback) {
614
+ var handlers = this._defaultHandlers;
615
+ if (!handlers)
616
+ handlers = this._defaultHandlers = {_disabled_: {}};
617
+
618
+ if (handlers[eventName]) {
619
+ var old = handlers[eventName];
620
+ var disabled = handlers._disabled_[eventName];
621
+ if (!disabled)
622
+ handlers._disabled_[eventName] = disabled = [];
623
+ disabled.push(old);
624
+ var i = disabled.indexOf(callback);
625
+ if (i != -1)
626
+ disabled.splice(i, 1);
627
+ }
628
+ handlers[eventName] = callback;
629
+ };
630
+ EventEmitter.removeDefaultHandler = function(eventName, callback) {
631
+ var handlers = this._defaultHandlers;
632
+ if (!handlers)
633
+ return;
634
+ var disabled = handlers._disabled_[eventName];
635
+
636
+ if (handlers[eventName] == callback) {
637
+ if (disabled)
638
+ this.setDefaultHandler(eventName, disabled.pop());
639
+ } else if (disabled) {
640
+ var i = disabled.indexOf(callback);
641
+ if (i != -1)
642
+ disabled.splice(i, 1);
643
+ }
644
+ };
645
+
646
+ EventEmitter.on =
647
+ EventEmitter.addEventListener = function(eventName, callback, capturing) {
648
+ this._eventRegistry = this._eventRegistry || {};
649
+
650
+ var listeners = this._eventRegistry[eventName];
651
+ if (!listeners)
652
+ listeners = this._eventRegistry[eventName] = [];
653
+
654
+ if (listeners.indexOf(callback) == -1)
655
+ listeners[capturing ? "unshift" : "push"](callback);
656
+ return callback;
657
+ };
658
+
659
+ EventEmitter.off =
660
+ EventEmitter.removeListener =
661
+ EventEmitter.removeEventListener = function(eventName, callback) {
662
+ this._eventRegistry = this._eventRegistry || {};
663
+
664
+ var listeners = this._eventRegistry[eventName];
665
+ if (!listeners)
666
+ return;
667
+
668
+ var index = listeners.indexOf(callback);
669
+ if (index !== -1)
670
+ listeners.splice(index, 1);
671
+ };
672
+
673
+ EventEmitter.removeAllListeners = function(eventName) {
674
+ if (!eventName) this._eventRegistry = this._defaultHandlers = undefined;
675
+ if (this._eventRegistry) this._eventRegistry[eventName] = undefined;
676
+ if (this._defaultHandlers) this._defaultHandlers[eventName] = undefined;
677
+ };
678
+
679
+ exports.EventEmitter = EventEmitter;
680
+
681
+ });
682
+
683
+ ace.define("ace/anchor",[], function(require, exports, module) {
684
+ "use strict";
685
+
686
+ var oop = require("./lib/oop");
687
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
688
+
689
+ var Anchor = exports.Anchor = function(doc, row, column) {
690
+ this.$onChange = this.onChange.bind(this);
691
+ this.attach(doc);
692
+
693
+ if (typeof column == "undefined")
694
+ this.setPosition(row.row, row.column);
695
+ else
696
+ this.setPosition(row, column);
697
+ };
698
+
699
+ (function() {
700
+
701
+ oop.implement(this, EventEmitter);
702
+ this.getPosition = function() {
703
+ return this.$clipPositionToDocument(this.row, this.column);
704
+ };
705
+ this.getDocument = function() {
706
+ return this.document;
707
+ };
708
+ this.$insertRight = false;
709
+ this.onChange = function(delta) {
710
+ if (delta.start.row == delta.end.row && delta.start.row != this.row)
711
+ return;
712
+
713
+ if (delta.start.row > this.row)
714
+ return;
715
+
716
+ var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
717
+ this.setPosition(point.row, point.column, true);
718
+ };
719
+
720
+ function $pointsInOrder(point1, point2, equalPointsInOrder) {
721
+ var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
722
+ return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
723
+ }
724
+
725
+ function $getTransformedPoint(delta, point, moveIfEqual) {
726
+ var deltaIsInsert = delta.action == "insert";
727
+ var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
728
+ var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
729
+ var deltaStart = delta.start;
730
+ var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
731
+ if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
732
+ return {
733
+ row: point.row,
734
+ column: point.column
735
+ };
736
+ }
737
+ if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
738
+ return {
739
+ row: point.row + deltaRowShift,
740
+ column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
741
+ };
742
+ }
743
+
744
+ return {
745
+ row: deltaStart.row,
746
+ column: deltaStart.column
747
+ };
748
+ }
749
+ this.setPosition = function(row, column, noClip) {
750
+ var pos;
751
+ if (noClip) {
752
+ pos = {
753
+ row: row,
754
+ column: column
755
+ };
756
+ } else {
757
+ pos = this.$clipPositionToDocument(row, column);
758
+ }
759
+
760
+ if (this.row == pos.row && this.column == pos.column)
761
+ return;
762
+
763
+ var old = {
764
+ row: this.row,
765
+ column: this.column
766
+ };
767
+
768
+ this.row = pos.row;
769
+ this.column = pos.column;
770
+ this._signal("change", {
771
+ old: old,
772
+ value: pos
773
+ });
774
+ };
775
+ this.detach = function() {
776
+ this.document.off("change", this.$onChange);
777
+ };
778
+ this.attach = function(doc) {
779
+ this.document = doc || this.document;
780
+ this.document.on("change", this.$onChange);
781
+ };
782
+ this.$clipPositionToDocument = function(row, column) {
783
+ var pos = {};
784
+
785
+ if (row >= this.document.getLength()) {
786
+ pos.row = Math.max(0, this.document.getLength() - 1);
787
+ pos.column = this.document.getLine(pos.row).length;
788
+ }
789
+ else if (row < 0) {
790
+ pos.row = 0;
791
+ pos.column = 0;
792
+ }
793
+ else {
794
+ pos.row = row;
795
+ pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
796
+ }
797
+
798
+ if (column < 0)
799
+ pos.column = 0;
800
+
801
+ return pos;
802
+ };
803
+
804
+ }).call(Anchor.prototype);
805
+
806
+ });
807
+
808
+ ace.define("ace/document",[], function(require, exports, module) {
809
+ "use strict";
810
+
811
+ var oop = require("./lib/oop");
812
+ var applyDelta = require("./apply_delta").applyDelta;
813
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
814
+ var Range = require("./range").Range;
815
+ var Anchor = require("./anchor").Anchor;
816
+
817
+ var Document = function(textOrLines) {
818
+ this.$lines = [""];
819
+ if (textOrLines.length === 0) {
820
+ this.$lines = [""];
821
+ } else if (Array.isArray(textOrLines)) {
822
+ this.insertMergedLines({row: 0, column: 0}, textOrLines);
823
+ } else {
824
+ this.insert({row: 0, column:0}, textOrLines);
825
+ }
826
+ };
827
+
828
+ (function() {
829
+
830
+ oop.implement(this, EventEmitter);
831
+ this.setValue = function(text) {
832
+ var len = this.getLength() - 1;
833
+ this.remove(new Range(0, 0, len, this.getLine(len).length));
834
+ this.insert({row: 0, column: 0}, text);
835
+ };
836
+ this.getValue = function() {
837
+ return this.getAllLines().join(this.getNewLineCharacter());
838
+ };
839
+ this.createAnchor = function(row, column) {
840
+ return new Anchor(this, row, column);
841
+ };
842
+ if ("aaa".split(/a/).length === 0) {
843
+ this.$split = function(text) {
844
+ return text.replace(/\r\n|\r/g, "\n").split("\n");
845
+ };
846
+ } else {
847
+ this.$split = function(text) {
848
+ return text.split(/\r\n|\r|\n/);
849
+ };
850
+ }
851
+
852
+
853
+ this.$detectNewLine = function(text) {
854
+ var match = text.match(/^.*?(\r\n|\r|\n)/m);
855
+ this.$autoNewLine = match ? match[1] : "\n";
856
+ this._signal("changeNewLineMode");
857
+ };
858
+ this.getNewLineCharacter = function() {
859
+ switch (this.$newLineMode) {
860
+ case "windows":
861
+ return "\r\n";
862
+ case "unix":
863
+ return "\n";
864
+ default:
865
+ return this.$autoNewLine || "\n";
866
+ }
867
+ };
868
+
869
+ this.$autoNewLine = "";
870
+ this.$newLineMode = "auto";
871
+ this.setNewLineMode = function(newLineMode) {
872
+ if (this.$newLineMode === newLineMode)
873
+ return;
874
+
875
+ this.$newLineMode = newLineMode;
876
+ this._signal("changeNewLineMode");
877
+ };
878
+ this.getNewLineMode = function() {
879
+ return this.$newLineMode;
880
+ };
881
+ this.isNewLine = function(text) {
882
+ return (text == "\r\n" || text == "\r" || text == "\n");
883
+ };
884
+ this.getLine = function(row) {
885
+ return this.$lines[row] || "";
886
+ };
887
+ this.getLines = function(firstRow, lastRow) {
888
+ return this.$lines.slice(firstRow, lastRow + 1);
889
+ };
890
+ this.getAllLines = function() {
891
+ return this.getLines(0, this.getLength());
892
+ };
893
+ this.getLength = function() {
894
+ return this.$lines.length;
895
+ };
896
+ this.getTextRange = function(range) {
897
+ return this.getLinesForRange(range).join(this.getNewLineCharacter());
898
+ };
899
+ this.getLinesForRange = function(range) {
900
+ var lines;
901
+ if (range.start.row === range.end.row) {
902
+ lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
903
+ } else {
904
+ lines = this.getLines(range.start.row, range.end.row);
905
+ lines[0] = (lines[0] || "").substring(range.start.column);
906
+ var l = lines.length - 1;
907
+ if (range.end.row - range.start.row == l)
908
+ lines[l] = lines[l].substring(0, range.end.column);
909
+ }
910
+ return lines;
911
+ };
912
+ this.insertLines = function(row, lines) {
913
+ console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
914
+ return this.insertFullLines(row, lines);
915
+ };
916
+ this.removeLines = function(firstRow, lastRow) {
917
+ console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
918
+ return this.removeFullLines(firstRow, lastRow);
919
+ };
920
+ this.insertNewLine = function(position) {
921
+ console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
922
+ return this.insertMergedLines(position, ["", ""]);
923
+ };
924
+ this.insert = function(position, text) {
925
+ if (this.getLength() <= 1)
926
+ this.$detectNewLine(text);
927
+
928
+ return this.insertMergedLines(position, this.$split(text));
929
+ };
930
+ this.insertInLine = function(position, text) {
931
+ var start = this.clippedPos(position.row, position.column);
932
+ var end = this.pos(position.row, position.column + text.length);
933
+
934
+ this.applyDelta({
935
+ start: start,
936
+ end: end,
937
+ action: "insert",
938
+ lines: [text]
939
+ }, true);
940
+
941
+ return this.clonePos(end);
942
+ };
943
+
944
+ this.clippedPos = function(row, column) {
945
+ var length = this.getLength();
946
+ if (row === undefined) {
947
+ row = length;
948
+ } else if (row < 0) {
949
+ row = 0;
950
+ } else if (row >= length) {
951
+ row = length - 1;
952
+ column = undefined;
953
+ }
954
+ var line = this.getLine(row);
955
+ if (column == undefined)
956
+ column = line.length;
957
+ column = Math.min(Math.max(column, 0), line.length);
958
+ return {row: row, column: column};
959
+ };
960
+
961
+ this.clonePos = function(pos) {
962
+ return {row: pos.row, column: pos.column};
963
+ };
964
+
965
+ this.pos = function(row, column) {
966
+ return {row: row, column: column};
967
+ };
968
+
969
+ this.$clipPosition = function(position) {
970
+ var length = this.getLength();
971
+ if (position.row >= length) {
972
+ position.row = Math.max(0, length - 1);
973
+ position.column = this.getLine(length - 1).length;
974
+ } else {
975
+ position.row = Math.max(0, position.row);
976
+ position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
977
+ }
978
+ return position;
979
+ };
980
+ this.insertFullLines = function(row, lines) {
981
+ row = Math.min(Math.max(row, 0), this.getLength());
982
+ var column = 0;
983
+ if (row < this.getLength()) {
984
+ lines = lines.concat([""]);
985
+ column = 0;
986
+ } else {
987
+ lines = [""].concat(lines);
988
+ row--;
989
+ column = this.$lines[row].length;
990
+ }
991
+ this.insertMergedLines({row: row, column: column}, lines);
992
+ };
993
+ this.insertMergedLines = function(position, lines) {
994
+ var start = this.clippedPos(position.row, position.column);
995
+ var end = {
996
+ row: start.row + lines.length - 1,
997
+ column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
998
+ };
999
+
1000
+ this.applyDelta({
1001
+ start: start,
1002
+ end: end,
1003
+ action: "insert",
1004
+ lines: lines
1005
+ });
1006
+
1007
+ return this.clonePos(end);
1008
+ };
1009
+ this.remove = function(range) {
1010
+ var start = this.clippedPos(range.start.row, range.start.column);
1011
+ var end = this.clippedPos(range.end.row, range.end.column);
1012
+ this.applyDelta({
1013
+ start: start,
1014
+ end: end,
1015
+ action: "remove",
1016
+ lines: this.getLinesForRange({start: start, end: end})
1017
+ });
1018
+ return this.clonePos(start);
1019
+ };
1020
+ this.removeInLine = function(row, startColumn, endColumn) {
1021
+ var start = this.clippedPos(row, startColumn);
1022
+ var end = this.clippedPos(row, endColumn);
1023
+
1024
+ this.applyDelta({
1025
+ start: start,
1026
+ end: end,
1027
+ action: "remove",
1028
+ lines: this.getLinesForRange({start: start, end: end})
1029
+ }, true);
1030
+
1031
+ return this.clonePos(start);
1032
+ };
1033
+ this.removeFullLines = function(firstRow, lastRow) {
1034
+ firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
1035
+ lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
1036
+ var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
1037
+ var deleteLastNewLine = lastRow < this.getLength() - 1;
1038
+ var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
1039
+ var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
1040
+ var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
1041
+ var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
1042
+ var range = new Range(startRow, startCol, endRow, endCol);
1043
+ var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
1044
+
1045
+ this.applyDelta({
1046
+ start: range.start,
1047
+ end: range.end,
1048
+ action: "remove",
1049
+ lines: this.getLinesForRange(range)
1050
+ });
1051
+ return deletedLines;
1052
+ };
1053
+ this.removeNewLine = function(row) {
1054
+ if (row < this.getLength() - 1 && row >= 0) {
1055
+ this.applyDelta({
1056
+ start: this.pos(row, this.getLine(row).length),
1057
+ end: this.pos(row + 1, 0),
1058
+ action: "remove",
1059
+ lines: ["", ""]
1060
+ });
1061
+ }
1062
+ };
1063
+ this.replace = function(range, text) {
1064
+ if (!(range instanceof Range))
1065
+ range = Range.fromPoints(range.start, range.end);
1066
+ if (text.length === 0 && range.isEmpty())
1067
+ return range.start;
1068
+ if (text == this.getTextRange(range))
1069
+ return range.end;
1070
+
1071
+ this.remove(range);
1072
+ var end;
1073
+ if (text) {
1074
+ end = this.insert(range.start, text);
1075
+ }
1076
+ else {
1077
+ end = range.start;
1078
+ }
1079
+
1080
+ return end;
1081
+ };
1082
+ this.applyDeltas = function(deltas) {
1083
+ for (var i=0; i<deltas.length; i++) {
1084
+ this.applyDelta(deltas[i]);
1085
+ }
1086
+ };
1087
+ this.revertDeltas = function(deltas) {
1088
+ for (var i=deltas.length-1; i>=0; i--) {
1089
+ this.revertDelta(deltas[i]);
1090
+ }
1091
+ };
1092
+ this.applyDelta = function(delta, doNotValidate) {
1093
+ var isInsert = delta.action == "insert";
1094
+ if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
1095
+ : !Range.comparePoints(delta.start, delta.end)) {
1096
+ return;
1097
+ }
1098
+
1099
+ if (isInsert && delta.lines.length > 20000) {
1100
+ this.$splitAndapplyLargeDelta(delta, 20000);
1101
+ }
1102
+ else {
1103
+ applyDelta(this.$lines, delta, doNotValidate);
1104
+ this._signal("change", delta);
1105
+ }
1106
+ };
1107
+
1108
+ this.$safeApplyDelta = function(delta) {
1109
+ var docLength = this.$lines.length;
1110
+ if (
1111
+ delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
1112
+ || delta.action == "insert" && delta.start.row <= docLength
1113
+ ) {
1114
+ this.applyDelta(delta);
1115
+ }
1116
+ };
1117
+
1118
+ this.$splitAndapplyLargeDelta = function(delta, MAX) {
1119
+ var lines = delta.lines;
1120
+ var l = lines.length - MAX + 1;
1121
+ var row = delta.start.row;
1122
+ var column = delta.start.column;
1123
+ for (var from = 0, to = 0; from < l; from = to) {
1124
+ to += MAX - 1;
1125
+ var chunk = lines.slice(from, to);
1126
+ chunk.push("");
1127
+ this.applyDelta({
1128
+ start: this.pos(row + from, column),
1129
+ end: this.pos(row + to, column = 0),
1130
+ action: delta.action,
1131
+ lines: chunk
1132
+ }, true);
1133
+ }
1134
+ delta.lines = lines.slice(from);
1135
+ delta.start.row = row + from;
1136
+ delta.start.column = column;
1137
+ this.applyDelta(delta, true);
1138
+ };
1139
+ this.revertDelta = function(delta) {
1140
+ this.$safeApplyDelta({
1141
+ start: this.clonePos(delta.start),
1142
+ end: this.clonePos(delta.end),
1143
+ action: (delta.action == "insert" ? "remove" : "insert"),
1144
+ lines: delta.lines.slice()
1145
+ });
1146
+ };
1147
+ this.indexToPosition = function(index, startRow) {
1148
+ var lines = this.$lines || this.getAllLines();
1149
+ var newlineLength = this.getNewLineCharacter().length;
1150
+ for (var i = startRow || 0, l = lines.length; i < l; i++) {
1151
+ index -= lines[i].length + newlineLength;
1152
+ if (index < 0)
1153
+ return {row: i, column: index + lines[i].length + newlineLength};
1154
+ }
1155
+ return {row: l-1, column: index + lines[l-1].length + newlineLength};
1156
+ };
1157
+ this.positionToIndex = function(pos, startRow) {
1158
+ var lines = this.$lines || this.getAllLines();
1159
+ var newlineLength = this.getNewLineCharacter().length;
1160
+ var index = 0;
1161
+ var row = Math.min(pos.row, lines.length);
1162
+ for (var i = startRow || 0; i < row; ++i)
1163
+ index += lines[i].length + newlineLength;
1164
+
1165
+ return index + pos.column;
1166
+ };
1167
+
1168
+ }).call(Document.prototype);
1169
+
1170
+ exports.Document = Document;
1171
+ });
1172
+
1173
+ ace.define("ace/lib/lang",[], function(require, exports, module) {
1174
+ "use strict";
1175
+
1176
+ exports.last = function(a) {
1177
+ return a[a.length - 1];
1178
+ };
1179
+
1180
+ exports.stringReverse = function(string) {
1181
+ return string.split("").reverse().join("");
1182
+ };
1183
+
1184
+ exports.stringRepeat = function (string, count) {
1185
+ var result = '';
1186
+ while (count > 0) {
1187
+ if (count & 1)
1188
+ result += string;
1189
+
1190
+ if (count >>= 1)
1191
+ string += string;
1192
+ }
1193
+ return result;
1194
+ };
1195
+
1196
+ var trimBeginRegexp = /^\s\s*/;
1197
+ var trimEndRegexp = /\s\s*$/;
1198
+
1199
+ exports.stringTrimLeft = function (string) {
1200
+ return string.replace(trimBeginRegexp, '');
1201
+ };
1202
+
1203
+ exports.stringTrimRight = function (string) {
1204
+ return string.replace(trimEndRegexp, '');
1205
+ };
1206
+
1207
+ exports.copyObject = function(obj) {
1208
+ var copy = {};
1209
+ for (var key in obj) {
1210
+ copy[key] = obj[key];
1211
+ }
1212
+ return copy;
1213
+ };
1214
+
1215
+ exports.copyArray = function(array){
1216
+ var copy = [];
1217
+ for (var i=0, l=array.length; i<l; i++) {
1218
+ if (array[i] && typeof array[i] == "object")
1219
+ copy[i] = this.copyObject(array[i]);
1220
+ else
1221
+ copy[i] = array[i];
1222
+ }
1223
+ return copy;
1224
+ };
1225
+
1226
+ exports.deepCopy = function deepCopy(obj) {
1227
+ if (typeof obj !== "object" || !obj)
1228
+ return obj;
1229
+ var copy;
1230
+ if (Array.isArray(obj)) {
1231
+ copy = [];
1232
+ for (var key = 0; key < obj.length; key++) {
1233
+ copy[key] = deepCopy(obj[key]);
1234
+ }
1235
+ return copy;
1236
+ }
1237
+ if (Object.prototype.toString.call(obj) !== "[object Object]")
1238
+ return obj;
1239
+
1240
+ copy = {};
1241
+ for (var key in obj)
1242
+ copy[key] = deepCopy(obj[key]);
1243
+ return copy;
1244
+ };
1245
+
1246
+ exports.arrayToMap = function(arr) {
1247
+ var map = {};
1248
+ for (var i=0; i<arr.length; i++) {
1249
+ map[arr[i]] = 1;
1250
+ }
1251
+ return map;
1252
+
1253
+ };
1254
+
1255
+ exports.createMap = function(props) {
1256
+ var map = Object.create(null);
1257
+ for (var i in props) {
1258
+ map[i] = props[i];
1259
+ }
1260
+ return map;
1261
+ };
1262
+ exports.arrayRemove = function(array, value) {
1263
+ for (var i = 0; i <= array.length; i++) {
1264
+ if (value === array[i]) {
1265
+ array.splice(i, 1);
1266
+ }
1267
+ }
1268
+ };
1269
+
1270
+ exports.escapeRegExp = function(str) {
1271
+ return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
1272
+ };
1273
+
1274
+ exports.escapeHTML = function(str) {
1275
+ return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
1276
+ };
1277
+
1278
+ exports.getMatchOffsets = function(string, regExp) {
1279
+ var matches = [];
1280
+
1281
+ string.replace(regExp, function(str) {
1282
+ matches.push({
1283
+ offset: arguments[arguments.length-2],
1284
+ length: str.length
1285
+ });
1286
+ });
1287
+
1288
+ return matches;
1289
+ };
1290
+ exports.deferredCall = function(fcn) {
1291
+ var timer = null;
1292
+ var callback = function() {
1293
+ timer = null;
1294
+ fcn();
1295
+ };
1296
+
1297
+ var deferred = function(timeout) {
1298
+ deferred.cancel();
1299
+ timer = setTimeout(callback, timeout || 0);
1300
+ return deferred;
1301
+ };
1302
+
1303
+ deferred.schedule = deferred;
1304
+
1305
+ deferred.call = function() {
1306
+ this.cancel();
1307
+ fcn();
1308
+ return deferred;
1309
+ };
1310
+
1311
+ deferred.cancel = function() {
1312
+ clearTimeout(timer);
1313
+ timer = null;
1314
+ return deferred;
1315
+ };
1316
+
1317
+ deferred.isPending = function() {
1318
+ return timer;
1319
+ };
1320
+
1321
+ return deferred;
1322
+ };
1323
+
1324
+
1325
+ exports.delayedCall = function(fcn, defaultTimeout) {
1326
+ var timer = null;
1327
+ var callback = function() {
1328
+ timer = null;
1329
+ fcn();
1330
+ };
1331
+
1332
+ var _self = function(timeout) {
1333
+ if (timer == null)
1334
+ timer = setTimeout(callback, timeout || defaultTimeout);
1335
+ };
1336
+
1337
+ _self.delay = function(timeout) {
1338
+ timer && clearTimeout(timer);
1339
+ timer = setTimeout(callback, timeout || defaultTimeout);
1340
+ };
1341
+ _self.schedule = _self;
1342
+
1343
+ _self.call = function() {
1344
+ this.cancel();
1345
+ fcn();
1346
+ };
1347
+
1348
+ _self.cancel = function() {
1349
+ timer && clearTimeout(timer);
1350
+ timer = null;
1351
+ };
1352
+
1353
+ _self.isPending = function() {
1354
+ return timer;
1355
+ };
1356
+
1357
+ return _self;
1358
+ };
1359
+ });
1360
+
1361
+ ace.define("ace/worker/mirror",[], function(require, exports, module) {
1362
+ "use strict";
1363
+
1364
+ var Range = require("../range").Range;
1365
+ var Document = require("../document").Document;
1366
+ var lang = require("../lib/lang");
1367
+
1368
+ var Mirror = exports.Mirror = function(sender) {
1369
+ this.sender = sender;
1370
+ var doc = this.doc = new Document("");
1371
+
1372
+ var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1373
+
1374
+ var _self = this;
1375
+ sender.on("change", function(e) {
1376
+ var data = e.data;
1377
+ if (data[0].start) {
1378
+ doc.applyDeltas(data);
1379
+ } else {
1380
+ for (var i = 0; i < data.length; i += 2) {
1381
+ if (Array.isArray(data[i+1])) {
1382
+ var d = {action: "insert", start: data[i], lines: data[i+1]};
1383
+ } else {
1384
+ var d = {action: "remove", start: data[i], end: data[i+1]};
1385
+ }
1386
+ doc.applyDelta(d, true);
1387
+ }
1388
+ }
1389
+ if (_self.$timeout)
1390
+ return deferredUpdate.schedule(_self.$timeout);
1391
+ _self.onUpdate();
1392
+ });
1393
+ };
1394
+
1395
+ (function() {
1396
+
1397
+ this.$timeout = 500;
1398
+
1399
+ this.setTimeout = function(timeout) {
1400
+ this.$timeout = timeout;
1401
+ };
1402
+
1403
+ this.setValue = function(value) {
1404
+ this.doc.setValue(value);
1405
+ this.deferredUpdate.schedule(this.$timeout);
1406
+ };
1407
+
1408
+ this.getValue = function(callbackId) {
1409
+ this.sender.callback(this.doc.getValue(), callbackId);
1410
+ };
1411
+
1412
+ this.onUpdate = function() {
1413
+ };
1414
+
1415
+ this.isPending = function() {
1416
+ return this.deferredUpdate.isPending();
1417
+ };
1418
+
1419
+ }).call(Mirror.prototype);
1420
+
1421
+ });
1422
+
1423
+ ace.define("ace/mode/lua/luaparse",[], function(require, exports, module) {
1424
+
1425
+ (function (root, name, factory) {
1426
+ factory(exports)
1427
+ }(this, 'luaparse', function (exports) {
1428
+ 'use strict';
1429
+
1430
+ exports.version = "0.3.1";
1431
+
1432
+ var input, options, length, features, encodingMode;
1433
+ var defaultOptions = exports.defaultOptions = {
1434
+ wait: false
1435
+ , comments: true
1436
+ , scope: false
1437
+ , locations: false
1438
+ , ranges: false
1439
+ , onCreateNode: null
1440
+ , onCreateScope: null
1441
+ , onDestroyScope: null
1442
+ , onLocalDeclaration: null
1443
+ , luaVersion: '5.1'
1444
+ , encodingMode: 'none'
1445
+ };
1446
+
1447
+ function encodeUTF8(codepoint, highMask) {
1448
+ highMask = highMask || 0;
1449
+
1450
+ if (codepoint < 0x80) {
1451
+ return String.fromCharCode(codepoint);
1452
+ } else if (codepoint < 0x800) {
1453
+ return String.fromCharCode(
1454
+ highMask | 0xc0 | (codepoint >> 6) ,
1455
+ highMask | 0x80 | ( codepoint & 0x3f)
1456
+ );
1457
+ } else if (codepoint < 0x10000) {
1458
+ return String.fromCharCode(
1459
+ highMask | 0xe0 | (codepoint >> 12) ,
1460
+ highMask | 0x80 | ((codepoint >> 6) & 0x3f),
1461
+ highMask | 0x80 | ( codepoint & 0x3f)
1462
+ );
1463
+ } else /* istanbul ignore else */ if (codepoint < 0x110000) {
1464
+ return String.fromCharCode(
1465
+ highMask | 0xf0 | (codepoint >> 18) ,
1466
+ highMask | 0x80 | ((codepoint >> 12) & 0x3f),
1467
+ highMask | 0x80 | ((codepoint >> 6) & 0x3f),
1468
+ highMask | 0x80 | ( codepoint & 0x3f)
1469
+ );
1470
+ } else {
1471
+ return null;
1472
+ }
1473
+ }
1474
+
1475
+ function toHex(num, digits) {
1476
+ var result = num.toString(16);
1477
+ while (result.length < digits)
1478
+ result = '0' + result;
1479
+ return result;
1480
+ }
1481
+
1482
+ function checkChars(rx) {
1483
+ return function (s) {
1484
+ var m = rx.exec(s);
1485
+ if (!m)
1486
+ return s;
1487
+ raise(null, errors.invalidCodeUnit, toHex(m[0].charCodeAt(0), 4).toUpperCase());
1488
+ };
1489
+ }
1490
+
1491
+ var encodingModes = {
1492
+ 'pseudo-latin1': {
1493
+ fixup: checkChars(/[^\x00-\xff]/),
1494
+ encodeByte: function (value) {
1495
+ if (value === null)
1496
+ return '';
1497
+ return String.fromCharCode(value);
1498
+ },
1499
+ encodeUTF8: function (codepoint) {
1500
+ return encodeUTF8(codepoint);
1501
+ },
1502
+ },
1503
+ 'x-user-defined': {
1504
+ fixup: checkChars(/[^\x00-\x7f\uf780-\uf7ff]/),
1505
+ encodeByte: function (value) {
1506
+ if (value === null)
1507
+ return '';
1508
+ if (value >= 0x80)
1509
+ return String.fromCharCode(value | 0xf700);
1510
+ return String.fromCharCode(value);
1511
+ },
1512
+ encodeUTF8: function (codepoint) {
1513
+ return encodeUTF8(codepoint, 0xf700);
1514
+ }
1515
+ },
1516
+ 'none': {
1517
+ discardStrings: true,
1518
+ fixup: function (s) {
1519
+ return s;
1520
+ },
1521
+ encodeByte: function (value) {
1522
+ return '';
1523
+ },
1524
+ encodeUTF8: function (codepoint) {
1525
+ return '';
1526
+ }
1527
+ }
1528
+ };
1529
+
1530
+ var EOF = 1, StringLiteral = 2, Keyword = 4, Identifier = 8
1531
+ , NumericLiteral = 16, Punctuator = 32, BooleanLiteral = 64
1532
+ , NilLiteral = 128, VarargLiteral = 256;
1533
+
1534
+ exports.tokenTypes = { EOF: EOF, StringLiteral: StringLiteral
1535
+ , Keyword: Keyword, Identifier: Identifier, NumericLiteral: NumericLiteral
1536
+ , Punctuator: Punctuator, BooleanLiteral: BooleanLiteral
1537
+ , NilLiteral: NilLiteral, VarargLiteral: VarargLiteral
1538
+ };
1539
+
1540
+ var errors = exports.errors = {
1541
+ unexpected: 'unexpected %1 \'%2\' near \'%3\''
1542
+ , unexpectedEOF: 'unexpected symbol near \'<eof>\''
1543
+ , expected: '\'%1\' expected near \'%2\''
1544
+ , expectedToken: '%1 expected near \'%2\''
1545
+ , unfinishedString: 'unfinished string near \'%1\''
1546
+ , malformedNumber: 'malformed number near \'%1\''
1547
+ , decimalEscapeTooLarge: 'decimal escape too large near \'%1\''
1548
+ , invalidEscape: 'invalid escape sequence near \'%1\''
1549
+ , hexadecimalDigitExpected: 'hexadecimal digit expected near \'%1\''
1550
+ , braceExpected: 'missing \'%1\' near \'%2\''
1551
+ , tooLargeCodepoint: 'UTF-8 value too large near \'%1\''
1552
+ , unfinishedLongString: 'unfinished long string (starting at line %1) near \'%2\''
1553
+ , unfinishedLongComment: 'unfinished long comment (starting at line %1) near \'%2\''
1554
+ , ambiguousSyntax: 'ambiguous syntax (function call x new statement) near \'%1\''
1555
+ , noLoopToBreak: 'no loop to break near \'%1\''
1556
+ , labelAlreadyDefined: 'label \'%1\' already defined on line %2'
1557
+ , labelNotVisible: 'no visible label \'%1\' for <goto>'
1558
+ , gotoJumpInLocalScope: '<goto %1> jumps into the scope of local \'%2\''
1559
+ , cannotUseVararg: 'cannot use \'...\' outside a vararg function near \'%1\''
1560
+ , invalidCodeUnit: 'code unit U+%1 is not allowed in the current encoding mode'
1561
+ };
1562
+
1563
+ var ast = exports.ast = {
1564
+ labelStatement: function(label) {
1565
+ return {
1566
+ type: 'LabelStatement'
1567
+ , label: label
1568
+ };
1569
+ }
1570
+
1571
+ , breakStatement: function() {
1572
+ return {
1573
+ type: 'BreakStatement'
1574
+ };
1575
+ }
1576
+
1577
+ , gotoStatement: function(label) {
1578
+ return {
1579
+ type: 'GotoStatement'
1580
+ , label: label
1581
+ };
1582
+ }
1583
+
1584
+ , returnStatement: function(args) {
1585
+ return {
1586
+ type: 'ReturnStatement'
1587
+ , 'arguments': args
1588
+ };
1589
+ }
1590
+
1591
+ , ifStatement: function(clauses) {
1592
+ return {
1593
+ type: 'IfStatement'
1594
+ , clauses: clauses
1595
+ };
1596
+ }
1597
+ , ifClause: function(condition, body) {
1598
+ return {
1599
+ type: 'IfClause'
1600
+ , condition: condition
1601
+ , body: body
1602
+ };
1603
+ }
1604
+ , elseifClause: function(condition, body) {
1605
+ return {
1606
+ type: 'ElseifClause'
1607
+ , condition: condition
1608
+ , body: body
1609
+ };
1610
+ }
1611
+ , elseClause: function(body) {
1612
+ return {
1613
+ type: 'ElseClause'
1614
+ , body: body
1615
+ };
1616
+ }
1617
+
1618
+ , whileStatement: function(condition, body) {
1619
+ return {
1620
+ type: 'WhileStatement'
1621
+ , condition: condition
1622
+ , body: body
1623
+ };
1624
+ }
1625
+
1626
+ , doStatement: function(body) {
1627
+ return {
1628
+ type: 'DoStatement'
1629
+ , body: body
1630
+ };
1631
+ }
1632
+
1633
+ , repeatStatement: function(condition, body) {
1634
+ return {
1635
+ type: 'RepeatStatement'
1636
+ , condition: condition
1637
+ , body: body
1638
+ };
1639
+ }
1640
+
1641
+ , localStatement: function(variables, init) {
1642
+ return {
1643
+ type: 'LocalStatement'
1644
+ , variables: variables
1645
+ , init: init
1646
+ };
1647
+ }
1648
+
1649
+ , assignmentStatement: function(variables, init) {
1650
+ return {
1651
+ type: 'AssignmentStatement'
1652
+ , variables: variables
1653
+ , init: init
1654
+ };
1655
+ }
1656
+
1657
+ , callStatement: function(expression) {
1658
+ return {
1659
+ type: 'CallStatement'
1660
+ , expression: expression
1661
+ };
1662
+ }
1663
+
1664
+ , functionStatement: function(identifier, parameters, isLocal, body) {
1665
+ return {
1666
+ type: 'FunctionDeclaration'
1667
+ , identifier: identifier
1668
+ , isLocal: isLocal
1669
+ , parameters: parameters
1670
+ , body: body
1671
+ };
1672
+ }
1673
+
1674
+ , forNumericStatement: function(variable, start, end, step, body) {
1675
+ return {
1676
+ type: 'ForNumericStatement'
1677
+ , variable: variable
1678
+ , start: start
1679
+ , end: end
1680
+ , step: step
1681
+ , body: body
1682
+ };
1683
+ }
1684
+
1685
+ , forGenericStatement: function(variables, iterators, body) {
1686
+ return {
1687
+ type: 'ForGenericStatement'
1688
+ , variables: variables
1689
+ , iterators: iterators
1690
+ , body: body
1691
+ };
1692
+ }
1693
+
1694
+ , chunk: function(body) {
1695
+ return {
1696
+ type: 'Chunk'
1697
+ , body: body
1698
+ };
1699
+ }
1700
+
1701
+ , identifier: function(name) {
1702
+ return {
1703
+ type: 'Identifier'
1704
+ , name: name
1705
+ };
1706
+ }
1707
+
1708
+ , literal: function(type, value, raw) {
1709
+ type = (type === StringLiteral) ? 'StringLiteral'
1710
+ : (type === NumericLiteral) ? 'NumericLiteral'
1711
+ : (type === BooleanLiteral) ? 'BooleanLiteral'
1712
+ : (type === NilLiteral) ? 'NilLiteral'
1713
+ : 'VarargLiteral';
1714
+
1715
+ return {
1716
+ type: type
1717
+ , value: value
1718
+ , raw: raw
1719
+ };
1720
+ }
1721
+
1722
+ , tableKey: function(key, value) {
1723
+ return {
1724
+ type: 'TableKey'
1725
+ , key: key
1726
+ , value: value
1727
+ };
1728
+ }
1729
+ , tableKeyString: function(key, value) {
1730
+ return {
1731
+ type: 'TableKeyString'
1732
+ , key: key
1733
+ , value: value
1734
+ };
1735
+ }
1736
+ , tableValue: function(value) {
1737
+ return {
1738
+ type: 'TableValue'
1739
+ , value: value
1740
+ };
1741
+ }
1742
+
1743
+
1744
+ , tableConstructorExpression: function(fields) {
1745
+ return {
1746
+ type: 'TableConstructorExpression'
1747
+ , fields: fields
1748
+ };
1749
+ }
1750
+ , binaryExpression: function(operator, left, right) {
1751
+ var type = ('and' === operator || 'or' === operator) ?
1752
+ 'LogicalExpression' :
1753
+ 'BinaryExpression';
1754
+
1755
+ return {
1756
+ type: type
1757
+ , operator: operator
1758
+ , left: left
1759
+ , right: right
1760
+ };
1761
+ }
1762
+ , unaryExpression: function(operator, argument) {
1763
+ return {
1764
+ type: 'UnaryExpression'
1765
+ , operator: operator
1766
+ , argument: argument
1767
+ };
1768
+ }
1769
+ , memberExpression: function(base, indexer, identifier) {
1770
+ return {
1771
+ type: 'MemberExpression'
1772
+ , indexer: indexer
1773
+ , identifier: identifier
1774
+ , base: base
1775
+ };
1776
+ }
1777
+
1778
+ , indexExpression: function(base, index) {
1779
+ return {
1780
+ type: 'IndexExpression'
1781
+ , base: base
1782
+ , index: index
1783
+ };
1784
+ }
1785
+
1786
+ , callExpression: function(base, args) {
1787
+ return {
1788
+ type: 'CallExpression'
1789
+ , base: base
1790
+ , 'arguments': args
1791
+ };
1792
+ }
1793
+
1794
+ , tableCallExpression: function(base, args) {
1795
+ return {
1796
+ type: 'TableCallExpression'
1797
+ , base: base
1798
+ , 'arguments': args
1799
+ };
1800
+ }
1801
+
1802
+ , stringCallExpression: function(base, argument) {
1803
+ return {
1804
+ type: 'StringCallExpression'
1805
+ , base: base
1806
+ , argument: argument
1807
+ };
1808
+ }
1809
+
1810
+ , comment: function(value, raw) {
1811
+ return {
1812
+ type: 'Comment'
1813
+ , value: value
1814
+ , raw: raw
1815
+ };
1816
+ }
1817
+ };
1818
+
1819
+ function finishNode(node) {
1820
+ if (trackLocations) {
1821
+ var location = locations.pop();
1822
+ location.complete();
1823
+ location.bless(node);
1824
+ }
1825
+ if (options.onCreateNode) options.onCreateNode(node);
1826
+ return node;
1827
+ }
1828
+
1829
+ var slice = Array.prototype.slice
1830
+ , toString = Object.prototype.toString
1831
+ ;
1832
+
1833
+ var indexOf = /* istanbul ignore next */ function (array, element) {
1834
+ for (var i = 0, length = array.length; i < length; ++i) {
1835
+ if (array[i] === element) return i;
1836
+ }
1837
+ return -1;
1838
+ };
1839
+ if (Array.prototype.indexOf)
1840
+ indexOf = function (array, element) {
1841
+ return array.indexOf(element);
1842
+ };
1843
+
1844
+ function indexOfObject(array, property, element) {
1845
+ for (var i = 0, length = array.length; i < length; ++i) {
1846
+ if (array[i][property] === element) return i;
1847
+ }
1848
+ return -1;
1849
+ }
1850
+
1851
+ function sprintf(format) {
1852
+ var args = slice.call(arguments, 1);
1853
+ format = format.replace(/%(\d)/g, function (match, index) {
1854
+ return '' + args[index - 1] || /* istanbul ignore next */ '';
1855
+ });
1856
+ return format;
1857
+ }
1858
+
1859
+ var assign = /* istanbul ignore next */ function (dest) {
1860
+ var args = slice.call(arguments, 1)
1861
+ , src, prop;
1862
+
1863
+ for (var i = 0, length = args.length; i < length; ++i) {
1864
+ src = args[i];
1865
+ for (prop in src)
1866
+ if (Object.prototype.hasOwnProperty.call(src, prop)) {
1867
+ dest[prop] = src[prop];
1868
+ }
1869
+ }
1870
+
1871
+ return dest;
1872
+ };
1873
+ if (Object.assign)
1874
+ assign = Object.assign;
1875
+
1876
+ exports.SyntaxError = SyntaxError;
1877
+
1878
+ function fixupError(e) {
1879
+ if (!Object.create)
1880
+ return e;
1881
+ return Object.create(e, {
1882
+ 'line': { 'writable': true, value: e.line },
1883
+ 'index': { 'writable': true, value: e.index },
1884
+ 'column': { 'writable': true, value: e.column }
1885
+ });
1886
+ }
1887
+
1888
+ function raise(token) {
1889
+ var message = sprintf.apply(null, slice.call(arguments, 1))
1890
+ , error, col;
1891
+
1892
+ if (token === null || typeof token.line === 'undefined') {
1893
+ col = index - lineStart + 1;
1894
+ error = fixupError(new SyntaxError(sprintf('[%1:%2] %3', line, col, message)));
1895
+ error.index = index;
1896
+ error.line = line;
1897
+ error.column = col;
1898
+ } else {
1899
+ col = token.range[0] - token.lineStart;
1900
+ error = fixupError(new SyntaxError(sprintf('[%1:%2] %3', token.line, col, message)));
1901
+ error.line = token.line;
1902
+ error.index = token.range[0];
1903
+ error.column = col;
1904
+ }
1905
+ throw error;
1906
+ }
1907
+
1908
+ function tokenValue(token) {
1909
+ var raw = input.slice(token.range[0], token.range[1]);
1910
+ if (raw)
1911
+ return raw;
1912
+ return token.value;
1913
+ }
1914
+
1915
+ function raiseUnexpectedToken(type, token) {
1916
+ raise(token, errors.expectedToken, type, tokenValue(token));
1917
+ }
1918
+
1919
+ function unexpected(found) {
1920
+ var near = tokenValue(lookahead);
1921
+ if ('undefined' !== typeof found.type) {
1922
+ var type;
1923
+ switch (found.type) {
1924
+ case StringLiteral: type = 'string'; break;
1925
+ case Keyword: type = 'keyword'; break;
1926
+ case Identifier: type = 'identifier'; break;
1927
+ case NumericLiteral: type = 'number'; break;
1928
+ case Punctuator: type = 'symbol'; break;
1929
+ case BooleanLiteral: type = 'boolean'; break;
1930
+ case NilLiteral:
1931
+ return raise(found, errors.unexpected, 'symbol', 'nil', near);
1932
+ case EOF:
1933
+ return raise(found, errors.unexpectedEOF);
1934
+ }
1935
+ return raise(found, errors.unexpected, type, tokenValue(found), near);
1936
+ }
1937
+ return raise(found, errors.unexpected, 'symbol', found, near);
1938
+ }
1939
+
1940
+ var index
1941
+ , token
1942
+ , previousToken
1943
+ , lookahead
1944
+ , comments
1945
+ , tokenStart
1946
+ , line
1947
+ , lineStart;
1948
+
1949
+ exports.lex = lex;
1950
+
1951
+ function lex() {
1952
+ skipWhiteSpace();
1953
+ while (45 === input.charCodeAt(index) &&
1954
+ 45 === input.charCodeAt(index + 1)) {
1955
+ scanComment();
1956
+ skipWhiteSpace();
1957
+ }
1958
+ if (index >= length) return {
1959
+ type : EOF
1960
+ , value: '<eof>'
1961
+ , line: line
1962
+ , lineStart: lineStart
1963
+ , range: [index, index]
1964
+ };
1965
+
1966
+ var charCode = input.charCodeAt(index)
1967
+ , next = input.charCodeAt(index + 1);
1968
+ tokenStart = index;
1969
+ if (isIdentifierStart(charCode)) return scanIdentifierOrKeyword();
1970
+
1971
+ switch (charCode) {
1972
+ case 39: case 34: // '"
1973
+ return scanStringLiteral();
1974
+
1975
+ case 48: case 49: case 50: case 51: case 52: case 53:
1976
+ case 54: case 55: case 56: case 57: // 0-9
1977
+ return scanNumericLiteral();
1978
+
1979
+ case 46: // .
1980
+ if (isDecDigit(next)) return scanNumericLiteral();
1981
+ if (46 === next) {
1982
+ if (46 === input.charCodeAt(index + 2)) return scanVarargLiteral();
1983
+ return scanPunctuator('..');
1984
+ }
1985
+ return scanPunctuator('.');
1986
+
1987
+ case 61: // =
1988
+ if (61 === next) return scanPunctuator('==');
1989
+ return scanPunctuator('=');
1990
+
1991
+ case 62: // >
1992
+ if (features.bitwiseOperators)
1993
+ if (62 === next) return scanPunctuator('>>');
1994
+ if (61 === next) return scanPunctuator('>=');
1995
+ return scanPunctuator('>');
1996
+
1997
+ case 60: // <
1998
+ if (features.bitwiseOperators)
1999
+ if (60 === next) return scanPunctuator('<<');
2000
+ if (61 === next) return scanPunctuator('<=');
2001
+ return scanPunctuator('<');
2002
+
2003
+ case 126: // ~
2004
+ if (61 === next) return scanPunctuator('~=');
2005
+ if (!features.bitwiseOperators)
2006
+ break;
2007
+ return scanPunctuator('~');
2008
+
2009
+ case 58: // :
2010
+ if (features.labels)
2011
+ if (58 === next) return scanPunctuator('::');
2012
+ return scanPunctuator(':');
2013
+
2014
+ case 91: // [
2015
+ if (91 === next || 61 === next) return scanLongStringLiteral();
2016
+ return scanPunctuator('[');
2017
+
2018
+ case 47: // /
2019
+ if (features.integerDivision)
2020
+ if (47 === next) return scanPunctuator('//');
2021
+ return scanPunctuator('/');
2022
+
2023
+ case 38: case 124: // & |
2024
+ if (!features.bitwiseOperators)
2025
+ break;
2026
+ case 42: case 94: case 37: case 44: case 123: case 125:
2027
+ case 93: case 40: case 41: case 59: case 35: case 45:
2028
+ case 43: // * ^ % , { } ] ( ) ; # - +
2029
+ return scanPunctuator(input.charAt(index));
2030
+ }
2031
+
2032
+ return unexpected(input.charAt(index));
2033
+ }
2034
+
2035
+ function consumeEOL() {
2036
+ var charCode = input.charCodeAt(index)
2037
+ , peekCharCode = input.charCodeAt(index + 1);
2038
+
2039
+ if (isLineTerminator(charCode)) {
2040
+ if (10 === charCode && 13 === peekCharCode) ++index;
2041
+ if (13 === charCode && 10 === peekCharCode) ++index;
2042
+ ++line;
2043
+ lineStart = ++index;
2044
+
2045
+ return true;
2046
+ }
2047
+ return false;
2048
+ }
2049
+
2050
+ function skipWhiteSpace() {
2051
+ while (index < length) {
2052
+ var charCode = input.charCodeAt(index);
2053
+ if (isWhiteSpace(charCode)) {
2054
+ ++index;
2055
+ } else if (!consumeEOL()) {
2056
+ break;
2057
+ }
2058
+ }
2059
+ }
2060
+
2061
+ function scanIdentifierOrKeyword() {
2062
+ var value, type;
2063
+ while (isIdentifierPart(input.charCodeAt(++index)));
2064
+ value = encodingMode.fixup(input.slice(tokenStart, index));
2065
+ if (isKeyword(value)) {
2066
+ type = Keyword;
2067
+ } else if ('true' === value || 'false' === value) {
2068
+ type = BooleanLiteral;
2069
+ value = ('true' === value);
2070
+ } else if ('nil' === value) {
2071
+ type = NilLiteral;
2072
+ value = null;
2073
+ } else {
2074
+ type = Identifier;
2075
+ }
2076
+
2077
+ return {
2078
+ type: type
2079
+ , value: value
2080
+ , line: line
2081
+ , lineStart: lineStart
2082
+ , range: [tokenStart, index]
2083
+ };
2084
+ }
2085
+
2086
+ function scanPunctuator(value) {
2087
+ index += value.length;
2088
+ return {
2089
+ type: Punctuator
2090
+ , value: value
2091
+ , line: line
2092
+ , lineStart: lineStart
2093
+ , range: [tokenStart, index]
2094
+ };
2095
+ }
2096
+
2097
+ function scanVarargLiteral() {
2098
+ index += 3;
2099
+ return {
2100
+ type: VarargLiteral
2101
+ , value: '...'
2102
+ , line: line
2103
+ , lineStart: lineStart
2104
+ , range: [tokenStart, index]
2105
+ };
2106
+ }
2107
+
2108
+ function scanStringLiteral() {
2109
+ var delimiter = input.charCodeAt(index++)
2110
+ , beginLine = line
2111
+ , beginLineStart = lineStart
2112
+ , stringStart = index
2113
+ , string = encodingMode.discardStrings ? null : ''
2114
+ , charCode;
2115
+
2116
+ for (;;) {
2117
+ charCode = input.charCodeAt(index++);
2118
+ if (delimiter === charCode) break;
2119
+ if (index > length || isLineTerminator(charCode)) {
2120
+ string += input.slice(stringStart, index - 1);
2121
+ raise(null, errors.unfinishedString, input.slice(tokenStart, index - 1));
2122
+ }
2123
+ if (92 === charCode) { // backslash
2124
+ if (!encodingMode.discardStrings) {
2125
+ var beforeEscape = input.slice(stringStart, index - 1);
2126
+ string += encodingMode.fixup(beforeEscape);
2127
+ }
2128
+ var escapeValue = readEscapeSequence();
2129
+ if (!encodingMode.discardStrings)
2130
+ string += escapeValue;
2131
+ stringStart = index;
2132
+ }
2133
+ }
2134
+ if (!encodingMode.discardStrings) {
2135
+ string += encodingMode.encodeByte(null);
2136
+ string += encodingMode.fixup(input.slice(stringStart, index - 1));
2137
+ }
2138
+
2139
+ return {
2140
+ type: StringLiteral
2141
+ , value: string
2142
+ , line: beginLine
2143
+ , lineStart: beginLineStart
2144
+ , lastLine: line
2145
+ , lastLineStart: lineStart
2146
+ , range: [tokenStart, index]
2147
+ };
2148
+ }
2149
+
2150
+ function scanLongStringLiteral() {
2151
+ var beginLine = line
2152
+ , beginLineStart = lineStart
2153
+ , string = readLongString(false);
2154
+ if (false === string) raise(token, errors.expected, '[', tokenValue(token));
2155
+
2156
+ return {
2157
+ type: StringLiteral
2158
+ , value: encodingMode.discardStrings ? null : encodingMode.fixup(string)
2159
+ , line: beginLine
2160
+ , lineStart: beginLineStart
2161
+ , lastLine: line
2162
+ , lastLineStart: lineStart
2163
+ , range: [tokenStart, index]
2164
+ };
2165
+ }
2166
+
2167
+ function scanNumericLiteral() {
2168
+ var character = input.charAt(index)
2169
+ , next = input.charAt(index + 1);
2170
+
2171
+ var literal = ('0' === character && 'xX'.indexOf(next || null) >= 0) ?
2172
+ readHexLiteral() : readDecLiteral();
2173
+
2174
+ var foundImaginaryUnit = readImaginaryUnitSuffix()
2175
+ , foundInt64Suffix = readInt64Suffix();
2176
+
2177
+ if (foundInt64Suffix && (foundImaginaryUnit || literal.hasFractionPart)) {
2178
+ raise(null, errors.malformedNumber, input.slice(tokenStart, index));
2179
+ }
2180
+
2181
+ return {
2182
+ type: NumericLiteral
2183
+ , value: literal.value
2184
+ , line: line
2185
+ , lineStart: lineStart
2186
+ , range: [tokenStart, index]
2187
+ };
2188
+ }
2189
+
2190
+ function readImaginaryUnitSuffix() {
2191
+ if (!features.imaginaryNumbers) return;
2192
+ if ('iI'.indexOf(input.charAt(index) || null) >= 0) {
2193
+ ++index;
2194
+ return true;
2195
+ } else {
2196
+ return false;
2197
+ }
2198
+ }
2199
+
2200
+ function readInt64Suffix() {
2201
+ if (!features.integerSuffixes) return;
2202
+
2203
+ if ('uU'.indexOf(input.charAt(index) || null) >= 0) {
2204
+ ++index;
2205
+ if ('lL'.indexOf(input.charAt(index) || null) >= 0) {
2206
+ ++index;
2207
+ if ('lL'.indexOf(input.charAt(index) || null) >= 0) {
2208
+ ++index;
2209
+ return 'ULL';
2210
+ } else {
2211
+ raise(null, errors.malformedNumber, input.slice(tokenStart, index));
2212
+ }
2213
+ } else {
2214
+ raise(null, errors.malformedNumber, input.slice(tokenStart, index));
2215
+ }
2216
+ } else if ('lL'.indexOf(input.charAt(index) || null) >= 0) {
2217
+ ++index;
2218
+ if ('lL'.indexOf(input.charAt(index) || null) >= 0) {
2219
+ ++index;
2220
+ return 'LL';
2221
+ } else {
2222
+ raise(null, errors.malformedNumber, input.slice(tokenStart, index));
2223
+ }
2224
+ }
2225
+ }
2226
+
2227
+ function readHexLiteral() {
2228
+ var fraction = 0 // defaults to 0 as it gets summed
2229
+ , binaryExponent = 1 // defaults to 1 as it gets multiplied
2230
+ , binarySign = 1 // positive
2231
+ , digit, fractionStart, exponentStart, digitStart;
2232
+
2233
+ digitStart = index += 2; // Skip 0x part
2234
+ if (!isHexDigit(input.charCodeAt(index)))
2235
+ raise(null, errors.malformedNumber, input.slice(tokenStart, index));
2236
+
2237
+ while (isHexDigit(input.charCodeAt(index))) ++index;
2238
+ digit = parseInt(input.slice(digitStart, index), 16);
2239
+ var foundFraction = false;
2240
+ if ('.' === input.charAt(index)) {
2241
+ foundFraction = true;
2242
+ fractionStart = ++index;
2243
+
2244
+ while (isHexDigit(input.charCodeAt(index))) ++index;
2245
+ fraction = input.slice(fractionStart, index);
2246
+ fraction = (fractionStart === index) ? 0
2247
+ : parseInt(fraction, 16) / Math.pow(16, index - fractionStart);
2248
+ }
2249
+ var foundBinaryExponent = false;
2250
+ if ('pP'.indexOf(input.charAt(index) || null) >= 0) {
2251
+ foundBinaryExponent = true;
2252
+ ++index;
2253
+ if ('+-'.indexOf(input.charAt(index) || null) >= 0)
2254
+ binarySign = ('+' === input.charAt(index++)) ? 1 : -1;
2255
+
2256
+ exponentStart = index;
2257
+ if (!isDecDigit(input.charCodeAt(index)))
2258
+ raise(null, errors.malformedNumber, input.slice(tokenStart, index));
2259
+
2260
+ while (isDecDigit(input.charCodeAt(index))) ++index;
2261
+ binaryExponent = input.slice(exponentStart, index);
2262
+ binaryExponent = Math.pow(2, binaryExponent * binarySign);
2263
+ }
2264
+
2265
+ return {
2266
+ value: (digit + fraction) * binaryExponent,
2267
+ hasFractionPart: foundFraction || foundBinaryExponent
2268
+ };
2269
+ }
2270
+
2271
+ function readDecLiteral() {
2272
+ while (isDecDigit(input.charCodeAt(index))) ++index;
2273
+ var foundFraction = false;
2274
+ if ('.' === input.charAt(index)) {
2275
+ foundFraction = true;
2276
+ ++index;
2277
+ while (isDecDigit(input.charCodeAt(index))) ++index;
2278
+ }
2279
+ var foundExponent = false;
2280
+ if ('eE'.indexOf(input.charAt(index) || null) >= 0) {
2281
+ foundExponent = true;
2282
+ ++index;
2283
+ if ('+-'.indexOf(input.charAt(index) || null) >= 0) ++index;
2284
+ if (!isDecDigit(input.charCodeAt(index)))
2285
+ raise(null, errors.malformedNumber, input.slice(tokenStart, index));
2286
+
2287
+ while (isDecDigit(input.charCodeAt(index))) ++index;
2288
+ }
2289
+
2290
+ return {
2291
+ value: parseFloat(input.slice(tokenStart, index)),
2292
+ hasFractionPart: foundFraction || foundExponent
2293
+ };
2294
+ }
2295
+
2296
+ function readUnicodeEscapeSequence() {
2297
+ var sequenceStart = index++;
2298
+
2299
+ if (input.charAt(index++) !== '{')
2300
+ raise(null, errors.braceExpected, '{', '\\' + input.slice(sequenceStart, index));
2301
+ if (!isHexDigit(input.charCodeAt(index)))
2302
+ raise(null, errors.hexadecimalDigitExpected, '\\' + input.slice(sequenceStart, index));
2303
+
2304
+ while (input.charCodeAt(index) === 0x30) ++index;
2305
+ var escStart = index;
2306
+
2307
+ while (isHexDigit(input.charCodeAt(index))) {
2308
+ ++index;
2309
+ if (index - escStart > 6)
2310
+ raise(null, errors.tooLargeCodepoint, '\\' + input.slice(sequenceStart, index));
2311
+ }
2312
+
2313
+ var b = input.charAt(index++);
2314
+ if (b !== '}') {
2315
+ if ((b === '"') || (b === "'"))
2316
+ raise(null, errors.braceExpected, '}', '\\' + input.slice(sequenceStart, index--));
2317
+ else
2318
+ raise(null, errors.hexadecimalDigitExpected, '\\' + input.slice(sequenceStart, index));
2319
+ }
2320
+
2321
+ var codepoint = parseInt(input.slice(escStart, index - 1) || '0', 16);
2322
+ var frag = '\\' + input.slice(sequenceStart, index);
2323
+
2324
+ if (codepoint > 0x10ffff) {
2325
+ raise(null, errors.tooLargeCodepoint, frag);
2326
+ }
2327
+
2328
+ return encodingMode.encodeUTF8(codepoint, frag);
2329
+ }
2330
+ function readEscapeSequence() {
2331
+ var sequenceStart = index;
2332
+ switch (input.charAt(index)) {
2333
+ case 'a': ++index; return '\x07';
2334
+ case 'n': ++index; return '\n';
2335
+ case 'r': ++index; return '\r';
2336
+ case 't': ++index; return '\t';
2337
+ case 'v': ++index; return '\x0b';
2338
+ case 'b': ++index; return '\b';
2339
+ case 'f': ++index; return '\f';
2340
+ case '\r':
2341
+ case '\n':
2342
+ consumeEOL();
2343
+ return '\n';
2344
+
2345
+ case '0': case '1': case '2': case '3': case '4':
2346
+ case '5': case '6': case '7': case '8': case '9':
2347
+ while (isDecDigit(input.charCodeAt(index)) && index - sequenceStart < 3) ++index;
2348
+
2349
+ var frag = input.slice(sequenceStart, index);
2350
+ var ddd = parseInt(frag, 10);
2351
+ if (ddd > 255) {
2352
+ raise(null, errors.decimalEscapeTooLarge, '\\' + ddd);
2353
+ }
2354
+ return encodingMode.encodeByte(ddd, '\\' + frag);
2355
+
2356
+ case 'z':
2357
+ if (features.skipWhitespaceEscape) {
2358
+ ++index;
2359
+ skipWhiteSpace();
2360
+ return '';
2361
+ }
2362
+ break;
2363
+
2364
+ case 'x':
2365
+ if (features.hexEscapes) {
2366
+ if (isHexDigit(input.charCodeAt(index + 1)) &&
2367
+ isHexDigit(input.charCodeAt(index + 2))) {
2368
+ index += 3;
2369
+ return encodingMode.encodeByte(parseInt(input.slice(sequenceStart + 1, index), 16), '\\' + input.slice(sequenceStart, index));
2370
+ }
2371
+ raise(null, errors.hexadecimalDigitExpected, '\\' + input.slice(sequenceStart, index + 2));
2372
+ }
2373
+ break;
2374
+
2375
+ case 'u':
2376
+ if (features.unicodeEscapes)
2377
+ return readUnicodeEscapeSequence();
2378
+ break;
2379
+
2380
+ case '\\': case '"': case "'":
2381
+ return input.charAt(index++);
2382
+ }
2383
+
2384
+ if (features.strictEscapes)
2385
+ raise(null, errors.invalidEscape, '\\' + input.slice(sequenceStart, index + 1));
2386
+ return input.charAt(index++);
2387
+ }
2388
+
2389
+ function scanComment() {
2390
+ tokenStart = index;
2391
+ index += 2; // --
2392
+
2393
+ var character = input.charAt(index)
2394
+ , content = ''
2395
+ , isLong = false
2396
+ , commentStart = index
2397
+ , lineStartComment = lineStart
2398
+ , lineComment = line;
2399
+
2400
+ if ('[' === character) {
2401
+ content = readLongString(true);
2402
+ if (false === content) content = character;
2403
+ else isLong = true;
2404
+ }
2405
+ if (!isLong) {
2406
+ while (index < length) {
2407
+ if (isLineTerminator(input.charCodeAt(index))) break;
2408
+ ++index;
2409
+ }
2410
+ if (options.comments) content = input.slice(commentStart, index);
2411
+ }
2412
+
2413
+ if (options.comments) {
2414
+ var node = ast.comment(content, input.slice(tokenStart, index));
2415
+ if (options.locations) {
2416
+ node.loc = {
2417
+ start: { line: lineComment, column: tokenStart - lineStartComment }
2418
+ , end: { line: line, column: index - lineStart }
2419
+ };
2420
+ }
2421
+ if (options.ranges) {
2422
+ node.range = [tokenStart, index];
2423
+ }
2424
+ if (options.onCreateNode) options.onCreateNode(node);
2425
+ comments.push(node);
2426
+ }
2427
+ }
2428
+
2429
+ function readLongString(isComment) {
2430
+ var level = 0
2431
+ , content = ''
2432
+ , terminator = false
2433
+ , character, stringStart, firstLine = line;
2434
+
2435
+ ++index; // [
2436
+ while ('=' === input.charAt(index + level)) ++level;
2437
+ if ('[' !== input.charAt(index + level)) return false;
2438
+
2439
+ index += level + 1;
2440
+ if (isLineTerminator(input.charCodeAt(index))) consumeEOL();
2441
+
2442
+ stringStart = index;
2443
+ while (index < length) {
2444
+ while (isLineTerminator(input.charCodeAt(index))) consumeEOL();
2445
+
2446
+ character = input.charAt(index++);
2447
+ if (']' === character) {
2448
+ terminator = true;
2449
+ for (var i = 0; i < level; ++i) {
2450
+ if ('=' !== input.charAt(index + i)) terminator = false;
2451
+ }
2452
+ if (']' !== input.charAt(index + level)) terminator = false;
2453
+ }
2454
+ if (terminator) {
2455
+ content += input.slice(stringStart, index - 1);
2456
+ index += level + 1;
2457
+ return content;
2458
+ }
2459
+ }
2460
+
2461
+ raise(null, isComment ?
2462
+ errors.unfinishedLongComment :
2463
+ errors.unfinishedLongString,
2464
+ firstLine, '<eof>');
2465
+ }
2466
+
2467
+ function next() {
2468
+ previousToken = token;
2469
+ token = lookahead;
2470
+ lookahead = lex();
2471
+ }
2472
+
2473
+ function consume(value) {
2474
+ if (value === token.value) {
2475
+ next();
2476
+ return true;
2477
+ }
2478
+ return false;
2479
+ }
2480
+
2481
+ function expect(value) {
2482
+ if (value === token.value) next();
2483
+ else raise(token, errors.expected, value, tokenValue(token));
2484
+ }
2485
+
2486
+ function isWhiteSpace(charCode) {
2487
+ return 9 === charCode || 32 === charCode || 0xB === charCode || 0xC === charCode;
2488
+ }
2489
+
2490
+ function isLineTerminator(charCode) {
2491
+ return 10 === charCode || 13 === charCode;
2492
+ }
2493
+
2494
+ function isDecDigit(charCode) {
2495
+ return charCode >= 48 && charCode <= 57;
2496
+ }
2497
+
2498
+ function isHexDigit(charCode) {
2499
+ return (charCode >= 48 && charCode <= 57) || (charCode >= 97 && charCode <= 102) || (charCode >= 65 && charCode <= 70);
2500
+ }
2501
+
2502
+ function isIdentifierStart(charCode) {
2503
+ if ((charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) || 95 === charCode)
2504
+ return true;
2505
+ if (features.extendedIdentifiers && charCode >= 128)
2506
+ return true;
2507
+ return false;
2508
+ }
2509
+
2510
+ function isIdentifierPart(charCode) {
2511
+ if ((charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) || 95 === charCode || (charCode >= 48 && charCode <= 57))
2512
+ return true;
2513
+ if (features.extendedIdentifiers && charCode >= 128)
2514
+ return true;
2515
+ return false;
2516
+ }
2517
+
2518
+ function isKeyword(id) {
2519
+ switch (id.length) {
2520
+ case 2:
2521
+ return 'do' === id || 'if' === id || 'in' === id || 'or' === id;
2522
+ case 3:
2523
+ return 'and' === id || 'end' === id || 'for' === id || 'not' === id;
2524
+ case 4:
2525
+ if ('else' === id || 'then' === id)
2526
+ return true;
2527
+ if (features.labels && !features.contextualGoto)
2528
+ return ('goto' === id);
2529
+ return false;
2530
+ case 5:
2531
+ return 'break' === id || 'local' === id || 'until' === id || 'while' === id;
2532
+ case 6:
2533
+ return 'elseif' === id || 'repeat' === id || 'return' === id;
2534
+ case 8:
2535
+ return 'function' === id;
2536
+ }
2537
+ return false;
2538
+ }
2539
+
2540
+ function isUnary(token) {
2541
+ if (Punctuator === token.type) return '#-~'.indexOf(token.value) >= 0;
2542
+ if (Keyword === token.type) return 'not' === token.value;
2543
+ return false;
2544
+ }
2545
+
2546
+ function isBlockFollow(token) {
2547
+ if (EOF === token.type) return true;
2548
+ if (Keyword !== token.type) return false;
2549
+ switch (token.value) {
2550
+ case 'else': case 'elseif':
2551
+ case 'end': case 'until':
2552
+ return true;
2553
+ default:
2554
+ return false;
2555
+ }
2556
+ }
2557
+ var scopes
2558
+ , scopeDepth
2559
+ , globals;
2560
+ function createScope() {
2561
+ var scope = scopes[scopeDepth++].slice();
2562
+ scopes.push(scope);
2563
+ if (options.onCreateScope) options.onCreateScope();
2564
+ }
2565
+ function destroyScope() {
2566
+ var scope = scopes.pop();
2567
+ --scopeDepth;
2568
+ if (options.onDestroyScope) options.onDestroyScope();
2569
+ }
2570
+ function scopeIdentifierName(name) {
2571
+ if (options.onLocalDeclaration) options.onLocalDeclaration(name);
2572
+ if (-1 !== indexOf(scopes[scopeDepth], name)) return;
2573
+ scopes[scopeDepth].push(name);
2574
+ }
2575
+ function scopeIdentifier(node) {
2576
+ scopeIdentifierName(node.name);
2577
+ attachScope(node, true);
2578
+ }
2579
+ function attachScope(node, isLocal) {
2580
+ if (!isLocal && -1 === indexOfObject(globals, 'name', node.name))
2581
+ globals.push(node);
2582
+
2583
+ node.isLocal = isLocal;
2584
+ }
2585
+ function scopeHasName(name) {
2586
+ return (-1 !== indexOf(scopes[scopeDepth], name));
2587
+ }
2588
+
2589
+ var locations = []
2590
+ , trackLocations;
2591
+
2592
+ function createLocationMarker() {
2593
+ return new Marker(token);
2594
+ }
2595
+
2596
+ function Marker(token) {
2597
+ if (options.locations) {
2598
+ this.loc = {
2599
+ start: {
2600
+ line: token.line
2601
+ , column: token.range[0] - token.lineStart
2602
+ }
2603
+ , end: {
2604
+ line: 0
2605
+ , column: 0
2606
+ }
2607
+ };
2608
+ }
2609
+ if (options.ranges) this.range = [token.range[0], 0];
2610
+ }
2611
+ Marker.prototype.complete = function() {
2612
+ if (options.locations) {
2613
+ this.loc.end.line = previousToken.lastLine || previousToken.line;
2614
+ this.loc.end.column = previousToken.range[1] - (previousToken.lastLineStart || previousToken.lineStart);
2615
+ }
2616
+ if (options.ranges) {
2617
+ this.range[1] = previousToken.range[1];
2618
+ }
2619
+ };
2620
+
2621
+ Marker.prototype.bless = function (node) {
2622
+ if (this.loc) {
2623
+ var loc = this.loc;
2624
+ node.loc = {
2625
+ start: {
2626
+ line: loc.start.line,
2627
+ column: loc.start.column
2628
+ },
2629
+ end: {
2630
+ line: loc.end.line,
2631
+ column: loc.end.column
2632
+ }
2633
+ };
2634
+ }
2635
+ if (this.range) {
2636
+ node.range = [
2637
+ this.range[0],
2638
+ this.range[1]
2639
+ ];
2640
+ }
2641
+ };
2642
+ function markLocation() {
2643
+ if (trackLocations) locations.push(createLocationMarker());
2644
+ }
2645
+ function pushLocation(marker) {
2646
+ if (trackLocations) locations.push(marker);
2647
+ }
2648
+
2649
+ function FullFlowContext() {
2650
+ this.scopes = [];
2651
+ this.pendingGotos = [];
2652
+ }
2653
+
2654
+ FullFlowContext.prototype.isInLoop = function () {
2655
+ var i = this.scopes.length;
2656
+ while (i --> 0) {
2657
+ if (this.scopes[i].isLoop)
2658
+ return true;
2659
+ }
2660
+ return false;
2661
+ };
2662
+
2663
+ FullFlowContext.prototype.pushScope = function (isLoop) {
2664
+ var scope = {
2665
+ labels: {},
2666
+ locals: [],
2667
+ deferredGotos: [],
2668
+ isLoop: !!isLoop
2669
+ };
2670
+ this.scopes.push(scope);
2671
+ };
2672
+
2673
+ FullFlowContext.prototype.popScope = function () {
2674
+ for (var i = 0; i < this.pendingGotos.length; ++i) {
2675
+ var theGoto = this.pendingGotos[i];
2676
+ if (theGoto.maxDepth >= this.scopes.length)
2677
+ if (--theGoto.maxDepth <= 0)
2678
+ raise(theGoto.token, errors.labelNotVisible, theGoto.target);
2679
+ }
2680
+
2681
+ this.scopes.pop();
2682
+ };
2683
+
2684
+ FullFlowContext.prototype.addGoto = function (target, token) {
2685
+ var localCounts = [];
2686
+
2687
+ for (var i = 0; i < this.scopes.length; ++i) {
2688
+ var scope = this.scopes[i];
2689
+ localCounts.push(scope.locals.length);
2690
+ if (Object.prototype.hasOwnProperty.call(scope.labels, target))
2691
+ return;
2692
+ }
2693
+
2694
+ this.pendingGotos.push({
2695
+ maxDepth: this.scopes.length,
2696
+ target: target,
2697
+ token: token,
2698
+ localCounts: localCounts
2699
+ });
2700
+ };
2701
+
2702
+ FullFlowContext.prototype.addLabel = function (name, token) {
2703
+ var scope = this.currentScope();
2704
+
2705
+ if (Object.prototype.hasOwnProperty.call(scope.labels, name)) {
2706
+ raise(token, errors.labelAlreadyDefined, name, scope.labels[name].line);
2707
+ } else {
2708
+ var newGotos = [];
2709
+
2710
+ for (var i = 0; i < this.pendingGotos.length; ++i) {
2711
+ var theGoto = this.pendingGotos[i];
2712
+
2713
+ if (theGoto.maxDepth >= this.scopes.length && theGoto.target === name) {
2714
+ if (theGoto.localCounts[this.scopes.length - 1] < scope.locals.length) {
2715
+ scope.deferredGotos.push(theGoto);
2716
+ }
2717
+ continue;
2718
+ }
2719
+
2720
+ newGotos.push(theGoto);
2721
+ }
2722
+
2723
+ this.pendingGotos = newGotos;
2724
+ }
2725
+
2726
+ scope.labels[name] = {
2727
+ localCount: scope.locals.length,
2728
+ line: token.line
2729
+ };
2730
+ };
2731
+
2732
+ FullFlowContext.prototype.addLocal = function (name, token) {
2733
+ this.currentScope().locals.push({
2734
+ name: name,
2735
+ token: token
2736
+ });
2737
+ };
2738
+
2739
+ FullFlowContext.prototype.currentScope = function () {
2740
+ return this.scopes[this.scopes.length - 1];
2741
+ };
2742
+
2743
+ FullFlowContext.prototype.raiseDeferredErrors = function () {
2744
+ var scope = this.currentScope();
2745
+ var bads = scope.deferredGotos;
2746
+ for (var i = 0; i < bads.length; ++i) {
2747
+ var theGoto = bads[i];
2748
+ raise(theGoto.token, errors.gotoJumpInLocalScope, theGoto.target, scope.locals[theGoto.localCounts[this.scopes.length - 1]].name);
2749
+ }
2750
+ };
2751
+
2752
+ function LoopFlowContext() {
2753
+ this.level = 0;
2754
+ this.loopLevels = [];
2755
+ }
2756
+
2757
+ LoopFlowContext.prototype.isInLoop = function () {
2758
+ return !!this.loopLevels.length;
2759
+ };
2760
+
2761
+ LoopFlowContext.prototype.pushScope = function (isLoop) {
2762
+ ++this.level;
2763
+ if (isLoop)
2764
+ this.loopLevels.push(this.level);
2765
+ };
2766
+
2767
+ LoopFlowContext.prototype.popScope = function () {
2768
+ var levels = this.loopLevels;
2769
+ var levlen = levels.length;
2770
+ if (levlen) {
2771
+ if (levels[levlen - 1] === this.level)
2772
+ levels.pop();
2773
+ }
2774
+ --this.level;
2775
+ };
2776
+
2777
+ LoopFlowContext.prototype.addGoto =
2778
+ LoopFlowContext.prototype.addLabel =
2779
+ function () { throw new Error('This should never happen'); };
2780
+
2781
+ LoopFlowContext.prototype.addLocal =
2782
+ LoopFlowContext.prototype.raiseDeferredErrors =
2783
+ function () {};
2784
+
2785
+ function makeFlowContext() {
2786
+ return features.labels ? new FullFlowContext() : new LoopFlowContext();
2787
+ }
2788
+
2789
+ function parseChunk() {
2790
+ next();
2791
+ markLocation();
2792
+ if (options.scope) createScope();
2793
+ var flowContext = makeFlowContext();
2794
+ flowContext.allowVararg = true;
2795
+ flowContext.pushScope();
2796
+ var body = parseBlock(flowContext);
2797
+ flowContext.popScope();
2798
+ if (options.scope) destroyScope();
2799
+ if (EOF !== token.type) unexpected(token);
2800
+ if (trackLocations && !body.length) previousToken = token;
2801
+ return finishNode(ast.chunk(body));
2802
+ }
2803
+
2804
+ function parseBlock(flowContext) {
2805
+ var block = []
2806
+ , statement;
2807
+
2808
+ while (!isBlockFollow(token)) {
2809
+ if ('return' === token.value || (!features.relaxedBreak && 'break' === token.value)) {
2810
+ block.push(parseStatement(flowContext));
2811
+ break;
2812
+ }
2813
+ statement = parseStatement(flowContext);
2814
+ consume(';');
2815
+ if (statement) block.push(statement);
2816
+ }
2817
+ return block;
2818
+ }
2819
+
2820
+ function parseStatement(flowContext) {
2821
+ markLocation();
2822
+
2823
+ if (Punctuator === token.type) {
2824
+ if (consume('::')) return parseLabelStatement(flowContext);
2825
+ }
2826
+ if (features.emptyStatement) {
2827
+ if (consume(';')) {
2828
+ if (trackLocations) locations.pop();
2829
+ return;
2830
+ }
2831
+ }
2832
+
2833
+ flowContext.raiseDeferredErrors();
2834
+
2835
+ if (Keyword === token.type) {
2836
+ switch (token.value) {
2837
+ case 'local': next(); return parseLocalStatement(flowContext);
2838
+ case 'if': next(); return parseIfStatement(flowContext);
2839
+ case 'return': next(); return parseReturnStatement(flowContext);
2840
+ case 'function': next();
2841
+ var name = parseFunctionName();
2842
+ return parseFunctionDeclaration(name);
2843
+ case 'while': next(); return parseWhileStatement(flowContext);
2844
+ case 'for': next(); return parseForStatement(flowContext);
2845
+ case 'repeat': next(); return parseRepeatStatement(flowContext);
2846
+ case 'break': next();
2847
+ if (!flowContext.isInLoop())
2848
+ raise(token, errors.noLoopToBreak, token.value);
2849
+ return parseBreakStatement();
2850
+ case 'do': next(); return parseDoStatement(flowContext);
2851
+ case 'goto': next(); return parseGotoStatement(flowContext);
2852
+ }
2853
+ }
2854
+
2855
+ if (features.contextualGoto &&
2856
+ token.type === Identifier && token.value === 'goto' &&
2857
+ lookahead.type === Identifier && lookahead.value !== 'goto') {
2858
+ next(); return parseGotoStatement(flowContext);
2859
+ }
2860
+ if (trackLocations) locations.pop();
2861
+
2862
+ return parseAssignmentOrCallStatement(flowContext);
2863
+ }
2864
+
2865
+ function parseLabelStatement(flowContext) {
2866
+ var nameToken = token
2867
+ , label = parseIdentifier();
2868
+
2869
+ if (options.scope) {
2870
+ scopeIdentifierName('::' + nameToken.value + '::');
2871
+ attachScope(label, true);
2872
+ }
2873
+
2874
+ expect('::');
2875
+
2876
+ flowContext.addLabel(nameToken.value, nameToken);
2877
+ return finishNode(ast.labelStatement(label));
2878
+ }
2879
+
2880
+ function parseBreakStatement() {
2881
+ return finishNode(ast.breakStatement());
2882
+ }
2883
+
2884
+ function parseGotoStatement(flowContext) {
2885
+ var name = token.value
2886
+ , gotoToken = previousToken
2887
+ , label = parseIdentifier();
2888
+
2889
+ flowContext.addGoto(name, gotoToken);
2890
+ return finishNode(ast.gotoStatement(label));
2891
+ }
2892
+
2893
+ function parseDoStatement(flowContext) {
2894
+ if (options.scope) createScope();
2895
+ flowContext.pushScope();
2896
+ var body = parseBlock(flowContext);
2897
+ flowContext.popScope();
2898
+ if (options.scope) destroyScope();
2899
+ expect('end');
2900
+ return finishNode(ast.doStatement(body));
2901
+ }
2902
+
2903
+ function parseWhileStatement(flowContext) {
2904
+ var condition = parseExpectedExpression(flowContext);
2905
+ expect('do');
2906
+ if (options.scope) createScope();
2907
+ flowContext.pushScope(true);
2908
+ var body = parseBlock(flowContext);
2909
+ flowContext.popScope();
2910
+ if (options.scope) destroyScope();
2911
+ expect('end');
2912
+ return finishNode(ast.whileStatement(condition, body));
2913
+ }
2914
+
2915
+ function parseRepeatStatement(flowContext) {
2916
+ if (options.scope) createScope();
2917
+ flowContext.pushScope(true);
2918
+ var body = parseBlock(flowContext);
2919
+ expect('until');
2920
+ flowContext.raiseDeferredErrors();
2921
+ var condition = parseExpectedExpression(flowContext);
2922
+ flowContext.popScope();
2923
+ if (options.scope) destroyScope();
2924
+ return finishNode(ast.repeatStatement(condition, body));
2925
+ }
2926
+
2927
+ function parseReturnStatement(flowContext) {
2928
+ var expressions = [];
2929
+
2930
+ if ('end' !== token.value) {
2931
+ var expression = parseExpression(flowContext);
2932
+ if (null != expression) expressions.push(expression);
2933
+ while (consume(',')) {
2934
+ expression = parseExpectedExpression(flowContext);
2935
+ expressions.push(expression);
2936
+ }
2937
+ consume(';'); // grammar tells us ; is optional here.
2938
+ }
2939
+ return finishNode(ast.returnStatement(expressions));
2940
+ }
2941
+
2942
+ function parseIfStatement(flowContext) {
2943
+ var clauses = []
2944
+ , condition
2945
+ , body
2946
+ , marker;
2947
+ if (trackLocations) {
2948
+ marker = locations[locations.length - 1];
2949
+ locations.push(marker);
2950
+ }
2951
+ condition = parseExpectedExpression(flowContext);
2952
+ expect('then');
2953
+ if (options.scope) createScope();
2954
+ flowContext.pushScope();
2955
+ body = parseBlock(flowContext);
2956
+ flowContext.popScope();
2957
+ if (options.scope) destroyScope();
2958
+ clauses.push(finishNode(ast.ifClause(condition, body)));
2959
+
2960
+ if (trackLocations) marker = createLocationMarker();
2961
+ while (consume('elseif')) {
2962
+ pushLocation(marker);
2963
+ condition = parseExpectedExpression(flowContext);
2964
+ expect('then');
2965
+ if (options.scope) createScope();
2966
+ flowContext.pushScope();
2967
+ body = parseBlock(flowContext);
2968
+ flowContext.popScope();
2969
+ if (options.scope) destroyScope();
2970
+ clauses.push(finishNode(ast.elseifClause(condition, body)));
2971
+ if (trackLocations) marker = createLocationMarker();
2972
+ }
2973
+
2974
+ if (consume('else')) {
2975
+ if (trackLocations) {
2976
+ marker = new Marker(previousToken);
2977
+ locations.push(marker);
2978
+ }
2979
+ if (options.scope) createScope();
2980
+ flowContext.pushScope();
2981
+ body = parseBlock(flowContext);
2982
+ flowContext.popScope();
2983
+ if (options.scope) destroyScope();
2984
+ clauses.push(finishNode(ast.elseClause(body)));
2985
+ }
2986
+
2987
+ expect('end');
2988
+ return finishNode(ast.ifStatement(clauses));
2989
+ }
2990
+
2991
+ function parseForStatement(flowContext) {
2992
+ var variable = parseIdentifier()
2993
+ , body;
2994
+
2995
+ if (options.scope) {
2996
+ createScope();
2997
+ scopeIdentifier(variable);
2998
+ }
2999
+ if (consume('=')) {
3000
+ var start = parseExpectedExpression(flowContext);
3001
+ expect(',');
3002
+ var end = parseExpectedExpression(flowContext);
3003
+ var step = consume(',') ? parseExpectedExpression(flowContext) : null;
3004
+
3005
+ expect('do');
3006
+ flowContext.pushScope(true);
3007
+ body = parseBlock(flowContext);
3008
+ flowContext.popScope();
3009
+ expect('end');
3010
+ if (options.scope) destroyScope();
3011
+
3012
+ return finishNode(ast.forNumericStatement(variable, start, end, step, body));
3013
+ }
3014
+ else {
3015
+ var variables = [variable];
3016
+ while (consume(',')) {
3017
+ variable = parseIdentifier();
3018
+ if (options.scope) scopeIdentifier(variable);
3019
+ variables.push(variable);
3020
+ }
3021
+ expect('in');
3022
+ var iterators = [];
3023
+ do {
3024
+ var expression = parseExpectedExpression(flowContext);
3025
+ iterators.push(expression);
3026
+ } while (consume(','));
3027
+
3028
+ expect('do');
3029
+ flowContext.pushScope(true);
3030
+ body = parseBlock(flowContext);
3031
+ flowContext.popScope();
3032
+ expect('end');
3033
+ if (options.scope) destroyScope();
3034
+
3035
+ return finishNode(ast.forGenericStatement(variables, iterators, body));
3036
+ }
3037
+ }
3038
+
3039
+ function parseLocalStatement(flowContext) {
3040
+ var name
3041
+ , declToken = previousToken;
3042
+
3043
+ if (Identifier === token.type) {
3044
+ var variables = []
3045
+ , init = [];
3046
+
3047
+ do {
3048
+ name = parseIdentifier();
3049
+
3050
+ variables.push(name);
3051
+ flowContext.addLocal(name.name, declToken);
3052
+ } while (consume(','));
3053
+
3054
+ if (consume('=')) {
3055
+ do {
3056
+ var expression = parseExpectedExpression(flowContext);
3057
+ init.push(expression);
3058
+ } while (consume(','));
3059
+ }
3060
+ if (options.scope) {
3061
+ for (var i = 0, l = variables.length; i < l; ++i) {
3062
+ scopeIdentifier(variables[i]);
3063
+ }
3064
+ }
3065
+
3066
+ return finishNode(ast.localStatement(variables, init));
3067
+ }
3068
+ if (consume('function')) {
3069
+ name = parseIdentifier();
3070
+ flowContext.addLocal(name.name, declToken);
3071
+
3072
+ if (options.scope) {
3073
+ scopeIdentifier(name);
3074
+ createScope();
3075
+ }
3076
+ return parseFunctionDeclaration(name, true);
3077
+ } else {
3078
+ raiseUnexpectedToken('<name>', token);
3079
+ }
3080
+ }
3081
+
3082
+ function parseAssignmentOrCallStatement(flowContext) {
3083
+ var previous = token
3084
+ , marker, startMarker;
3085
+ var lvalue, base, name;
3086
+
3087
+ var targets = [];
3088
+
3089
+ if (trackLocations) startMarker = createLocationMarker();
3090
+
3091
+ do {
3092
+ if (trackLocations) marker = createLocationMarker();
3093
+
3094
+ if (Identifier === token.type) {
3095
+ name = token.value;
3096
+ base = parseIdentifier();
3097
+ if (options.scope) attachScope(base, scopeHasName(name));
3098
+ lvalue = true;
3099
+ } else if ('(' === token.value) {
3100
+ next();
3101
+ base = parseExpectedExpression(flowContext);
3102
+ expect(')');
3103
+ lvalue = false;
3104
+ } else {
3105
+ return unexpected(token);
3106
+ }
3107
+
3108
+ both: for (;;) {
3109
+ var newBase;
3110
+
3111
+ switch (StringLiteral === token.type ? '"' : token.value) {
3112
+ case '.':
3113
+ case '[':
3114
+ lvalue = true;
3115
+ break;
3116
+ case ':':
3117
+ case '(':
3118
+ case '{':
3119
+ case '"':
3120
+ lvalue = null;
3121
+ break;
3122
+ default:
3123
+ break both;
3124
+ }
3125
+
3126
+ base = parsePrefixExpressionPart(base, marker, flowContext);
3127
+ }
3128
+
3129
+ targets.push(base);
3130
+
3131
+ if (',' !== token.value)
3132
+ break;
3133
+
3134
+ if (!lvalue) {
3135
+ return unexpected(token);
3136
+ }
3137
+
3138
+ next();
3139
+ } while (true);
3140
+
3141
+ if (targets.length === 1 && lvalue === null) {
3142
+ pushLocation(marker);
3143
+ return finishNode(ast.callStatement(targets[0]));
3144
+ } else if (!lvalue) {
3145
+ return unexpected(token);
3146
+ }
3147
+
3148
+ expect('=');
3149
+
3150
+ var values = [];
3151
+
3152
+ do {
3153
+ values.push(parseExpectedExpression(flowContext));
3154
+ } while (consume(','));
3155
+
3156
+ pushLocation(startMarker);
3157
+ return finishNode(ast.assignmentStatement(targets, values));
3158
+ }
3159
+
3160
+ function parseIdentifier() {
3161
+ markLocation();
3162
+ var identifier = token.value;
3163
+ if (Identifier !== token.type) raiseUnexpectedToken('<name>', token);
3164
+ next();
3165
+ return finishNode(ast.identifier(identifier));
3166
+ }
3167
+
3168
+ function parseFunctionDeclaration(name, isLocal) {
3169
+ var flowContext = makeFlowContext();
3170
+ flowContext.pushScope();
3171
+
3172
+ var parameters = [];
3173
+ expect('(');
3174
+ if (!consume(')')) {
3175
+ while (true) {
3176
+ if (Identifier === token.type) {
3177
+ var parameter = parseIdentifier();
3178
+ if (options.scope) scopeIdentifier(parameter);
3179
+
3180
+ parameters.push(parameter);
3181
+
3182
+ if (consume(',')) continue;
3183
+ }
3184
+ else if (VarargLiteral === token.type) {
3185
+ flowContext.allowVararg = true;
3186
+ parameters.push(parsePrimaryExpression(flowContext));
3187
+ } else {
3188
+ raiseUnexpectedToken('<name> or \'...\'', token);
3189
+ }
3190
+ expect(')');
3191
+ break;
3192
+ }
3193
+ }
3194
+
3195
+ var body = parseBlock(flowContext);
3196
+ flowContext.popScope();
3197
+ expect('end');
3198
+ if (options.scope) destroyScope();
3199
+
3200
+ isLocal = isLocal || false;
3201
+ return finishNode(ast.functionStatement(name, parameters, isLocal, body));
3202
+ }
3203
+
3204
+ function parseFunctionName() {
3205
+ var base, name, marker;
3206
+
3207
+ if (trackLocations) marker = createLocationMarker();
3208
+ base = parseIdentifier();
3209
+
3210
+ if (options.scope) {
3211
+ attachScope(base, scopeHasName(base.name));
3212
+ createScope();
3213
+ }
3214
+
3215
+ while (consume('.')) {
3216
+ pushLocation(marker);
3217
+ name = parseIdentifier();
3218
+ base = finishNode(ast.memberExpression(base, '.', name));
3219
+ }
3220
+
3221
+ if (consume(':')) {
3222
+ pushLocation(marker);
3223
+ name = parseIdentifier();
3224
+ base = finishNode(ast.memberExpression(base, ':', name));
3225
+ if (options.scope) scopeIdentifierName('self');
3226
+ }
3227
+
3228
+ return base;
3229
+ }
3230
+
3231
+ function parseTableConstructor(flowContext) {
3232
+ var fields = []
3233
+ , key, value;
3234
+
3235
+ while (true) {
3236
+ markLocation();
3237
+ if (Punctuator === token.type && consume('[')) {
3238
+ key = parseExpectedExpression(flowContext);
3239
+ expect(']');
3240
+ expect('=');
3241
+ value = parseExpectedExpression(flowContext);
3242
+ fields.push(finishNode(ast.tableKey(key, value)));
3243
+ } else if (Identifier === token.type) {
3244
+ if ('=' === lookahead.value) {
3245
+ key = parseIdentifier();
3246
+ next();
3247
+ value = parseExpectedExpression(flowContext);
3248
+ fields.push(finishNode(ast.tableKeyString(key, value)));
3249
+ } else {
3250
+ value = parseExpectedExpression(flowContext);
3251
+ fields.push(finishNode(ast.tableValue(value)));
3252
+ }
3253
+ } else {
3254
+ if (null == (value = parseExpression(flowContext))) {
3255
+ locations.pop();
3256
+ break;
3257
+ }
3258
+ fields.push(finishNode(ast.tableValue(value)));
3259
+ }
3260
+ if (',;'.indexOf(token.value) >= 0) {
3261
+ next();
3262
+ continue;
3263
+ }
3264
+ break;
3265
+ }
3266
+ expect('}');
3267
+ return finishNode(ast.tableConstructorExpression(fields));
3268
+ }
3269
+
3270
+ function parseExpression(flowContext) {
3271
+ var expression = parseSubExpression(0, flowContext);
3272
+ return expression;
3273
+ }
3274
+
3275
+ function parseExpectedExpression(flowContext) {
3276
+ var expression = parseExpression(flowContext);
3277
+ if (null == expression) raiseUnexpectedToken('<expression>', token);
3278
+ else return expression;
3279
+ }
3280
+
3281
+ function binaryPrecedence(operator) {
3282
+ var charCode = operator.charCodeAt(0)
3283
+ , length = operator.length;
3284
+
3285
+ if (1 === length) {
3286
+ switch (charCode) {
3287
+ case 94: return 12; // ^
3288
+ case 42: case 47: case 37: return 10; // * / %
3289
+ case 43: case 45: return 9; // + -
3290
+ case 38: return 6; // &
3291
+ case 126: return 5; // ~
3292
+ case 124: return 4; // |
3293
+ case 60: case 62: return 3; // < >
3294
+ }
3295
+ } else if (2 === length) {
3296
+ switch (charCode) {
3297
+ case 47: return 10; // //
3298
+ case 46: return 8; // ..
3299
+ case 60: case 62:
3300
+ if('<<' === operator || '>>' === operator) return 7; // << >>
3301
+ return 3; // <= >=
3302
+ case 61: case 126: return 3; // == ~=
3303
+ case 111: return 1; // or
3304
+ }
3305
+ } else if (97 === charCode && 'and' === operator) return 2;
3306
+ return 0;
3307
+ }
3308
+
3309
+ function parseSubExpression(minPrecedence, flowContext) {
3310
+ var operator = token.value
3311
+ , expression, marker;
3312
+
3313
+ if (trackLocations) marker = createLocationMarker();
3314
+ if (isUnary(token)) {
3315
+ markLocation();
3316
+ next();
3317
+ var argument = parseSubExpression(10, flowContext);
3318
+ if (argument == null) raiseUnexpectedToken('<expression>', token);
3319
+ expression = finishNode(ast.unaryExpression(operator, argument));
3320
+ }
3321
+ if (null == expression) {
3322
+ expression = parsePrimaryExpression(flowContext);
3323
+ if (null == expression) {
3324
+ expression = parsePrefixExpression(flowContext);
3325
+ }
3326
+ }
3327
+ if (null == expression) return null;
3328
+
3329
+ var precedence;
3330
+ while (true) {
3331
+ operator = token.value;
3332
+
3333
+ precedence = (Punctuator === token.type || Keyword === token.type) ?
3334
+ binaryPrecedence(operator) : 0;
3335
+
3336
+ if (precedence === 0 || precedence <= minPrecedence) break;
3337
+ if ('^' === operator || '..' === operator) --precedence;
3338
+ next();
3339
+ var right = parseSubExpression(precedence, flowContext);
3340
+ if (null == right) raiseUnexpectedToken('<expression>', token);
3341
+ if (trackLocations) locations.push(marker);
3342
+ expression = finishNode(ast.binaryExpression(operator, expression, right));
3343
+
3344
+ }
3345
+ return expression;
3346
+ }
3347
+
3348
+ function parsePrefixExpressionPart(base, marker, flowContext) {
3349
+ var expression, identifier;
3350
+
3351
+ if (Punctuator === token.type) {
3352
+ switch (token.value) {
3353
+ case '[':
3354
+ pushLocation(marker);
3355
+ next();
3356
+ expression = parseExpectedExpression(flowContext);
3357
+ expect(']');
3358
+ return finishNode(ast.indexExpression(base, expression));
3359
+ case '.':
3360
+ pushLocation(marker);
3361
+ next();
3362
+ identifier = parseIdentifier();
3363
+ return finishNode(ast.memberExpression(base, '.', identifier));
3364
+ case ':':
3365
+ pushLocation(marker);
3366
+ next();
3367
+ identifier = parseIdentifier();
3368
+ base = finishNode(ast.memberExpression(base, ':', identifier));
3369
+ pushLocation(marker);
3370
+ return parseCallExpression(base, flowContext);
3371
+ case '(': case '{': // args
3372
+ pushLocation(marker);
3373
+ return parseCallExpression(base, flowContext);
3374
+ }
3375
+ } else if (StringLiteral === token.type) {
3376
+ pushLocation(marker);
3377
+ return parseCallExpression(base, flowContext);
3378
+ }
3379
+
3380
+ return null;
3381
+ }
3382
+
3383
+ function parsePrefixExpression(flowContext) {
3384
+ var base, name, marker;
3385
+
3386
+ if (trackLocations) marker = createLocationMarker();
3387
+ if (Identifier === token.type) {
3388
+ name = token.value;
3389
+ base = parseIdentifier();
3390
+ if (options.scope) attachScope(base, scopeHasName(name));
3391
+ } else if (consume('(')) {
3392
+ base = parseExpectedExpression(flowContext);
3393
+ expect(')');
3394
+ } else {
3395
+ return null;
3396
+ }
3397
+ for (;;) {
3398
+ var newBase = parsePrefixExpressionPart(base, marker, flowContext);
3399
+ if (newBase === null)
3400
+ break;
3401
+ base = newBase;
3402
+ }
3403
+
3404
+ return base;
3405
+ }
3406
+
3407
+ function parseCallExpression(base, flowContext) {
3408
+ if (Punctuator === token.type) {
3409
+ switch (token.value) {
3410
+ case '(':
3411
+ if (!features.emptyStatement) {
3412
+ if (token.line !== previousToken.line)
3413
+ raise(null, errors.ambiguousSyntax, token.value);
3414
+ }
3415
+ next();
3416
+ var expressions = [];
3417
+ var expression = parseExpression(flowContext);
3418
+ if (null != expression) expressions.push(expression);
3419
+ while (consume(',')) {
3420
+ expression = parseExpectedExpression(flowContext);
3421
+ expressions.push(expression);
3422
+ }
3423
+
3424
+ expect(')');
3425
+ return finishNode(ast.callExpression(base, expressions));
3426
+
3427
+ case '{':
3428
+ markLocation();
3429
+ next();
3430
+ var table = parseTableConstructor(flowContext);
3431
+ return finishNode(ast.tableCallExpression(base, table));
3432
+ }
3433
+ } else if (StringLiteral === token.type) {
3434
+ return finishNode(ast.stringCallExpression(base, parsePrimaryExpression(flowContext)));
3435
+ }
3436
+
3437
+ raiseUnexpectedToken('function arguments', token);
3438
+ }
3439
+
3440
+ function parsePrimaryExpression(flowContext) {
3441
+ var literals = StringLiteral | NumericLiteral | BooleanLiteral | NilLiteral | VarargLiteral
3442
+ , value = token.value
3443
+ , type = token.type
3444
+ , marker;
3445
+
3446
+ if (trackLocations) marker = createLocationMarker();
3447
+
3448
+ if (type === VarargLiteral && !flowContext.allowVararg) {
3449
+ raise(token, errors.cannotUseVararg, token.value);
3450
+ }
3451
+
3452
+ if (type & literals) {
3453
+ pushLocation(marker);
3454
+ var raw = input.slice(token.range[0], token.range[1]);
3455
+ next();
3456
+ return finishNode(ast.literal(type, value, raw));
3457
+ } else if (Keyword === type && 'function' === value) {
3458
+ pushLocation(marker);
3459
+ next();
3460
+ if (options.scope) createScope();
3461
+ return parseFunctionDeclaration(null);
3462
+ } else if (consume('{')) {
3463
+ pushLocation(marker);
3464
+ return parseTableConstructor(flowContext);
3465
+ }
3466
+ }
3467
+
3468
+ exports.parse = parse;
3469
+
3470
+ var versionFeatures = {
3471
+ '5.1': {
3472
+ },
3473
+ '5.2': {
3474
+ labels: true,
3475
+ emptyStatement: true,
3476
+ hexEscapes: true,
3477
+ skipWhitespaceEscape: true,
3478
+ strictEscapes: true,
3479
+ relaxedBreak: true
3480
+ },
3481
+ '5.3': {
3482
+ labels: true,
3483
+ emptyStatement: true,
3484
+ hexEscapes: true,
3485
+ skipWhitespaceEscape: true,
3486
+ strictEscapes: true,
3487
+ unicodeEscapes: true,
3488
+ bitwiseOperators: true,
3489
+ integerDivision: true,
3490
+ relaxedBreak: true
3491
+ },
3492
+ 'LuaJIT': {
3493
+ labels: true,
3494
+ contextualGoto: true,
3495
+ hexEscapes: true,
3496
+ skipWhitespaceEscape: true,
3497
+ strictEscapes: true,
3498
+ unicodeEscapes: true,
3499
+ imaginaryNumbers: true,
3500
+ integerSuffixes: true
3501
+ }
3502
+ };
3503
+
3504
+ function parse(_input, _options) {
3505
+ if ('undefined' === typeof _options && 'object' === typeof _input) {
3506
+ _options = _input;
3507
+ _input = undefined;
3508
+ }
3509
+ if (!_options) _options = {};
3510
+
3511
+ input = _input || '';
3512
+ options = assign({}, defaultOptions, _options);
3513
+ index = 0;
3514
+ line = 1;
3515
+ lineStart = 0;
3516
+ length = input.length;
3517
+ scopes = [[]];
3518
+ scopeDepth = 0;
3519
+ globals = [];
3520
+ locations = [];
3521
+
3522
+ if (!Object.prototype.hasOwnProperty.call(versionFeatures, options.luaVersion)) {
3523
+ throw new Error(sprintf("Lua version '%1' not supported", options.luaVersion));
3524
+ }
3525
+
3526
+ features = assign({}, versionFeatures[options.luaVersion]);
3527
+ if (options.extendedIdentifiers !== void 0)
3528
+ features.extendedIdentifiers = !!options.extendedIdentifiers;
3529
+
3530
+ if (!Object.prototype.hasOwnProperty.call(encodingModes, options.encodingMode)) {
3531
+ throw new Error(sprintf("Encoding mode '%1' not supported", options.encodingMode));
3532
+ }
3533
+
3534
+ encodingMode = encodingModes[options.encodingMode];
3535
+
3536
+ if (options.comments) comments = [];
3537
+ if (!options.wait) return end();
3538
+ return exports;
3539
+ }
3540
+ exports.write = write;
3541
+
3542
+ function write(_input) {
3543
+ input += String(_input);
3544
+ length = input.length;
3545
+ return exports;
3546
+ }
3547
+ exports.end = end;
3548
+
3549
+ function end(_input) {
3550
+ if ('undefined' !== typeof _input) write(_input);
3551
+ if (input && input.substr(0, 2) === '#!') input = input.replace(/^.*/, function (line) {
3552
+ return line.replace(/./g, ' ');
3553
+ });
3554
+
3555
+ length = input.length;
3556
+ trackLocations = options.locations || options.ranges;
3557
+ lookahead = lex();
3558
+
3559
+ var chunk = parseChunk();
3560
+ if (options.comments) chunk.comments = comments;
3561
+ if (options.scope) chunk.globals = globals;
3562
+ if (locations.length > 0)
3563
+ throw new Error('Location tracking failed. This is most likely a bug in luaparse');
3564
+
3565
+ return chunk;
3566
+ }
3567
+
3568
+ }));
3569
+
3570
+ });
3571
+
3572
+ ace.define("ace/mode/lua_worker",[], function(require, exports, module) {
3573
+ "use strict";
3574
+
3575
+ var oop = require("../lib/oop");
3576
+ var Mirror = require("../worker/mirror").Mirror;
3577
+ var luaparse = require("../mode/lua/luaparse");
3578
+
3579
+ var Worker = exports.Worker = function(sender) {
3580
+ Mirror.call(this, sender);
3581
+ this.setTimeout(500);
3582
+ };
3583
+
3584
+ oop.inherits(Worker, Mirror);
3585
+
3586
+ (function() {
3587
+
3588
+ this.onUpdate = function() {
3589
+ var value = this.doc.getValue();
3590
+ var errors = [];
3591
+ try {
3592
+ luaparse.parse(value);
3593
+ } catch(e) {
3594
+ if (e instanceof luaparse.SyntaxError) {
3595
+ errors.push({
3596
+ row: e.line - 1,
3597
+ column: e.column,
3598
+ text: e.message,
3599
+ type: "error"
3600
+ });
3601
+ }
3602
+ }
3603
+ this.sender.emit("annotate", errors);
3604
+ };
3605
+
3606
+ }).call(Worker.prototype);
3607
+
3608
+ });