novac 2.2.0 → 2.2.2
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 +0 -0
- package/README.md +0 -0
- package/bin/novac +6 -3
- package/bin/nvc +0 -0
- package/bin/nvml +0 -0
- package/demo.nv +0 -0
- package/demo_builtins.nv +0 -0
- package/demo_http.nv +0 -0
- package/examples/bf.nv +5 -13
- package/examples/math.nv +2 -2
- package/kits/kitffmpeg/kitdef.js +1174 -0
- package/kits/libos/kitdef.js +3135 -0
- package/kits/libtasker/kitdef.js +125 -0
- package/package.json +1 -1
- package/scripts/update-bin.js +0 -0
- package/src/core/executor.js +7 -4
- package/src/core/lexer.js +2 -2
- package/src/index.js +0 -0
- package/novac/LICENSE +0 -21
- package/novac/README.md +0 -1823
- package/novac/bin/novac +0 -950
- package/novac/bin/nvc +0 -522
- package/novac/bin/nvml +0 -542
- package/novac/demo.nv +0 -245
- package/novac/demo_builtins.nv +0 -209
- package/novac/demo_http.nv +0 -62
- package/novac/examples/bf.nv +0 -69
- package/novac/examples/math.nv +0 -21
- package/novac/kits/kitai/kitdef.js +0 -2185
- package/novac/kits/kitansi/kitdef.js +0 -1402
- package/novac/kits/kitformat/kitdef.js +0 -1485
- package/novac/kits/kitgps/kitdef.js +0 -1862
- package/novac/kits/kitlibfs/kitdef.js +0 -231
- package/novac/kits/kitlibproc/kitdef.js +0 -78
- package/novac/kits/kitmatrix/ex.js +0 -19
- package/novac/kits/kitmatrix/kitdef.js +0 -960
- package/novac/kits/kitmpatch/kitdef.js +0 -906
- package/novac/kits/kitnovacweb/README.md +0 -1572
- package/novac/kits/kitnovacweb/demo.nv +0 -12
- package/novac/kits/kitnovacweb/demo.nvml +0 -71
- package/novac/kits/kitnovacweb/index.nova +0 -12
- package/novac/kits/kitnovacweb/kitdef.js +0 -692
- package/novac/kits/kitnovacweb/nova.kit.json +0 -8
- package/novac/kits/kitnovacweb/nvml/executor.js +0 -739
- package/novac/kits/kitnovacweb/nvml/index.js +0 -67
- package/novac/kits/kitnovacweb/nvml/lexer.js +0 -263
- package/novac/kits/kitnovacweb/nvml/parser.js +0 -508
- package/novac/kits/kitnovacweb/nvml/renderer.js +0 -924
- package/novac/kits/kitparse/kitdef.js +0 -1688
- package/novac/kits/kitregex++/kitdef.js +0 -1353
- package/novac/kits/kitrequire/kitdef.js +0 -1599
- package/novac/kits/kitx11/kitdef.js +0 -1
- package/novac/kits/kitx11/kitx11.js +0 -2472
- package/novac/kits/kitx11/kitx11_conn.js +0 -948
- package/novac/kits/kitx11/kitx11_worker.js +0 -121
- package/novac/kits/libtea/tf.js +0 -2691
- package/novac/kits/libterm/ex.js +0 -285
- package/novac/kits/libterm/kitdef.js +0 -1927
- package/novac/node_modules/chalk/license +0 -9
- package/novac/node_modules/chalk/package.json +0 -83
- package/novac/node_modules/chalk/readme.md +0 -297
- package/novac/node_modules/chalk/source/index.d.ts +0 -325
- package/novac/node_modules/chalk/source/index.js +0 -225
- package/novac/node_modules/chalk/source/utilities.js +0 -33
- package/novac/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -236
- package/novac/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -223
- package/novac/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
- package/novac/node_modules/chalk/source/vendor/supports-color/browser.js +0 -34
- package/novac/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
- package/novac/node_modules/chalk/source/vendor/supports-color/index.js +0 -190
- package/novac/node_modules/commander/LICENSE +0 -22
- package/novac/node_modules/commander/Readme.md +0 -1176
- package/novac/node_modules/commander/esm.mjs +0 -16
- package/novac/node_modules/commander/index.js +0 -24
- package/novac/node_modules/commander/lib/argument.js +0 -150
- package/novac/node_modules/commander/lib/command.js +0 -2777
- package/novac/node_modules/commander/lib/error.js +0 -39
- package/novac/node_modules/commander/lib/help.js +0 -747
- package/novac/node_modules/commander/lib/option.js +0 -380
- package/novac/node_modules/commander/lib/suggestSimilar.js +0 -101
- package/novac/node_modules/commander/package-support.json +0 -19
- package/novac/node_modules/commander/package.json +0 -82
- package/novac/node_modules/commander/typings/esm.d.mts +0 -3
- package/novac/node_modules/commander/typings/index.d.ts +0 -1113
- package/novac/node_modules/node-addon-api/LICENSE.md +0 -9
- package/novac/node_modules/node-addon-api/README.md +0 -95
- package/novac/node_modules/node-addon-api/common.gypi +0 -21
- package/novac/node_modules/node-addon-api/except.gypi +0 -25
- package/novac/node_modules/node-addon-api/index.js +0 -14
- package/novac/node_modules/node-addon-api/napi-inl.deprecated.h +0 -186
- package/novac/node_modules/node-addon-api/napi-inl.h +0 -7165
- package/novac/node_modules/node-addon-api/napi.h +0 -3364
- package/novac/node_modules/node-addon-api/node_addon_api.gyp +0 -42
- package/novac/node_modules/node-addon-api/node_api.gyp +0 -9
- package/novac/node_modules/node-addon-api/noexcept.gypi +0 -26
- package/novac/node_modules/node-addon-api/nothing.c +0 -0
- package/novac/node_modules/node-addon-api/package-support.json +0 -21
- package/novac/node_modules/node-addon-api/package.json +0 -480
- package/novac/node_modules/node-addon-api/tools/README.md +0 -73
- package/novac/node_modules/node-addon-api/tools/check-napi.js +0 -99
- package/novac/node_modules/node-addon-api/tools/clang-format.js +0 -71
- package/novac/node_modules/node-addon-api/tools/conversion.js +0 -301
- package/novac/node_modules/serialize-javascript/LICENSE +0 -27
- package/novac/node_modules/serialize-javascript/README.md +0 -149
- package/novac/node_modules/serialize-javascript/index.js +0 -297
- package/novac/node_modules/serialize-javascript/package.json +0 -33
- package/novac/package.json +0 -27
- package/novac/scripts/update-bin.js +0 -24
- package/novac/src/core/bstd.js +0 -1035
- package/novac/src/core/config.js +0 -155
- package/novac/src/core/describe.js +0 -187
- package/novac/src/core/emitter.js +0 -499
- package/novac/src/core/error.js +0 -86
- package/novac/src/core/executor.js +0 -5606
- package/novac/src/core/formatter.js +0 -686
- package/novac/src/core/lexer.js +0 -1026
- package/novac/src/core/nova_builtins.js +0 -717
- package/novac/src/core/nova_thread_worker.js +0 -166
- package/novac/src/core/parser.js +0 -2181
- package/novac/src/core/types.js +0 -112
- package/novac/src/index.js +0 -28
- package/novac/src/runtime/stdlib.js +0 -244
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* NVML — Full pipeline
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* const nvml = require('./nvml');
|
|
8
|
-
* const html = nvml.compile(source, { novaRunner, novaEmitter });
|
|
9
|
-
* const doc = nvml.execute(source, { novaRunner });
|
|
10
|
-
* const html = nvml.renderDoc(doc, { novaEmitter });
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const { Lexer } = require('./lexer');
|
|
14
|
-
const { Parser } = require('./parser');
|
|
15
|
-
const { Executor, NvmlDocument, makeBfObject } = require('./executor');
|
|
16
|
-
const { Renderer } = require('./renderer');
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Parse NVML source into AST (no side effects).
|
|
20
|
-
*/
|
|
21
|
-
function parse(source) {
|
|
22
|
-
return new Parser(source).parse();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Execute AST into a live NvmlDocument.
|
|
27
|
-
* @param {object} ast
|
|
28
|
-
* @param {object} opts
|
|
29
|
-
* novaRunner(code, doc) — called for server-side Nova scripts
|
|
30
|
-
* existingDoc — reuse an existing document (for incremental re-runs)
|
|
31
|
-
*/
|
|
32
|
-
function executeAst(ast, opts = {}) {
|
|
33
|
-
const exec = new Executor(opts.novaRunner || null);
|
|
34
|
-
return exec.execute(ast, opts.existingDoc || null);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Render a live NvmlDocument to an HTML string.
|
|
39
|
-
* @param {NvmlDocument} doc
|
|
40
|
-
* @param {object} opts
|
|
41
|
-
* novaEmitter(code) — compiles Nova code to JS for client scripts
|
|
42
|
-
*/
|
|
43
|
-
function renderDoc(doc, opts = {}) {
|
|
44
|
-
const renderer = new Renderer({ novaEmitter: opts.novaEmitter || null });
|
|
45
|
-
return renderer.render(doc);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Full pipeline: source → HTML
|
|
50
|
-
*/
|
|
51
|
-
function compile(source, opts = {}) {
|
|
52
|
-
const ast = parse(source);
|
|
53
|
-
const doc = executeAst(ast, opts);
|
|
54
|
-
return renderDoc(doc, opts);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Execute source and return both doc + html.
|
|
59
|
-
*/
|
|
60
|
-
function run(source, opts = {}) {
|
|
61
|
-
const ast = parse(source);
|
|
62
|
-
const doc = executeAst(ast, opts);
|
|
63
|
-
const html = renderDoc(doc, opts);
|
|
64
|
-
return { doc, html, ast };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = { parse, executeAst, renderDoc, compile, run, NvmlDocument, makeBfObject };
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// ══════════════════════════════════════════════════════════════════════
|
|
4
|
-
// NVML Lexer v2
|
|
5
|
-
// New tokens:
|
|
6
|
-
// HASH #signal-name (reactive signal ref)
|
|
7
|
-
// BANG_IDENT !event (event emit shorthand)
|
|
8
|
-
// AT_IDENT @config @visual @ss @component @state @computed @effect @route @slot @use
|
|
9
|
-
// ELEMENT {tag} {element.tag} {component.Name}
|
|
10
|
-
// LBRACKET [ RBRACKET ]
|
|
11
|
-
// LPAREN ( (multiline string / expression)
|
|
12
|
-
// COLONCOLON ::
|
|
13
|
-
// ARROW -> (one-way binding)
|
|
14
|
-
// DARROW <-> (two-way binding)
|
|
15
|
-
// QUESTION ? (conditional render)
|
|
16
|
-
// TILDE ~ (transition/animation hint)
|
|
17
|
-
// EQ = COMMA , PIPE | STRING IDENT NUMBER DOT DOTDOT EOF
|
|
18
|
-
// ══════════════════════════════════════════════════════════════════════
|
|
19
|
-
|
|
20
|
-
const TT = {
|
|
21
|
-
AT_IDENT: 'AT_IDENT',
|
|
22
|
-
ELEMENT: 'ELEMENT',
|
|
23
|
-
LBRACKET: 'LBRACKET',
|
|
24
|
-
RBRACKET: 'RBRACKET',
|
|
25
|
-
LPAREN: 'LPAREN',
|
|
26
|
-
RPAREN: 'RPAREN',
|
|
27
|
-
COLONCOLON: 'COLONCOLON',
|
|
28
|
-
ARROW: 'ARROW', // ->
|
|
29
|
-
DARROW: 'DARROW', // <->
|
|
30
|
-
QUESTION: 'QUESTION', // ?
|
|
31
|
-
TILDE: 'TILDE', // ~
|
|
32
|
-
HASH: 'HASH', // #signalName
|
|
33
|
-
BANG_IDENT: 'BANG_IDENT', // !eventName
|
|
34
|
-
EQ: 'EQ',
|
|
35
|
-
COMMA: 'COMMA',
|
|
36
|
-
PIPE: 'PIPE',
|
|
37
|
-
STRING: 'STRING',
|
|
38
|
-
IDENT: 'IDENT',
|
|
39
|
-
NUMBER: 'NUMBER',
|
|
40
|
-
DOT: 'DOT',
|
|
41
|
-
DOTDOT: 'DOTDOT',
|
|
42
|
-
EOF: 'EOF',
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
class Token {
|
|
46
|
-
constructor(type, value, line, col) {
|
|
47
|
-
this.type = type;
|
|
48
|
-
this.value = value;
|
|
49
|
-
this.line = line;
|
|
50
|
-
this.col = col;
|
|
51
|
-
}
|
|
52
|
-
toString() { return `Token(${this.type}, ${JSON.stringify(this.value)}, ${this.line}:${this.col})`; }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class LexError extends Error {
|
|
56
|
-
constructor(msg, line, col) {
|
|
57
|
-
super(`[NVML Lexer ${line}:${col}] ${msg}`);
|
|
58
|
-
this.name = 'LexError';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
class Lexer {
|
|
63
|
-
constructor(source) {
|
|
64
|
-
this.src = source;
|
|
65
|
-
this.pos = 0;
|
|
66
|
-
this.line = 1;
|
|
67
|
-
this.col = 1;
|
|
68
|
-
this.tokens = [];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
peek(offset = 0) { return this.src[this.pos + offset] ?? '\0'; }
|
|
72
|
-
isAtEnd() { return this.pos >= this.src.length; }
|
|
73
|
-
|
|
74
|
-
advance() {
|
|
75
|
-
const ch = this.src[this.pos++];
|
|
76
|
-
if (ch === '\n') { this.line++; this.col = 1; } else { this.col++; }
|
|
77
|
-
return ch;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
addToken(type, value) {
|
|
81
|
-
this.tokens.push(new Token(type, value, this.line, this.col));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
error(msg) { throw new LexError(msg, this.line, this.col); }
|
|
85
|
-
|
|
86
|
-
skipWhitespaceAndComments() {
|
|
87
|
-
while (!this.isAtEnd()) {
|
|
88
|
-
const ch = this.peek();
|
|
89
|
-
if (ch === ' ' || ch === '\t' || ch === '\r' || ch === '\n') { this.advance(); continue; }
|
|
90
|
-
// line comment
|
|
91
|
-
if (ch === '/' && this.peek(1) === '/') {
|
|
92
|
-
while (!this.isAtEnd() && this.peek() !== '\n') this.advance();
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
// block comment
|
|
96
|
-
if (ch === '/' && this.peek(1) === '*') {
|
|
97
|
-
this.advance(); this.advance();
|
|
98
|
-
while (!this.isAtEnd()) {
|
|
99
|
-
if (this.peek() === '*' && this.peek(1) === '/') { this.advance(); this.advance(); break; }
|
|
100
|
-
this.advance();
|
|
101
|
-
}
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
readQuotedString(quote) {
|
|
109
|
-
let val = '';
|
|
110
|
-
while (!this.isAtEnd()) {
|
|
111
|
-
const ch = this.advance();
|
|
112
|
-
if (ch === '\\') {
|
|
113
|
-
const esc = this.advance();
|
|
114
|
-
switch (esc) {
|
|
115
|
-
case 'n': val += '\n'; break; case 't': val += '\t'; break;
|
|
116
|
-
case 'r': val += '\r'; break; case '\\': val += '\\'; break;
|
|
117
|
-
default: val += esc;
|
|
118
|
-
}
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
if (ch === quote) break;
|
|
122
|
-
val += ch;
|
|
123
|
-
}
|
|
124
|
-
return val;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
readParenString() {
|
|
128
|
-
let val = '', depth = 1;
|
|
129
|
-
while (!this.isAtEnd()) {
|
|
130
|
-
const ch = this.advance();
|
|
131
|
-
if (ch === '(') { depth++; val += ch; continue; }
|
|
132
|
-
if (ch === ')') { depth--; if (depth === 0) break; val += ch; continue; }
|
|
133
|
-
val += ch;
|
|
134
|
-
}
|
|
135
|
-
return val;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
readElement() {
|
|
139
|
-
let name = '';
|
|
140
|
-
while (!this.isAtEnd() && this.peek() !== '}') name += this.advance();
|
|
141
|
-
if (this.isAtEnd()) this.error("Unterminated element name, expected '}'");
|
|
142
|
-
this.advance();
|
|
143
|
-
return name.trim();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
readIdent(firstChar) {
|
|
147
|
-
let val = firstChar;
|
|
148
|
-
while (!this.isAtEnd() && /[a-zA-Z0-9_\-]/.test(this.peek())) val += this.advance();
|
|
149
|
-
return val;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
readNumber(firstChar) {
|
|
153
|
-
let val = firstChar;
|
|
154
|
-
while (!this.isAtEnd() && /[0-9\.]/.test(this.peek())) val += this.advance();
|
|
155
|
-
return parseFloat(val);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
tokenize() {
|
|
159
|
-
while (true) {
|
|
160
|
-
this.skipWhitespaceAndComments();
|
|
161
|
-
if (this.isAtEnd()) { this.addToken(TT.EOF, null); break; }
|
|
162
|
-
|
|
163
|
-
const line = this.line, col = this.col;
|
|
164
|
-
const ch = this.advance();
|
|
165
|
-
|
|
166
|
-
switch (ch) {
|
|
167
|
-
case '[': {
|
|
168
|
-
if (this.peek() === '.' && this.peek(1) === '.') {
|
|
169
|
-
this.advance(); this.advance();
|
|
170
|
-
if (this.peek() === ']') {
|
|
171
|
-
this.advance();
|
|
172
|
-
this.tokens.push(new Token(TT.DOTDOT, '..', line, col));
|
|
173
|
-
} else { this.error("Expected ']' after '..'"); }
|
|
174
|
-
} else {
|
|
175
|
-
this.tokens.push(new Token(TT.LBRACKET, '[', line, col));
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
case ']': this.tokens.push(new Token(TT.RBRACKET, ']', line, col)); break;
|
|
180
|
-
case '(': {
|
|
181
|
-
const val = this.readParenString();
|
|
182
|
-
this.tokens.push(new Token(TT.STRING, val, line, col));
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
case ')': this.tokens.push(new Token(TT.RPAREN, ')', line, col)); break;
|
|
186
|
-
case ',': this.tokens.push(new Token(TT.COMMA, ',', line, col)); break;
|
|
187
|
-
case '|': this.tokens.push(new Token(TT.PIPE, '|', line, col)); break;
|
|
188
|
-
case '=': this.tokens.push(new Token(TT.EQ, '=', line, col)); break;
|
|
189
|
-
case '?': this.tokens.push(new Token(TT.QUESTION, '?', line, col)); break;
|
|
190
|
-
case '~': this.tokens.push(new Token(TT.TILDE, '~', line, col)); break;
|
|
191
|
-
case '-': {
|
|
192
|
-
if (this.peek() === '>') { this.advance(); this.tokens.push(new Token(TT.ARROW, '->', line, col)); }
|
|
193
|
-
else this.error("Unexpected '-', did you mean '->'?");
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
case '<': {
|
|
197
|
-
if (this.peek() === '-' && this.peek(1) === '>') {
|
|
198
|
-
this.advance(); this.advance();
|
|
199
|
-
this.tokens.push(new Token(TT.DARROW, '<->', line, col));
|
|
200
|
-
} else { this.error("Unexpected '<', did you mean '<->'?"); }
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
case ':': {
|
|
204
|
-
if (this.peek() === ':') { this.advance(); this.tokens.push(new Token(TT.COLONCOLON, '::', line, col)); }
|
|
205
|
-
else this.error("Unexpected ':', did you mean '::'?");
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
case '.': {
|
|
209
|
-
if (this.peek() === '.') { this.advance(); this.tokens.push(new Token(TT.DOTDOT, '..', line, col)); }
|
|
210
|
-
else this.tokens.push(new Token(TT.DOT, '.', line, col));
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
case '#': {
|
|
214
|
-
// #signalName — reactive signal reference
|
|
215
|
-
if (/[a-zA-Z_]/.test(this.peek())) {
|
|
216
|
-
const name = this.readIdent(this.advance());
|
|
217
|
-
this.tokens.push(new Token(TT.HASH, name, line, col));
|
|
218
|
-
} else { this.error("Expected signal name after '#'"); }
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
case '!': {
|
|
222
|
-
// !eventName — event emit shorthand
|
|
223
|
-
if (/[a-zA-Z_]/.test(this.peek())) {
|
|
224
|
-
const name = this.readIdent(this.advance());
|
|
225
|
-
this.tokens.push(new Token(TT.BANG_IDENT, name, line, col));
|
|
226
|
-
} else { this.error("Expected event name after '!'"); }
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
case '@': {
|
|
230
|
-
if (/[a-zA-Z_]/.test(this.peek())) {
|
|
231
|
-
const name = this.readIdent(this.advance());
|
|
232
|
-
this.tokens.push(new Token(TT.AT_IDENT, name, line, col));
|
|
233
|
-
} else { this.error("Expected identifier after '@'"); }
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
case '{': {
|
|
237
|
-
const name = this.readElement();
|
|
238
|
-
this.tokens.push(new Token(TT.ELEMENT, name, line, col));
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
case "'": case '"': {
|
|
242
|
-
const val = this.readQuotedString(ch);
|
|
243
|
-
this.tokens.push(new Token(TT.STRING, val, line, col));
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
default: {
|
|
247
|
-
if (/[a-zA-Z_]/.test(ch)) {
|
|
248
|
-
const val = this.readIdent(ch);
|
|
249
|
-
this.tokens.push(new Token(TT.IDENT, val, line, col));
|
|
250
|
-
} else if (/[0-9]/.test(ch)) {
|
|
251
|
-
const val = this.readNumber(ch);
|
|
252
|
-
this.tokens.push(new Token(TT.NUMBER, val, line, col));
|
|
253
|
-
} else {
|
|
254
|
-
this.error(`Unexpected character '${ch}'`);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return this.tokens;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
module.exports = { Lexer, Token, TT };
|