occam-furtle 2.0.331 → 2.0.335

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.
@@ -2,17 +2,16 @@
2
2
 
3
3
  import elements from "../elements";
4
4
 
5
+ import { NODE_TYPE, NODES_TYPE, STRING_TYPE, BOOLEAN_TYPE } from "../types";
5
6
  import { primtiveStringFromNode, primtiveStringFromNodes, primtiveStringFromBoolean, primtiveStringFromStringLiteral } from "../utilities/string";
6
7
 
7
8
  export function primitiveFromNode(node, context) {
8
9
  const { Primitive } = elements,
9
10
  primitiveString = primtiveStringFromNode(node, context),
10
11
  string = primitiveString, ///
11
- nodes = null,
12
- number = null,
13
- boolean = null,
14
- stringLiteral = null,
15
- primitive = new Primitive(string, node, nodes, number, boolean, stringLiteral);
12
+ type = NODE_TYPE,
13
+ value = node, ///
14
+ primitive = new Primitive(string, type, value);
16
15
 
17
16
  return primitive;
18
17
  }
@@ -21,11 +20,9 @@ export function primitiveFromNodes(nodes, context) {
21
20
  const { Primitive } = elements,
22
21
  primitiveString = primtiveStringFromNodes(nodes, context),
23
22
  string = primitiveString, ///
24
- node = null,
25
- number = null,
26
- boolean = null,
27
- stringLiteral = null,
28
- primitive = new Primitive(string, node, nodes, number, boolean, stringLiteral);
23
+ type = NODES_TYPE,
24
+ value = nodes, ///
25
+ primitive = new Primitive(string, type, value);
29
26
 
30
27
  return primitive;
31
28
  }
@@ -34,11 +31,9 @@ export function primitiveFromBoolean(boolean, context) {
34
31
  const { Primitive } = elements,
35
32
  primitiveString = primtiveStringFromBoolean(boolean),
36
33
  string = primitiveString, ///
37
- node = null,
38
- nodes = null,
39
- number = null,
40
- stringLiteral = null,
41
- primitive = new Primitive(string, node, nodes, number, boolean, stringLiteral);
34
+ type = BOOLEAN_TYPE,
35
+ value = boolean, ///
36
+ primitive = new Primitive(string, type, value);
42
37
 
43
38
  return primitive;
44
39
  }
@@ -47,11 +42,9 @@ export function primitiveFromStringLiteral(stringLiteral, context) {
47
42
  const { Primitive } = elements,
48
43
  primitiveString = primtiveStringFromStringLiteral(stringLiteral),
49
44
  string = primitiveString, ///
50
- node = null,
51
- nodes = null,
52
- number = null,
53
- boolean = null,
54
- primitive = new Primitive(string, node, nodes, number, boolean, stringLiteral);
45
+ type = STRING_TYPE,
46
+ value = stringLiteral, ///
47
+ primitive = new Primitive(string, type, value);
55
48
 
56
49
  return primitive;
57
50
  }
@@ -5,6 +5,13 @@ import nullNode from "../nullNode";
5
5
  import { NULL } from "../constants";
6
6
  import { stringFromStringLiteral } from "./stringLiteral";
7
7
 
