.editorconfig 🔗
@@ -0,0 +1,7 @@
+
+root = true
+
+[*]
+indent_style = space
+tab_width = 2
+indent_size = 2
Phillip Davis created
.editorconfig | 7 +++++++
.github/workflows/test.yml | 23 +++++++++++++++++++++++
.gitignore | 4 ++++
README.md | 24 ++++++++++++++++++++++++
gleam.toml | 20 ++++++++++++++++++++
manifest.toml | 16 ++++++++++++++++
shell.nix | 3 +++
src/ghall.gleam | 10 ++++++++++
src/node.gleam | 1 +
src/quasi_lexer.gleam | 17 +++++++++++++++++
src/state.gleam | 1 +
test/ghall_test.gleam | 22 ++++++++++++++++++++++
12 files changed, 148 insertions(+)
@@ -0,0 +1,7 @@
+
+root = true
+
+[*]
+indent_style = space
+tab_width = 2
+indent_size = 2
@@ -0,0 +1,23 @@
+name: test
+
+on:
+ push:
+ branches:
+ - master
+ - 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"
+ # elixir-version: "1"
+ - run: gleam deps download
+ - run: gleam test
+ - run: gleam format --check src test
@@ -0,0 +1,4 @@
+*.beam
+*.ez
+/build
+erl_crash.dump
@@ -0,0 +1,24 @@
+# ghall
+
+[](https://hex.pm/packages/ghall)
+[](https://hexdocs.pm/ghall/)
+
+```sh
+gleam add ghall@1
+```
+```gleam
+import ghall
+
+pub fn main() -> Nil {
+ // TODO: An example of the project in use
+}
+```
+
+Further documentation can be found at <https://hexdocs.pm/ghall>.
+
+## Development
+
+```sh
+gleam run # Run the project
+gleam test # Run the tests
+```
@@ -0,0 +1,20 @@
+name = "ghall"
+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"
+nibble = ">= 1.1.4 and < 2.0.0"
+
+[dev-dependencies]
+gleeunit = ">= 1.0.0 and < 2.0.0"
@@ -0,0 +1,16 @@
+# This file was generated by Gleam
+# You typically do not need to edit this file
+
+packages = [
+ { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
+ { name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
+ { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
+ { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
+ { name = "iv", version = "1.3.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "iv", source = "hex", outer_checksum = "1FE22E047705BE69EA366E3A2E73C2E1310CBCB27DDE767DE17AE3FA86499947" },
+ { name = "nibble", version = "1.1.4", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "iv"], otp_app = "nibble", source = "hex", outer_checksum = "06397501730FF486AE6F99299982A33F5EA9F8945B5A25920C82C8F924CEA481" },
+]
+
+[requirements]
+gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
+gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
+nibble = { version = ">= 1.1.4 and < 2.0.0" }
@@ -0,0 +1,3 @@
+{ pkgs ? import <nixpkgs> { } }:
+
+pkgs.mkShell { packages = [ pkgs.gleam pkgs.erlang_28 pkgs.sqlc ]; }
@@ -0,0 +1,10 @@
+import gleam/list
+import nibble/lexer.{type Token, Token}
+import quasi_lexer
+
+pub fn main() -> Nil {
+ let tokens = quasi_lexer.chars() |> quasi_lexer.run(on: "let x1 = e1")
+ echo tokens
+
+ Nil
+}
@@ -0,0 +1 @@
+pub type Node
@@ -0,0 +1,17 @@
+import gleam/list
+import nibble/lexer.{type Token, Keep}
+
+pub fn chars() -> lexer.Lexer(String, Nil) {
+ lexer.simple([lexer.custom(fn(_, lexeme, _) { Keep(lexeme, Nil) })])
+}
+
+pub fn run(
+ lexer: lexer.Lexer(String, Nil),
+ on input: String,
+) -> List(Token(String)) {
+ let assert Ok(tokens) = lexer.run(input, lexer)
+
+ // Nibble's lexer prepends an empty string to the quasi_lexer's
+ // otherwise acceptable output
+ tokens |> list.drop(1)
+}
@@ -0,0 +1 @@
+
@@ -0,0 +1,22 @@
+import gleam/list
+import gleeunit
+import nibble/lexer.{Span, Token}
+import quasi_lexer
+
+pub fn main() -> Nil {
+ gleeunit.main()
+}
+
+pub fn simple_quasi_lexer_test() {
+ quasi_lexer.chars()
+ |> quasi_lexer.run(on: "let x1 = e1")
+ |> list.index_map(fn(token, index) {
+ let Token(span, lexeme, value) = token
+ assert lexeme == value
+
+ let Span(row_start, col_start, row_end, col_end) = span
+ assert row_start == row_end && row_start == 1
+ assert col_start == index + 1
+ assert col_end == col_start + 1
+ })
+}