diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed363ca --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +AbleGo +====== + +Reference: https://go.dev/ref/spec diff --git a/default.nix b/default.nix index 82c1fc8..905757e 100644 --- a/default.nix +++ b/default.nix @@ -6,6 +6,6 @@ mkSilverBin { src = nix-gitignore.gitignoreSource [ ./.gitignore ] ./.; - grammarName = "io:mzhang:ableGo:compiler"; + grammarName = "io:mzhang:ableGo:Compiler"; javaFlags = [ "-Xss8M" ]; } diff --git a/examples/trivial.go b/examples/trivial.go new file mode 100644 index 0000000..7905807 --- /dev/null +++ b/examples/trivial.go @@ -0,0 +1,5 @@ +package main + +func main() { + +} diff --git a/flake.lock b/flake.lock index 9935e9f..1c12be5 100644 --- a/flake.lock +++ b/flake.lock @@ -14,24 +14,14 @@ "type": "indirect" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "id": "flake-utils", - "type": "indirect" - } - }, "melt": { "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs" + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1667881871, @@ -48,20 +38,6 @@ } }, "nixpkgs": { - "locked": { - "lastModified": 1666926733, - "narHash": "sha256-+gYfOEnQVISPDRNoWm2VJD5OEuTUySt48RchLpvm61o=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f44ba1be526c8da9e79a5759feca2365204003f6", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1667629849, "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=", @@ -79,7 +55,7 @@ "inputs": { "flake-utils": "flake-utils", "melt": "melt", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index abb0523..39d8f93 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,11 @@ { description = "A very basic flake"; - inputs.melt.url = "sourcehut:~remexre/melt.nix"; + inputs.melt = { + url = "sourcehut:~remexre/melt.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; outputs = { self, nixpkgs, flake-utils, melt }: flake-utils.lib.eachDefaultSystem (system: @@ -21,6 +25,9 @@ packages = flake-utils.lib.flattenTree flakePkgs; - devShell = pkgs.mkShell { inputsFrom = with packages; [ ablego ]; }; + devShell = pkgs.mkShell { + inputsFrom = with packages; [ ablego ]; + packages = with pkgs; [ go ]; + }; }); } diff --git a/grammars/io.mzhang.ableGo/compiler/Main.sv b/grammars/io.mzhang.ableGo/Compiler/Main.sv similarity index 55% rename from grammars/io.mzhang.ableGo/compiler/Main.sv rename to grammars/io.mzhang.ableGo/Compiler/Main.sv index 80a786c..a59c1e6 100644 --- a/grammars/io.mzhang.ableGo/compiler/Main.sv +++ b/grammars/io.mzhang.ableGo/Compiler/Main.sv @@ -1,11 +1,16 @@ +imports io:mzhang:ableGo:ConcreteSyntax as cst; + function main IOVal ::= args::[String] ioIn::IOToken { local fileName :: String = head(args); local result :: IO = do { + text :: String <- readFile(fileName); return 123; }; return evalIO(result, ioIn); } + +parser AbleGoParser :: cst:Root { io:mzhang:ableGo:ConcreteSyntax; } diff --git a/grammars/io.mzhang.ableGo/ConcreteSyntax/ConcreteSyntax.sv b/grammars/io.mzhang.ableGo/ConcreteSyntax/ConcreteSyntax.sv new file mode 100644 index 0000000..e69de29 diff --git a/grammars/io.mzhang.ableGo/ConcreteSyntax/Root.sv b/grammars/io.mzhang.ableGo/ConcreteSyntax/Root.sv new file mode 100644 index 0000000..6a9776f --- /dev/null +++ b/grammars/io.mzhang.ableGo/ConcreteSyntax/Root.sv @@ -0,0 +1,5 @@ +grammar io:mzhang:ableGo:ConcreteSyntax; + +nonterminal Root; + +concrete productions top::Root {} diff --git a/grammars/io.mzhang.ableGo/ConcreteSyntax/Terminals.sv b/grammars/io.mzhang.ableGo/ConcreteSyntax/Terminals.sv new file mode 100644 index 0000000..9a63b11 --- /dev/null +++ b/grammars/io.mzhang.ableGo/ConcreteSyntax/Terminals.sv @@ -0,0 +1,3 @@ +lexer class Keyword; + +terminal Break_t 'break' lexer classes {Keyword};