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

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 +143 -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
package/mode/fcl.js ADDED
@@ -0,0 +1,153 @@
1
+ var keywords = {
2
+ "term": true,
3
+ "method": true, "accu": true,
4
+ "rule": true, "then": true, "is": true, "and": true, "or": true,
5
+ "if": true, "default": true
6
+ };
7
+
8
+ var start_blocks = {
9
+ "var_input": true,
10
+ "var_output": true,
11
+ "fuzzify": true,
12
+ "defuzzify": true,
13
+ "function_block": true,
14
+ "ruleblock": true
15
+ };
16
+
17
+ var end_blocks = {
18
+ "end_ruleblock": true,
19
+ "end_defuzzify": true,
20
+ "end_function_block": true,
21
+ "end_fuzzify": true,
22
+ "end_var": true
23
+ };
24
+
25
+ var atoms = {
26
+ "true": true, "false": true, "nan": true,
27
+ "real": true, "min": true, "max": true, "cog": true, "cogs": true
28
+ };
29
+
30
+ var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
31
+
32
+ function tokenBase(stream, state) {
33
+ var ch = stream.next();
34
+
35
+ if (/[\d\.]/.test(ch)) {
36
+ if (ch == ".") {
37
+ stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
38
+ } else if (ch == "0") {
39
+ stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
40
+ } else {
41
+ stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
42
+ }
43
+ return "number";
44
+ }
45
+
46
+ if (ch == "/" || ch == "(") {
47
+ if (stream.eat("*")) {
48
+ state.tokenize = tokenComment;
49
+ return tokenComment(stream, state);
50
+ }
51
+ if (stream.eat("/")) {
52
+ stream.skipToEnd();
53
+ return "comment";
54
+ }
55
+ }
56
+ if (isOperatorChar.test(ch)) {
57
+ stream.eatWhile(isOperatorChar);
58
+ return "operator";
59
+ }
60
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
61
+
62
+ var cur = stream.current().toLowerCase();
63
+ if (keywords.propertyIsEnumerable(cur) ||
64
+ start_blocks.propertyIsEnumerable(cur) ||
65
+ end_blocks.propertyIsEnumerable(cur)) {
66
+ return "keyword";
67
+ }
68
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
69
+ return "variable";
70
+ }
71
+
72
+
73
+ function tokenComment(stream, state) {
74
+ var maybeEnd = false, ch;
75
+ while (ch = stream.next()) {
76
+ if ((ch == "/" || ch == ")") && maybeEnd) {
77
+ state.tokenize = tokenBase;
78
+ break;
79
+ }
80
+ maybeEnd = (ch == "*");
81
+ }
82
+ return "comment";
83
+ }
84
+
85
+ function Context(indented, column, type, align, prev) {
86
+ this.indented = indented;
87
+ this.column = column;
88
+ this.type = type;
89
+ this.align = align;
90
+ this.prev = prev;
91
+ }
92
+
93
+ function pushContext(state, col, type) {
94
+ return state.context = new Context(state.indented, col, type, null, state.context);
95
+ }
96
+
97
+ function popContext(state) {
98
+ if (!state.context.prev) return;
99
+ var t = state.context.type;
100
+ if (t == "end_block")
101
+ state.indented = state.context.indented;
102
+ return state.context = state.context.prev;
103
+ }
104
+
105
+ // Interface
106
+
107
+ export const fcl = {
108
+ name: "fcl",
109
+ startState: function(indentUnit) {
110
+ return {
111
+ tokenize: null,
112
+ context: new Context(-indentUnit, 0, "top", false),
113
+ indented: 0,
114
+ startOfLine: true
115
+ };
116
+ },
117
+
118
+ token: function(stream, state) {
119
+ var ctx = state.context;
120
+ if (stream.sol()) {
121
+ if (ctx.align == null) ctx.align = false;
122
+ state.indented = stream.indentation();
123
+ state.startOfLine = true;
124
+ }
125
+ if (stream.eatSpace()) return null;
126
+
127
+ var style = (state.tokenize || tokenBase)(stream, state);
128
+ if (style == "comment") return style;
129
+ if (ctx.align == null) ctx.align = true;
130
+
131
+ var cur = stream.current().toLowerCase();
132
+
133
+ if (start_blocks.propertyIsEnumerable(cur)) pushContext(state, stream.column(), "end_block");
134
+ else if (end_blocks.propertyIsEnumerable(cur)) popContext(state);
135
+
136
+ state.startOfLine = false;
137
+ return style;
138
+ },
139
+
140
+ indent: function(state, textAfter, cx) {
141
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
142
+ var ctx = state.context;
143
+
144
+ var closing = end_blocks.propertyIsEnumerable(textAfter);
145
+ if (ctx.align) return ctx.column + (closing ? 0 : 1);
146
+ else return ctx.indented + (closing ? 0 : cx.unit);
147
+ },
148
+
149
+ languageData: {
150
+ commentTokens: {line: "//", block: {open: "(*", close: "*)"}}
151
+ }
152
+ };
153
+
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const forth: StreamParser<unknown>
package/mode/forth.js ADDED
@@ -0,0 +1,162 @@
1
+ function toWordList(words) {
2
+ var ret = [];
3
+ words.split(' ').forEach(function(e){
4
+ ret.push({name: e});
5
+ });
6
+ return ret;
7
+ }
8
+
9
+ var coreWordList = toWordList(
10
+ 'INVERT AND OR XOR\
11
+ 2* 2/ LSHIFT RSHIFT\
12
+ 0= = 0< < > U< MIN MAX\
13
+ 2DROP 2DUP 2OVER 2SWAP ?DUP DEPTH DROP DUP OVER ROT SWAP\
14
+ >R R> R@\
15
+ + - 1+ 1- ABS NEGATE\
16
+ S>D * M* UM*\
17
+ FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD\
18
+ HERE , @ ! CELL+ CELLS C, C@ C! CHARS 2@ 2!\
19
+ ALIGN ALIGNED +! ALLOT\
20
+ CHAR [CHAR] [ ] BL\
21
+ FIND EXECUTE IMMEDIATE COUNT LITERAL STATE\
22
+ ; DOES> >BODY\
23
+ EVALUATE\
24
+ SOURCE >IN\
25
+ <# # #S #> HOLD SIGN BASE >NUMBER HEX DECIMAL\
26
+ FILL MOVE\
27
+ . CR EMIT SPACE SPACES TYPE U. .R U.R\
28
+ ACCEPT\
29
+ TRUE FALSE\
30
+ <> U> 0<> 0>\
31
+ NIP TUCK ROLL PICK\
32
+ 2>R 2R@ 2R>\
33
+ WITHIN UNUSED MARKER\
34
+ I J\
35
+ TO\
36
+ COMPILE, [COMPILE]\
37
+ SAVE-INPUT RESTORE-INPUT\
38
+ PAD ERASE\
39
+ 2LITERAL DNEGATE\
40
+ D- D+ D0< D0= D2* D2/ D< D= DMAX DMIN D>S DABS\
41
+ M+ M*/ D. D.R 2ROT DU<\
42
+ CATCH THROW\
43
+ FREE RESIZE ALLOCATE\
44
+ CS-PICK CS-ROLL\
45
+ GET-CURRENT SET-CURRENT FORTH-WORDLIST GET-ORDER SET-ORDER\
46
+ PREVIOUS SEARCH-WORDLIST WORDLIST FIND ALSO ONLY FORTH DEFINITIONS ORDER\
47
+ -TRAILING /STRING SEARCH COMPARE CMOVE CMOVE> BLANK SLITERAL');
48
+
49
+ var immediateWordList = toWordList('IF ELSE THEN BEGIN WHILE REPEAT UNTIL RECURSE [IF] [ELSE] [THEN] ?DO DO LOOP +LOOP UNLOOP LEAVE EXIT AGAIN CASE OF ENDOF ENDCASE');
50
+
51
+ function searchWordList (wordList, word) {
52
+ var i;
53
+ for (i = wordList.length - 1; i >= 0; i--) {
54
+ if (wordList[i].name === word.toUpperCase()) {
55
+ return wordList[i];
56
+ }
57
+ }
58
+ return undefined;
59
+ }
60
+ export const forth = {
61
+ name: "forth",
62
+ startState: function() {
63
+ return {
64
+ state: '',
65
+ base: 10,
66
+ coreWordList: coreWordList,
67
+ immediateWordList: immediateWordList,
68
+ wordList: []
69
+ };
70
+ },
71
+ token: function (stream, stt) {
72
+ var mat;
73
+ if (stream.eatSpace()) {
74
+ return null;
75
+ }
76
+ if (stt.state === '') { // interpretation
77
+ if (stream.match(/^(\]|:NONAME)(\s|$)/i)) {
78
+ stt.state = ' compilation';
79
+ return 'builtin';
80
+ }
81
+ mat = stream.match(/^(\:)\s+(\S+)(\s|$)+/);
82
+ if (mat) {
83
+ stt.wordList.push({name: mat[2].toUpperCase()});
84
+ stt.state = ' compilation';
85
+ return 'def';
86
+ }
87
+ mat = stream.match(/^(VARIABLE|2VARIABLE|CONSTANT|2CONSTANT|CREATE|POSTPONE|VALUE|WORD)\s+(\S+)(\s|$)+/i);
88
+ if (mat) {
89
+ stt.wordList.push({name: mat[2].toUpperCase()});
90
+ return 'def';
91
+ }
92
+ mat = stream.match(/^(\'|\[\'\])\s+(\S+)(\s|$)+/);
93
+ if (mat) {
94
+ return 'builtin'
95
+ }
96
+ } else { // compilation
97
+ // ; [
98
+ if (stream.match(/^(\;|\[)(\s)/)) {
99
+ stt.state = '';
100
+ stream.backUp(1);
101
+ return 'builtin';
102
+ }
103
+ if (stream.match(/^(\;|\[)($)/)) {
104
+ stt.state = '';
105
+ return 'builtin';
106
+ }
107
+ if (stream.match(/^(POSTPONE)\s+\S+(\s|$)+/)) {
108
+ return 'builtin';
109
+ }
110
+ }
111
+
112
+ // dynamic wordlist
113
+ mat = stream.match(/^(\S+)(\s+|$)/);
114
+ if (mat) {
115
+ if (searchWordList(stt.wordList, mat[1]) !== undefined) {
116
+ return 'variable';
117
+ }
118
+
119
+ // comments
120
+ if (mat[1] === '\\') {
121
+ stream.skipToEnd();
122
+ return 'comment';
123
+ }
124
+
125
+ // core words
126
+ if (searchWordList(stt.coreWordList, mat[1]) !== undefined) {
127
+ return 'builtin';
128
+ }
129
+ if (searchWordList(stt.immediateWordList, mat[1]) !== undefined) {
130
+ return 'keyword';
131
+ }
132
+
133
+ if (mat[1] === '(') {
134
+ stream.eatWhile(function (s) { return s !== ')'; });
135
+ stream.eat(')');
136
+ return 'comment';
137
+ }
138
+
139
+ // // strings
140
+ if (mat[1] === '.(') {
141
+ stream.eatWhile(function (s) { return s !== ')'; });
142
+ stream.eat(')');
143
+ return 'string';
144
+ }
145
+ if (mat[1] === 'S"' || mat[1] === '."' || mat[1] === 'C"') {
146
+ stream.eatWhile(function (s) { return s !== '"'; });
147
+ stream.eat('"');
148
+ return 'string';
149
+ }
150
+
151
+ // numbers
152
+ if (mat[1] - 0xfffffffff) {
153
+ return 'number';
154
+ }
155
+ // if (mat[1].match(/^[-+]?[0-9]+\.[0-9]*/)) {
156
+ // return 'number';
157
+ // }
158
+
159
+ return 'atom';
160
+ }
161
+ }
162
+ };
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const fortran: StreamParser<unknown>
@@ -0,0 +1,171 @@
1
+ function words(array) {
2
+ var keys = {};
3
+ for (var i = 0; i < array.length; ++i) {
4
+ keys[array[i]] = true;
5
+ }
6
+ return keys;
7
+ }
8
+
9
+ var keywords = words([
10
+ "abstract", "accept", "allocatable", "allocate",
11
+ "array", "assign", "asynchronous", "backspace",
12
+ "bind", "block", "byte", "call", "case",
13
+ "class", "close", "common", "contains",
14
+ "continue", "cycle", "data", "deallocate",
15
+ "decode", "deferred", "dimension", "do",
16
+ "elemental", "else", "encode", "end",
17
+ "endif", "entry", "enumerator", "equivalence",
18
+ "exit", "external", "extrinsic", "final",
19
+ "forall", "format", "function", "generic",
20
+ "go", "goto", "if", "implicit", "import", "include",
21
+ "inquire", "intent", "interface", "intrinsic",
22
+ "module", "namelist", "non_intrinsic",
23
+ "non_overridable", "none", "nopass",
24
+ "nullify", "open", "optional", "options",
25
+ "parameter", "pass", "pause", "pointer",
26
+ "print", "private", "program", "protected",
27
+ "public", "pure", "read", "recursive", "result",
28
+ "return", "rewind", "save", "select", "sequence",
29
+ "stop", "subroutine", "target", "then", "to", "type",
30
+ "use", "value", "volatile", "where", "while",
31
+ "write"]);
32
+ var builtins = words(["abort", "abs", "access", "achar", "acos",
33
+ "adjustl", "adjustr", "aimag", "aint", "alarm",
34
+ "all", "allocated", "alog", "amax", "amin",
35
+ "amod", "and", "anint", "any", "asin",
36
+ "associated", "atan", "besj", "besjn", "besy",
37
+ "besyn", "bit_size", "btest", "cabs", "ccos",
38
+ "ceiling", "cexp", "char", "chdir", "chmod",
39
+ "clog", "cmplx", "command_argument_count",
40
+ "complex", "conjg", "cos", "cosh", "count",
41
+ "cpu_time", "cshift", "csin", "csqrt", "ctime",
42
+ "c_funloc", "c_loc", "c_associated", "c_null_ptr",
43
+ "c_null_funptr", "c_f_pointer", "c_null_char",
44
+ "c_alert", "c_backspace", "c_form_feed",
45
+ "c_new_line", "c_carriage_return",
46
+ "c_horizontal_tab", "c_vertical_tab", "dabs",
47
+ "dacos", "dasin", "datan", "date_and_time",
48
+ "dbesj", "dbesj", "dbesjn", "dbesy", "dbesy",
49
+ "dbesyn", "dble", "dcos", "dcosh", "ddim", "derf",
50
+ "derfc", "dexp", "digits", "dim", "dint", "dlog",
51
+ "dlog", "dmax", "dmin", "dmod", "dnint",
52
+ "dot_product", "dprod", "dsign", "dsinh",
53
+ "dsin", "dsqrt", "dtanh", "dtan", "dtime",
54
+ "eoshift", "epsilon", "erf", "erfc", "etime",
55
+ "exit", "exp", "exponent", "extends_type_of",
56
+ "fdate", "fget", "fgetc", "float", "floor",
57
+ "flush", "fnum", "fputc", "fput", "fraction",
58
+ "fseek", "fstat", "ftell", "gerror", "getarg",
59
+ "get_command", "get_command_argument",
60
+ "get_environment_variable", "getcwd",
61
+ "getenv", "getgid", "getlog", "getpid",
62
+ "getuid", "gmtime", "hostnm", "huge", "iabs",
63
+ "iachar", "iand", "iargc", "ibclr", "ibits",
64
+ "ibset", "ichar", "idate", "idim", "idint",
65
+ "idnint", "ieor", "ierrno", "ifix", "imag",
66
+ "imagpart", "index", "int", "ior", "irand",
67
+ "isatty", "ishft", "ishftc", "isign",
68
+ "iso_c_binding", "is_iostat_end", "is_iostat_eor",
69
+ "itime", "kill", "kind", "lbound", "len", "len_trim",
70
+ "lge", "lgt", "link", "lle", "llt", "lnblnk", "loc",
71
+ "log", "logical", "long", "lshift", "lstat", "ltime",
72
+ "matmul", "max", "maxexponent", "maxloc", "maxval",
73
+ "mclock", "merge", "move_alloc", "min", "minexponent",
74
+ "minloc", "minval", "mod", "modulo", "mvbits",
75
+ "nearest", "new_line", "nint", "not", "or", "pack",
76
+ "perror", "precision", "present", "product", "radix",
77
+ "rand", "random_number", "random_seed", "range",
78
+ "real", "realpart", "rename", "repeat", "reshape",
79
+ "rrspacing", "rshift", "same_type_as", "scale",
80
+ "scan", "second", "selected_int_kind",
81
+ "selected_real_kind", "set_exponent", "shape",
82
+ "short", "sign", "signal", "sinh", "sin", "sleep",
83
+ "sngl", "spacing", "spread", "sqrt", "srand", "stat",
84
+ "sum", "symlnk", "system", "system_clock", "tan",
85
+ "tanh", "time", "tiny", "transfer", "transpose",
86
+ "trim", "ttynam", "ubound", "umask", "unlink",
87
+ "unpack", "verify", "xor", "zabs", "zcos", "zexp",
88
+ "zlog", "zsin", "zsqrt"]);
89
+
90
+ var dataTypes = words(["c_bool", "c_char", "c_double", "c_double_complex",
91
+ "c_float", "c_float_complex", "c_funptr", "c_int",
92
+ "c_int16_t", "c_int32_t", "c_int64_t", "c_int8_t",
93
+ "c_int_fast16_t", "c_int_fast32_t", "c_int_fast64_t",
94
+ "c_int_fast8_t", "c_int_least16_t", "c_int_least32_t",
95
+ "c_int_least64_t", "c_int_least8_t", "c_intmax_t",
96
+ "c_intptr_t", "c_long", "c_long_double",
97
+ "c_long_double_complex", "c_long_long", "c_ptr",
98
+ "c_short", "c_signed_char", "c_size_t", "character",
99
+ "complex", "double", "integer", "logical", "real"]);
100
+ var isOperatorChar = /[+\-*&=<>\/\:]/;
101
+ var litOperator = /^\.(and|or|eq|lt|le|gt|ge|ne|not|eqv|neqv)\./i;
102
+
103
+ function tokenBase(stream, state) {
104
+
105
+ if (stream.match(litOperator)){
106
+ return 'operator';
107
+ }
108
+
109
+ var ch = stream.next();
110
+ if (ch == "!") {
111
+ stream.skipToEnd();
112
+ return "comment";
113
+ }
114
+ if (ch == '"' || ch == "'") {
115
+ state.tokenize = tokenString(ch);
116
+ return state.tokenize(stream, state);
117
+ }
118
+ if (/[\[\]\(\),]/.test(ch)) {
119
+ return null;
120
+ }
121
+ if (/\d/.test(ch)) {
122
+ stream.eatWhile(/[\w\.]/);
123
+ return "number";
124
+ }
125
+ if (isOperatorChar.test(ch)) {
126
+ stream.eatWhile(isOperatorChar);
127
+ return "operator";
128
+ }
129
+ stream.eatWhile(/[\w\$_]/);
130
+ var word = stream.current().toLowerCase();
131
+
132
+ if (keywords.hasOwnProperty(word)){
133
+ return 'keyword';
134
+ }
135
+ if (builtins.hasOwnProperty(word) || dataTypes.hasOwnProperty(word)) {
136
+ return 'builtin';
137
+ }
138
+ return "variable";
139
+ }
140
+
141
+ function tokenString(quote) {
142
+ return function(stream, state) {
143
+ var escaped = false, next, end = false;
144
+ while ((next = stream.next()) != null) {
145
+ if (next == quote && !escaped) {
146
+ end = true;
147
+ break;
148
+ }
149
+ escaped = !escaped && next == "\\";
150
+ }
151
+ if (end || !escaped) state.tokenize = null;
152
+ return "string";
153
+ };
154
+ }
155
+
156
+ // Interface
157
+
158
+ export const fortran = {
159
+ name: "fortran",
160
+ startState: function() {
161
+ return {tokenize: null};
162
+ },
163
+
164
+ token: function(stream, state) {
165
+ if (stream.eatSpace()) return null;
166
+ var style = (state.tokenize || tokenBase)(stream, state);
167
+ if (style == "comment" || style == "meta") return style;
168
+ return style;
169
+ }
170
+ };
171
+
package/mode/gas.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const gas: StreamParser<unknown>
3
+ export declare const gasArm: StreamParser<unknown>