You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+17-21
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,6 @@ Table of Contents
6
6
7
7
*[math-compiler](#math-compiler)
8
8
*[Installation](#installation)
9
-
*[Source Installation go <= 1.11](#source-installation-go---111)
10
-
*[Source installation go >= 1.12](#source-installation-go---112)
11
9
*[Quick Overview](#quick-overview)
12
10
*[About Our Output](#about-our-output)
13
11
*[Test Cases](#test-cases)
@@ -17,6 +15,8 @@ Table of Contents
17
15
*[Github Setup](#github-setup)
18
16
19
17
18
+
19
+
20
20
# math-compiler
21
21
22
22
This project contains the simplest possible compiler, which converts mathematical operations into assembly language, allowing all the speed in your sums!
@@ -56,27 +56,24 @@ Some errors will be caught at run-time, as the generated code has support for:
56
56
* For example this program is invalid `3 +`, because the addition operator requires two operands. (i.e. `3 4 +`)
57
57
58
58
59
-
## Installation
60
-
61
-
There are two ways to install this project from source, which depend on the version of the [go](https://golang.org/) version you're using.
62
-
63
-
If you just need the binaries you can find them upon the [project release page](https://github.com/skx/math-compiler/releases).
64
-
65
-
66
-
### Source Installation go <= 1.11
67
59
68
-
If you're using `go` before 1.11 then the following command should fetch/update the project and install it upon your system:
60
+
## Installation
69
61
70
-
$ go get -u github.com/skx/math-compiler
62
+
If you just need a binary you can find them upon the [project release page](https://github.com/skx/math-compiler/releases), however if you wish to build and install locally you can do that in either of the standard ways:
71
63
72
-
### Source installation go >= 1.12
64
+
1. Install from the latest revision:
73
65
74
-
If you're using a more recent version of `go` (which is _highly_ recommended), you need to clone to a directory which is not present upon your `GOPATH`:
66
+
```sh
67
+
$ go install github.com/skx/math-compiler@master
68
+
```
75
69
76
-
git clone https://github.com/skx/math-compiler
77
-
cd math-compiler
78
-
go install
70
+
2. Or you can clone the source, and build from it:
79
71
72
+
```sh
73
+
$ git clone https://github.com/skx/math-compiler
74
+
$ cd math-compiler
75
+
$ go install .
76
+
```
80
77
81
78
82
79
@@ -98,10 +95,9 @@ However I even simplified that, via the use of a "[Reverse Polish](https://en.wi
98
95
99
96
100
97
101
-
102
98
## About Our Output
103
99
104
-
The output of `math-compiler` will typically be an assembly-language file, which then needs to be compiled before it may be executed.
100
+
The output of `math-compiler` will be an assembly-language file, which then needs to be compiled before it may be executed.
105
101
106
102
Given our previous example of `2 + ( 4 * 54)` we can compile & execute that program like so:
107
103
@@ -128,6 +124,7 @@ Or to compile __and__ execute directly:
128
124
Result 12
129
125
130
126
127
+
131
128
## Test Cases
132
129
133
130
The codebase itself contains some simple test-cases, however these are not comprehensive as a large part of our operation is merely to populate a simple template-file, and it is hard to test that.
@@ -153,8 +150,6 @@ they produce the correct result.
153
150
...
154
151
155
152
156
-
157
-
158
153
### Debugging the generated programs
159
154
160
155
If you run the compiler with the `-debug` flag a breakpoint will be generated
@@ -215,6 +210,7 @@ Further documentation can be found in the `gdb` manual, which is worth reading
215
210
if you've an interest in compilers, debuggers, and decompilers.
216
211
217
212
213
+
218
214
## Possible Expansion?
219
215
220
216
The obvious thing to improve in this compiler is to add support for more operations. At the moment support for the most obvious/common operations is present, but perhaps more functions could be added.
0 commit comments