fable 3.0.124 → 3.0.126

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.
Files changed (23) hide show
  1. package/debug/Harness.js +48 -24
  2. package/dist/fable.compatible.js +329 -55
  3. package/dist/fable.compatible.min.js +2 -2
  4. package/dist/fable.compatible.min.js.map +1 -1
  5. package/dist/fable.js +304 -30
  6. package/dist/fable.min.js +2 -2
  7. package/dist/fable.min.js.map +1 -1
  8. package/package.json +2 -2
  9. package/source/Fable.js +18 -0
  10. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Base.js +55 -0
  11. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js +158 -0
  12. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json +22 -0
  13. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Linter.js +180 -0
  14. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js +626 -0
  15. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-SolvePostfixedExpression.js +125 -0
  16. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-TokenMap.json +75 -0
  17. package/source/services/Fable-Service-ExpressionParser.js +210 -0
  18. package/source/services/Fable-Service-Math.js +30 -1
  19. package/source/services/Fable-Service-MetaTemplate/MetaTemplate-StringParser.js +23 -14
  20. package/source/services/Fable-Service-MetaTemplate.js +4 -2
  21. package/source/services/Fable-Service-Template.js +1 -1
  22. package/test/ExpressionParser_tests.js +184 -0
  23. package/test/MetaTemplating_tests.js +41 -1
package/debug/Harness.js CHANGED
@@ -1,24 +1,48 @@
1
-
2
-
3
- testFable.addServiceType('SimpleService', SimpleService);
4
-
5
- testFable.instantiateServiceProvider('SimpleService', {SomeOption: true}, 'SimpleService-123');
6
-
7
-
8
- testFable.servicesMap['SimpleService']['SimpleService-123'].doSomething();
9
-
10
- testFable.SimpleService.doSomething();
11
-
12
- console.log(`Initialized Service ${testFable.servicesMap['SimpleService']['SimpleService-123'].serviceType} as UUID ${testFable.servicesMap['SimpleService']['SimpleService-123'].UUID} with hash ${testFable.servicesMap['SimpleService']['SimpleService-123'].Hash}`);
13
-
14
- testFable.servicesMap['SimpleService']['SimpleService-123'].doSomething();
15
-
16
- // Instantiate the RestClient Service Provider
17
- let tmpRestClient = testFable.instantiateServiceProvider('RestClient', {TraceLog: true}, 'RestClient-99');
18
-
19
- // Download the wiktionary entry for dog!
20
- tmpRestClient.getJSON('https://en.wiktionary.org/w/api.php?action=parse&prop=wikitext&format=json&page=dog',
21
- (pError, pResponse, pBody)=>
22
- {
23
- testFable.log.info('Response received~', pBody);
24
- });
1
+ //let libBookstore = require('../retold-harness/bookstore-serve-meadow-endpoint-apis-run.js');
2
+ const libFable = require('../source/Fable.js');
3
+
4
+ let testFable = new libFable({"Product": "Ti"});
5
+
6
+ testFable.instantiateServiceProviderIfNotExists('ExpressionParser');
7
+
8
+ let tmpExpression = '';
9
+ //tmpExpression = 'Result = 5+3 - sqrt(75 / (3 + {Depth}) * Width)^ 3';
10
+ //tmpExpression = 'Result = (160 * PR * Z) / (C / 100) * PR * Z + (160 * (1 - C / 100))';
11
+ tmpExpression = "Result = (160 * PR * Z) / (C / 100) * PR * Z + (160 * (1 - C / 100))";
12
+
13
+ let tmpSimpleDataObject = { "PR": 1.5, "Z": "20.036237", "C": -13 };
14
+
15
+ testFable.log.info(`tmpExpression: ${tmpExpression}`);
16
+
17
+ let tmpResultsObject = {};
18
+
19
+ let complexTokenizedResults = testFable.ExpressionParser.tokenize(tmpExpression, tmpResultsObject);
20
+ let complexLintedResults = testFable.ExpressionParser.lintTokenizedExpression(complexTokenizedResults, tmpResultsObject);
21
+ let complexPostfixedResults = testFable.ExpressionParser.buildPostfixedSolveList(complexTokenizedResults, tmpResultsObject);
22
+ testFable.ExpressionParser.substituteValuesInTokenizedObjects(tmpResultsObject.PostfixTokenObjects, tmpSimpleDataObject);
23
+
24
+ //testFable.log.info(`Full Results:\n--\n${JSON.stringify(tmpResultsObject,null,4)}\n--\n`);
25
+ //testFable.log.info(`Postfix: ${JSON.stringify(complexPostfixedResults,null,4)}`);
26
+ getTokenString = (pToken) =>
27
+ {
28
+ switch (pToken.Type)
29
+ {
30
+ case 'Token.Symbol':
31
+ return `(${pToken.Token} = ${pToken.Value})`;
32
+ case 'Token.StateAddress':
33
+ return `({${pToken.Token}} = ${pToken.Value})`;
34
+ case 'Token.Constant':
35
+ default:
36
+ return pToken.Token;
37
+ }
38
+
39
+ }
40
+ for (let i = 0; i < tmpResultsObject.PostfixSolveList.length; i++)
41
+ {
42
+ let tmpToken = tmpResultsObject.PostfixSolveList[i];
43
+ console.log(`${i}: ${tmpToken.VirtualSymbolName} = ${getTokenString(tmpToken.LeftValue)} ${tmpToken.Operation.Token} ${getTokenString(tmpToken.RightValue)}`)
44
+ }
45
+
46
+ let tmpResultValue = testFable.ExpressionParser.solvePostfixedExpression(tmpResultsObject.PostfixSolveList, tmpSimpleDataObject, tmpResultsObject);
47
+ console.log(`Result: ${tmpResultValue}`);
48
+ console.log('QED');