@aleph-alpha/chat-kit 5.13.0 → 6.1.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 (199) hide show
  1. package/dist/{CkHistory.vue_vue_type_script_setup_true_lang-BNcJURkq.js → CkHistory.vue_vue_type_script_setup_true_lang-Cr8vF94e.js} +221 -115
  2. package/dist/adapters/responses-api.d.ts +1 -1
  3. package/dist/adapters/responses-api.d.ts.map +1 -1
  4. package/dist/adapters/responses-api.js +9 -7
  5. package/dist/apl-fqmucPXA.js +140 -0
  6. package/dist/asciiarmor-DucZyvP0.js +56 -0
  7. package/dist/asn1-BnOEsgAm.js +144 -0
  8. package/dist/asterisk-QAlztEwS.js +345 -0
  9. package/dist/brainfuck-DZVCuF_t.js +53 -0
  10. package/dist/chat-kit.css +1177 -12
  11. package/dist/clike-CTYGlS6x.js +799 -0
  12. package/dist/clojure-BhXMqnxz.js +849 -0
  13. package/dist/cmake-BGaNd9E7.js +71 -0
  14. package/dist/cobol-4yqQntpt.js +120 -0
  15. package/dist/coffeescript-D2dXvhEc.js +308 -0
  16. package/dist/commonlisp-CF_VNHQR.js +130 -0
  17. package/dist/components/base/CkHistoryItem/CkHistoryItem.vue.d.ts.map +1 -1
  18. package/dist/components/base/CkHistoryWrapper/CkHistoryWrapper.vue.d.ts.map +1 -1
  19. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts.map +1 -1
  20. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.stories.d.ts +41 -0
  21. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.stories.d.ts.map +1 -0
  22. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.vue.d.ts +26 -0
  23. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.vue.d.ts.map +1 -0
  24. package/dist/components/base/CkMilkdownEditor/codeMirrorTheme.d.ts +20 -0
  25. package/dist/components/base/CkMilkdownEditor/codeMirrorTheme.d.ts.map +1 -0
  26. package/dist/components/base/CkMilkdownEditor/createCrepeEditor.d.ts +42 -0
  27. package/dist/components/base/CkMilkdownEditor/createCrepeEditor.d.ts.map +1 -0
  28. package/dist/components/base/CkMilkdownEditor/crepeIcons.d.ts +33 -0
  29. package/dist/components/base/CkMilkdownEditor/crepeIcons.d.ts.map +1 -0
  30. package/dist/components/base/CkMilkdownEditor/index.d.ts +3 -0
  31. package/dist/components/base/CkMilkdownEditor/index.d.ts.map +1 -0
  32. package/dist/components/base/CkMilkdownEditor/markdownClassAttrs.d.ts +16 -0
  33. package/dist/components/base/CkMilkdownEditor/markdownClassAttrs.d.ts.map +1 -0
  34. package/dist/components/base/CkMilkdownEditor/types.d.ts +98 -0
  35. package/dist/components/base/CkMilkdownEditor/types.d.ts.map +1 -0
  36. package/dist/components/base/index.d.ts +2 -0
  37. package/dist/components/base/index.d.ts.map +1 -1
  38. package/dist/components/index.d.ts +2 -2
  39. package/dist/components/index.d.ts.map +1 -1
  40. package/dist/components/index.js +12 -11
  41. package/dist/composables/fileUpload/useFileUpload.d.ts.map +1 -1
  42. package/dist/composables/index.js +1 -1
  43. package/dist/composables/useChat.d.ts.map +1 -1
  44. package/dist/composables/useConversations.d.ts.map +1 -1
  45. package/dist/createCrepeEditor-CFbvSH3s.js +74141 -0
  46. package/dist/crystal-DyuLTqLs.js +398 -0
  47. package/dist/css-DkSyTW67.js +1772 -0
  48. package/dist/cypher-Dlu_3r4V.js +121 -0
  49. package/dist/d-UURgV0Ux.js +179 -0
  50. package/dist/diff-B_Bi2Crb.js +25 -0
  51. package/dist/dockerfile-Bvk733Ga.js +201 -0
  52. package/dist/dtd-Dy74G54E.js +114 -0
  53. package/dist/dylan-TSb-Nfix.js +314 -0
  54. package/dist/ebnf-4fKAGW3a.js +140 -0
  55. package/dist/ecl-B59qGGVg.js +178 -0
  56. package/dist/eiffel-Dze7nlu3.js +134 -0
  57. package/dist/elm-DG7jkhNZ.js +176 -0
  58. package/dist/erlang-BO6gOnGA.js +674 -0
  59. package/dist/factor-CMxFHDqz.js +65 -0
  60. package/dist/fcl-CDDUNjTj.js +141 -0
  61. package/dist/forth-B9D2JCeE.js +116 -0
  62. package/dist/fortran-CAG2BFbe.js +467 -0
  63. package/dist/gas-0Aw8zDr5.js +293 -0
  64. package/dist/gherkin-DhZlEZiy.js +115 -0
  65. package/dist/groovy-CpwJiBl7.js +223 -0
  66. package/dist/handlers/index.js +1 -1
  67. package/dist/handlers/useChatKitLabels.d.ts +62 -1
  68. package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
  69. package/dist/haskell-ySd-OUo8.js +459 -0
  70. package/dist/haxe-7MlzfeYV.js +514 -0
  71. package/dist/http-BqypyemW.js +79 -0
  72. package/dist/idl-4HIGJlDI.js +985 -0
  73. package/dist/index-A5rWjRtZ.js +689 -0
  74. package/dist/index-B0ldhzaj.js +385 -0
  75. package/dist/index-BVOjyn3y.js +2490 -0
  76. package/dist/index-BWvkps_G.js +309 -0
  77. package/dist/index-BaS8OW8V.js +151 -0
  78. package/dist/index-BlHHEbV-.js +406 -0
  79. package/dist/index-BoqzHVNB.js +82 -0
  80. package/dist/index-C6zYjwIQ.js +704 -0
  81. package/dist/{index-Dn4ctxk8.js → index-C72e57-5.js} +48 -24
  82. package/dist/index-CMJGuXap.js +330 -0
  83. package/dist/index-CRfGWVdQ.js +116 -0
  84. package/dist/index-C_gTb50u.js +81 -0
  85. package/dist/index-DSU7cBGz.js +178 -0
  86. package/dist/index-DSq3gvqU.js +1767 -0
  87. package/dist/index-Da3777l2.js +289 -0
  88. package/dist/index-DdlzabmR.js +1021 -0
  89. package/dist/index-DhY_9bdS.js +61 -0
  90. package/dist/index-Dm6C1blN.js +1052 -0
  91. package/dist/index-Tj3pzx-E.js +327 -0
  92. package/dist/index-ZeRS5rER.js +97 -0
  93. package/dist/index-gzleljO6.js +157 -0
  94. package/dist/index-naWlQpaL.js +642 -0
  95. package/dist/index-sKO1lHHC.js +312 -0
  96. package/dist/index.d.ts +2 -2
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +15 -14
  99. package/dist/javascript-Bt8B7yTi.js +992 -0
  100. package/dist/julia-Bs6JJhYG.js +407 -0
  101. package/dist/livescript-DmzgM3Yt.js +296 -0
  102. package/dist/lua-Cvg8VrAA.js +256 -0
  103. package/dist/mathematica-DNLOL9PQ.js +110 -0
  104. package/dist/mbox-Ga7d4MMN.js +117 -0
  105. package/dist/mirc-Dma3B8rS.js +107 -0
  106. package/dist/mllike-DHn7xckP.js +334 -0
  107. package/dist/modelica-0d55jYY0.js +147 -0
  108. package/dist/mscgen-DdqZYINH.js +135 -0
  109. package/dist/mumps-Btr8VblO.js +93 -0
  110. package/dist/nginx-DTDtBDVN.js +141 -0
  111. package/dist/nsis-CyKBdPWp.js +62 -0
  112. package/dist/ntriples-CvgOYMpL.js +153 -0
  113. package/dist/octave-DYBj3-tl.js +200 -0
  114. package/dist/oz-R_e8WMIi.js +231 -0
  115. package/dist/pascal-GD8iposT.js +105 -0
  116. package/dist/perl-DL9mHpoi.js +1105 -0
  117. package/dist/pig-C_4T4YIV.js +101 -0
  118. package/dist/powershell-B0suO7Vd.js +328 -0
  119. package/dist/properties-BR-vP1aU.js +58 -0
  120. package/dist/protobuf-BxgpyhoW.js +77 -0
  121. package/dist/pug-vHnWR0UE.js +405 -0
  122. package/dist/puppet-Bdao66PW.js +137 -0
  123. package/dist/python-BFGRmuZ9.js +426 -0
  124. package/dist/q-CrbCVq4a.js +131 -0
  125. package/dist/r-V7nswm59.js +170 -0
  126. package/dist/rpm-C-DLY-If.js +109 -0
  127. package/dist/ruby-CQTpZw6f.js +331 -0
  128. package/dist/sas-D2UG-yhZ.js +207 -0
  129. package/dist/scheme-BKzrkGJD.js +222 -0
  130. package/dist/shell-BlsXDxCn.js +222 -0
  131. package/dist/sieve-CjwBwOY5.js +135 -0
  132. package/dist/simple-mode-DMneyfDu.js +130 -0
  133. package/dist/smalltalk-BOIGQuhN.js +121 -0
  134. package/dist/solr-CwD7U71z.js +69 -0
  135. package/dist/sparql-DYskk2vE.js +249 -0
  136. package/dist/spreadsheet-Bgtt3oLP.js +87 -0
  137. package/dist/sql-Cei9CMfk.js +342 -0
  138. package/dist/stex-C1nZSzAw.js +230 -0
  139. package/dist/stylus-BkS-boTH.js +565 -0
  140. package/dist/swift-FRZi1uvB.js +291 -0
  141. package/dist/tcl-CUcaCdmq.js +114 -0
  142. package/dist/test-utils/createTextPlugin.d.ts +7 -1
  143. package/dist/test-utils/createTextPlugin.d.ts.map +1 -1
  144. package/dist/textile-BnFpjsrl.js +414 -0
  145. package/dist/tiddlywiki-CjprD-Qp.js +218 -0
  146. package/dist/tiki-DK9DOeWn.js +268 -0
  147. package/dist/toml-BOuWGMcf.js +76 -0
  148. package/dist/troff-E1bJ0PPL.js +61 -0
  149. package/dist/ttcn-cfg-Dc39-fIP.js +133 -0
  150. package/dist/ttcn-tKd4HLu4.js +192 -0
  151. package/dist/turtle-Dq7-1WAf.js +124 -0
  152. package/dist/{useChatKitLabels-CMOr3Kjq.js → useChatKitLabels-Ww1Q7xUr.js} +26 -3
  153. package/dist/vb-Dp90gtsv.js +196 -0
  154. package/dist/vbscript-Bfn8O8I7.js +478 -0
  155. package/dist/velocity-BwIZK1TH.js +149 -0
  156. package/dist/verilog-CnT9bMk0.js +429 -0
  157. package/dist/vhdl-DCkMIyT9.js +158 -0
  158. package/dist/webidl-BTLTThCm.js +204 -0
  159. package/dist/xquery-BrBUuxMR.js +525 -0
  160. package/dist/yacas-b5lAVEIl.js +130 -0
  161. package/dist/z80-ClgwfNdB.js +92 -0
  162. package/package.json +11 -5
  163. package/src/adapters/responses-api.spec.ts +86 -0
  164. package/src/adapters/responses-api.ts +13 -9
  165. package/src/components/base/CkCitationCard/CkCitationCard.vue +1 -1
  166. package/src/components/base/CkCitationLabel/CkCitationLabel.vue +1 -1
  167. package/src/components/base/CkConversationLayout/CkConversationLayout.spec.ts +1 -5
  168. package/src/components/base/CkCopyMessageButton/CkCopyMessageButton.spec.ts +1 -1
  169. package/src/components/base/CkFeedbackButton/CkFeedbackButton.vue +3 -3
  170. package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.vue +9 -9
  171. package/src/components/base/CkHistoryItem/CkHistoryItem.vue +5 -7
  172. package/src/components/base/CkHistoryWrapper/CkHistoryWrapper.vue +2 -1
  173. package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.ts +9 -4
  174. package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue +1 -1
  175. package/src/components/base/CkMilkdownEditor/CkMilkdownEditor.spec.ts +221 -0
  176. package/src/components/base/CkMilkdownEditor/CkMilkdownEditor.stories.ts +274 -0
  177. package/src/components/base/CkMilkdownEditor/CkMilkdownEditor.vue +151 -0
  178. package/src/components/base/CkMilkdownEditor/codeMirrorTheme.ts +132 -0
  179. package/src/components/base/CkMilkdownEditor/createCrepeEditor.ts +192 -0
  180. package/src/components/base/CkMilkdownEditor/crepeIcons.ts +77 -0
  181. package/src/components/base/CkMilkdownEditor/index.ts +2 -0
  182. package/src/components/base/CkMilkdownEditor/markdownClassAttrs.ts +64 -0
  183. package/src/components/base/CkMilkdownEditor/milkdown-theme.css +441 -0
  184. package/src/components/base/CkMilkdownEditor/types.ts +100 -0
  185. package/src/components/base/CkModelSelector/CkModelSelector.vue +3 -3
  186. package/src/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.stories.ts +2 -2
  187. package/src/components/base/index.ts +6 -0
  188. package/src/components/index.ts +4 -0
  189. package/src/composables/fileUpload/useFileUpload.ts +45 -30
  190. package/src/composables/fileUpload/useFileUploadWrapper.spec.ts +1 -1
  191. package/src/composables/fileUpload/useFileUploadWrapper.ts +3 -3
  192. package/src/composables/useChat.ts +3 -1
  193. package/src/composables/useConversations.ts +8 -5
  194. package/src/handlers/useChatKitLabels.spec.ts +0 -1
  195. package/src/handlers/useChatKitLabels.ts +29 -2
  196. package/src/handlers/useMarkdownParser.ts +1 -1
  197. package/src/index.ts +4 -0
  198. package/src/test-setup.ts +3 -3
  199. package/src/test-utils/createTextPlugin.ts +11 -3
