diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 3d2ea220c..ab47c0da0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist/ *.pgf *.tmp *~ +.direnv \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..8c98dfecc --- /dev/null +++ b/flake.lock @@ -0,0 +1,62 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1775036866, + "narHash": "sha256-ZojAnPuCdy657PbTq5V0Y+AHKhZAIwSIT2cb8UgAz/U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6201e203d09599479a3b3450ed24fa81537ebc4e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1750386251, + "narHash": "sha256-1ovgdmuDYVo5OUC5NzdF+V4zx2uT8RtsgZahxidBTyw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "076e8c6678d8c54204abcb4b1b14c366835a58bb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "sydpkgs": "sydpkgs" + } + }, + "sydpkgs": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1771299872, + "narHash": "sha256-+OPW1SKKHT7aqhyjs2O20gd1MXa7LyD+9/lwMUCVL7Y=", + "ref": "refs/heads/main", + "rev": "53bf019e26478666ab7f458f78e569b8b106cc1f", + "revCount": 36, + "type": "git", + "url": "https://git.deertopia.net/msyds/sydpkgs" + }, + "original": { + "type": "git", + "url": "https://git.deertopia.net/msyds/sydpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..aaa9665ef --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + # gf.url = "github:anka-213/cclaw-nix-stuff/nix-flakes"; + sydpkgs.url = "git+https://git.deertopia.net/msyds/sydpkgs"; + }; + + outputs = { self, nixpkgs, sydpkgs, ... }@inputs: + let + supportedSystems = [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + + each-system = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec { + pkgs = import nixpkgs { + inherit system; + overlays = [ + # (final: prev: { inherit (gf.packages.${system}) gf-core; }) + sydpkgs.overlays.default + ]; + }; + inherit (pkgs) lib; + inherit system; + }); + in { + # Exposed as a REPL convenience. + _pkgs = each-system ({ pkgs, ... }: pkgs); + + packages = each-system ({ pkgs, ... }: { + default = pkgs.callPackage ./package.nix {}; + }); + + devShells = each-system ({ pkgs, system, ... }: + let + gf-lsp = import + (pkgs.fetchzip { + url = "https://github.com/anka-213/gf-lsp/archive/refs/tags/1.0.6.0.tar.gz"; + hash = "sha256-UAI2qUslzLOWYjTirZJ0y4DZbkPZnVXTY0XtFO8+Rks="; + }) {inherit system;}; + in { + default = pkgs.mkShell { + inputsFrom = [ self.packages.${system}.default ]; + packages = [ + gf-lsp.gf-lsp + pkgs.gftest + pkgs.graphviz + pkgs.imagemagick + ]; + }; + }); + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 000000000..4a30a1800 --- /dev/null +++ b/package.nix @@ -0,0 +1,23 @@ +{ stdenv +, ghc +, gf-core +}: + +stdenv.mkDerivation { + name = "gf-rgl"; + src = ./.; + buildInputs = [ ghc gf-core ]; + # Keep references to source, so go to definition works + # postUnpack = '' + # rm -r source/src + # ln -s $src/src source/src + # ''; + LC_ALL = "C.UTF-8"; + buildPhase = '' + runghc Setup.hs build + ''; + installPhase = '' + mkdir -p $out/share/gf/lib + runghc Setup.hs copy --dest=$out/share/gf/lib + ''; +} diff --git a/src/toki-pona/CatTok.gf b/src/toki-pona/CatTok.gf index 7f6e13d33..46eb4c63c 100644 --- a/src/toki-pona/CatTok.gf +++ b/src/toki-pona/CatTok.gf @@ -1,3 +1,4 @@ +--# -path=.:../abstract:../common:../prelude concrete CatTok of Cat = CommonX ** open ResTok, Coordination, Prelude in { flags optimize=all_subs ; @@ -51,7 +52,8 @@ concrete CatTok of Cat = CommonX ** open ResTok, Coordination, Prelude in { CN = ResTok.LinCN ; NP = ResTok.LinNP ; - Pron = SS ; -- NB. Pronouns need enough info to become NP or Quant. + -- NB. Pronouns need enough info to become NP or Quant. + Pron = ResTok.LinPron ; Det = ResTok.LinDet ; -- s : Str , n : Number Predet = SS ; Quant = ResTok.LinQuant ; -- s : Number => Str @@ -68,14 +70,12 @@ concrete CatTok of Cat = CommonX ** open ResTok, Coordination, Prelude in { Numeral = ResTok.LinNumeral ; Digits = ResTok.LinNumeral ; + Decimal = SS ; --2 Structural words -- Constructed in StructuralTok. - Conj = Coordination.ConjunctionDistr ** { - -- n : Number -- The number of the NP that results from - -- coordinating a list of NPs with that Conj. - } ; -- "[Ann and Bob] are children" → and_Conj.n = Pl + Conj = Coordination.ConjunctionDistr ; Subj = SS ; Prep = SS ; diff --git a/src/toki-pona/LexiconTok.gf b/src/toki-pona/LexiconTok.gf index cb1d6885c..22783198c 100644 --- a/src/toki-pona/LexiconTok.gf +++ b/src/toki-pona/LexiconTok.gf @@ -10,7 +10,7 @@ concrete LexiconTok of Lexicon = CatTok ** -- lin already_Adv = mkA "" ; lin animal_N = mkN "soweli" ; -- lin answer_V2S = mkV2S (mkV "") ; -lin apartment_N = mkN "taso" ; +lin apartment_N = mkN "tomo" ; -- lin apple_N = mkN "" ; -- lin art_N = mkN "" ; -- lin ashes_N = mkN "" ; @@ -153,7 +153,7 @@ lin dog_N = mkN "soweli" ; -- lin glove_N = mkN "" ; -- lin go_V = mkV "" ; -- lin gold_N = mkN "" ; --- lin good_A = mkA "" ; +-- lin good_A = mkA "pona" ; -- lin grammar_N = mkN "" ; -- lin grass_N = mkN "" ; -- lin green_A = mkA "" ; @@ -202,7 +202,7 @@ lin dog_N = mkN "soweli" ; -- lin lake_N = mkN "" ; -- lin lamp_N = mkN "" ; --- lin language_N = mkN "" ; +lin language_N = mkN "toki" ; -- lin laugh_V = mkV "" ; -- lin leaf_N = mkN "" ; -- lin learn_V2 = mkV2 "" ; @@ -217,8 +217,8 @@ lin dog_N = mkN "soweli" ; -- lin long_A = mkA "" ; -- lin lose_V2 = mkV2 "" ; -- lin louse_N = mkN "" ; --- lin love_N = mkN "" ; --- lin love_V2 = mkV2 "" ; +lin love_N = mkN "olin" ; +-- lin love_V2 = mkV2 "olin" ; ---- -- M @@ -281,7 +281,7 @@ lin play_V = mkV "musi" ; -- lin read_V2 = mkV2 "" ; -- lin ready_A = mkA "" ; -- lin reason_N = mkN "" ; --- lin red_A = mkA "loje" ; +lin red_A = mkA "loje" ; -- lin religion_N = mkN "" ; -- lin restaurant_N = mkN "" ; -- lin river_N = mkN "" ; diff --git a/src/toki-pona/NounTok.gf b/src/toki-pona/NounTok.gf index aeb70119c..8d94b658a 100644 --- a/src/toki-pona/NounTok.gf +++ b/src/toki-pona/NounTok.gf @@ -11,15 +11,15 @@ concrete NounTok of Noun = CatTok ** open ResTok, Prelude in { DetCN det cn = emptyNP ** { s = cn.s ++ det.s } ; -{- + -- : PN -> NP ; -- Assuming that lincat PN = lincat NP - UsePN pn = pn ; + -- UsePN pn = pn ; -- : Pron -> NP ; -- Assuming that lincat Pron = lincat NP UsePron pron = pron ; - +{- -- : Predet -> NP -> NP ; -- only the man PredetNP predet np = diff --git a/src/toki-pona/ParadigmsTok.gf b/src/toki-pona/ParadigmsTok.gf index 76fd54a48..e18c908ce 100644 --- a/src/toki-pona/ParadigmsTok.gf +++ b/src/toki-pona/ParadigmsTok.gf @@ -121,16 +121,16 @@ oper -- TODO: more overload instances } ; -{- mkPN = overload { - mkPN : Str -> PN = … + mkPN : Str -> PN = \s -> ss s ; } ; --2 Adjectives mkA = overload { - mkA : Str -> A = \s -> … + mkA : Str -> A = \s -> ss s } ; +{- mkA2 = overload { mkA2 : Str -> A2 = \s -> … diff --git a/src/toki-pona/ResTok.gf b/src/toki-pona/ResTok.gf index c02db8dfb..b8c7277dd 100644 --- a/src/toki-pona/ResTok.gf +++ b/src/toki-pona/ResTok.gf @@ -1,3 +1,4 @@ +--# -path=.:../abstract:../common:../prelude resource ResTok = open Prelude, Predef in { -------------------------------------------------------------------------------- @@ -51,6 +52,8 @@ https://inariksit.github.io/gf/2018/08/28/gf-gotchas.html#my-naming-scheme-for-l param Person = P1 | P2 | P3 ; + LiSubject = MiSina | NotMiSina ; + oper LinN : Type = {s : Str ;} ; @@ -111,13 +114,18 @@ oper LinPron : Type = { s : Str ; p : Person ; + li : LiSubject ; -- Alternative to the `n` and `p` fields: -- a : Agr -- sketched above, lines 97-103 } ; mkPron : (_ : Str) -> Person -> LinPron = \str,per -> { s = str ; - p = per + p = per ; + li = case str of { + "mi"|"sina" => MiSina ; + _ => NotMiSina + } ; } ; --------------------------------------------- @@ -135,6 +143,8 @@ That's why I'm copying over the definition below, instead of the neater `LinNP : LinNP : Type = { s : Str ; p : Person ; + li : LiSubject ; + -- Alternative to the `n` and `p` fields: -- a : Agr -- sketched on lines 97-101 } ; @@ -144,6 +154,7 @@ That's why I'm copying over the definition below, instead of the neater `LinNP : emptyNP : LinNP = { -- Change when you change LinNP s = [] ; p = P3 ; + li = NotMiSina } ; -------------------------------------------------------------------------------- @@ -235,6 +246,11 @@ oper pred : Str ; -- TODO: depend on Temp and Pol } ; + -- linCl : LinCl -> Str = \cl -> case cl.subj of { + -- "mi"|"sina" => cl.subj ++ cl.pred ; + -- _ => cl.subj ++ "li" ++ cl.pred + -- } ; + linCl : LinCl -> Str = \cl -> cl.subj ++ cl.pred ; } diff --git a/src/toki-pona/SentenceTok.gf b/src/toki-pona/SentenceTok.gf index bfe64ad98..96810b0f7 100644 --- a/src/toki-pona/SentenceTok.gf +++ b/src/toki-pona/SentenceTok.gf @@ -11,12 +11,10 @@ lin -- : NP -> VP -> Cl PredVP np vp = { subj = np.s ; -- ! Nom, if there are cases - pred = - -- table {something with tense+polarity => - vp.s - -- TODO: all of the VP's tense and polarity should be open here! - -- PredVP only decides the subject. - -- } + pred = case np.li of { + MiSina => vp.s ; + NotMiSina => "li" ++ vp.s + } ; } ; {- diff --git a/src/toki-pona/StructuralTok.gf b/src/toki-pona/StructuralTok.gf index 9ec4d467d..74317a3ca 100644 --- a/src/toki-pona/StructuralTok.gf +++ b/src/toki-pona/StructuralTok.gf @@ -3,39 +3,39 @@ concrete StructuralTok of Structural = CatTok ** ------- -- Ad* -{- -lin almost_AdA = -lin almost_AdN = -lin at_least_AdN = -lin at_most_AdN = -lin so_AdA = -lin too_AdA = -lin very_AdA = -lin as_CAdv = -lin less_CAdv = -lin more_CAdv = +-- lin almost_AdA = +-- lin almost_AdN = +-- lin at_least_AdN = +-- lin at_most_AdN = +-- lin so_AdA = +-- lin too_AdA = +-- lin very_AdA = -lin how8much_IAdv = -lin when_IAdv = +-- lin as_CAdv = +-- lin less_CAdv = +-- lin more_CAdv = -lin how_IAdv = -lin where_IAdv = -lin why_IAdv = +-- lin how8much_IAdv = +-- lin when_IAdv = -lin always_AdV = ss "" ; +-- lin how_IAdv = +-- lin where_IAdv = +-- lin why_IAdv = + +-- lin always_AdV = ss "" ; + +-- lin everywhere_Adv = ss "" ; +-- lin here7from_Adv = ss "" ; +-- lin here7to_Adv = ss "" ; +-- lin here_Adv = ss "" ; +-- lin quite_Adv = ss "" ; +-- lin somewhere_Adv = ss "" ; +-- lin there7from_Adv = ss "" ; +-- lin there7to_Adv = ss "" ; +-- lin there_Adv = ss "" ; -lin everywhere_Adv = ss "" ; -lin here7from_Adv = ss "" ; -lin here7to_Adv = ss "" ; -lin here_Adv = ss "" ; -lin quite_Adv = ss "" ; -lin somewhere_Adv = ss "" ; -lin there7from_Adv = ss "" ; -lin there7to_Adv = ss "" ; -lin there_Adv = ss "" ; --} ------- -- Conj @@ -43,10 +43,10 @@ lin there_Adv = ss "" ; -- which means that there are two fields for the strings, and -- n:Number which specifies the number of the resulting NP. -lin and_Conj = {s1 = [] ; s2 = "and" } ; +-- lin and_Conj = {s1 = [] ; s2 = "and" } ; -- lin or_Conj = -- lin if_then_Conj = -lin both7and_DConj = {s1 = "both" ; s2 = "and" } ; +-- lin both7and_DConj = {s1 = "both" ; s2 = "and" } ; -- lin either7or_DConj = -- lin but_PConj = @@ -56,116 +56,116 @@ lin both7and_DConj = {s1 = "both" ; s2 = "and" } ; ----------------- -- *Det and Quant -{- -lin how8many_IDet = -lin every_Det = -lin all_Predet = {s = ""} ; -lin not_Predet = { s = "" } ; -lin only_Predet = { s = "" } ; -lin most_Predet = {s = ""} ; +-- lin how8many_IDet = +-- lin every_Det = -lin few_Det = R.indefDet "" pl ; -lin many_Det = R.indefDet "" pl ; -lin much_Det = R.indefDet "" sg ; +-- lin all_Predet = {s = ""} ; +-- lin not_Predet = { s = "" } ; +-- lin only_Predet = { s = "" } ; +-- lin most_Predet = {s = ""} ; -lin somePl_Det = -lin someSg_Det = +-- lin few_Det = R.indefDet "" pl ; +-- lin many_Det = R.indefDet "" pl ; +-- lin much_Det = R.indefDet "" sg ; -lin no_Quant = -lin that_Quant = mkQuant "" ; -lin this_Quant = mkQuant "" ; -lin which_IQuant = mkQuant "" ; +-- lin somePl_Det = +-- lin someSg_Det = + +-- lin no_Quant = +-- lin that_Quant = mkQuant "" ; +-- lin this_Quant = mkQuant "" ; +-- lin which_IQuant = mkQuant "" ; ----- -- NP -lin somebody_NP = +-- lin somebody_NP = -lin everybody_NP = -lin everything_NP = -lin nobody_NP = -lin nothing_NP = -lin somebody_NP = -lin something_NP = +-- lin everybody_NP = +-- lin everything_NP = +-- lin nobody_NP = +-- lin nothing_NP = +-- lin somebody_NP = +-- lin something_NP = ------- -- Prep -lin above_Prep = mkPrep "" ; -lin after_Prep = mkPrep "" ; -lin before_Prep = mkPrep "" ; -lin behind_Prep = mkPrep "" ; -lin between_Prep = = mkPrep "" ; -lin by8agent_Prep = mkPrep "" ; -lin by8means_Prep = mkPrep "" ; -lin during_Prep = mkPrep "" ; -lin except_Prep = mkPrep "" ; -lin for_Prep = mkPrep "" ; -lin from_Prep = mkPrep "" ; -lin in8front_Prep = mkPrep "" ; -lin in_Prep = mkPrep "" ; -lin on_Prep = mkPrep "" ; -lin part_Prep = mkPrep ; -lin possess_Prep = mkPrep "" ; -lin through_Prep = mkPrep "" ; -lin to_Prep = mkPrep "k" ; -lin under_Prep = mkPrep "" ; -lin with_Prep = mkPrep "" ; -lin without_Prep = mkPrep "" ; +-- lin above_Prep = mkPrep "" ; +-- lin after_Prep = mkPrep "" ; +-- lin before_Prep = mkPrep "" ; +-- lin behind_Prep = mkPrep "" ; +-- lin between_Prep = = mkPrep "" ; +-- lin by8agent_Prep = mkPrep "" ; +-- lin by8means_Prep = mkPrep "" ; +-- lin during_Prep = mkPrep "" ; +-- lin except_Prep = mkPrep "" ; +-- lin for_Prep = mkPrep "" ; +-- lin from_Prep = mkPrep "" ; +-- lin in8front_Prep = mkPrep "" ; +-- lin in_Prep = mkPrep "" ; +-- lin on_Prep = mkPrep "" ; +-- lin part_Prep = mkPrep ; +-- lin possess_Prep = mkPrep "" ; +-- lin through_Prep = mkPrep "" ; +-- lin to_Prep = mkPrep "k" ; +-- lin under_Prep = mkPrep "" ; +-- lin with_Prep = mkPrep "" ; +-- lin without_Prep = mkPrep "" ; ------- -- Pron -- Pronouns are closed class, no constructor in ParadigmsTok. -lin it_Pron = -lin i_Pron = -lin youPol_Pron = -lin youSg_Pron = -lin he_Pron = -lin she_Pron = -lin we_Pron = -lin youPl_Pron = -lin they_Pron = +-- lin it_Pron = +lin i_Pron = mkPron "mi" P1 ; +-- lin youPol_Pron = +lin youSg_Pron = mkPron "sina" P2 ; +-- lin he_Pron = +-- lin she_Pron = +lin we_Pron = mkPron "mi" P1 ; +lin youPl_Pron = mkPron "sina" P2 ; +-- lin they_Pron = -lin whatPl_IP = -lin whatSg_IP = -lin whoPl_IP = -lin whoSg_IP = +-- lin whatPl_IP = +-- lin whatSg_IP = +-- lin whoPl_IP = +-- lin whoSg_IP = ------- -- Subj -lin although_Subj = -lin because_Subj = -lin if_Subj = -lin that_Subj = -lin when_Subj = +-- lin although_Subj = +-- lin because_Subj = +-- lin if_Subj = +-- lin that_Subj = +-- lin when_Subj = ------ -- Utt -lin language_title_Utt = ss "" ; -lin no_Utt = ss "" ; -lin yes_Utt = ss "" ; +-- lin language_title_Utt = ss "" ; +-- lin no_Utt = ss "" ; +-- lin yes_Utt = ss "" ; ------- -- Verb -lin have_V2 = +-- lin have_V2 = -lin can8know_VV = -- can (capacity) -lin can_VV = -- can (possibility) -lin must_VV = -lin want_VV = +-- lin can8know_VV = -- can (capacity) +-- lin can_VV = -- can (possibility) +-- lin must_VV = +-- lin want_VV = ------ -- Voc -lin please_Voc = ss "" ; --} +-- lin please_Voc = ss "" ; + }