@quirekit/cm-legacy-modes 0.0.0-stage → 0.0.1-alpha.1

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 (420) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -2
  3. package/README.zh-CN.md +28 -0
  4. package/THIRD_PARTY_NOTICES.md +141 -0
  5. package/UPSTREAM.json +16 -0
  6. package/dist/mode/README.md +52 -0
  7. package/dist/mode/apl.d.ts +2 -0
  8. package/dist/mode/apl.js +140 -0
  9. package/dist/mode/asciiarmor.d.ts +2 -0
  10. package/dist/mode/asciiarmor.js +54 -0
  11. package/dist/mode/asn1.d.ts +12 -0
  12. package/dist/mode/asn1.js +190 -0
  13. package/dist/mode/asterisk.d.ts +2 -0
  14. package/dist/mode/asterisk.js +186 -0
  15. package/dist/mode/brainfuck.d.ts +2 -0
  16. package/dist/mode/brainfuck.js +68 -0
  17. package/dist/mode/clike.d.ts +35 -0
  18. package/dist/mode/clike.js +1019 -0
  19. package/dist/mode/clojure.d.ts +2 -0
  20. package/dist/mode/clojure.js +272 -0
  21. package/dist/mode/cmake.d.ts +2 -0
  22. package/dist/mode/cmake.js +80 -0
  23. package/dist/mode/cobol.d.ts +2 -0
  24. package/dist/mode/cobol.js +234 -0
  25. package/dist/mode/coffeescript.d.ts +2 -0
  26. package/dist/mode/coffeescript.js +327 -0
  27. package/dist/mode/commonlisp.d.ts +2 -0
  28. package/dist/mode/commonlisp.js +107 -0
  29. package/dist/mode/crystal.d.ts +2 -0
  30. package/dist/mode/crystal.js +417 -0
  31. package/dist/mode/css.d.ts +5 -0
  32. package/dist/mode/css.js +846 -0
  33. package/dist/mode/cypher.d.ts +2 -0
  34. package/dist/mode/cypher.js +120 -0
  35. package/dist/mode/d.d.ts +2 -0
  36. package/dist/mode/d.js +203 -0
  37. package/dist/mode/diff.d.ts +2 -0
  38. package/dist/mode/diff.js +29 -0
  39. package/dist/mode/dockerfile.d.ts +2 -0
  40. package/dist/mode/dockerfile.js +198 -0
  41. package/dist/mode/dtd.d.ts +2 -0
  42. package/dist/mode/dtd.js +120 -0
  43. package/dist/mode/dylan.d.ts +2 -0
  44. package/dist/mode/dylan.js +336 -0
  45. package/dist/mode/ebnf.d.ts +2 -0
  46. package/dist/mode/ebnf.js +149 -0
  47. package/dist/mode/ecl.d.ts +2 -0
  48. package/dist/mode/ecl.js +188 -0
  49. package/dist/mode/eiffel.d.ts +2 -0
  50. package/dist/mode/eiffel.js +145 -0
  51. package/dist/mode/elm.d.ts +2 -0
  52. package/dist/mode/elm.js +228 -0
  53. package/dist/mode/erlang.d.ts +2 -0
  54. package/dist/mode/erlang.js +580 -0
  55. package/dist/mode/factor.d.ts +2 -0
  56. package/dist/mode/factor.js +63 -0
  57. package/dist/mode/fcl.d.ts +2 -0
  58. package/dist/mode/fcl.js +153 -0
  59. package/dist/mode/forth.d.ts +2 -0
  60. package/dist/mode/forth.js +162 -0
  61. package/dist/mode/fortran.d.ts +2 -0
  62. package/dist/mode/fortran.js +171 -0
  63. package/dist/mode/gas.d.ts +3 -0
  64. package/dist/mode/gas.js +342 -0
  65. package/dist/mode/gherkin.d.ts +2 -0
  66. package/dist/mode/gherkin.js +146 -0
  67. package/dist/mode/go.d.ts +2 -0
  68. package/dist/mode/go.js +163 -0
  69. package/dist/mode/groovy.d.ts +2 -0
  70. package/dist/mode/groovy.js +226 -0
  71. package/dist/mode/haskell.d.ts +2 -0
  72. package/dist/mode/haskell.js +238 -0
  73. package/dist/mode/haxe.d.ts +3 -0
  74. package/dist/mode/haxe.js +490 -0
  75. package/dist/mode/http.d.ts +2 -0
  76. package/dist/mode/http.js +87 -0
  77. package/dist/mode/idl.d.ts +2 -0
  78. package/dist/mode/idl.js +274 -0
  79. package/dist/mode/javascript.d.ts +5 -0
  80. package/dist/mode/javascript.js +922 -0
  81. package/dist/mode/jinja2.d.ts +2 -0
  82. package/dist/mode/jinja2.js +170 -0
  83. package/dist/mode/julia.d.ts +2 -0
  84. package/dist/mode/julia.js +367 -0
  85. package/dist/mode/livescript.d.ts +2 -0
  86. package/dist/mode/livescript.js +257 -0
  87. package/dist/mode/lua.d.ts +2 -0
  88. package/dist/mode/lua.js +135 -0
  89. package/dist/mode/mathematica.d.ts +2 -0
  90. package/dist/mode/mathematica.js +153 -0
  91. package/dist/mode/mbox.d.ts +2 -0
  92. package/dist/mode/mbox.js +114 -0
  93. package/dist/mode/mirc.d.ts +2 -0
  94. package/dist/mode/mirc.js +174 -0
  95. package/dist/mode/mllike.d.ts +4 -0
  96. package/dist/mode/mllike.js +346 -0
  97. package/dist/mode/modelica.d.ts +2 -0
  98. package/dist/mode/modelica.js +190 -0
  99. package/dist/mode/mscgen.d.ts +4 -0
  100. package/dist/mode/mscgen.js +147 -0
  101. package/dist/mode/mumps.d.ts +2 -0
  102. package/dist/mode/mumps.js +127 -0
  103. package/dist/mode/nginx.d.ts +2 -0
  104. package/dist/mode/nginx.js +161 -0
  105. package/dist/mode/nsis.d.ts +2 -0
  106. package/dist/mode/nsis.js +78 -0
  107. package/dist/mode/ntriples.d.ts +2 -0
  108. package/dist/mode/ntriples.js +139 -0
  109. package/dist/mode/octave.d.ts +2 -0
  110. package/dist/mode/octave.js +123 -0
  111. package/dist/mode/oz.d.ts +2 -0
  112. package/dist/mode/oz.js +233 -0
  113. package/dist/mode/pascal.d.ts +2 -0
  114. package/dist/mode/pascal.js +122 -0
  115. package/dist/mode/pegjs.d.ts +2 -0
  116. package/dist/mode/pegjs.js +85 -0
  117. package/dist/mode/perl.d.ts +2 -0
  118. package/dist/mode/perl.js +818 -0
  119. package/dist/mode/pig.d.ts +2 -0
  120. package/dist/mode/pig.js +147 -0
  121. package/dist/mode/powershell.d.ts +2 -0
  122. package/dist/mode/powershell.js +379 -0
  123. package/dist/mode/properties.d.ts +2 -0
  124. package/dist/mode/properties.js +60 -0
  125. package/dist/mode/protobuf.d.ts +2 -0
  126. package/dist/mode/protobuf.js +55 -0
  127. package/dist/mode/pug.d.ts +2 -0
  128. package/dist/mode/pug.js +502 -0
  129. package/dist/mode/puppet.d.ts +2 -0
  130. package/dist/mode/puppet.js +203 -0
  131. package/dist/mode/python.d.ts +3 -0
  132. package/dist/mode/python.js +388 -0
  133. package/dist/mode/q.d.ts +2 -0
  134. package/dist/mode/q.js +124 -0
  135. package/dist/mode/r.d.ts +2 -0
  136. package/dist/mode/r.js +172 -0
  137. package/dist/mode/rpm.d.ts +3 -0
  138. package/dist/mode/rpm.js +88 -0
  139. package/dist/mode/ruby.d.ts +2 -0
  140. package/dist/mode/ruby.js +287 -0
  141. package/dist/mode/rust.d.ts +2 -0
  142. package/dist/mode/rust.js +54 -0
  143. package/dist/mode/sas.d.ts +2 -0
  144. package/dist/mode/sas.js +266 -0
  145. package/dist/mode/sass.d.ts +2 -0
  146. package/dist/mode/sass.js +427 -0
  147. package/dist/mode/scheme.d.ts +2 -0
  148. package/dist/mode/scheme.js +261 -0
  149. package/dist/mode/shell.d.ts +2 -0
  150. package/dist/mode/shell.js +146 -0
  151. package/dist/mode/sieve.d.ts +2 -0
  152. package/dist/mode/sieve.js +176 -0
  153. package/dist/mode/simple-mode.d.ts +14 -0
  154. package/dist/mode/simple-mode.js +136 -0
  155. package/dist/mode/smalltalk.d.ts +2 -0
  156. package/dist/mode/smalltalk.js +151 -0
  157. package/dist/mode/solr.d.ts +2 -0
  158. package/dist/mode/solr.js +78 -0
  159. package/dist/mode/sparql.d.ts +2 -0
  160. package/dist/mode/sparql.js +169 -0
  161. package/dist/mode/spreadsheet.d.ts +2 -0
  162. package/dist/mode/spreadsheet.js +96 -0
  163. package/dist/mode/sql.d.ts +27 -0
  164. package/dist/mode/sql.js +481 -0
  165. package/dist/mode/stex.d.ts +3 -0
  166. package/dist/mode/stex.js +245 -0
  167. package/dist/mode/stylus.d.ts +2 -0
  168. package/dist/mode/stylus.js +747 -0
  169. package/dist/mode/swift.d.ts +2 -0
  170. package/dist/mode/swift.js +200 -0
  171. package/dist/mode/tcl.d.ts +2 -0
  172. package/dist/mode/tcl.js +123 -0
  173. package/dist/mode/textile.d.ts +2 -0
  174. package/dist/mode/textile.js +440 -0
  175. package/dist/mode/tiddlywiki.d.ts +2 -0
  176. package/dist/mode/tiddlywiki.js +277 -0
  177. package/dist/mode/tiki.d.ts +2 -0
  178. package/dist/mode/tiki.js +291 -0
  179. package/dist/mode/toml.d.ts +2 -0
  180. package/dist/mode/toml.js +74 -0
  181. package/dist/mode/troff.d.ts +2 -0
  182. package/dist/mode/troff.js +63 -0
  183. package/dist/mode/ttcn-cfg.d.ts +2 -0
  184. package/dist/mode/ttcn-cfg.js +199 -0
  185. package/dist/mode/ttcn.d.ts +2 -0
  186. package/dist/mode/ttcn.js +255 -0
  187. package/dist/mode/turtle.d.ts +2 -0
  188. package/dist/mode/turtle.js +145 -0
  189. package/dist/mode/vb.d.ts +2 -0
  190. package/dist/mode/vb.js +254 -0
  191. package/dist/mode/vbscript.d.ts +3 -0
  192. package/dist/mode/vbscript.js +320 -0
  193. package/dist/mode/velocity.d.ts +2 -0
  194. package/dist/mode/velocity.js +184 -0
  195. package/dist/mode/verilog.d.ts +3 -0
  196. package/dist/mode/verilog.js +601 -0
  197. package/dist/mode/vhdl.d.ts +2 -0
  198. package/dist/mode/vhdl.js +172 -0
  199. package/dist/mode/wast.d.ts +2 -0
  200. package/dist/mode/wast.js +119 -0
  201. package/dist/mode/webidl.d.ts +2 -0
  202. package/dist/mode/webidl.js +179 -0
  203. package/dist/mode/xml.d.ts +3 -0
  204. package/dist/mode/xml.js +397 -0
  205. package/dist/mode/xquery.d.ts +2 -0
  206. package/dist/mode/xquery.js +415 -0
  207. package/dist/mode/yacas.d.ts +2 -0
  208. package/dist/mode/yacas.js +181 -0
  209. package/dist/mode/yaml.d.ts +2 -0
  210. package/dist/mode/yaml.js +101 -0
  211. package/dist/mode/z80.d.ts +3 -0
  212. package/dist/mode/z80.js +101 -0
  213. package/mode/README.md +52 -0
  214. package/mode/apl.d.ts +2 -0
  215. package/mode/apl.js +140 -0
  216. package/mode/asciiarmor.d.ts +2 -0
  217. package/mode/asciiarmor.js +54 -0
  218. package/mode/asn1.d.ts +12 -0
  219. package/mode/asn1.js +190 -0
  220. package/mode/asterisk.d.ts +2 -0
  221. package/mode/asterisk.js +186 -0
  222. package/mode/brainfuck.d.ts +2 -0
  223. package/mode/brainfuck.js +68 -0
  224. package/mode/clike.d.ts +35 -0
  225. package/mode/clike.js +1019 -0
  226. package/mode/clojure.d.ts +2 -0
  227. package/mode/clojure.js +272 -0
  228. package/mode/cmake.d.ts +2 -0
  229. package/mode/cmake.js +80 -0
  230. package/mode/cobol.d.ts +2 -0
  231. package/mode/cobol.js +234 -0
  232. package/mode/coffeescript.d.ts +2 -0
  233. package/mode/coffeescript.js +327 -0
  234. package/mode/commonlisp.d.ts +2 -0
  235. package/mode/commonlisp.js +107 -0
  236. package/mode/crystal.d.ts +2 -0
  237. package/mode/crystal.js +417 -0
  238. package/mode/css.d.ts +5 -0
  239. package/mode/css.js +846 -0
  240. package/mode/cypher.d.ts +2 -0
  241. package/mode/cypher.js +120 -0
  242. package/mode/d.d.ts +2 -0
  243. package/mode/d.js +203 -0
  244. package/mode/diff.d.ts +2 -0
  245. package/mode/diff.js +29 -0
  246. package/mode/dockerfile.d.ts +2 -0
  247. package/mode/dockerfile.js +198 -0
  248. package/mode/dtd.d.ts +2 -0
  249. package/mode/dtd.js +120 -0
  250. package/mode/dylan.d.ts +2 -0
  251. package/mode/dylan.js +336 -0
  252. package/mode/ebnf.d.ts +2 -0
  253. package/mode/ebnf.js +149 -0
  254. package/mode/ecl.d.ts +2 -0
  255. package/mode/ecl.js +188 -0
  256. package/mode/eiffel.d.ts +2 -0
  257. package/mode/eiffel.js +145 -0
  258. package/mode/elm.d.ts +2 -0
  259. package/mode/elm.js +228 -0
  260. package/mode/erlang.d.ts +2 -0
  261. package/mode/erlang.js +580 -0
  262. package/mode/factor.d.ts +2 -0
  263. package/mode/factor.js +63 -0
  264. package/mode/fcl.d.ts +2 -0
  265. package/mode/fcl.js +153 -0
  266. package/mode/forth.d.ts +2 -0
  267. package/mode/forth.js +162 -0
  268. package/mode/fortran.d.ts +2 -0
  269. package/mode/fortran.js +171 -0
  270. package/mode/gas.d.ts +3 -0
  271. package/mode/gas.js +342 -0
  272. package/mode/gherkin.d.ts +2 -0
  273. package/mode/gherkin.js +146 -0
  274. package/mode/go.d.ts +2 -0
  275. package/mode/go.js +163 -0
  276. package/mode/groovy.d.ts +2 -0
  277. package/mode/groovy.js +226 -0
  278. package/mode/haskell.d.ts +2 -0
  279. package/mode/haskell.js +238 -0
  280. package/mode/haxe.d.ts +3 -0
  281. package/mode/haxe.js +490 -0
  282. package/mode/http.d.ts +2 -0
  283. package/mode/http.js +87 -0
  284. package/mode/idl.d.ts +2 -0
  285. package/mode/idl.js +274 -0
  286. package/mode/javascript.d.ts +5 -0
  287. package/mode/javascript.js +922 -0
  288. package/mode/jinja2.d.ts +2 -0
  289. package/mode/jinja2.js +170 -0
  290. package/mode/julia.d.ts +2 -0
  291. package/mode/julia.js +367 -0
  292. package/mode/livescript.d.ts +2 -0
  293. package/mode/livescript.js +257 -0
  294. package/mode/lua.d.ts +2 -0
  295. package/mode/lua.js +135 -0
  296. package/mode/mathematica.d.ts +2 -0
  297. package/mode/mathematica.js +153 -0
  298. package/mode/mbox.d.ts +2 -0
  299. package/mode/mbox.js +114 -0
  300. package/mode/mirc.d.ts +2 -0
  301. package/mode/mirc.js +174 -0
  302. package/mode/mllike.d.ts +4 -0
  303. package/mode/mllike.js +346 -0
  304. package/mode/modelica.d.ts +2 -0
  305. package/mode/modelica.js +190 -0
  306. package/mode/mscgen.d.ts +4 -0
  307. package/mode/mscgen.js +147 -0
  308. package/mode/mumps.d.ts +2 -0
  309. package/mode/mumps.js +127 -0
  310. package/mode/nginx.d.ts +2 -0
  311. package/mode/nginx.js +161 -0
  312. package/mode/nsis.d.ts +2 -0
  313. package/mode/nsis.js +78 -0
  314. package/mode/ntriples.d.ts +2 -0
  315. package/mode/ntriples.js +139 -0
  316. package/mode/octave.d.ts +2 -0
  317. package/mode/octave.js +123 -0
  318. package/mode/oz.d.ts +2 -0
  319. package/mode/oz.js +233 -0
  320. package/mode/pascal.d.ts +2 -0
  321. package/mode/pascal.js +122 -0
  322. package/mode/pegjs.d.ts +2 -0
  323. package/mode/pegjs.js +85 -0
  324. package/mode/perl.d.ts +2 -0
  325. package/mode/perl.js +818 -0
  326. package/mode/pig.d.ts +2 -0
  327. package/mode/pig.js +147 -0
  328. package/mode/powershell.d.ts +2 -0
  329. package/mode/powershell.js +379 -0
  330. package/mode/properties.d.ts +2 -0
  331. package/mode/properties.js +60 -0
  332. package/mode/protobuf.d.ts +2 -0
  333. package/mode/protobuf.js +55 -0
  334. package/mode/pug.d.ts +2 -0
  335. package/mode/pug.js +502 -0
  336. package/mode/puppet.d.ts +2 -0
  337. package/mode/puppet.js +203 -0
  338. package/mode/python.d.ts +3 -0
  339. package/mode/python.js +388 -0
  340. package/mode/q.d.ts +2 -0
  341. package/mode/q.js +124 -0
  342. package/mode/r.d.ts +2 -0
  343. package/mode/r.js +172 -0
  344. package/mode/rpm.d.ts +3 -0
  345. package/mode/rpm.js +88 -0
  346. package/mode/ruby.d.ts +2 -0
  347. package/mode/ruby.js +287 -0
  348. package/mode/rust.d.ts +2 -0
  349. package/mode/rust.js +54 -0
  350. package/mode/sas.d.ts +2 -0
  351. package/mode/sas.js +266 -0
  352. package/mode/sass.d.ts +2 -0
  353. package/mode/sass.js +427 -0
  354. package/mode/scheme.d.ts +2 -0
  355. package/mode/scheme.js +261 -0
  356. package/mode/shell.d.ts +2 -0
  357. package/mode/shell.js +146 -0
  358. package/mode/sieve.d.ts +2 -0
  359. package/mode/sieve.js +176 -0
  360. package/mode/simple-mode.d.ts +14 -0
  361. package/mode/simple-mode.js +136 -0
  362. package/mode/smalltalk.d.ts +2 -0
  363. package/mode/smalltalk.js +151 -0
  364. package/mode/solr.d.ts +2 -0
  365. package/mode/solr.js +78 -0
  366. package/mode/sparql.d.ts +2 -0
  367. package/mode/sparql.js +169 -0
  368. package/mode/spreadsheet.d.ts +2 -0
  369. package/mode/spreadsheet.js +96 -0
  370. package/mode/sql.d.ts +27 -0
  371. package/mode/sql.js +481 -0
  372. package/mode/stex.d.ts +3 -0
  373. package/mode/stex.js +245 -0
  374. package/mode/stylus.d.ts +2 -0
  375. package/mode/stylus.js +747 -0
  376. package/mode/swift.d.ts +2 -0
  377. package/mode/swift.js +200 -0
  378. package/mode/tcl.d.ts +2 -0
  379. package/mode/tcl.js +123 -0
  380. package/mode/textile.d.ts +2 -0
  381. package/mode/textile.js +440 -0
  382. package/mode/tiddlywiki.d.ts +2 -0
  383. package/mode/tiddlywiki.js +277 -0
  384. package/mode/tiki.d.ts +2 -0
  385. package/mode/tiki.js +291 -0
  386. package/mode/toml.d.ts +2 -0
  387. package/mode/toml.js +74 -0
  388. package/mode/troff.d.ts +2 -0
  389. package/mode/troff.js +63 -0
  390. package/mode/ttcn-cfg.d.ts +2 -0
  391. package/mode/ttcn-cfg.js +199 -0
  392. package/mode/ttcn.d.ts +2 -0
  393. package/mode/ttcn.js +255 -0
  394. package/mode/turtle.d.ts +2 -0
  395. package/mode/turtle.js +145 -0
  396. package/mode/vb.d.ts +2 -0
  397. package/mode/vb.js +254 -0
  398. package/mode/vbscript.d.ts +3 -0
  399. package/mode/vbscript.js +320 -0
  400. package/mode/velocity.d.ts +2 -0
  401. package/mode/velocity.js +184 -0
  402. package/mode/verilog.d.ts +3 -0
  403. package/mode/verilog.js +601 -0
  404. package/mode/vhdl.d.ts +2 -0
  405. package/mode/vhdl.js +172 -0
  406. package/mode/wast.d.ts +2 -0
  407. package/mode/wast.js +119 -0
  408. package/mode/webidl.d.ts +2 -0
  409. package/mode/webidl.js +179 -0
  410. package/mode/xml.d.ts +3 -0
  411. package/mode/xml.js +397 -0
  412. package/mode/xquery.d.ts +2 -0
  413. package/mode/xquery.js +415 -0
  414. package/mode/yacas.d.ts +2 -0
  415. package/mode/yacas.js +181 -0
  416. package/mode/yaml.d.ts +2 -0
  417. package/mode/yaml.js +101 -0
  418. package/mode/z80.d.ts +3 -0
  419. package/mode/z80.js +101 -0
  420. package/package.json +37 -3