8
+ export function ternaryStringFromTerm(term) {
9
+ const termString = term.getString(),
10
+ ternaryString = `if (${termString}) { ... } else { ... }`;
11
+
12
+ return ternaryString;
13
+ }
14
+
8
15
  export function variableStringFromName(name) {
9
16
  const variableString = name; ///
10
17
 
@@ -53,12 +60,26 @@ export function primtiveStringFromStringLiteral(stringLiteral) {
53
60
  return primtiveString;
54
61
  }
55
62
 
56
- export function variableAssignmentStringFromVariable(expression, variable) {
57
- const type = variable.getType(),
58
- variableString = variable.getString(),
59
- variableAssignmentString = `${type} ${variableString} = ... ;`;
63
+ export function termStringFromPrimitiveAndProperties(primitive, properties) {
64
+ let termString;
60
65
 
61
- return variableAssignmentString;
66
+ if (false) {
67
+ ///
68
+ } else if (primitive !== null) {
69
+ const primitiveString = primitive.toString();
70
+
71
+ termString = primitiveString; ///
72
+ } else {
73
+ properties.forEach((property) => {
74
+ if (property !== null) {
75
+ const propertyString = property.getString();
76
+
77
+ termString = propertyString; ///
78
+ }
79
+ });
80
+ }
81
+
82
+ return termString;
62
83
  }
63
84
 
64
85
  export function procedureDeclarationStringFromProcedure(procedure) {
@@ -103,6 +124,13 @@ export function expressionStringFromPrimitiveAndProperties(primitive, properties
103
124
  return expressionString;
104
125
  }
105
126
 
127
+ export function variableAssignmentStringFromTypeAndVariable(type, variable) {
128
+ const variableString = variable.getString(),
129
+ variableAssignmentString = `${type} ${variableString} = ... ;`;
130
+
131
+ return variableAssignmentString;
132
+ }
133
+
106
134
  export function someStringFromVariableAndAnonymousProcedure(variable, anonymousProcedure) {
107
135
  const variableString = variable.getString(),
108
136
  anonymousProcedureString = anonymousProcedure.getString(),
@@ -137,27 +165,29 @@ export function procedureStringFromTypeLabelParametersAndReturnBlock(type, label
137
165
  return procedureString;
138
166
  }
139
167
 
140
- export function variableAssignmentStringFromVariableAssignmentsArray(variableAssignmentsArray) {
141
- const variableAssignmentsString = variableAssignmentsArray.reduce((variableAssignmentsString, variableAssignment) => {
168
+ export function anonymousProcedureStringFromTypeParametersAndReturnBlock(type, parameters, returnBlock) {
169
+ const typeString = type, ///
170
+ parametersString = parameters.getString(),
171
+ returnBlockString = returnBlock.getString(),
172
+ anonymousProcedureString = `${typeString} (${parametersString}) ${returnBlockString}`;
173
+
174
+ return anonymousProcedureString;
175
+ }
176
+
177
+ export function variableAssignmentStringFromTypeAndVariableAssignmentsArray(type, variableAssignmentsArray) {
178
+ let variableAssignmentsString = variableAssignmentsArray.reduce((variableAssignmentsString, variableAssignment) => {
142
179
  const variableAssignmentString = variableAssignmentStringFromVariableAssignment(variableAssignment);
143
180
 
144
181
  variableAssignmentsString = (variableAssignmentsString === null) ?
145
- variableAssignmentString :
146
- `${variableAssignmentsString}, ${variableAssignmentString}`;
182
+ variableAssignmentString :
183
+ `${variableAssignmentsString}, ${variableAssignmentString}`;
147
184
 
148
185
  return variableAssignmentsString;
149
186
  }, null); ///
150
187
 
151
- return variableAssignmentsString;
152
- }
188
+ variableAssignmentsString = `${type} ${variableAssignmentsString}`; ///
153
189
 
154
- export function anonymousProcedureStringFromTypeParametersAndReturnBlock(type, parameters, returnBlock) {
155
- const typeString = type, ///
156
- parametersString = parameters.getString(),
157
- returnBlockString = returnBlock.getString(),
158
- anonymousProcedureString = `${typeString} (${parametersString}) ${returnBlockString}`;
159
-
160
- return anonymousProcedureString;
190
+ return variableAssignmentsString;
161
191
  }
162
192
 
163
193
  export function reduceStringFromVariableInitialExpressionAndAnonymousProcedure(variable, initialExpression, anonymousProcedure) {
package/test/main.js CHANGED
@@ -40,116 +40,3 @@ console.log(boolean);
40
40
  //
41
41
  // console.log(message);
42
42
  // }
43
-
44
- /*
45
- That's fine. I've come across this problem before. It's simple enough to set a flag, in fact, or, as you say, simply detect whether or not a debugger is being used.
46
-
47
-
48
-
49
- You've mentioned imports so let's cover that off.
50
-
51
-
52
-
53
- I have the source code in a src/ directory and this gets transpiled to a lib/d directory. I run my tests in a test/ directory and, because I'm running them directly on Node, I have never switched over to ES6 import syntax and use require() calls in the old-fashioned way.
54
-
55
-
56
-
57
- You can see my test here to give you an idea:
58
-
59
-
60
-
61
- +++
62
-
63
-
64
-
65
- "use strict";
66
-
67
-
68
-
69
- const ReleaseContext = require("./context/release");
70
-
71
-
72
-
73
- const { termsFromFileContext } = require("./helpers/terms"),
74
-
75
- { furtleFileFromNothing } = require("./helpers/furtle"),
76
-
77
- { procedureFromReleaseContext } = require("./helpers/procedure"),
78
-
79
- { nominalFileContextFromReleaseContext } = require("./helpers/nominal");
80
-
81
-
82
-
83
- let fileContext,
84
-
85
- releaseContext;
86
-
87
-
88
-
89
- releaseContext = ReleaseContext.fromNothing();
90
-
91
-
92
-
93
- const furtleFile = furtleFileFromNothing(),
94
-
95
- file = furtleFile; ///
96
-
97
-
98
-
99
- releaseContext.addFile(file);
100
-
101
-
102
-
103
- releaseContext.verify();
104
-
105
-
106
-
107
- const nominalFileContext = nominalFileContextFromReleaseContext(releaseContext);
108
-
109
-
110
-
111
- fileContext = nominalFileContext; ///
112
-
113
-
114
-
115
- releaseContext.addFileContext(fileContext);
116
-
117
-
118
-
119
- const free = true,
120
-
121
- terms = termsFromFileContext(fileContext, free),
122
-
123
- procedure = procedureFromReleaseContext(releaseContext);
124
-
125
-
126
-
127
- // try {
128
-
129
- const context = fileContext, ///
130
-
131
- expression = procedure.call(terms, context),
132
-
133
- boolean = expression.getBoolean();
134
-
135
-
136
-
137
- console.log(boolean);
138
-
139
- // } catch (exception) {
140
-
141
- // const message = exception.getMessage();
142
-
143
- //
144
-
145
- // console.log(message);
146
-
147
- // }
148
-
149
-
150
-
151
- +++
152
-
153
-
154
-
155
- */