Browse Source

add person example

Getty Ritter 1 year ago
parent
commit
83a054031d
1 changed files with 43 additions and 0 deletions
  1. 43 0
      examples/person.matzo

+ 43 - 0
examples/person.matzo

@@ -0,0 +1,43 @@
+gender:= Male | Female | Unspec;
+byGender := { [m,f,n] => { [Male] => m; [Female] => f; [_] => n }};
+
+ending  := byGender["o","a","e"];
+pronoun := byGender["He","She","They"];
+noun    := byGender["man","woman","person"];
+are     := byGender["is","is","are"];
+have    := byGender["has", "has", "have"];
+
+cons  ::= p t c d g r l m n x;
+vowel ::= a e i o u;
+
+name := { [g] => (vowel | "") rep[1..3, cons vowel] cons ending[g] };
+
+hairColor ::= black brown blonde;
+eyeColor  ::= brown green blue;
+
+job := { [g] =>
+    "stonemason"
+  | "baker"
+  | "accountant"
+  | case g in
+      { Male   => "fisherman"
+      ; Female => "fisherwoman"
+      } };
+tool := { ["stonemason"] => "chisel"
+        ; ["baker"]      => "bowl"
+        ; ["accountant"] => "tablet"
+        ; [_]            => "fishing pole"
+        };
+
+adjective ::= happy cheerful focused quiet meek rash;
+
+person :=
+  let fix my-gender := gender in {
+  let fix my-job := job[my-gender] in {
+    "You come across " str/capitalize[name[my-gender]] ", a " noun[my-gender]
+      " from the city of " str/capitalize[name[Female]] ". "
+      pronoun[my-gender] " " are[my-gender] " a hardworking " my-job " with "
+      hairColor " hair and " eyeColor " eyes. "
+      str/capitalize[pronoun[my-gender]] " "
+      have[my-gender] " a " tool[my-job] " and " are[my-gender] " very " adjective "." } };
+puts person;