8 files changed,
130 insertions(+),
0 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2025-10-16 18:33:16 +0300
Change ID:
vwlqokoyywzsnxnqltmswqvwpyyppsvv
jump to
| A | .github/workflows/test.yml |
| A | .gitignore |
| A | README.md |
| A | gleam.toml |
| A | manifest.toml |
| A | src/gbf.gleam |
| A | src/gbf/token.gleam |
| A | test/gbf_test.gleam |
A
.github/workflows/test.yml
@@ -0,0 +1,20 @@
+name: test + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + otp-version: "27.1.2" + gleam-version: "1.12.0" + rebar3-version: "3" + - run: gleam deps download + - run: gleam test + - run: gleam format --check src test
A
README.md
@@ -0,0 +1,24 @@
+# gbf + +[](https://hex.pm/packages/gbf) +[](https://hexdocs.pm/gbf/) + +```sh +gleam add gbf@1 +``` +```gleam +import gbf + +pub fn main() -> Nil { + // TODO: An example of the project in use +} +``` + +Further documentation can be found at <https://hexdocs.pm/gbf>. + +## Development + +```sh +gleam run # Run the project +gleam test # Run the tests +```
A
gleam.toml
@@ -0,0 +1,19 @@
+name = "gbf" +version = "1.0.0" + +# Fill out these fields if you intend to generate HTML documentation or publish +# your project to the Hex package manager. +# +# description = "" +# licences = ["Apache-2.0"] +# repository = { type = "github", user = "", repo = "" } +# links = [{ title = "Website", href = "" }] +# +# For a full reference of all the available options, you can have a look at +# https://gleam.run/writing-gleam/gleam-toml/. + +[dependencies] +gleam_stdlib = ">= 0.44.0 and < 2.0.0" + +[dev-dependencies] +gleeunit = ">= 1.0.0 and < 2.0.0"
A
manifest.toml
@@ -0,0 +1,11 @@
+# This file was generated by Gleam +# You typically do not need to edit this file + +packages = [ + { name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" }, + { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, +] + +[requirements] +gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } +gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
A
src/gbf/token.gleam
@@ -0,0 +1,39 @@
+pub type Token { + /// Everything that is not one of the tokens below, considered the be a comment + Comment + + /// Increment the data pointer by one (to point to the next cell to the right). + /// `>` symbol + IncrementPointer + + /// Decrement the data pointer by one (to point to the next cell to the left). + /// `<` symbol + DecrementPointer + + /// Increment the byte at the data pointer by one. + /// `+` symbol + IncrementByte + + /// Decrement the byte at the data pointer by one. + /// `-` symbol + DecrementByte + + /// Output the byte at the data pointer. + /// `.` symbol + OutputByte + + /// Accept one byte of input, storing its value in the byte at the data pointer. + /// `,` symbol + InputByte + + /// If the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command. + /// `[` symbol + StartBlock + + /// If the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command. + /// `]` symbol + EndBlock + + /// End of file + EOF +}
A
test/gbf_test.gleam
@@ -0,0 +1,13 @@
+import gleeunit + +pub fn main() -> Nil { + gleeunit.main() +} + +// gleeunit test functions end in `_test` +pub fn hello_world_test() { + let name = "Joe" + let greeting = "Hello, " <> name <> "!" + + assert greeting == "Hello, Joe!" +}