kni 4.0.2 → 5.0.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.
- package/LICENSE +21 -0
- package/README.md +9 -7
- package/console.js +33 -35
- package/describe.js +54 -89
- package/document.js +103 -72
- package/engine.js +436 -407
- package/entry.js +88 -0
- package/evaluate.js +221 -228
- package/excerpt.js +117 -115
- package/grammar.js +1025 -785
- package/html.js +174 -167
- package/inline-lexer.js +155 -125
- package/kni.js +286 -279
- package/link.js +50 -52
- package/outline-lexer.js +64 -37
- package/package.json +27 -34
- package/parser.js +32 -20
- package/path.js +34 -46
- package/readline.js +89 -79
- package/scanner.js +101 -78
- package/scope.js +32 -36
- package/story.js +174 -165
- package/test.js +6 -0
- package/translate-json.js +3 -5
- package/tsconfig.json +11 -0
- package/verify.js +121 -117
- package/wrapper.js +37 -41
- package/template.js +0 -69
package/html.js
CHANGED
|
@@ -1,168 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
process.exit(-1);
|
|
1
|
+
import {rollup} from 'rollup';
|
|
2
|
+
import {nodeResolve} from '@rollup/plugin-node-resolve';
|
|
3
|
+
import {fileURLToPath} from 'url';
|
|
4
|
+
import {dirname, join} from 'path';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
const makeHtml = async (story, output, templateArgs) => {
|
|
10
|
+
try {
|
|
11
|
+
// Create a virtual story module plugin
|
|
12
|
+
const virtualStoryPlugin = {
|
|
13
|
+
name: 'virtual-story',
|
|
14
|
+
resolveId(id) {
|
|
15
|
+
if (id === 'virtual:story') {
|
|
16
|
+
return id;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
},
|
|
20
|
+
load(id) {
|
|
21
|
+
if (id === 'virtual:story') {
|
|
22
|
+
return `export default ${JSON.stringify(story, null, 2)};`;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Bundle with Rollup
|
|
29
|
+
const bundle = await rollup({
|
|
30
|
+
input: join(__dirname, 'entry.js'),
|
|
31
|
+
plugins: [
|
|
32
|
+
virtualStoryPlugin,
|
|
33
|
+
nodeResolve({
|
|
34
|
+
rootDir: __dirname,
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
external: [],
|
|
39
38
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
39
|
+
|
|
40
|
+
// Generate output
|
|
41
|
+
const {output: outputs} = await bundle.generate({
|
|
42
|
+
format: 'iife',
|
|
43
|
+
name: 'kni',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const script = outputs[0].code;
|
|
47
|
+
|
|
48
|
+
// Generate HTML
|
|
49
|
+
const html = template(script, templateArgs);
|
|
50
|
+
output.end(html);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
process.exit(-1);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default makeHtml;
|
|
58
|
+
|
|
59
|
+
const template = (bundle, args) => {
|
|
60
|
+
const title = args.title != null ? `<title>${args.title}</title>` : '';
|
|
61
|
+
const bgcolor = args.backgroundColor ?? 'hsla(60, 42.00%, 66.00%, 1)';
|
|
62
|
+
const color = args.color ?? 'hsla(240, 42.00%, 25.00%, 1)';
|
|
63
|
+
|
|
64
|
+
return `<!doctype html>
|
|
65
|
+
<html>
|
|
66
|
+
<head>
|
|
67
|
+
<meta charset="utf8">
|
|
68
|
+
<meta name="viewport" content="width=device-width, initial-scale=0.75">
|
|
69
|
+
${title}
|
|
70
|
+
<style>
|
|
71
|
+
@media handheld {
|
|
72
|
+
body {
|
|
73
|
+
font-size: 150%;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
body {
|
|
78
|
+
font-size: 200%;
|
|
79
|
+
background-color: ${bgcolor};
|
|
80
|
+
color: ${color};
|
|
81
|
+
overflow: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.body {
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: 0;
|
|
87
|
+
bottom: 1.5em;
|
|
88
|
+
left: 0;
|
|
89
|
+
right: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.kni-frame {
|
|
93
|
+
position: absolute;
|
|
94
|
+
height: 100%;
|
|
95
|
+
width: 100%;
|
|
96
|
+
overflow-y: scroll;
|
|
97
|
+
transition: transform 1s ease, opacity 1s ease-out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.kni-frame-a {
|
|
101
|
+
display: table;
|
|
102
|
+
height: 100%;
|
|
103
|
+
width: 100%;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.kni-frame-b {
|
|
107
|
+
display: table-cell;
|
|
108
|
+
vertical-align: middle;
|
|
109
|
+
padding: 1em;
|
|
110
|
+
width: 40ex;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.kni-frame-c {
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: row;
|
|
116
|
+
flex-wrap: nowrap;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
align-items: flex-start;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.kni-body {
|
|
122
|
+
display: flex-item;
|
|
123
|
+
flex: 0 1 auto;
|
|
124
|
+
max-width: 40ex;
|
|
125
|
+
text-align: justify;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
th {
|
|
129
|
+
vertical-align: top;
|
|
130
|
+
padding-right: 1ex;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
td {
|
|
134
|
+
vertical-align: top;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
li {
|
|
139
|
+
list-style-type: decimal;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
a {
|
|
143
|
+
color: inherit;
|
|
144
|
+
font-family: 200%;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
a:link {
|
|
148
|
+
color: inherit;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
a:hover {
|
|
152
|
+
color: inherit;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
a:visited {
|
|
156
|
+
color: inherit;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.reset {
|
|
160
|
+
position: absolute;
|
|
161
|
+
height: 1em;
|
|
162
|
+
bottom: 0;
|
|
163
|
+
left: 0;
|
|
164
|
+
margin: 10px;
|
|
165
|
+
}
|
|
166
|
+
</style>
|
|
167
|
+
</head>
|
|
168
|
+
<body>
|
|
169
|
+
<div class="reset"><a href="#">reset</a></div>
|
|
170
|
+
<script><!--
|
|
171
|
+
${bundle}
|
|
172
|
+
--></script>
|
|
173
|
+
</body>
|
|
174
|
+
</html>`;
|
|
175
|
+
};
|
package/inline-lexer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
2
|
|
|
3
3
|
// Receives a stream of start, stop, and text tokens from an outline lexer and
|
|
4
4
|
// produces a more comprehensive stream of tokens by breaking text tokens into
|
|
@@ -11,152 +11,182 @@
|
|
|
11
11
|
// states.
|
|
12
12
|
// The final parse state captures the entire syntax tree.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const L1 = '@[]{}|/<>';
|
|
15
|
+
const L2 = ['->', '<-', '==', '<>', '>=', '<=', '{"', '"}', "{'", "'}", '//', '**'];
|
|
16
|
+
const num = /\d/;
|
|
15
17
|
|
|
16
|
-
var debug = typeof process === 'object' && process.env.DEBUG_INLINE_LEXER;
|
|
17
|
-
|
|
18
|
-
var L1 = '@[]{}|/<>';
|
|
19
|
-
var L2 = ['->', '<-', '==', '<>', '>=', '<=', '{"', '"}', '{\'', '\'}', '//', '**'];
|
|
20
|
-
var num = /\d/;
|
|
21
|
-
var space = /\s/;
|
|
22
18
|
// alphanumerics including non-english
|
|
23
|
-
|
|
19
|
+
const alpha = /[\w\u00C0-\u1FFF\u2C00-\uD7FF\d_]/;
|
|
20
|
+
|
|
21
|
+
/** Receives outline tokens, passing through inter-line structure tokens, and
|
|
22
|
+
* decomposing line tokens along with interstitial space tracking.
|
|
23
|
+
*/
|
|
24
|
+
export default class InlineLexer {
|
|
25
|
+
debug = typeof process === 'object' && process.env.DEBUG_INLINE_LEXER;
|
|
26
|
+
|
|
27
|
+
space = '';
|
|
28
|
+
accumulator = '';
|
|
29
|
+
type = 'symbol';
|
|
30
|
+
|
|
31
|
+
/** @typedef {import('./scanner')} Scanner */
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
/** Inline lexer state object, which receives typed text tokens along with
|
|
34
|
+
* any preceding collapsed space, and the current scanner.
|
|
35
|
+
*
|
|
36
|
+
* NOTE: unlike the upstream OutlineLexer.State monad, which
|
|
37
|
+
* InlineLexer.next implements, this is not quite a state monad, as it does
|
|
38
|
+
* not support subsequent state chaining; in practice, that is implemented
|
|
39
|
+
* by Parser. This curious decoupling stands in interesting contrast to the
|
|
40
|
+
* outline layer having coupled together the iterator callback interface
|
|
41
|
+
* with state retention and chaining.
|
|
42
|
+
*
|
|
43
|
+
* @typedef {object} State
|
|
44
|
+
* @prop {(type: string, space: string, text: string, sc: Scanner) => void} next
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {State} generator
|
|
49
|
+
*/
|
|
50
|
+
constructor(generator) {
|
|
26
51
|
this.generator = generator;
|
|
27
|
-
|
|
28
|
-
this.accumulator = '';
|
|
29
|
-
this.type = 'symbol';
|
|
30
|
-
this.debug = debug;
|
|
31
|
-
Object.seal(this);
|
|
32
|
-
}
|
|
52
|
+
}
|
|
33
53
|
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} type
|
|
56
|
+
* @param {string} text
|
|
57
|
+
* @param {Scanner} scanner
|
|
58
|
+
*/
|
|
59
|
+
next(type, text, scanner) {
|
|
36
60
|
if (this.debug) {
|
|
37
|
-
|
|
61
|
+
console.log('ILL', type, JSON.stringify(text));
|
|
38
62
|
}
|
|
39
63
|
|
|
40
64
|
if (type !== 'text') {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
this.flush(scanner);
|
|
66
|
+
this.generator.next(type, ' ', text, scanner);
|
|
67
|
+
this.space = '';
|
|
68
|
+
return this;
|
|
45
69
|
}
|
|
46
70
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Otherwise, treat all following space as a single space.
|
|
74
|
-
this.flush(scanner);
|
|
75
|
-
this.generator.next('literal', '', ' ', scanner);
|
|
76
|
-
this.space = '';
|
|
77
|
-
}
|
|
78
|
-
} else if (c === '\\') {
|
|
79
|
-
// TODO account for escaped space through to the end of line
|
|
80
|
-
this.flush(scanner);
|
|
81
|
-
this.generator.next('literal', this.space, d, scanner);
|
|
82
|
-
this.space = '';
|
|
83
|
-
i++;
|
|
84
|
-
} else if (L2.indexOf(cd) >= 0) {
|
|
85
|
-
this.flush(scanner);
|
|
86
|
-
this.generator.next('token', this.space, cd, scanner);
|
|
87
|
-
this.space = '';
|
|
88
|
-
i++;
|
|
89
|
-
} else if (L1.indexOf(c) >= 0) {
|
|
90
|
-
this.flush(scanner);
|
|
91
|
-
this.generator.next('token', this.space, c, scanner);
|
|
92
|
-
this.space = '';
|
|
93
|
-
} else if (cd === '--') {
|
|
94
|
-
this.flush(scanner);
|
|
95
|
-
for (var j = i + 2; j < text.length; j++) {
|
|
96
|
-
c = text[j];
|
|
97
|
-
if (c !== '-') {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
this.generator.next('dash', this.space, text.slice(i, j), scanner);
|
|
102
|
-
i = j - 1;
|
|
103
|
-
} else if (this.type !== 'alphanum' && numeric) {
|
|
104
|
-
if (this.type != 'number') {
|
|
105
|
-
this.flush(scanner);
|
|
106
|
-
}
|
|
107
|
-
this.accumulator += c;
|
|
108
|
-
this.type = 'number';
|
|
109
|
-
} else if (alphanum) {
|
|
110
|
-
if (this.type != 'alphanum') {
|
|
111
|
-
this.flush(scanner);
|
|
112
|
-
}
|
|
113
|
-
this.accumulator += c;
|
|
114
|
-
this.type = 'alphanum';
|
|
71
|
+
let wrap = false;
|
|
72
|
+
let i = 0;
|
|
73
|
+
for (; i < text.length - 1; i++) {
|
|
74
|
+
let c = text[i];
|
|
75
|
+
const d = text[i + 1];
|
|
76
|
+
const cd = c + d;
|
|
77
|
+
const numeric = num.test(c);
|
|
78
|
+
const alphanum = alpha.test(c);
|
|
79
|
+
if (c === ' ' || c === '\t') {
|
|
80
|
+
this.flush(scanner);
|
|
81
|
+
this.space = ' ';
|
|
82
|
+
} else if (cd === '\\ ') {
|
|
83
|
+
// Scan forward to end of line until encountering a non-space
|
|
84
|
+
// character.
|
|
85
|
+
for (i = i + 2; i < text.length; i++) {
|
|
86
|
+
c = text[i];
|
|
87
|
+
if (c !== ' ' && c !== '\t') {
|
|
88
|
+
i--;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (i === text.length) {
|
|
93
|
+
// If everything after \ is whitespace, then treat it as if
|
|
94
|
+
// there is no whitespace, meaning that the \ means continue
|
|
95
|
+
// through next line.
|
|
96
|
+
wrap = true;
|
|
115
97
|
} else {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
98
|
+
// Otherwise, treat all following space as a single space.
|
|
99
|
+
this.flush(scanner);
|
|
100
|
+
this.generator.next('literal', '', ' ', scanner);
|
|
101
|
+
this.space = '';
|
|
119
102
|
}
|
|
103
|
+
} else if (c === '\\') {
|
|
104
|
+
// TODO account for escaped space through to the end of line
|
|
105
|
+
this.flush(scanner);
|
|
106
|
+
this.generator.next('literal', this.space, d, scanner);
|
|
107
|
+
this.space = '';
|
|
108
|
+
i++;
|
|
109
|
+
} else if (L2.indexOf(cd) >= 0) {
|
|
110
|
+
this.flush(scanner);
|
|
111
|
+
this.generator.next('token', this.space, cd, scanner);
|
|
112
|
+
this.space = '';
|
|
113
|
+
i++;
|
|
114
|
+
} else if (L1.indexOf(c) >= 0) {
|
|
115
|
+
this.flush(scanner);
|
|
116
|
+
this.generator.next('token', this.space, c, scanner);
|
|
117
|
+
this.space = '';
|
|
118
|
+
} else if (cd === '--') {
|
|
119
|
+
this.flush(scanner);
|
|
120
|
+
let j = i + 2;
|
|
121
|
+
for (; j < text.length; j++) {
|
|
122
|
+
c = text[j];
|
|
123
|
+
if (c !== '-') {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
this.generator.next('dash', this.space, text.slice(i, j), scanner);
|
|
128
|
+
i = j - 1;
|
|
129
|
+
} else if (this.type !== 'alphanum' && numeric) {
|
|
130
|
+
if (this.type != 'number') {
|
|
131
|
+
this.flush(scanner);
|
|
132
|
+
}
|
|
133
|
+
this.accumulator += c;
|
|
134
|
+
this.type = 'number';
|
|
135
|
+
} else if (alphanum) {
|
|
136
|
+
if (this.type != 'alphanum') {
|
|
137
|
+
this.flush(scanner);
|
|
138
|
+
}
|
|
139
|
+
this.accumulator += c;
|
|
140
|
+
this.type = 'alphanum';
|
|
141
|
+
} else {
|
|
142
|
+
this.flush(scanner);
|
|
143
|
+
this.generator.next(this.type, this.space, c, scanner);
|
|
144
|
+
this.space = '';
|
|
145
|
+
}
|
|
120
146
|
}
|
|
121
147
|
|
|
122
148
|
if (i < text.length) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
this.accumulator += c;
|
|
138
|
-
this.type = 'number';
|
|
139
|
-
} else if (!alphanum) {
|
|
140
|
-
this.flush(scanner);
|
|
141
|
-
this.generator.next(this.type, this.space, c, scanner);
|
|
142
|
-
} else {
|
|
143
|
-
this.type = 'alphanum';
|
|
144
|
-
this.accumulator += c;
|
|
149
|
+
const c = text[i];
|
|
150
|
+
const numeric = num.test(c);
|
|
151
|
+
const alphanum = alpha.test(c);
|
|
152
|
+
if (c === '\\') {
|
|
153
|
+
wrap = true;
|
|
154
|
+
} else if (c === ' ' || c === '\t') {
|
|
155
|
+
// noop
|
|
156
|
+
} else if (L1.indexOf(c) >= 0) {
|
|
157
|
+
this.flush(scanner);
|
|
158
|
+
this.generator.next('token', this.space, c, scanner);
|
|
159
|
+
} else if (this.type !== 'alphanum' && numeric) {
|
|
160
|
+
if (this.type !== 'number') {
|
|
161
|
+
this.flush(scanner);
|
|
145
162
|
}
|
|
163
|
+
this.accumulator += c;
|
|
164
|
+
this.type = 'number';
|
|
165
|
+
} else if (!alphanum) {
|
|
166
|
+
this.flush(scanner);
|
|
167
|
+
this.generator.next(this.type, this.space, c, scanner);
|
|
168
|
+
} else {
|
|
169
|
+
this.type = 'alphanum';
|
|
170
|
+
this.accumulator += c;
|
|
171
|
+
}
|
|
146
172
|
}
|
|
147
173
|
|
|
148
174
|
if (!wrap) {
|
|
149
|
-
|
|
150
|
-
|
|
175
|
+
this.flush(scanner);
|
|
176
|
+
this.space = ' ';
|
|
151
177
|
}
|
|
152
178
|
return this;
|
|
153
|
-
}
|
|
179
|
+
}
|
|
154
180
|
|
|
155
|
-
|
|
181
|
+
/**
|
|
182
|
+
* @param {Scanner} scanner
|
|
183
|
+
*/
|
|
184
|
+
flush(scanner) {
|
|
156
185
|
if (this.accumulator) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
186
|
+
this.generator.next(this.type, this.space, this.accumulator, scanner);
|
|
187
|
+
this.accumulator = '';
|
|
188
|
+
this.space = '';
|
|
189
|
+
this.type = 'symbol';
|
|
161
190
|
}
|
|
162
|
-
}
|
|
191
|
+
}
|
|
192
|
+
}
|