summaryrefslogtreecommitdiff
path: root/04a
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2021-11-17 22:58:17 -0500
committerpommicket <pommicket@gmail.com>2021-11-17 22:58:17 -0500
commit17cf6b6fa02db452c3b0b88b09b8884f73b0c1eb (patch)
tree6dd2df582b20935e5537bd6c55b885aeeea9fc65 /04a
parent3922fc11cde176e41c98a73f88e5552736b13e2f (diff)
04a readme and corrections
Diffstat (limited to '04a')
-rw-r--r--04a/Makefile4
-rw-r--r--04a/README.md23
-rw-r--r--04a/in032
-rw-r--r--04a/in04a10
4 files changed, 30 insertions, 9 deletions
diff --git a/04a/Makefile b/04a/Makefile
index e6187d4..f6b9915 100644
--- a/04a/Makefile
+++ b/04a/Makefile
@@ -1,6 +1,8 @@
-all: out03
+all: out03 out04a README.html
out03: in03 ../03/out02
../03/out02
+out04a: out03 in04a
+ ./out03 in04a out04a
%.html: %.md ../markdown
../markdown $<
clean:
diff --git a/04a/README.md b/04a/README.md
new file mode 100644
index 0000000..42dbc46
--- /dev/null
+++ b/04a/README.md
@@ -0,0 +1,23 @@
+# stage 04a
+
+Rather than a compiler, this stage only consists of a simple [preprocessor](https://en.wikipedia.org/wiki/Preprocessor).
+In the future, we'll run our code through this program, then run its output
+through a compiler.
+
+It take lines like:
+```
+#define THREE d3
+```
+and then replaces `THREE` anywhere in the rest of the code with `d3`.
+I've provided `in04a` as a little example.
+Unlike previous programs, you can control the input and output file names
+without recompiling it. So to compile the example program:
+```
+make out03
+./out03 in04a out04a
+```
+
+Although it seems simple, this program will be very useful:
+it'll let us define constants and it'll work in any language.
+There really isn't much else to say about this program. With that,
+we can move on to [the next stage](../04b/README.md) which should be more exciting.
diff --git a/04a/in03 b/04a/in03
index e4771f3..ed965e6 100644
--- a/04a/in03
+++ b/04a/in03
@@ -68,7 +68,7 @@ R=:line
; check if we reached the end of the line
C=1R
D=xa
- ?C=A:read_line
+ ?C=D:read_line
; increment R, keep looping
R+=d1
!:process_line_loop
diff --git a/04a/in04a b/04a/in04a
index 9798c24..0cd1eed 100644
--- a/04a/in04a
+++ b/04a/in04a
@@ -1,7 +1,3 @@
-A+B=hello A adfhsakjfhjksah+B
-#define COLON d1
-#define SEMICOLON d2
-#define COMMA d3
-
-A=COLON
-1B=A
+#define H Hello,
+#define W world
+H W!