File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 8
8
"name" : " calcool" ,
9
9
10
10
"configurations" : [{
11
- "name" : " cli_app " ,
11
+ "name" : " Cli_app " ,
12
12
"targetType" : " executable" ,
13
13
"versions" : [" CLI_APP" ]
14
14
},
15
15
{
16
- "name" : " library " ,
16
+ "name" : " Library " ,
17
17
"targetType" : " library" ,
18
18
"versions" : [" LIBRARY" ]
19
19
}
Original file line number Diff line number Diff line change @@ -23,9 +23,45 @@ Usage: calcool [OPTION] [ARGUMENT]
23
23
24
24
### Use as a library
25
25
26
+ Add calcool to your dependencies
27
+
28
+ ``` json
29
+ "dependencies" : {
30
+ "calcool" : " ~>1.2.0"
31
+ }
32
+ ```
33
+
34
+ Set its subconfiguration to ` Library `
35
+
36
+ ``` json
37
+ "configurations" : [{
38
+ "name" : " your app's name" ,
39
+ "subConfigurations" : {
40
+ "calcool" : " Library"
41
+ }
42
+ }]
43
+ ```
44
+
45
+ Use it in your app
46
+
26
47
``` d
48
+ import calcool.parser;
49
+
27
50
auto p = new Prser();
28
- string result = p.evaluateFromString("sin(45*2) - 22 * -exp(3)");
51
+
52
+ try {
53
+ // You can call evaluateFromString as many times as you want
54
+ string result = p.evaluateFromString("sin(45*2) - 22 * -exp(3)");
55
+ writeln(result);
56
+ } catch (CalcoolException ce) {
57
+ // CalcoolException means your expression was not valid
58
+ stderr.writefln(ce.msg);
59
+ } catch (EndException e) {
60
+ // Ignore EndException, it only indicates the end of parsing phase, sorry
61
+ } catch (Exception e) {
62
+ // Something bad happened! Do what you have to do.
63
+ }
64
+
29
65
```
30
66
31
67
# License
Original file line number Diff line number Diff line change
1
+ module calcool.app ;
1
2
version (CLI_APP) {
2
3
import std.stdio ;
3
4
import std.getopt ;
You can’t perform that action at this time.
0 commit comments