This commit is contained in:
Michael Zhang 2022-12-16 08:17:03 -06:00
parent e7e4cf403d
commit 5217761cc1
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
9 changed files with 39 additions and 34 deletions

4
README.md Normal file
View file

@ -0,0 +1,4 @@
AbleGo
======
Reference: https://go.dev/ref/spec

View file

@ -6,6 +6,6 @@ mkSilverBin {
src = nix-gitignore.gitignoreSource [ ./.gitignore ] ./.; src = nix-gitignore.gitignoreSource [ ./.gitignore ] ./.;
grammarName = "io:mzhang:ableGo:compiler"; grammarName = "io:mzhang:ableGo:Compiler";
javaFlags = [ "-Xss8M" ]; javaFlags = [ "-Xss8M" ];
} }

5
examples/trivial.go Normal file
View file

@ -0,0 +1,5 @@
package main
func main() {
}

View file

@ -14,24 +14,14 @@
"type": "indirect" "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": { "melt": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": [
"nixpkgs": "nixpkgs" "flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1667881871, "lastModified": 1667881871,
@ -48,20 +38,6 @@
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1666926733,
"narHash": "sha256-+gYfOEnQVISPDRNoWm2VJD5OEuTUySt48RchLpvm61o=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f44ba1be526c8da9e79a5759feca2365204003f6",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1667629849, "lastModified": 1667629849,
"narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=", "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=",
@ -79,7 +55,7 @@
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"melt": "melt", "melt": "melt",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs"
} }
} }
}, },

View file

@ -1,7 +1,11 @@
{ {
description = "A very basic flake"; 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 }: outputs = { self, nixpkgs, flake-utils, melt }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
@ -21,6 +25,9 @@
packages = flake-utils.lib.flattenTree flakePkgs; packages = flake-utils.lib.flattenTree flakePkgs;
devShell = pkgs.mkShell { inputsFrom = with packages; [ ablego ]; }; devShell = pkgs.mkShell {
inputsFrom = with packages; [ ablego ];
packages = with pkgs; [ go ];
};
}); });
} }

View file

@ -1,11 +1,16 @@
imports io:mzhang:ableGo:ConcreteSyntax as cst;
function main function main
IOVal<Integer> ::= args::[String] ioIn::IOToken IOVal<Integer> ::= args::[String] ioIn::IOToken
{ {
local fileName :: String = head(args); local fileName :: String = head(args);
local result :: IO<Integer> = do { local result :: IO<Integer> = do {
text :: String <- readFile(fileName);
return 123; return 123;
}; };
return evalIO(result, ioIn); return evalIO(result, ioIn);
} }
parser AbleGoParser :: cst:Root { io:mzhang:ableGo:ConcreteSyntax; }

View file

@ -0,0 +1,5 @@
grammar io:mzhang:ableGo:ConcreteSyntax;
nonterminal Root;
concrete productions top::Root {}

View file

@ -0,0 +1,3 @@
lexer class Keyword;
terminal Break_t 'break' lexer classes {Keyword};