@@ -0,0 +1,136 @@
1
+ export function simpleMode(states) {
2
+ ensureState(states, "start");
3
+ var states_ = {}, meta = states.languageData || {}, hasIndentation = false;
4
+ for (var state in states) if (state != meta && states.hasOwnProperty(state)) {
5
+ var list = states_[state] = [], orig = states[state];
6
+ for (var i = 0; i < orig.length; i++) {
7
+ var data = orig[i];
8
+ list.push(new Rule(data, states));
9
+ if (data.indent || data.dedent) hasIndentation = true;
10
+ }
11
+ }
12
+ return {
13
+ name: meta.name,
14
+ startState: function() {
15
+ return {state: "start", pending: null, indent: hasIndentation ? [] : null};
16
+ },
17
+ copyState: function(state) {
18
+ var s = {state: state.state, pending: state.pending, indent: state.indent && state.indent.slice(0)};
19
+ if (state.stack)
20
+ s.stack = state.stack.slice(0);
21
+ return s;
22
+ },
23
+ token: tokenFunction(states_),
24
+ indent: indentFunction(states_, meta),
25
+ mergeTokens: meta.mergeTokens,
26
+ languageData: meta
27
+ }
28
+ };
29
+
30
+ function ensureState(states, name) {
31
+ if (!states.hasOwnProperty(name))
32
+ throw new Error("Undefined state " + name + " in simple mode");
33
+ }
34
+
35
+ function toRegex(val, caret) {
36
+ if (!val) return /(?:)/;
37
+ var flags = "";
38
+ if (val instanceof RegExp) {
39
+ if (val.ignoreCase) flags = "i";
40
+ if (val.unicode) flags += "u";
41
+ val = val.source;
42
+ } else {
43
+ val = String(val);
44
+ }
45
+ return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
46
+ }
47
+
48
+ function asToken(val) {
49
+ if (!val) return null;
50
+ if (val.apply) return val
51
+ if (typeof val == "string") return val.replace(/\./g, " ");
52
+ var result = [];
53
+ for (var i = 0; i < val.length; i++)
54
+ result.push(val[i] && val[i].replace(/\./g, " "));
55
+ return result;
56
+ }
57
+
58
+ function Rule(data, states) {
59
+ if (data.next || data.push) ensureState(states, data.next || data.push);
60
+ this.regex = toRegex(data.regex);
61
+ this.token = asToken(data.token);
62
+ this.data = data;
63
+ }
64
+
65
+ function tokenFunction(states) {
66
+ return function(stream, state) {
67
+ if (state.pending) {
68
+ var pend = state.pending.shift();
69
+ if (state.pending.length == 0) state.pending = null;
70
+ stream.pos += pend.text.length;
71
+ return pend.token;
72
+ }
73
+
74
+ var curState = states[state.state];
75
+ for (var i = 0; i < curState.length; i++) {
76
+ var rule = curState[i];
77
+ var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
78
+ if (matches) {
79
+ if (rule.data.next) {
80
+ state.state = rule.data.next;
81
+ } else if (rule.data.push) {
82
+ (state.stack || (state.stack = [])).push(state.state);
83
+ state.state = rule.data.push;
84
+ } else if (rule.data.pop && state.stack && state.stack.length) {
85
+ state.state = state.stack.pop();
86
+ }
87
+
88
+ if (rule.data.indent)
89
+ state.indent.push(stream.indentation() + stream.indentUnit);
90
+ if (rule.data.dedent)
91
+ state.indent.pop();
92
+ var token = rule.token
93
+ if (token && token.apply) token = token(matches)
94
+ if (matches.length > 2 && rule.token && typeof rule.token != "string") {
95
+ state.pending = [];
96
+ for (var j = 2; j < matches.length; j++)
97
+ if (matches[j])
98
+ state.pending.push({text: matches[j], token: rule.token[j - 1]});
99
+ stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
100
+ return token[0];
101
+ } else if (token && token.join) {
102
+ return token[0];
103
+ } else {
104
+ return token;
105
+ }
106
+ }
107
+ }
108
+ stream.next();
109
+ return null;
110
+ };
111
+ }
112
+
113
+ function indentFunction(states, meta) {
114
+ return function(state, textAfter) {
115
+ if (state.indent == null || meta.dontIndentStates && meta.dontIndentStates.indexOf(state.state) > -1)
116
+ return null
117
+
118
+ var pos = state.indent.length - 1, rules = states[state.state];
119
+ scan: for (;;) {
120
+ for (var i = 0; i < rules.length; i++) {
121
+ var rule = rules[i];
122
+ if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
123
+ var m = rule.regex.exec(textAfter);
124
+ if (m && m[0]) {
125
+ pos--;
126
+ if (rule.next || rule.push) rules = states[rule.next || rule.push];
127
+ textAfter = textAfter.slice(m[0].length);
128
+ continue scan;
129
+ }
130
+ }
131
+ }
132
+ break;
133
+ }
134
+ return pos < 0 ? 0 : state.indent[pos];
135
+ };
136
+ }
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const smalltalk: StreamParser<unknown>
@@ -0,0 +1,151 @@
1
+ var specialChars = /[+\-\/\\*~<>=@%|&?!.,:;^]/;
2
+ var keywords = /true|false|nil|self|super|thisContext/;
3
+
4
+ var Context = function(tokenizer, parent) {
5
+ this.next = tokenizer;
6
+ this.parent = parent;
7
+ };
8
+
9
+ var Token = function(name, context, eos) {
10
+ this.name = name;
11
+ this.context = context;
12
+ this.eos = eos;
13
+ };
14
+
15
+ var State = function() {
16
+ this.context = new Context(next, null);
17
+ this.expectVariable = true;
18
+ this.indentation = 0;
19
+ this.userIndentationDelta = 0;
20
+ };
21
+
22
+ State.prototype.userIndent = function(indentation, indentUnit) {
23
+ this.userIndentationDelta = indentation > 0 ? (indentation / indentUnit - this.indentation) : 0;
24
+ };
25
+
26
+ var next = function(stream, context, state) {
27
+ var token = new Token(null, context, false);
28
+ var aChar = stream.next();
29
+
30
+ if (aChar === '"') {
31
+ token = nextComment(stream, new Context(nextComment, context));
32
+
33
+ } else if (aChar === '\'') {
34
+ token = nextString(stream, new Context(nextString, context));
35
+
36
+ } else if (aChar === '#') {
37
+ if (stream.peek() === '\'') {
38
+ stream.next();
39
+ token = nextSymbol(stream, new Context(nextSymbol, context));
40
+ } else {
41
+ if (stream.eatWhile(/[^\s.{}\[\]()]/))
42
+ token.name = 'string.special';
43
+ else
44
+ token.name = 'meta';
45
+ }
46
+
47
+ } else if (aChar === '$') {
48
+ if (stream.next() === '<') {
49
+ stream.eatWhile(/[^\s>]/);
50
+ stream.next();
51
+ }
52
+ token.name = 'string.special';
53
+
54
+ } else if (aChar === '|' && state.expectVariable) {
55
+ token.context = new Context(nextTemporaries, context);
56
+
57
+ } else if (/[\[\]{}()]/.test(aChar)) {
58
+ token.name = 'bracket';
59
+ token.eos = /[\[{(]/.test(aChar);
60
+
61
+ if (aChar === '[') {
62
+ state.indentation++;
63
+ } else if (aChar === ']') {
64
+ state.indentation = Math.max(0, state.indentation - 1);
65
+ }
66
+
67
+ } else if (specialChars.test(aChar)) {
68
+ stream.eatWhile(specialChars);
69
+ token.name = 'operator';
70
+ token.eos = aChar !== ';'; // ; cascaded message expression
71
+
72
+ } else if (/\d/.test(aChar)) {
73
+ stream.eatWhile(/[\w\d]/);
74
+ token.name = 'number';
75
+
76
+ } else if (/[\w_]/.test(aChar)) {
77
+ stream.eatWhile(/[\w\d_]/);
78
+ token.name = state.expectVariable ? (keywords.test(stream.current()) ? 'keyword' : 'variable') : null;
79
+
80
+ } else {
81
+ token.eos = state.expectVariable;
82
+ }
83
+
84
+ return token;
85
+ };
86
+
87
+ var nextComment = function(stream, context) {
88
+ stream.eatWhile(/[^"]/);
89
+ return new Token('comment', stream.eat('"') ? context.parent : context, true);
90
+ };
91
+
92
+ var nextString = function(stream, context) {
93
+ stream.eatWhile(/[^']/);
94
+ return new Token('string', stream.eat('\'') ? context.parent : context, false);
95
+ };
96
+
97
+ var nextSymbol = function(stream, context) {
98
+ stream.eatWhile(/[^']/);
99
+ return new Token('string.special', stream.eat('\'') ? context.parent : context, false);
100
+ };
101
+
102
+ var nextTemporaries = function(stream, context) {
103
+ var token = new Token(null, context, false);
104
+ var aChar = stream.next();
105
+
106
+ if (aChar === '|') {
107
+ token.context = context.parent;
108
+ token.eos = true;
109
+
110
+ } else {
111
+ stream.eatWhile(/[^|]/);
112
+ token.name = 'variable';
113
+ }
114
+
115
+ return token;
116
+ };
117
+
118
+ export const smalltalk = {
119
+ name: "smalltalk",
120
+
121
+ startState: function() {
122
+ return new State;
123
+ },
124
+
125
+ token: function(stream, state) {
126
+ state.userIndent(stream.indentation(), stream.indentUnit);
127
+
128
+ if (stream.eatSpace()) {
129
+ return null;
130
+ }
131
+
132
+ var token = state.context.next(stream, state.context, state);
133
+ state.context = token.context;
134
+ state.expectVariable = token.eos;
135
+
136
+ return token.name;
137
+ },
138
+
139
+ blankLine: function(state, indentUnit) {
140
+ state.userIndent(0, indentUnit);
141
+ },
142
+
143
+ indent: function(state, textAfter, cx) {
144
+ var i = state.context.next === next && textAfter && textAfter.charAt(0) === ']' ? -1 : state.userIndentationDelta;
145
+ return (state.indentation + i) * cx.unit;
146
+ },
147
+
148
+ languageData: {
149
+ indentOnInput: /^\s*\]$/
150
+ }
151
+ }
package/mode/solr.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const solr: StreamParser<unknown>
package/mode/solr.js ADDED
@@ -0,0 +1,78 @@
1
+ var isStringChar = /[^\s\|\!\+\-\*\?\~\^\&\:\(\)\[\]\{\}\"\\]/;
2
+ var isOperatorChar = /[\|\!\+\-\*\?\~\^\&]/;
3
+ var isOperatorString = /^(OR|AND|NOT|TO)$/;
4
+
5
+ function isNumber(word) {
6
+ return parseFloat(word).toString() === word;
7
+ }
8
+
9
+ function tokenString(quote) {
10
+ return function(stream, state) {
11
+ var escaped = false, next;
12
+ while ((next = stream.next()) != null) {
13
+ if (next == quote && !escaped) break;
14
+ escaped = !escaped && next == "\\";
15
+ }
16
+
17
+ if (!escaped) state.tokenize = tokenBase;
18
+ return "string";
19
+ };
20
+ }
21
+
22
+ function tokenOperator(operator) {
23
+ return function(stream, state) {
24
+ if (operator == "|")
25
+ stream.eat(/\|/);
26
+ else if (operator == "&")
27
+ stream.eat(/\&/);
28
+
29
+ state.tokenize = tokenBase;
30
+ return "operator";
31
+ };
32
+ }
33
+
34
+ function tokenWord(ch) {
35
+ return function(stream, state) {
36
+ var word = ch;
37
+ while ((ch = stream.peek()) && ch.match(isStringChar) != null) {
38
+ word += stream.next();
39
+ }
40
+
41
+ state.tokenize = tokenBase;
42
+ if (isOperatorString.test(word))
43
+ return "operator";
44
+ else if (isNumber(word))
45
+ return "number";
46
+ else if (stream.peek() == ":")
47
+ return "propertyName";
48
+ else
49
+ return "string";
50
+ };
51
+ }
52
+
53
+ function tokenBase(stream, state) {
54
+ var ch = stream.next();
55
+ if (ch == '"')
56
+ state.tokenize = tokenString(ch);
57
+ else if (isOperatorChar.test(ch))
58
+ state.tokenize = tokenOperator(ch);
59
+ else if (isStringChar.test(ch))
60
+ state.tokenize = tokenWord(ch);
61
+
62
+ return (state.tokenize != tokenBase) ? state.tokenize(stream, state) : null;
63
+ }
64
+
65
+ export const solr = {
66
+ name: "solr",
67
+
68
+ startState: function() {
69
+ return {
70
+ tokenize: tokenBase
71
+ };
72
+ },
73
+
74
+ token: function(stream, state) {
75
+ if (stream.eatSpace()) return null;
76
+ return state.tokenize(stream, state);
77
+ }
78
+ };
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const sparql: StreamParser<unknown>
package/mode/sparql.js ADDED
@@ -0,0 +1,169 @@
1
+ var curPunc;
2
+
3
+ function wordRegexp(words) {
4
+ return new RegExp("^(?:" + words.join("|") + ")$", "i");
5
+ }
6
+ var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
7
+ "iri", "uri", "bnode", "count", "sum", "min", "max", "avg", "sample",
8
+ "group_concat", "rand", "abs", "ceil", "floor", "round", "concat", "substr", "strlen",
9
+ "replace", "ucase", "lcase", "encode_for_uri", "contains", "strstarts", "strends",
10
+ "strbefore", "strafter", "year", "month", "day", "hours", "minutes", "seconds",
11
+ "timezone", "tz", "now", "uuid", "struuid", "md5", "sha1", "sha256", "sha384",
12
+ "sha512", "coalesce", "if", "strlang", "strdt", "isnumeric", "regex", "exists",
13
+ "isblank", "isliteral", "a", "bind"]);
14
+ var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
15
+ "ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
16
+ "graph", "by", "asc", "desc", "as", "having", "undef", "values", "group",
17
+ "minus", "in", "not", "service", "silent", "using", "insert", "delete", "union",
18
+ "true", "false", "with",
19
+ "data", "copy", "to", "move", "add", "create", "drop", "clear", "load", "into"]);
20
+ var operatorChars = /[*+\-<>=&|\^\/!\?]/;
21
+ var PN_CHARS = "[A-Za-z_\\-0-9]";
22
+ var PREFIX_START = new RegExp("[A-Za-z]");
23
+ var PREFIX_REMAINDER = new RegExp("((" + PN_CHARS + "|\\.)*(" + PN_CHARS + "))?:");
24
+
25
+ function tokenBase(stream, state) {
26
+ var ch = stream.next();
27
+ curPunc = null;
28
+ if (ch == "$" || ch == "?") {
29
+ if(ch == "?" && stream.match(/\s/, false)){
30
+ return "operator";
31
+ }
32
+ stream.match(/^[A-Za-z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][A-Za-z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*/);
33
+ return "variableName.local";
34
+ }
35
+ else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) {
36
+ stream.match(/^[^\s\u00a0>]*>?/);
37
+ return "atom";
38
+ }
39
+ else if (ch == "\"" || ch == "'") {
40
+ state.tokenize = tokenLiteral(ch);
41
+ return state.tokenize(stream, state);
42
+ }
43
+ else if (/[{}\(\),\.;\[\]]/.test(ch)) {
44
+ curPunc = ch;
45
+ return "bracket";
46
+ }
47
+ else if (ch == "#") {
48
+ stream.skipToEnd();
49
+ return "comment";
50
+ }
51
+ else if (operatorChars.test(ch)) {
52
+ return "operator";
53
+ }
54
+ else if (ch == ":") {
55
+ eatPnLocal(stream);
56
+ return "atom";
57
+ }
58
+ else if (ch == "@") {
59
+ stream.eatWhile(/[a-z\d\-]/i);
60
+ return "meta";
61
+ }
62
+ else if (PREFIX_START.test(ch) && stream.match(PREFIX_REMAINDER)) {
63
+ eatPnLocal(stream);
64
+ return "atom";
65
+ }
66
+ stream.eatWhile(/[_\w\d]/);
67
+ var word = stream.current();
68
+ if (ops.test(word))
69
+ return "builtin";
70
+ else if (keywords.test(word))
71
+ return "keyword";
72
+ else
73
+ return "variable";
74
+ }
75
+
76
+ function eatPnLocal(stream) {
77
+ stream.match(/(\.(?=[\w_\-\\%])|[:\w_-]|\\[-\\_~.!$&'()*+,;=/?#@%]|%[a-f\d][a-f\d])+/i);
78
+ }
79
+
80
+ function tokenLiteral(quote) {
81
+ return function(stream, state) {
82
+ var escaped = false, ch;
83
+ while ((ch = stream.next()) != null) {
84
+ if (ch == quote && !escaped) {
85
+ state.tokenize = tokenBase;
86
+ break;
87
+ }
88
+ escaped = !escaped && ch == "\\";
89
+ }
90
+ return "string";
91
+ };
92
+ }
93
+
94
+ function pushContext(state, type, col) {
95
+ state.context = {prev: state.context, indent: state.indent, col: col, type: type};
96
+ }
97
+ function popContext(state) {
98
+ state.indent = state.context.indent;
99
+ state.context = state.context.prev;
100
+ }
101
+
102
+ export const sparql = {
103
+ name: "sparql",
104
+
105
+ startState: function() {
106
+ return {tokenize: tokenBase,
107
+ context: null,
108
+ indent: 0,
109
+ col: 0};
110
+ },
111
+
112
+ token: function(stream, state) {
113
+ if (stream.sol()) {
114
+ if (state.context && state.context.align == null) state.context.align = false;
115
+ state.indent = stream.indentation();
116
+ }
117
+ if (stream.eatSpace()) return null;
118
+ var style = state.tokenize(stream, state);
119
+
120
+ if (style != "comment" && state.context && state.context.align == null && state.context.type != "pattern") {
121
+ state.context.align = true;
122
+ }
123
+
124
+ if (curPunc == "(") pushContext(state, ")", stream.column());
125
+ else if (curPunc == "[") pushContext(state, "]", stream.column());
126
+ else if (curPunc == "{") pushContext(state, "}", stream.column());
127
+ else if (/[\]\}\)]/.test(curPunc)) {
128
+ while (state.context && state.context.type == "pattern") popContext(state);
129
+ if (state.context && curPunc == state.context.type) {
130
+ popContext(state);
131
+ if (curPunc == "}" && state.context && state.context.type == "pattern")
132
+ popContext(state);
133
+ }
134
+ }
135
+ else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state);
136
+ else if (/atom|string|variable/.test(style) && state.context) {
137
+ if (/[\}\]]/.test(state.context.type))
138
+ pushContext(state, "pattern", stream.column());
139
+ else if (state.context.type == "pattern" && !state.context.align) {
140
+ state.context.align = true;
141
+ state.context.col = stream.column();
142
+ }
143
+ }
144
+
145
+ return style;
146
+ },
147
+
148
+ indent: function(state, textAfter, cx) {
149
+ var firstChar = textAfter && textAfter.charAt(0);
150
+ var context = state.context;
151
+ if (/[\]\}]/.test(firstChar))
152
+ while (context && context.type == "pattern") context = context.prev;
153
+
154
+ var closing = context && firstChar == context.type;
155
+ if (!context)
156
+ return 0;
157
+ else if (context.type == "pattern")
158
+ return context.col;
159
+ else if (context.align)
160
+ return context.col + (closing ? 0 : 1);
161
+ else
162
+ return context.indent + (closing ? 0 : cx.unit);
163
+ },
164
+
165
+ languageData: {
166
+ commentTokens: {line: "#"}
167
+ }
168
+ };
169
+
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const spreadsheet: StreamParser<unknown>
@@ -0,0 +1,96 @@
1
+ export const spreadsheet = {
2
+ name: "spreadsheet",
3
+
4
+ startState: function () {
5
+ return {
6
+ stringType: null,
7
+ stack: []
8
+ };
9
+ },
10
+ token: function (stream, state) {
11
+ if (!stream) return;
12
+
13
+ //check for state changes
14
+ if (state.stack.length === 0) {
15
+ //strings
16
+ if ((stream.peek() == '"') || (stream.peek() == "'")) {
17
+ state.stringType = stream.peek();
18
+ stream.next(); // Skip quote
19
+ state.stack.unshift("string");
20
+ }
21
+ }
22
+
23
+ //return state
24
+ //stack has
25
+ switch (state.stack[0]) {
26
+ case "string":
27
+ while (state.stack[0] === "string" && !stream.eol()) {
28
+ if (stream.peek() === state.stringType) {
29
+ stream.next(); // Skip quote
30
+ state.stack.shift(); // Clear flag
31
+ } else if (stream.peek() === "\\") {
32
+ stream.next();
33
+ stream.next();
34
+ } else {
35
+ stream.match(/^.[^\\\"\']*/);
36
+ }
37
+ }
38
+ return "string";
39
+
40
+ case "characterClass":
41
+ while (state.stack[0] === "characterClass" && !stream.eol()) {
42
+ if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./)))
43
+ state.stack.shift();
44
+ }
45
+ return "operator";
46
+ }
47
+
48
+ var peek = stream.peek();
49
+
50
+ //no stack
51
+ switch (peek) {
52
+ case "[":
53
+ stream.next();
54
+ state.stack.unshift("characterClass");
55
+ return "bracket";
56
+ case ":":
57
+ stream.next();
58
+ return "operator";
59
+ case "\\":
60
+ if (stream.match(/\\[a-z]+/)) return "string.special";
61
+ else {
62
+ stream.next();
63
+ return "atom";
64
+ }
65
+ case ".":
66
+ case ",":
67
+ case ";":
68
+ case "*":
69
+ case "-":
70
+ case "+":
71
+ case "^":
72
+ case "<":
73
+ case "/":
74
+ case "=":
75
+ stream.next();
76
+ return "atom";
77
+ case "$":
78
+ stream.next();
79
+ return "builtin";
80
+ }
81
+
82
+ if (stream.match(/\d+/)) {
83
+ if (stream.match(/^\w+/)) return "error";
84
+ return "number";
85
+ } else if (stream.match(/^[a-zA-Z_]\w*/)) {
86
+ if (stream.match(/(?=[\(.])/, false)) return "keyword";
87
+ return "variable";
88
+ } else if (["[", "]", "(", ")", "{", "}"].indexOf(peek) != -1) {
89
+ stream.next();
90
+ return "bracket";
91
+ } else if (!stream.eatSpace()) {
92
+ stream.next();
93
+ }
94
+ return null;
95
+ }
96
+ };
package/mode/sql.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare function sql(conf: {
3
+ client?: {[word: string]: any},
4
+ atoms?: {[word: string]: any},
5
+ builtin?: {[word: string]: any},
6
+ keywords?: {[word: string]: any},
7
+ operatorChars?: RegExp,
8
+ support?: {[word: string]: any},
9
+ hooks?: {[hook: string]: any},
10
+ dateSQL?: {[word: string]: any},
11
+ backslashStringEscapes?: boolean,
12
+ brackets?: RegExp,
13
+ punctuation?: RegExp
14
+ }): StreamParser<unknown>
15
+ export declare const standardSQL: StreamParser<unknown>
16
+ export declare const msSQL: StreamParser<unknown>
17
+ export declare const mySQL: StreamParser<unknown>
18
+ export declare const mariaDB: StreamParser<unknown>
19
+ export declare const sqlite: StreamParser<unknown>
20
+ export declare const cassandra: StreamParser<unknown>
21
+ export declare const plSQL: StreamParser<unknown>
22
+ export declare const hive: StreamParser<unknown>
23
+ export declare const pgSQL: StreamParser<unknown>
24
+ export declare const gql: StreamParser<unknown>
25
+ export declare const gpSQL: StreamParser<unknown>
26
+ export declare const sparkSQL: StreamParser<unknown>
27
+ export declare const esper: StreamParser<unknown>