- commit
- 5695046
- parent
- d15d879
- author
- xplshn
- date
- 2025-08-24 02:44:06 +0000 UTC
Merge branch 'master' of https://github.com/xplshn/gbc
1 files changed,
+61,
-68
+61,
-68
1@@ -7,84 +7,77 @@
2
3 This compiler is a project aiming to make a valid B compiler, with _optional_ syntax extensions, and a modules system like Go's
4
5-```
6+```sh
7 ]~/Documents/TrulyMine/gbc@ ./gbc --help
8
9-Copyright (c) 2025: xplshn and contributors
10-For more details refer to <https://github.com/xplshn/gbc>
11-
12- Synopsis
13- gbc [options] <input.b> ...
14-
15- Description
16- A compiler for the B programming language and its extensions, written in Go.
17-
18- Options
19- -o <file> Place the output into <file>.
20- -t, --target <target> Set the QBE target ABI.
21- -I <path> Add a directory to the include path.
22- -L <arg> Pass an argument to the linker.
23- -C <arg> Pass a compiler-specific argument (e.g., -C linker_args='-s').
24- -l<lib> Link with a library (e.g., -lb for 'b').
25- -h, --help Display this information.
26- -std=<std> Specify language standard (B, Bx). Default: Bx
27- -pedantic Issue all warnings demanded by the current B std.
28-
29- Warning Flags
30- -Wall Enable most warnings.
31- -Wno-all Disable all warnings.
32- -W<warnings> Enable a specific warnings.
33- -Wno-<warnings> Disable a specific warnings.
34- Available warnings:
35- c-esc Warn on usage of C-style '\' escapes. [x]
36- b-esc Warn on usage of B-style '*' escapes. [x]
37- b-ops Warn on usage of B-style assignment operators like '=+'. [x]
38- c-ops Warn on usage of C-style assignment operators like '+='. [x]
39- u-esc Warn on unrecognized character escape sequences. [x]
40- truncated-char Warn when a character escape value is truncated. [x]
41- long-char-const Warn when a multi-character constant is too long for a word. [x]
42- c-comments Warn on usage of non-standard C-style '//' comments. [-]
43- overflow Warn when an integer constant is out of range for its type. [x]
44- pedantic Issue all warnings demanded by the strict standard. [-]
45- unreachable-code Warn about code that will never be executed. [x]
46- implicit-decl Warn about implicit function or variable declarations. [x]
47- type Warn about type mismatches in expressions and assignments. [x]
48- extra Enable extra miscellaneous warnings. [x]
49-
50- Feature Flags
51- -F<features> Enable a specific features.
52- -Fno-<features> Disable a specific features.
53- Available features:
54- extrn Allow the 'extrn' keyword. [x]
55- asm Allow `__asm__` blocks for inline assembly. [x]
56- b-esc Recognize B-style '*' character escapes. [-]
57- c-esc Recognize C-style '\' character escapes. [x]
58- b-ops Recognize B-style assignment operators like '=+'. [-]
59- c-ops Recognize C-style assignment operators like '+='. [x]
60- c-comments Recognize C-style '//' line comments. [x]
61- typed Enable the Bx opt-in & backwards-compatible type system. [x]
62- short-decl Enable Bx-style short declaration `:=`. [x]
63- bx-decl Enable Bx-style `auto name = val` declarations. [x]
64- allow-uninitialized Allow declarations without an initializer (`var;` or `auto var;`). [x]
65- strict-decl Require all declarations to be initialized. [-]
66- no-directives Disable `// [b]:` directives. [-]
67- continue Allow the Bx keyword `continue` to be used. [x]
68-
69+ Copyright (c) 2025: xplshn and contributors
70+ For more details refer to <https://github.com/xplshn/gbc>
71+
72+ Synopsis
73+ gbc [options] <input.b> ...
74+
75+ Description
76+ A compiler for the B programming language and its extensions, written in Go.
77+
78+ Options
79+ --compiler-arg<arg> Pass a compiler-specific argument (e.g., -C linker_args='-s')
80+ -h, --help Display this information
81+ --include<path> Add a directory to the include path
82+ --linker-arg<arg> Pass an argument to the linker
83+ -o <file>, --output <file> Place the output into <file> |a.out|
84+ --std<std> Specify language standard (B, Bx) |Bx|
85+ -t <backend/target>, --target <backend/target> Set the backend and target ABI (e.g., llvm/x86_64-linux-musl) |qbe|
86+
87+ Feature Flags
88+ -F<feature flag> Enable a specific feature flag
89+ -Fno-<feature flag> Disable a specific feature flag
90+ Available feature flags:
91+ allow-uninitialized Allow declarations without an initializer (`var;` or `auto var;`). |x|
92+ asm Allow `__asm__` blocks for inline assembly. |x|
93+ b-esc Recognize B-style '*' character escapes. |-|
94+ b-ops Recognize B-style assignment operators like '=+'. |-|
95+ bx-decl Enable Bx-style `auto name = val` declarations. |x|
96+ c-comments Recognize C-style '//' line comments. |x|
97+ c-esc Recognize C-style '\' character escapes. |x|
98+ c-ops Recognize C-style assignment operators like '+='. |x|
99+ continue Allow the Bx keyword `continue` to be used. |x|
100+ extrn Allow the 'extrn' keyword. |x|
101+ no-directives Disable `// [b]:` directives. |-|
102+ short-decl Enable Bx-style short declaration `:=`. |x|
103+ strict-decl Require all declarations to be initialized. |-|
104+ typed Enable the Bx opt-in & backwards-compatible type system. |x|
105+
106+ Warning Flags
107+ -W<warning flag> Enable a specific warning flag
108+ -Wno-<warning flag> Disable a specific warning flag
109+ Available Warning Flags:
110+ b-esc Warn on usage of B-style '*' escapes. |x|
111+ b-ops Warn on usage of B-style assignment operators like '=+'. |x|
112+ c-comments Warn on usage of non-standard C-style '//' comments. |-|
113+ c-esc Warn on usage of C-style '\' escapes. |x|
114+ c-ops Warn on usage of C-style assignment operators like '+='. |x|
115+ extra Enable extra miscellaneous warnings. |x|
116+ implicit-decl Warn about implicit function or variable declarations. |x|
117+ long-char-const Warn when a multi-character constant is too long for a word. |x|
118+ overflow Warn when an integer constant is out of range for its type. |x|
119+ pedantic Issue all warnings demanded by the strict standard. |-|
120+ truncated-char Warn when a character escape value is truncated. |x|
121+ type Warn about type mismatches in expressions and assignments. |x|
122+ u-esc Warn on unrecognized character escape sequences. |x|
123+ unreachable-code Warn about code that will never be executed. |x|
124 ]~/Documents/TrulyMine/gbc@
125 ```
126
127 ### Progress Report:
128 - Capable of passing all tests
129-- Capable of compiling donut.b
130-- Capable of compiling snake.b
131-- Capable of compiling raylib.b (just remember to link with Raylib via `-L -lraylib`)
132-- Capable of compiling langtons_ants.b
133-- Capable of compiling brainfck.b
134+- Capable of compiling all examples. Producing the same output as the reference B compiler, against the same STDIN and argument inputs.
135 - Etc, these are just the most impressive examples
136 - I added a completely opt-in type system. It uses type first declarations like C, and uses the Go type names. (can also be used with strict B via `-std=B -Ftyped`, the syntax is backwards compatible. Its so reliable it comes enabled by default.)
137 - `gbc` will warn about poorly written code. TODO: Convert these warnings into annotations that offer suggestions.
138-- I'm working on adding support for alternative backends. QBE will remain as the default, but there should be other options as well, including a C one. (TODO: Expose GOABI0 target that libQBE provides)
139- - UPDATE: LLVM target will be made available soon. I'm also making progress towards achieving full cross-compilation.
140+- Portable and with multiple backends:
141+ - QBE (default, via modernc.org/libQBE, a pure Go version of QBE)
142+ - LLVM (via `llc`)
143+ - TODO: GameBoy Color Target... Coming soon!!!
144
145 ## Demo
146 <img width="1920" height="1080" alt="RayLib B demo" src="https://github.com/user-attachments/assets/ed941fc1-0754-4978-98fb-13ff2774b880" />