repos / gbc

GBC - Go B Compiler
git clone https://github.com/xplshn/gbc.git

commit
0805fab
parent
0e50106
author
xplshn
date
2025-08-24 02:21:34 +0000 UTC
Merge branch 'master' of https://github.com/xplshn/gbc
1 files changed,  +40, -28
M README.md
+40, -28
  1@@ -5,10 +5,10 @@
  2 
  3 # (gbc) | The Go B Compiler
  4 
  5-This compiler is a project aiming to make a valid B compiler, with _optional_ extensions for C interoperability, and a modules system like Go's
  6+This compiler is a project aiming to make a valid B compiler, with _optional_ syntax extensions, and a modules system like Go's
  7 
  8 ```
  9-]~/Documents/TrulyMine/gbc@ ./gbc -h
 10+]~/Documents/TrulyMine/gbc@ ./gbc --help
 11 
 12 Copyright (c) 2025: xplshn and contributors
 13 For more details refer to <https://github.com/xplshn/gbc>
 14@@ -21,9 +21,11 @@ For more details refer to <https://github.com/xplshn/gbc>
 15 
 16   Options
 17     -o <file>              Place the output into <file>.
 18+    -t, --target <target>  Set the QBE target ABI.
 19     -I <path>              Add a directory to the include path.
 20     -L <arg>               Pass an argument to the linker.
 21-    -l<lib>                Link with a B library (e.g., -lb for 'b').
 22+    -C <arg>               Pass a compiler-specific argument (e.g., -C linker_args='-s').
 23+    -l<lib>                Link with a library (e.g., -lb for 'b').
 24     -h, --help             Display this information.
 25     -std=<std>             Specify language standard (B, Bx). Default: Bx
 26     -pedantic              Issue all warnings demanded by the current B std.
 27@@ -31,35 +33,44 @@ For more details refer to <https://github.com/xplshn/gbc>
 28   Warning Flags
 29     -Wall                  Enable most warnings.
 30     -Wno-all               Disable all warnings.
 31-    -W<warning>            Enable a specific warning.
 32-    -Wno-<warning>         Disable a specific warning.
 33+    -W<warnings>           Enable a specific warnings.
 34+    -Wno-<warnings>        Disable a specific warnings.
 35     Available warnings:
 36-      c-escapes            Using C-style '\' escapes instead of B's '*'                                [x]
 37-      b-escapes            Using historical B-style '*' escapes instead of C's '\'                     [x]
 38-      b-ops                Using historical B assignment operators like '=+'                           [x]
 39-      c-ops                Using C-style assignment operators like '+=' in -std=B mode                 [x]
 40-      unrecognized-escape  Using unrecognized escape sequences                                         [x]
 41-      truncated-char       Character escape value is too large for a byte and has been truncated       [x]
 42-      long-char-const      Multi-character constant is too long for a word                             [x]
 43-      c-comments           Using non-standard C-style '//' comments                                    [-]
 44-      overflow             Integer constant is out of range for its type                               [x]
 45-      pedantic             Issues that violate the current strict -std=                                [-]
 46-      unreachable-code     Unreachable code                                                            [x]
 47-      extra                Extra warnings (e.g., poor choices, unrecognized flags)                     [x]
 48+  c-esc                Warn on usage of C-style '\' escapes.                                       [x]
 49+  b-esc                Warn on usage of B-style '*' escapes.                                       [x]
 50+  b-ops                Warn on usage of B-style assignment operators like '=+'.                    [x]
 51+  c-ops                Warn on usage of C-style assignment operators like '+='.                    [x]
 52+  u-esc                Warn on unrecognized character escape sequences.                            [x]
 53+  truncated-char       Warn when a character escape value is truncated.                            [x]
 54+  long-char-const      Warn when a multi-character constant is too long for a word.                [x]
 55+  c-comments           Warn on usage of non-standard C-style '//' comments.                        [-]
 56+  overflow             Warn when an integer constant is out of range for its type.                 [x]
 57+  pedantic             Issue all warnings demanded by the strict standard.                         [-]
 58+  unreachable-code     Warn about code that will never be executed.                                [x]
 59+  implicit-decl        Warn about implicit function or variable declarations.                      [x]
 60+  type                 Warn about type mismatches in expressions and assignments.                  [x]
 61+  extra                Enable extra miscellaneous warnings.                                        [x]
 62 
 63   Feature Flags
 64-    -F<feature>            Enable a specific feature.
 65-    -Fno-<feature>         Disable a specific feature.
 66+    -F<features>           Enable a specific features.
 67+    -Fno-<features>        Disable a specific features.
 68     Available features:
 69-      extrn                Allow the 'extrn' keyword                                                   [x]
 70-      asm                  Allow the '__asm__' keyword and blocks                                      [x]
 71-      b-escapes            Recognize B-style '*' character escapes                                     [x]
 72-      c-escapes            Recognize C-style '\' character escapes                                     [x]
 73-      b-ops                Recognize B-style assignment operators like '=+'                            [x]
 74-      c-ops                Recognize C-style assignment operators like '+='                            [x]
 75-      c-comments           Recognize C-style '//' comments                                             [x]
 76-
 77-]~/Documents/TrulyMine/gbc@  
 78+  extrn                Allow the 'extrn' keyword.                                                  [x]
 79+  asm                  Allow `__asm__` blocks for inline assembly.                                 [x]
 80+  b-esc                Recognize B-style '*' character escapes.                                    [-]
 81+  c-esc                Recognize C-style '\' character escapes.                                    [x]
 82+  b-ops                Recognize B-style assignment operators like '=+'.                           [-]
 83+  c-ops                Recognize C-style assignment operators like '+='.                           [x]
 84+  c-comments           Recognize C-style '//' line comments.                                       [x]
 85+  typed                Enable the Bx opt-in & backwards-compatible type system.                    [x]
 86+  short-decl           Enable Bx-style short declaration `:=`.                                     [x]
 87+  bx-decl              Enable Bx-style `auto name = val` declarations.                             [x]
 88+  allow-uninitialized  Allow declarations without an initializer (`var;` or `auto var;`).          [x]
 89+  strict-decl          Require all declarations to be initialized.                                 [-]
 90+  no-directives        Disable `// [b]:` directives.                                               [-]
 91+  continue             Allow the Bx keyword `continue` to be used.                                 [x]
 92+
 93+]~/Documents/TrulyMine/gbc@ 
 94 ```
 95 
 96 ### Progress Report:
 97@@ -73,6 +84,7 @@ For more details refer to <https://github.com/xplshn/gbc>
 98 - 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.)
 99 - `gbc` will warn about poorly written code. TODO: Convert these warnings into annotations that offer suggestions.
100 - 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)
101+  - UPDATE: LLVM target will be made available soon. I'm also making progress towards achieving full cross-compilation.
102 
103 ## Demo
104 <img width="1920" height="1080" alt="RayLib B demo" src="https://github.com/user-attachments/assets/ed941fc1-0754-4978-98fb-13ff2774b880" />