G

G Programming Language
git clone http://git.omkov.net/G
Log | Tree | Refs | README | Download

AuthorJakob Wakeling <[email protected]>
Date2021-09-08 01:20:15
Commitff4f429a2f9611bf5753132ff45c13e78c9e1726
Parent6070d4c635e627855f43977a16b501b8bf47ecc6

meta: Add more usage instructions to the README

Diffstat

M README.md | 23 +++++++++++++++++++++++
M src/main.c | 9 ++++-----

2 files changed, 27 insertions, 5 deletions

diff --git a/README.md b/README.md
index e9b16b7..7d9c0b5 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,8 @@ main :: proc() -> (sint) {
 ### Dependencies
 
 - CMake >= 3.12, to build
+- LLVM, to build
+- Clang, for linking compiled object files
 
 ### Building
 
@@ -31,6 +33,27 @@ main :: proc() -> (sint) {
 cmake -S . -B build && cmake --build build
 ```
 
+### Running
+
+> See `./bin/g --help` for program options.
+
+Once the compiler is itself compiled, it can compile sources into object files
+by running `./bin/g FILES`, where FILES is replaced with a list of G source
+files to compile. At present, errors may not be correctly reported and the
+compiler may just die if any are encountered.
+
+> For example, to compile the *main.g* example file, run
+
+```sh
+./bin/g examples/main.g
+clang llvm.o
+```
+
+The first command will produce two files, *llvm.bc* and *llvm.o*, the *bc* file
+is LLVM IR bitcode, and can be decompiled to LLVM IR using llvm-dis, and the *o*
+file is an object file that can be linked into an executable with the second
+command. The second command will output an executable file, *a.out* by default.
+
 ## Todo
 
 > Not all todo items will necesarilly be implemented
diff --git a/src/main.c b/src/main.c
index 27965f2..dbeac27 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,10 +27,10 @@ static void hlp(void);
 static void ver(void);
 
 int main(int ac, char *av[]) { (void)(ac); A0 = av[0];
-	struct opt opt = OPTGET_INIT; opt.str = "lp"; opt.lops = lops;
+	struct opt opt = OPTGET_INIT; opt.str = "LP"; opt.lops = lops;
 	for (int o; (o = optget(&opt, av, 1)) != -1;) switch (o) {
-	case 'l': { lflag = true; break; }
-	case 'p': { pflag = true; break; }
+	case 'L': { lflag = true; break; }
+	case 'P': { pflag = true; break; }
 	case 256: { hlp(); return 0; }
 	case 257: { ver(); return 0; }
 	default: { return 1; }
@@ -46,8 +46,8 @@ static void hlp(void) {
 	puts("GC - G Compiler\n");
 	puts("Usage: gc [-lp]\n");
 	puts("Options:");
-	puts("  -l         Print lexer output and exit");
-	puts("  -p         Print parser output and exit");
+	puts("  -L         Print lexer debug output and exit");
+	puts("  -P         Print parser debug output and exit");
 	puts("  --help     Display help information");
 	puts("  --version  Display version information");
 	return;