aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md46
1 files changed, 46 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b7e684b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,46 @@
+# metac: A table-driven preprocessor for C
+
+## Overview
+`metac` is my attempt at a C preprocessor that adds the features I would like C to have. It is
+inspired by Ryan Fleury's article, see resources below.
+
+### Features
+- `@table` keyword for specifying data, eg.
+```
+@table(name, str) MyEnumTable
+{
+ { A "A" }
+ { B "B" }
+ { C "C" }
+}
+```
+- `@expand` keyword for using data from a table, eg.
+```
+typedef enum
+{
+@expand(MyEnumTable t)
+` MyEnum_$a(a.name),`
+ MyEnum_Count
+} MyEnum;
+```
+
+## Build
+Run the build script.
+```sh
+./source/build.sh
+```
+
+## Try it out
+To chek the usage you can run withuot arguments.
+```
+./build/metac
+Usage: ./build/metac filename [output_filename]
+```
+Run the program on the example file.
+```sh
+./build/metac examples/table.c
+```
+Checkout the newly created `table.meta.c`. This is your metaprogram!
+
+# Resources
+- [Ryan Fleury - table-driven code generation](https://www.rfleury.com/p/table-driven-code-generation)