/* Ċ Ġ* ĠCopyright ĠĠ 2 0 2 0 ĠDavid ĠG ĠJ ones Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ* Ċ Ġ*/ Ċ Ċ package Ġinfo . dg j ones . bar nable . domain . general Ċ Ċ import Ġinfo . dg j ones . bar nable . concept .* Ċ import Ġinfo . dg j ones . bar nable . parser .* Ċ Ċ enum Ġclass ĠPhysical Object Kind Ġ{ ĊĠĠĠ ĠPhysical Object , ĊĠĠĠ ĠContainer , ĊĠĠĠ ĠGameObject , ĊĠĠĠ ĠBook , ĊĠĠĠ ĠFood , ĊĠĠĠ ĠLi quid , ĊĠĠĠ ĠLocation , ĊĠĠĠ ĠBody Part , ĊĠĠĠ ĠPl ant , Ġ// ĠTree ? Ċ } Ċ Ċ interface ĠPhysical Object Definitions Ġ{ ĊĠĠĠ Ġval Ġtitle : ĠString ĊĠĠĠ Ġfun Ġtitle (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġtitle ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġkind : ĠPhysical Object Kind ĊĠĠĠ Ġfun Ġkind (): ĠPhysical Object Kind Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġkind ĊĠĠĠ Ġ} Ċ } Ċ Ċ enum Ġclass ĠPhysical Objects ( override Ġval Ġtitle : ĠString , Ġoverride Ġval Ġkind : ĠPhysical Object Kind ): ĠPhysical Object Definitions Ġ{ ĊĠĠĠ ĠBall (" ball ", ĠPhysical Object Kind . GameObject ), ĊĠĠĠ ĠBook (" book ", ĠPhysical Object Kind . Physical Object ), ĊĠĠĠ ĠBox (" box ", ĠPhysical Object Kind . Container ), ĊĠĠĠ ĠTree (" tree ", ĠPhysical Object Kind . Plant ), Ċ } Ċ Ċ fun ĠLex ical Concept Builder . physical Object ( name : ĠString , Ġkind : ĠString , Ġinitializer : ĠLex ical Concept Builder . () Ġ-> ĠUnit ) Ġ Ġ{ ĊĠĠĠ Ġval Ġchild Ġ= ĠLex ical Concept Builder ( root , ĠPhysical Object Kind . Physical Object . name ) ĊĠĠĠ Ġchild . slot ( Core Fields . Name , Ġname ) ĊĠĠĠ Ġchild . slot ( Core Fields . Kind , Ġkind ) ĊĠĠĠ Ġchild . apply ( initializer ) ĊĠĠĠ Ġchild . save As Object () ĊĠĠĠ Ġchild . build () Ċ } Ċ Ċ fun Ġbuild Physical Object ( physical Object : ĠPhysical Object Definitions ): ĠConcept Ġ= ĊĠĠĠ ĠConcept ( Physical Object Kind . Physical Object . name ) ĊĠĠĠĠĠĠĠ Ġ. with ( Slot ( Core Fields . Name , ĠConcept ( physical Object . title ))) ĊĠĠĠĠĠĠĠ Ġ. with ( Slot ( Core Fields . Kind , ĠConcept ( physical Object . kind . name ))) Ċ Ċ fun Ġbuild Lex ical Physical Object ( kind : ĠString , Ġname : ĠString , Ġ Ġword Context : ĠWord Context , Ġinitializer : Ġ( Lex ical Concept Builder . () Ġ-> ĠUnit )? Ġ= Ġnull ): ĠLex ical Concept Ġ{ ĊĠĠĠ Ġval Ġbuilder Ġ= ĠLex ical Root Builder ( word Context , ĠPhysical Object Kind . Physical Object . name ) ĊĠĠĠ Ġbuilder . root . apply Ġ{ ĊĠĠĠĠĠĠĠ Ġslot ( Core Fields . Kind , Ġkind ) ĊĠĠĠĠĠĠĠ Ġslot ( Core Fields . Name , Ġname ) ĊĠĠĠĠĠĠĠ Ġsave As Object () ĊĠĠĠ Ġ} ĊĠĠĠ Ġinitializer ?. let Ġ{ Ġbuilder . root . apply ( initializer )} ĊĠĠĠ Ġreturn Ġbuilder . build () Ċ } Ċ Ċ fun ĠLex ical Concept Builder . save As Object () Ġ{ ĊĠĠĠ Ġroot . add D emon ( Save Object D emon ( root . word Context )) Ċ } Ċ Ċ // ĠWord ĠS enses Ċ Ċ fun Ġbuild General Physical Objects Lex icon ( lex icon : ĠLex icon ) Ġ{ ĊĠĠĠ ĠPhysical Objects . values (). forEach Ġ{ Ġlex icon . add Mapping ( Physical Object Word ( it )) Ġ} Ċ } Ċ Ċ class ĠPhysical Object Word ( private Ġval Ġphysical Object : ĠPhysical Object Definitions ): ĠWord Handler ( Entry Word ( physical Object . title )) Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġbuild ( word Context : ĠWord Context ): ĠList < D emon > Ġ= ĊĠĠĠĠĠĠĠ Ġbuild Lex ical Physical Object ( physical Object . kind . name , Ġphysical Object . title , Ġword Context ). de mon s Ċ } Ċ