@@ -0,0 +1,65 @@
1
+ import { s as simpleMode } from "./simple-mode-DMneyfDu.js";
2
+ const factor = simpleMode({
3
+ start: [
4
+ // comments
5
+ { regex: /#?!.*/, token: "comment" },
6
+ // strings """, multiline --> state
7
+ { regex: /"""/, token: "string", next: "string3" },
8
+ { regex: /(STRING:)(\s)/, token: ["keyword", null], next: "string2" },
9
+ { regex: /\S*?"/, token: "string", next: "string" },
10
+ // numbers: dec, hex, unicode, bin, fractional, complex
11
+ { regex: /(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\-?\d+.?\d*)(?=\s)/, token: "number" },
12
+ //{regex: /[+-]?/} //fractional
13
+ // definition: defining word, defined word, etc
14
+ { regex: /((?:GENERIC)|\:?\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "bracket"], next: "stack" },
15
+ // method definition: defining word, type, defined word, etc
16
+ { regex: /(M\:)(\s+)(\S+)(\s+)(\S+)/, token: ["keyword", null, "def", null, "tag"] },
17
+ // vocabulary using --> state
18
+ { regex: /USING\:/, token: "keyword", next: "vocabulary" },
19
+ // vocabulary definition/use
20
+ { regex: /(USE\:|IN\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "tag"] },
21
+ // definition: a defining word, defined word
22
+ { regex: /(\S+\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "def"] },
23
+ // "keywords", incl. ; t f . [ ] { } defining words
24
+ { regex: /(?:;|\\|t|f|if|loop|while|until|do|PRIVATE>|<PRIVATE|\.|\S*\[|\]|\S*\{|\})(?=\s|$)/, token: "keyword" },
25
+ // <constructors> and the like
26
+ { regex: /\S+[\)>\.\*\?]+(?=\s|$)/, token: "builtin" },
27
+ { regex: /[\)><]+\S+(?=\s|$)/, token: "builtin" },
28
+ // operators
29
+ { regex: /(?:[\+\-\=\/\*<>])(?=\s|$)/, token: "keyword" },
30
+ // any id (?)
31
+ { regex: /\S+/, token: "variable" },
32
+ { regex: /\s+|./, token: null }
33
+ ],
34
+ vocabulary: [
35
+ { regex: /;/, token: "keyword", next: "start" },
36
+ { regex: /\S+/, token: "tag" },
37
+ { regex: /\s+|./, token: null }
38
+ ],
39
+ string: [
40
+ { regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start" },
41
+ { regex: /.*/, token: "string" }
42
+ ],
43
+ string2: [
44
+ { regex: /^;/, token: "keyword", next: "start" },
45
+ { regex: /.*/, token: "string" }
46
+ ],
47
+ string3: [
48
+ { regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start" },
49
+ { regex: /.*/, token: "string" }
50
+ ],
51
+ stack: [
52
+ { regex: /\)/, token: "bracket", next: "start" },
53
+ { regex: /--/, token: "bracket" },
54
+ { regex: /\S+/, token: "meta" },
55
+ { regex: /\s+|./, token: null }
56
+ ],
57
+ languageData: {
58
+ name: "factor",
59
+ dontIndentStates: ["start", "vocabulary", "string", "string3", "stack"],
60
+ commentTokens: { line: "!" }
61
+ }
62
+ });
63
+ export {
64
+ factor
65
+ };
@@ -0,0 +1,141 @@
1
+ var keywords = {
2
+ "term": true,
3
+ "method": true,
4
+ "accu": true,
5
+ "rule": true,
6
+ "then": true,
7
+ "is": true,
8
+ "and": true,
9
+ "or": true,
10
+ "if": true,
11
+ "default": true
12
+ };
13
+ var start_blocks = {
14
+ "var_input": true,
15
+ "var_output": true,
16
+ "fuzzify": true,
17
+ "defuzzify": true,
18
+ "function_block": true,
19
+ "ruleblock": true
20
+ };
21
+ var end_blocks = {
22
+ "end_ruleblock": true,
23
+ "end_defuzzify": true,
24
+ "end_function_block": true,
25
+ "end_fuzzify": true,
26
+ "end_var": true
27
+ };
28
+ var atoms = {
29
+ "true": true,
30
+ "false": true,
31
+ "nan": true,
32
+ "real": true,
33
+ "min": true,
34
+ "max": true,
35
+ "cog": true,
36
+ "cogs": true
37
+ };
38
+ var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
39
+ function tokenBase(stream, state) {
40
+ var ch = stream.next();
41
+ if (/[\d\.]/.test(ch)) {
42
+ if (ch == ".") {
43
+ stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
44
+ } else if (ch == "0") {
45
+ stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
46
+ } else {
47
+ stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
48
+ }
49
+ return "number";
50
+ }
51
+ if (ch == "/" || ch == "(") {
52
+ if (stream.eat("*")) {
53
+ state.tokenize = tokenComment;
54
+ return tokenComment(stream, state);
55
+ }
56
+ if (stream.eat("/")) {
57
+ stream.skipToEnd();
58
+ return "comment";
59
+ }
60
+ }
61
+ if (isOperatorChar.test(ch)) {
62
+ stream.eatWhile(isOperatorChar);
63
+ return "operator";
64
+ }
65
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/);
66
+ var cur = stream.current().toLowerCase();
67
+ if (keywords.propertyIsEnumerable(cur) || start_blocks.propertyIsEnumerable(cur) || end_blocks.propertyIsEnumerable(cur)) {
68
+ return "keyword";
69
+ }
70
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
71
+ return "variable";
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
+ function Context(indented, column, type, align, prev) {
85
+ this.indented = indented;
86
+ this.column = column;
87
+ this.type = type;
88
+ this.align = align;
89
+ this.prev = prev;
90
+ }
91
+ function pushContext(state, col, type) {
92
+ return state.context = new Context(state.indented, col, type, null, state.context);
93
+ }
94
+ function popContext(state) {
95
+ if (!state.context.prev) return;
96
+ var t = state.context.type;
97
+ if (t == "end_block")
98
+ state.indented = state.context.indented;
99
+ return state.context = state.context.prev;
100
+ }
101
+ const fcl = {
102
+ name: "fcl",
103
+ startState: function(indentUnit) {
104
+ return {
105
+ tokenize: null,
106
+ context: new Context(-indentUnit, 0, "top", false),
107
+ indented: 0,
108
+ startOfLine: true
109
+ };
110
+ },
111
+ token: function(stream, state) {
112
+ var ctx = state.context;
113
+ if (stream.sol()) {
114
+ if (ctx.align == null) ctx.align = false;
115
+ state.indented = stream.indentation();
116
+ state.startOfLine = true;
117
+ }
118
+ if (stream.eatSpace()) return null;
119
+ var style = (state.tokenize || tokenBase)(stream, state);
120
+ if (style == "comment") return style;
121
+ if (ctx.align == null) ctx.align = true;
122
+ var cur = stream.current().toLowerCase();
123
+ if (start_blocks.propertyIsEnumerable(cur)) pushContext(state, stream.column(), "end_block");
124
+ else if (end_blocks.propertyIsEnumerable(cur)) popContext(state);
125
+ state.startOfLine = false;
126
+ return style;
127
+ },
128
+ indent: function(state, textAfter, cx) {
129
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
130
+ var ctx = state.context;
131
+ var closing = end_blocks.propertyIsEnumerable(textAfter);
132
+ if (ctx.align) return ctx.column + (closing ? 0 : 1);
133
+ else return ctx.indented + (closing ? 0 : cx.unit);
134
+ },
135
+ languageData: {
136
+ commentTokens: { line: "//", block: { open: "(*", close: "*)" } }
137
+ }
138
+ };
139
+ export {
140
+ fcl
141
+ };
@@ -0,0 +1,116 @@
1
+ function toWordList(words) {
2
+ var ret = [];
3
+ words.split(" ").forEach(function(e) {
4
+ ret.push({ name: e });
5
+ });
6
+ return ret;
7
+ }
8
+ var coreWordList = toWordList(
9
+ "INVERT AND OR XOR 2* 2/ LSHIFT RSHIFT 0= = 0< < > U< MIN MAX 2DROP 2DUP 2OVER 2SWAP ?DUP DEPTH DROP DUP OVER ROT SWAP >R R> R@ + - 1+ 1- ABS NEGATE S>D * M* UM* FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD HERE , @ ! CELL+ CELLS C, C@ C! CHARS 2@ 2! ALIGN ALIGNED +! ALLOT CHAR [CHAR] [ ] BL FIND EXECUTE IMMEDIATE COUNT LITERAL STATE ; DOES> >BODY EVALUATE SOURCE >IN <# # #S #> HOLD SIGN BASE >NUMBER HEX DECIMAL FILL MOVE . CR EMIT SPACE SPACES TYPE U. .R U.R ACCEPT TRUE FALSE <> U> 0<> 0> NIP TUCK ROLL PICK 2>R 2R@ 2R> WITHIN UNUSED MARKER I J TO COMPILE, [COMPILE] SAVE-INPUT RESTORE-INPUT PAD ERASE 2LITERAL DNEGATE D- D+ D0< D0= D2* D2/ D< D= DMAX DMIN D>S DABS M+ M*/ D. D.R 2ROT DU< CATCH THROW FREE RESIZE ALLOCATE CS-PICK CS-ROLL GET-CURRENT SET-CURRENT FORTH-WORDLIST GET-ORDER SET-ORDER PREVIOUS SEARCH-WORDLIST WORDLIST FIND ALSO ONLY FORTH DEFINITIONS ORDER -TRAILING /STRING SEARCH COMPARE CMOVE CMOVE> BLANK SLITERAL"
10
+ );
11
+ 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");
12
+ function searchWordList(wordList, word) {
13
+ var i;
14
+ for (i = wordList.length - 1; i >= 0; i--) {
15
+ if (wordList[i].name === word.toUpperCase()) {
16
+ return wordList[i];
17
+ }
18
+ }
19
+ return void 0;
20
+ }
21
+ const forth = {
22
+ name: "forth",
23
+ startState: function() {
24
+ return {
25
+ state: "",
26
+ base: 10,
27
+ coreWordList,
28
+ immediateWordList,
29
+ wordList: []
30
+ };
31
+ },
32
+ token: function(stream, stt) {
33
+ var mat;
34
+ if (stream.eatSpace()) {
35
+ return null;
36
+ }
37
+ if (stt.state === "") {
38
+ if (stream.match(/^(\]|:NONAME)(\s|$)/i)) {
39
+ stt.state = " compilation";
40
+ return "builtin";
41
+ }
42
+ mat = stream.match(/^(\:)\s+(\S+)(\s|$)+/);
43
+ if (mat) {
44
+ stt.wordList.push({ name: mat[2].toUpperCase() });
45
+ stt.state = " compilation";
46
+ return "def";
47
+ }
48
+ mat = stream.match(/^(VARIABLE|2VARIABLE|CONSTANT|2CONSTANT|CREATE|POSTPONE|VALUE|WORD)\s+(\S+)(\s|$)+/i);
49
+ if (mat) {
50
+ stt.wordList.push({ name: mat[2].toUpperCase() });
51
+ return "def";
52
+ }
53
+ mat = stream.match(/^(\'|\[\'\])\s+(\S+)(\s|$)+/);
54
+ if (mat) {
55
+ return "builtin";
56
+ }
57
+ } else {
58
+ if (stream.match(/^(\;|\[)(\s)/)) {
59
+ stt.state = "";
60
+ stream.backUp(1);
61
+ return "builtin";
62
+ }
63
+ if (stream.match(/^(\;|\[)($)/)) {
64
+ stt.state = "";
65
+ return "builtin";
66
+ }
67
+ if (stream.match(/^(POSTPONE)\s+\S+(\s|$)+/)) {
68
+ return "builtin";
69
+ }
70
+ }
71
+ mat = stream.match(/^(\S+)(\s+|$)/);
72
+ if (mat) {
73
+ if (searchWordList(stt.wordList, mat[1]) !== void 0) {
74
+ return "variable";
75
+ }
76
+ if (mat[1] === "\\") {
77
+ stream.skipToEnd();
78
+ return "comment";
79
+ }
80
+ if (searchWordList(stt.coreWordList, mat[1]) !== void 0) {
81
+ return "builtin";
82
+ }
83
+ if (searchWordList(stt.immediateWordList, mat[1]) !== void 0) {
84
+ return "keyword";
85
+ }
86
+ if (mat[1] === "(") {
87
+ stream.eatWhile(function(s) {
88
+ return s !== ")";
89
+ });
90
+ stream.eat(")");
91
+ return "comment";
92
+ }
93
+ if (mat[1] === ".(") {
94
+ stream.eatWhile(function(s) {
95
+ return s !== ")";
96
+ });
97
+ stream.eat(")");
98
+ return "string";
99
+ }
100
+ if (mat[1] === 'S"' || mat[1] === '."' || mat[1] === 'C"') {
101
+ stream.eatWhile(function(s) {
102
+ return s !== '"';
103
+ });
104
+ stream.eat('"');
105
+ return "string";
106
+ }
107
+ if (mat[1] - 68719476735) {
108
+ return "number";
109
+ }
110
+ return "atom";
111
+ }
112
+ }
113
+ };
114
+ export {
115
+ forth
116
+ };