blob: c56173e669af200173f92534d55025a27c28db46 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
math-server
===========
[![CI](https://github.com/egor-tensin/math-server/workflows/CI/badge.svg)](https://github.com/egor-tensin/math-server/actions?query=workflow%3ACI)
Development
-----------
Build using CMake.
Depends on Boost.{Filesystem,Program_options,Regex,Test}.
There's a Makefile with useful shortcuts to build the project in the .build/
directory along with the dependencies:
make deps
make build
make test
Usage
-----
### `math-server`
If you just run `math-server`, it'll start a server on port 18000.
You can `telnet` to it, type in arithmetic expressions, and it'll give you the
results:
1
1
2 * 2
4
1 / (3 - -3)
0.16666666666666666
1 / (-3 - -3)
server error: parser error: division by zero
-4 ^ 2
-16
(-4) ^ 2
16
Consult `math-server --help` for more info.
### `math-client`
A `telnet`-like client for the server.
It'll try to connect to the server on localhost:18000.
Supports reading input from:
* the command line,
> math-client -c "2 * 2"
4
* a file(s),
> math-client test.txt
result1
result2
* stdin.
> math-client
1
1
2 * 2
4
1 / (3 - -3)
0.16666666666666666
1 / (-3 - -3)
server error: parser error: division by zero
-4 ^ 2
-16
(-4) ^ 2
16
Consult `math-client --help` for more info.
### Docker
Start the server using
docker-compose pull && docker-compose up -d server
Connect to localhost:18000 to query it or run the client:
> docker-compose run --rm client -c "69 * 420"
28980
> docker-compose run --rm client
12 * 12
144
asdf
server error: lexer error: invalid input at: asdf
License
-------
Distributed under the MIT License.
See [LICENSE.txt] for details.
[LICENSE.txt]: LICENSE.txt
|