harmonyc 0.8.1 → 0.8.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/code_generator/JavaScript.js +10 -10
- package/package.json +1 -1
- package/parser/lexer.steps.js +0 -9
- package/parser/parser.steps.js +0 -12
|
@@ -99,13 +99,13 @@ export class NodeTest {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
phrase(p) {
|
|
102
|
-
const phrasefn =
|
|
102
|
+
const phrasefn = functionName(p);
|
|
103
103
|
if (!this.phraseFns.has(phrasefn))
|
|
104
104
|
this.phraseFns.set(phrasefn, p);
|
|
105
105
|
const f = this.featureVars.get(p.feature.name);
|
|
106
106
|
const args = p.args.map((a) => a.toCode(this));
|
|
107
107
|
args.push(...this.extraArgs);
|
|
108
|
-
this.tf.print(`await ${f}.${
|
|
108
|
+
this.tf.print(`await ${f}.${functionName(p)}(${args.join(', ')});`);
|
|
109
109
|
}
|
|
110
110
|
stringLiteral(text) {
|
|
111
111
|
return str(text);
|
|
@@ -122,14 +122,6 @@ export class NodeTest {
|
|
|
122
122
|
variantParamDeclaration(index) {
|
|
123
123
|
return `${this.paramName(index)}: any`;
|
|
124
124
|
}
|
|
125
|
-
functionName(phrase) {
|
|
126
|
-
const { kind } = phrase;
|
|
127
|
-
return ((kind === 'response' ? 'Then_' : 'When_') +
|
|
128
|
-
([...phrase.content, phrase.docstring ? [phrase.docstring] : []]
|
|
129
|
-
.map((c) => c instanceof Word ? underscore(c.text) : c instanceof Arg ? '_' : '')
|
|
130
|
-
.filter((x) => x)
|
|
131
|
-
.join('_') || '_'));
|
|
132
|
-
}
|
|
133
125
|
}
|
|
134
126
|
function str(s) {
|
|
135
127
|
if (s.includes('\n'))
|
|
@@ -171,3 +163,11 @@ function abbrev(s) {
|
|
|
171
163
|
.map((x) => x.charAt(0).toUpperCase())
|
|
172
164
|
.join('');
|
|
173
165
|
}
|
|
166
|
+
export function functionName(phrase) {
|
|
167
|
+
const { kind } = phrase;
|
|
168
|
+
return ((kind === 'response' ? 'Then_' : 'When_') +
|
|
169
|
+
([...phrase.content, phrase.docstring ? [phrase.docstring] : []]
|
|
170
|
+
.flatMap((c) => c instanceof Word ? words(c.text) : c instanceof Arg ? ['_'] : [])
|
|
171
|
+
.filter((x) => x)
|
|
172
|
+
.join('_') || '_'));
|
|
173
|
+
}
|
package/package.json
CHANGED
package/parser/lexer.steps.js
DELETED
package/parser/parser.steps.js
DELETED