@oat-sa/tao-core-ui 1.67.0 → 1.69.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 (54) hide show
  1. package/dist/ckeditor/ckConfigurator.js +10 -1
  2. package/dist/maths/calculator/basicCalculator.js +4 -4
  3. package/dist/maths/calculator/calculatorComponent.js +22 -25
  4. package/dist/maths/calculator/core/board.js +12329 -720
  5. package/dist/maths/calculator/core/labels.js +7924 -138
  6. package/dist/maths/calculator/core/plugin.js +4 -5
  7. package/dist/maths/calculator/css/calculator.css +18 -5
  8. package/dist/maths/calculator/css/calculator.css.map +1 -1
  9. package/dist/maths/calculator/defaultCalculator.js +10 -6
  10. package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +23 -25
  11. package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +7979 -194
  12. package/dist/maths/calculator/scientificCalculator.js +7 -12
  13. package/package.json +5 -7
  14. package/src/ckeditor/ckConfigurator.js +11 -4
  15. package/src/maths/calculator/basicCalculator.js +1 -4
  16. package/src/maths/calculator/calculatorComponent.js +49 -60
  17. package/src/maths/calculator/core/board.js +372 -493
  18. package/src/maths/calculator/core/labels.js +46 -48
  19. package/src/maths/calculator/core/plugin.js +3 -5
  20. package/src/maths/calculator/core/tpl/terms.tpl +7 -1
  21. package/src/maths/calculator/css/calculator.css +18 -5
  22. package/src/maths/calculator/css/calculator.css.map +1 -1
  23. package/src/maths/calculator/defaultCalculator.js +7 -9
  24. package/src/maths/calculator/plugins/keyboard/templateKeyboard/defaultTemplate.tpl +3 -3
  25. package/src/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +17 -20
  26. package/src/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +102 -108
  27. package/src/maths/calculator/scientificCalculator.js +2 -10
  28. package/src/maths/calculator/scss/calculator.scss +14 -1
  29. package/src/maths/calculator/tpl/basicKeyboard.tpl +3 -3
  30. package/src/maths/calculator/tpl/scientificKeyboard.tpl +4 -4
  31. package/dist/maths/calculator/core/areaBroker.js +0 -43
  32. package/dist/maths/calculator/core/expression.js +0 -463
  33. package/dist/maths/calculator/core/terms.js +0 -456
  34. package/dist/maths/calculator/core/tokenizer.js +0 -229
  35. package/dist/maths/calculator/core/tokens.js +0 -167
  36. package/dist/maths/calculator/plugins/core/degrad.js +0 -71
  37. package/dist/maths/calculator/plugins/core/history.js +0 -149
  38. package/dist/maths/calculator/plugins/core/remind.js +0 -76
  39. package/dist/maths/calculator/plugins/core/stepNavigation.js +0 -148
  40. package/dist/maths/calculator/plugins/modifiers/pow10.js +0 -136
  41. package/dist/maths/calculator/plugins/modifiers/sign.js +0 -314
  42. package/dist/maths/calculator/pluginsLoader.js +0 -47
  43. package/src/maths/calculator/core/areaBroker.js +0 -38
  44. package/src/maths/calculator/core/expression.js +0 -430
  45. package/src/maths/calculator/core/terms.js +0 -459
  46. package/src/maths/calculator/core/tokenizer.js +0 -245
  47. package/src/maths/calculator/core/tokens.js +0 -178
  48. package/src/maths/calculator/plugins/core/degrad.js +0 -90
  49. package/src/maths/calculator/plugins/core/history.js +0 -166
  50. package/src/maths/calculator/plugins/core/remind.js +0 -96
  51. package/src/maths/calculator/plugins/core/stepNavigation.js +0 -175
  52. package/src/maths/calculator/plugins/modifiers/pow10.js +0 -143
  53. package/src/maths/calculator/plugins/modifiers/sign.js +0 -339
  54. package/src/maths/calculator/pluginsLoader.js +0 -46
