naider 1.18.0 → 1.20.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/bin/naide.js +218 -6
- package/mcp/server.js +249 -0
- package/package.json +4 -2
- package/src/gen.js +731 -0
- package/src/index.js +8 -1
- package/src/parser.js +1 -1
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Parser } from './parser.js';
|
|
|
3
3
|
import { Generator } from './generator.js';
|
|
4
4
|
import { preprocess } from './preprocess.js';
|
|
5
5
|
import { TypeChecker } from './typechecker.js';
|
|
6
|
+
import { generate, expandDirectives } from './gen.js';
|
|
6
7
|
|
|
7
8
|
async function getGenerator(target, options) {
|
|
8
9
|
switch (target) {
|
|
@@ -80,6 +81,9 @@ export function compile(source, { mode = 'naide', runtimePath, sourceFile, typeC
|
|
|
80
81
|
if (mode === 'x') {
|
|
81
82
|
processedSource = preprocess(source);
|
|
82
83
|
}
|
|
84
|
+
if (processedSource.includes('~~')) {
|
|
85
|
+
processedSource = expandDirectives(processedSource).source;
|
|
86
|
+
}
|
|
83
87
|
try {
|
|
84
88
|
const lexer = new Lexer(processedSource);
|
|
85
89
|
const tokens = lexer.tokenize();
|
|
@@ -118,6 +122,9 @@ export async function compileAsync(source, { mode = 'naide', runtimePath, source
|
|
|
118
122
|
if (mode === 'x') {
|
|
119
123
|
processedSource = preprocess(source);
|
|
120
124
|
}
|
|
125
|
+
if (processedSource.includes('~~')) {
|
|
126
|
+
processedSource = expandDirectives(processedSource).source;
|
|
127
|
+
}
|
|
121
128
|
try {
|
|
122
129
|
const lexer = new Lexer(processedSource);
|
|
123
130
|
const tokens = lexer.tokenize();
|
|
@@ -155,4 +162,4 @@ export function transpile(source, opts) {
|
|
|
155
162
|
return compile(source, opts).js;
|
|
156
163
|
}
|
|
157
164
|
|
|
158
|
-
export { preprocess };
|
|
165
|
+
export { preprocess, generate };
|
package/src/parser.js
CHANGED
|
@@ -1497,7 +1497,7 @@ export class Parser {
|
|
|
1497
1497
|
|
|
1498
1498
|
const modifiers = [];
|
|
1499
1499
|
while (!this.at(T.NEWLINE) && !this.at(T.DEDENT) && !this.at(T.EOF)) {
|
|
1500
|
-
if (this.
|
|
1500
|
+
if (this.isIdentLike(this.peek().type)) {
|
|
1501
1501
|
const modName = this.advance().value;
|
|
1502
1502
|
if (this.at(T.LPAREN)) {
|
|
1503
1503
|
this.advance();
|