nodalis-compiler 1.0.5 → 1.0.6
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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.6]
|
|
9
|
+
|
|
10
|
+
- Fixed issue with JS compile where program was not compiling exactly right.
|
|
11
|
+
- Integrated latest version of mticp-npm.
|
|
12
|
+
|
|
8
13
|
## [1.0.5]
|
|
9
14
|
|
|
10
15
|
- Changed JSCompiler to avoid including the setup and run functions if we are just compiling generic ST.
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// limitations under the License.
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
|
|
18
19
|
/**
|
|
19
20
|
* @description Expression Converter
|
|
20
21
|
* @author Nathan Skipper, MTI
|
|
@@ -72,7 +73,7 @@ export function convertExpression(expr, isjsfb = false, jsfbVars = [], isjs=fals
|
|
|
72
73
|
results = tokens.join(' ');
|
|
73
74
|
// Replace %I/Q/M references
|
|
74
75
|
const parts = results.split(/\s+/);
|
|
75
|
-
results = parts.map(e => {
|
|
76
|
+
results = parts.map((e, index, tks) => {
|
|
76
77
|
// Don't touch raw address reads
|
|
77
78
|
if (/^%[IQM][XBWDL]?\d+(\.\d+)?$/i.test(e)) return getReadAddressExpression(e);
|
|
78
79
|
|
|
@@ -84,7 +85,8 @@ export function convertExpression(expr, isjsfb = false, jsfbVars = [], isjs=fals
|
|
|
84
85
|
|
|
85
86
|
// Don't wrap dot-bit references already processed
|
|
86
87
|
if (/^&?[A-Za-z_]\w*\.\d+$/.test(e)) return e;
|
|
87
|
-
|
|
88
|
+
// token is a function call
|
|
89
|
+
if (tks.length > index && tks[index + 1] === "(") return e;
|
|
88
90
|
// Otherwise, wrap in resolve()
|
|
89
91
|
if(isjs)
|
|
90
92
|
return `resolve(${e})`;
|
|
@@ -42,7 +42,7 @@ export function transpile(ast) {
|
|
|
42
42
|
|
|
43
43
|
case 'ProgramDeclaration':
|
|
44
44
|
lines.push(`export function ${block.name}() { // PROGRAM:${block.name}`);
|
|
45
|
-
lines.push(...declareVars(block.varSections
|
|
45
|
+
lines.push(...declareVars(block.varSections, false, block.name));
|
|
46
46
|
lines.push(...transpileStatements(block.statements));
|
|
47
47
|
lines.push('}');
|
|
48
48
|
break;
|
|
@@ -304,12 +304,13 @@ function parseStatementsUntil(endTokens) {
|
|
|
304
304
|
while (peek() && peek().value.toUpperCase().startsWith('VAR')) {
|
|
305
305
|
vars.push(...parseVarSection());
|
|
306
306
|
}
|
|
307
|
+
|
|
308
|
+
stmts.push(...parseStatements('END_PROGRAM'));
|
|
307
309
|
vars.forEach((v) => {
|
|
308
|
-
if(mapType(v.type) === "auto"){
|
|
309
|
-
stmts.push({type: "CALL", name: v.name});
|
|
310
|
+
if (mapType(v.type) === "auto") {
|
|
311
|
+
stmts.push({ type: "CALL", name: v.name });
|
|
310
312
|
}
|
|
311
313
|
});
|
|
312
|
-
stmts.push(...parseStatements('END_PROGRAM'));
|
|
313
314
|
expect('END_PROGRAM');
|
|
314
315
|
|
|
315
316
|
return { type: 'ProgramDeclaration', name, varSections: vars, statements: stmts };
|
|
@@ -326,12 +327,13 @@ function parseStatementsUntil(endTokens) {
|
|
|
326
327
|
while (peek() && peek().value.toUpperCase().startsWith('VAR')) {
|
|
327
328
|
vars.push(...parseVarSection());
|
|
328
329
|
}
|
|
330
|
+
|
|
331
|
+
stmts.push(...parseStatements('END_FUNCTION'));
|
|
329
332
|
vars.forEach((v) => {
|
|
330
|
-
if(mapType(v.type) === "auto"){
|
|
331
|
-
stmts.push({type: "CALL", name: v.name});
|
|
333
|
+
if (mapType(v.type) === "auto") {
|
|
334
|
+
stmts.push({ type: "CALL", name: v.name });
|
|
332
335
|
}
|
|
333
336
|
});
|
|
334
|
-
stmts.push(...parseStatements('END_FUNCTION'));
|
|
335
337
|
expect('END_FUNCTION');
|
|
336
338
|
|
|
337
339
|
return { type: 'FunctionDeclaration', name, returnType, varSections: vars, statements: stmts };
|
|
@@ -346,12 +348,13 @@ function parseStatementsUntil(endTokens) {
|
|
|
346
348
|
while (peek() && peek().value.toUpperCase().startsWith('VAR')) {
|
|
347
349
|
vars.push(...parseVarSection());
|
|
348
350
|
}
|
|
351
|
+
|
|
352
|
+
stmts.push(...parseStatements('END_FUNCTION_BLOCK'));
|
|
349
353
|
vars.forEach((v) => {
|
|
350
|
-
if(mapType(v.type) === "auto"){
|
|
351
|
-
stmts.push({type: "CALL", name: v.name});
|
|
354
|
+
if (mapType(v.type) === "auto") {
|
|
355
|
+
stmts.push({ type: "CALL", name: v.name });
|
|
352
356
|
}
|
|
353
357
|
});
|
|
354
|
-
stmts.push(...parseStatements('END_FUNCTION_BLOCK'));
|
|
355
358
|
expect('END_FUNCTION_BLOCK');
|
|
356
359
|
|
|
357
360
|
return { type: 'FunctionBlockDeclaration', name, varSections: vars, statements: stmts };
|