@@ -1,456 +0,0 @@
1
- define(['i18n', 'ui/maths/calculator/core/labels'], function (__, labels) { 'use strict';
2
-
3
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
4
- labels = labels && Object.prototype.hasOwnProperty.call(labels, 'default') ? labels['default'] : labels;
5
-
6
- /**
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; under version 2
10
- * of the License (non-upgradable).
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
- *
21
- * Copyright (c) 2018-2019 Open Assessment Technologies SA ;
22
- */
23
-
24
- /**
25
- * @typedef {Object} term - Represents a tokenizable term
26
- * @property {String} label - The displayable text
27
- * @property {String} value - The related text that should be found in the expression
28
- * @property {String} type - The type of token
29
- * @property {String} description - A description of what represent the term
30
- * @property {String|null} exponent - Some terms introduce exponent notation, and this property tells on which side
31
- */
32
-
33
- /**
34
- * Defines the terms that can be tokenized from an expression
35
- * @type {term[]}
36
- */
37
- var terms = {
38
- // Digits definition
39
- NUM0: {
40
- label: labels.NUM0,
41
- value: '0',
42
- type: 'digit',
43
- description: __('Digit 0'),
44
- exponent: null
45
- },
46
- NUM1: {
47
- label: labels.NUM1,
48
- value: '1',
49
- type: 'digit',
50
- description: __('Digit 1'),
51
- exponent: null
52
- },
53
- NUM2: {
54
- label: labels.NUM2,
55
- value: '2',
56
- type: 'digit',
57
- description: __('Digit 2'),
58
- exponent: null
59
- },
60
- NUM3: {
61
- label: labels.NUM3,
62
- value: '3',
63
- type: 'digit',
64
- description: __('Digit 3'),
65
- exponent: null
66
- },
67
- NUM4: {
68
- label: labels.NUM4,
69
- value: '4',
70
- type: 'digit',
71
- description: __('Digit 4'),
72
- exponent: null
73
- },
74
- NUM5: {
75
- label: labels.NUM5,
76
- value: '5',
77
- type: 'digit',
78
- description: __('Digit 5'),
79
- exponent: null
80
- },
81
- NUM6: {
82
- label: labels.NUM6,
83
- value: '6',
84
- type: 'digit',
85
- description: __('Digit 6'),
86
- exponent: null
87
- },
88
- NUM7: {
89
- label: labels.NUM7,
90
- value: '7',
91
- type: 'digit',
92
- description: __('Digit 7'),
93
- exponent: null
94
- },
95
- NUM8: {
96
- label: labels.NUM8,
97
- value: '8',
98
- type: 'digit',
99
- description: __('Digit 8'),
100
- exponent: null
101
- },
102
- NUM9: {
103
- label: labels.NUM9,
104
- value: '9',
105
- type: 'digit',
106
- description: __('Digit 9'),
107
- exponent: null
108
- },
109
- DOT: {
110
- label: labels.DOT,
111
- value: '.',
112
- type: 'digit',
113
- description: __('Dot'),
114
- exponent: null
115
- },
116
- EXP10: {
117
- label: labels.EXP10,
118
- value: 'e',
119
- type: 'digit',
120
- description: __('Power of 10'),
121
- exponent: 'right'
122
- },
123
- // Aggregators
124
- LPAR: {
125
- label: labels.LPAR,
126
- value: '(',
127
- type: 'aggregator',
128
- description: __('Left parenthesis'),
129
- exponent: null
130
- },
131
- RPAR: {
132
- label: labels.RPAR,
133
- value: ')',
134
- type: 'aggregator',
135
- description: __('Right parenthesis'),
136
- exponent: null
137
- },
138
- // Separator
139
- COMMA: {
140
- label: labels.COMMA,
141
- value: ',',
142
- type: 'separator',
143
- description: __('Arguments separator'),
144
- exponent: null
145
- },
146
- ELLIPSIS: {
147
- label: labels.ELLIPSIS,
148
- value: '~',
149
- type: 'separator',
150
- description: __('Value ellipsis'),
151
- exponent: null
152
- },
153
- // Operators
154
- SUB: {
155
- label: labels.SUB,
156
- value: '-',
157
- type: 'operator',
158
- description: __('Binary operator -'),
159
- exponent: null
160
- },
161
- NEG: {
162
- label: labels.NEG,
163
- value: labels.NEG,
164
- type: 'operator',
165
- description: __('Unary operator -'),
166
- exponent: null
167
- },
168
- ADD: {
169
- label: labels.ADD,
170
- value: '+',
171
- type: 'operator',
172
- description: __('Binary operator +'),
173
- exponent: null
174
- },
175
- POS: {
176
- label: labels.POS,
177
- value: labels.POS,
178
- type: 'operator',
179
- description: __('Unary operator +'),
180
- exponent: null
181
- },
182
- MUL: {
183
- label: labels.MUL,
184
- value: '*',
185
- type: 'operator',
186
- description: __('Binary operator *'),
187
- exponent: null
188
- },
189
- DIV: {
190
- label: labels.DIV,
191
- value: '/',
192
- type: 'operator',
193
- description: __('Binary operator /'),
194
- exponent: null
195
- },
196
- MOD: {
197
- label: labels.MOD,
198
- value: '%',
199
- type: 'operator',
200
- description: __('Binary operator modulo'),
201
- exponent: null
202
- },
203
- POW: {
204
- label: labels.POW,
205
- value: '^',
206
- type: 'operator',
207
- description: __('Power of'),
208
- exponent: 'right'
209
- },
210
- FAC: {
211
- label: labels.FAC,
212
- value: '!',
213
- type: 'operator',
214
- description: __('Factorial'),
215
- exponent: null
216
- },
217
- ASSIGN: {
218
- label: labels.ASSIGN,
219
- value: '=',
220
- type: 'operator',
221
- description: __('Assign'),
222
- exponent: null
223
- },
224
- // Variables
225
- ANS: {
226
- label: labels.ANS,
227
- value: 'ans',
228
- type: 'variable',
229
- description: __('Last result'),
230
- exponent: null
231
- },
232
- // Constants
233
- PI: {
234
- label: labels.PI,
235
- value: 'PI',
236
- type: 'constant',
237
- description: __('Value of PI'),
238
- exponent: null
239
- },
240
- E: {
241
- label: labels.E,
242
- value: 'E',
243
- type: 'constant',
244
- description: __('Value of E'),
245
- exponent: null
246
- },
247
- // Errors
248
- NAN: {
249
- label: labels.NAN,
250
- value: 'NaN',
251
- type: 'error',
252
- description: __('Error in value'),
253
- exponent: null
254
- },
255
- INFINITY: {
256
- label: labels.INFINITY,
257
- value: 'Infinity',
258
- type: 'error',
259
- description: __('Error in result'),
260
- exponent: null
261
- },
262
- ERROR: {
263
- label: labels.ERROR,
264
- value: '#',
265
- type: 'error',
266
- description: __('Error in syntax'),
267
- exponent: null
268
- },
269
- // Functions
270
- EXP: {
271
- label: labels.EXP,
272
- value: 'exp',
273
- type: 'function',
274
- description: __('Exponent'),
275
- exponent: 'right'
276
- },
277
- SQRT: {
278
- label: labels.SQRT,
279
- value: 'sqrt',
280
- type: 'function',
281
- description: __('Square root'),
282
- exponent: null
283
- },
284
- CBRT: {
285
- label: labels.CBRT,
286
- value: 'cbrt',
287
- type: 'function',
288
- description: __('Cube root'),
289
- exponent: null
290
- },
291
- NTHRT: {
292
- label: labels.SQRT,
293
- value: 'nthrt',
294
- type: 'function',
295
- description: __('Nth root'),
296
- exponent: 'left'
297
- },
298
- FLOOR: {
299
- label: labels.FLOOR,
300
- value: 'floor',
301
- type: 'function',
302
- description: __('Round to lower whole number'),
303
- exponent: null
304
- },
305
- CEIL: {
306
- label: labels.CEIL,
307
- value: 'ceil',
308
- type: 'function',
309
- description: __('Round to upper whole number'),
310
- exponent: null
311
- },
312
- ROUND: {
313
- label: labels.ROUND,
314
- value: 'round',
315
- type: 'function',
316
- description: __('Round to closest whole number'),
317
- exponent: null
318
- },
319
- TRUNC: {
320
- label: labels.TRUNC,
321
- value: 'trunc',
322
- type: 'function',
323
- description: __('Whole number part'),
324
- exponent: null
325
- },
326
- SIN: {
327
- label: labels.SIN,
328
- value: 'sin',
329
- type: 'function',
330
- description: __('Sine'),
331
- exponent: null
332
- },
333
- COS: {
334
- label: labels.COS,
335
- value: 'cos',
336
- type: 'function',
337
- description: __('Cosine'),
338
- exponent: null
339
- },
340
- TAN: {
341
- label: labels.TAN,
342
- value: 'tan',
343
- type: 'function',
344
- description: __('Tangent'),
345
- exponent: null
346
- },
347
- ASIN: {
348
- label: labels.ASIN,
349
- value: 'asin',
350
- type: 'function',
351
- description: __('Arc sine'),
352
- exponent: null
353
- },
354
- ACOS: {
355
- label: labels.ACOS,
356
- value: 'acos',
357
- type: 'function',
358
- description: __('Arc cosine'),
359
- exponent: null
360
- },
361
- ATAN: {
362
- label: labels.ATAN,
363
- value: 'atan',
364
- type: 'function',
365
- description: __('Arc tangent'),
366
- exponent: null
367
- },
368
- SINH: {
369
- label: labels.SINH,
370
- value: 'sinh',
371
- type: 'function',
372
- description: __('Hyperbolic sine'),
373
- exponent: null
374
- },
375
- COSH: {
376
- label: labels.COSH,
377
- value: 'cosh',
378
- type: 'function',
379
- description: __('Hyperbolic cosine'),
380
- exponent: null
381
- },
382
- TANH: {
383
- label: labels.TANH,
384
- value: 'tanh',
385
- type: 'function',
386
- description: __('Hyperbolic tangent'),
387
- exponent: null
388
- },
389
- ASINH: {
390
- label: labels.ASINH,
391
- value: 'asinh',
392
- type: 'function',
393
- description: __('Hyperbolic arc sine'),
394
- exponent: null
395
- },
396
- ACOSH: {
397
- label: labels.ACOSH,
398
- value: 'acosh',
399
- type: 'function',
400
- description: __('Hyperbolic arc cosine'),
401
- exponent: null
402
- },
403
- ATANH: {
404
- label: labels.ATANH,
405
- value: 'atanh',
406
- type: 'function',
407
- description: __('Hyperbolic arc tangent'),
408
- exponent: null
409
- },
410
- LN: {
411
- label: labels.LN,
412
- value: 'ln',
413
- type: 'function',
414
- description: __('Natural logarithm'),
415
- exponent: null
416
- },
417
- LOG: {
418
- label: labels.LN,
419
- value: 'log',
420
- type: 'function',
421
- description: __('Natural logarithm'),
422
- exponent: null
423
- },
424
- LG: {
425
- label: labels.LOG,
426
- value: 'lg',
427
- type: 'function',
428
- description: __('Base-10 logarithm'),
429
- exponent: null
430
- },
431
- LOG10: {
432
- label: labels.LOG,
433
- value: 'log10',
434
- type: 'function',
435
- description: __('Base-10 logarithm'),
436
- exponent: null
437
- },
438
- ABS: {
439
- label: labels.ABS,
440
- value: 'abs',
441
- type: 'function',
442
- description: __('Absolute value'),
443
- exponent: null
444
- },
445
- RAND: {
446
- label: labels.RAND,
447
- value: 'random',
448
- type: 'function',
449
- description: __('Random value'),
450
- exponent: null
451
- }
452
- };
453
-
454
- return terms;
455
-
456
- });
@@ -1,229 +0,0 @@
1
- define(['lodash', 'ui/maths/calculator/core/terms', 'ui/maths/calculator/core/tokens', 'lib/moo/moo'], function (_, registeredTerms, tokensHelper, moo) { 'use strict';
2
-
3
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
4
- registeredTerms = registeredTerms && Object.prototype.hasOwnProperty.call(registeredTerms, 'default') ? registeredTerms['default'] : registeredTerms;
5
- tokensHelper = tokensHelper && Object.prototype.hasOwnProperty.call(tokensHelper, 'default') ? tokensHelper['default'] : tokensHelper;
6
- moo = moo && Object.prototype.hasOwnProperty.call(moo, 'default') ? moo['default'] : moo;
7
-
8
- /**
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU General Public License
11
- * as published by the Free Software Foundation; under version 2
12
- * of the License (non-upgradable).
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
- *
23
- * Copyright (c) 2018-2019 Open Assessment Technologies SA ;
24
- */
25
-
26
- /**
27
- * List of ignored tokens
28
- * @type {Object}
29
- */
30
- var ignoredTokens = {
31
- SPACE: {
32
- match: /\s+/,
33
- lineBreaks: true
34
- }
35
- };
36
-
37
- /**
38
- * Match keywords
39
- * @type {RegExp}
40
- */
41
- var reKeyword = /[a-zA-Z_]\w*/;
42
-
43
- /**
44
- * Match numbers
45
- * @type {RegExp}
46
- */
47
- var reNumber = /[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/;
48
-
49
- /**
50
- * Match keywords prefixed with @
51
- * @type {RegExp}
52
- */
53
- var rePrefixedKeyword = new RegExp('@' + reKeyword.source);
54
-
55
- /**
56
- * Match keywords only
57
- * @type {RegExp}
58
- */
59
- var reKeywordOnly = new RegExp('^' + reKeyword.source + '$');
60
-
61
- /**
62
- * List of keywords (functions from the list of registered terms).
63
- * @type {Object}
64
- */
65
- var keywords = _.pick(registeredTerms, filterKeyword);
66
-
67
- /**
68
- * List of symbols (operators and operands from the list of registered terms).
69
- * @type {Object}
70
- */
71
- var symbols = _.omit(registeredTerms, filterKeyword);
72
-
73
- /**
74
- * List of digits and related symbols
75
- * @type {Object}
76
- */
77
- var digits = _.pick(registeredTerms, filterDigit);
78
-
79
- /**
80
- * Filter function that checks if the provided term is a keyword.
81
- * Keywords are all terms that have alphanumeric non digit value from the list of terms.
82
- * @param term
83
- * @returns {boolean}
84
- */
85
- function filterKeyword(term) {
86
- return term.value.match(reKeywordOnly);
87
- }
88
-
89
- /**
90
- * Filter function that checks if the provided term is a digit or a related symbol.
91
- * @param term
92
- * @returns {boolean}
93
- */
94
- function filterDigit(term) {
95
- return tokensHelper.isDigit(term.type) || term.value === '-' || term.value === '+';
96
- }
97
-
98
- /**
99
- * @typedef {Object} token
100
- * @property {String} type - The identifier of the token
101
- * @property {String} value - The actual value of the token
102
- * @property {String} text - The raw value that produced the token
103
- * @property {Number} offset - The original offset in the source
104
- * @property {Number} lineBreaks - How many line breaks are contained in the raw value
105
- * @property {Number} line - The line number of the token (starting from 1)
106
- * @property {Number} col - The column number of the token (starting from 1)
107
- */
108
-
109
- /**
110
- * Generates an expression tokenizer.
111
- *
112
- * @example
113
- *
114
- * var expression = '(.1 + .2) * 10^8';
115
- * var tokenizer = calculatorTokenizerFactory();
116
- * var terms = tokenizer(expression);
117
- *
118
- * // terms now contains an array of terms:
119
- * // [{type: "LPAR", value: "(", text: "(", offset: 0, lineBreaks: 0, line: 1, col: 1},
120
- * // {type: "DOT", value: ".", text: ".", offset: 1, lineBreaks: 0, line: 1, col: 2},
121
- * // {type: "NUM1", value: "1", text: "1", offset: 2, lineBreaks: 0, line: 1, col: 3},
122
- * // {type: "ADD", value: "+", text: "+", offset: 4, lineBreaks: 0, line: 1, col: 5},
123
- * // {type: "DOT", value: ".", text: ".", offset: 6, lineBreaks: 0, line: 1, col: 7},
124
- * // {type: "NUM2", value: "2", text: "2", offset: 7, lineBreaks: 0, line: 1, col: 8},
125
- * // {type: "RPAR", value: ")", text: ")", offset: 8, lineBreaks: 0, line: 1, col: 9},
126
- * // {type: "MUL", value: "*", text: "*", offset: 10, lineBreaks: 0, line: 1, col: 11},
127
- * // {type: "NUM1", value: "1", text: "1", offset: 12, lineBreaks: 0, line: 1, col: 13},
128
- * // {type: "NUM0", value: "0", text: "0", offset: 13, lineBreaks: 0, line: 1, col: 14},
129
- * // {type: "POW", value: "^", text: "^", offset: 14, lineBreaks: 0, line: 1, col: 15},
130
- * // {type: "NUM8", value: "8", text: "8", offset: 15, lineBreaks: 0, line: 1, col: 16}]
131
- *
132
- * @param {Object} [config]
133
- * @param {Object} [config.keywords] - List of additional keywords: key being the name, value being the pattern (should be on the domain /[a-zA-Z]+/)
134
- * @param {Object} [config.symbols] - List of additional symbols: key being the name, value being the pattern
135
- * @returns {calculatorTokenizer}
136
- */
137
- function calculatorTokenizerFactory(config) {
138
- var keywordsTransform, lexer, digitLexer, digitContext;
139
-
140
- /**
141
- * Extracts a token from the current position in the expression
142
- * @returns {token}
143
- */
144
- var next = function next() {
145
- var term;
146
- if (digitContext) {
147
- term = digitLexer.next();
148
- if (term) {
149
- term.offset += digitContext.offset;
150
- }
151
- }
152
- if (!term) {
153
- digitContext = null;
154
- do {
155
- term = lexer.next();
156
- } while (term && ignoredTokens[term.type]);
157
-
158
- // rely on a specific lexer to tokenize numbers
159
- // this is required to properly identify numbers like 42e15 without colliding with regular identifiers
160
- if (term && term.type === 'number') {
161
- digitContext = term;
162
- digitLexer.reset(term.value);
163
- term = next();
164
- }
165
- }
166
- return term;
167
- };
168
-
169
- /**
170
- * @typedef {Object} calculatorTokenizer
171
- */
172
- var tokenizer = {
173
- /**
174
- * Gets an iterator that will returns tokens from the provided expression
175
- * @param {String} expression
176
- * @returns {function(): token}
177
- */
178
- iterator: function iterator(expression) {
179
- lexer.reset(tokensHelper.stringValue(expression));
180
- return next;
181
- },
182
- /**
183
- * Tokenizes the expression
184
- * @param {String} expression
185
- * @returns {token[]}
186
- */
187
- tokenize: function tokenize(expression) {
188
- var iterator = tokenizer.iterator(expression);
189
- var terms = [];
190
- var term;
191
- do {
192
- term = iterator();
193
- if (term) {
194
- terms.push(term);
195
- }
196
- } while (term);
197
- return terms;
198
- }
199
- };
200
- config = config || {};
201
- config.keywords = _.defaults(_.mapValues(keywords, 'value'), config.keywords);
202
- config.symbols = _.defaults(_.mapValues(symbols, 'value'), config.symbols);
203
- keywordsTransform = moo.keywords(config.keywords);
204
-
205
- // Lexer used to tokenize the expression
206
- lexer = moo.compile(_.defaults({}, ignoredTokens, {
207
- number: reNumber,
208
- prefixed: {
209
- match: rePrefixedKeyword,
210
- type: function (token) {
211
- // simply rely on the keywords transform to identify the prefixed keyword
212
- return keywordsTransform(token.substring(1));
213
- }
214
- },
215
- term: {
216
- match: reKeyword,
217
- type: keywordsTransform
218
- },
219
- syntaxError: moo.error
220
- }, config.symbols));
221
-
222
- // Lexer used to tokenize numbers
223
- digitLexer = moo.compile(_.mapValues(digits, 'value'));
224
- return tokenizer;
225
- }
226
-
227
- return calculatorTokenizerFactory;
228
-
229
- });