README 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. SELSL is a Simple English Like Scripting Language
  2. It is implemented in Go language for use with Go muds, such as my Woe
  3. MUD engine. It is indended to be usable both as an interective command
  4. interpreter for the users of the MUD as well as a scripting language
  5. for the builders.
  6. While the goal is to be english like, a second goal is to be simple,
  7. so it does not use any advanced AI like techniques to parse the
  8. input. Rarther it uses a few simple rules to reduce the user input to
  9. commands, and blocks of commands.
  10. he
  11. him
  12. his
  13. she
  14. her
  15. hers
  16. they
  17. them
  18. their
  19. theirs
  20. it
  21. its
  22. me
  23. myself
  24. i
  25. Rethinking the OOP part: SELSL is focused for use in MUDs and similar.
  26. Thinking about it pure OOP is a bad fit for that. We can see this from this
  27. example command: "Move apple from tree to box." On which object this
  28. command is acting? On the apple as it would seem? But the apple itself is
  29. basically unchanged, only it's membership changed from being part of the tree
  30. to being in of box. The tree and box are also changed, but which one of the two
  31. should get the method then? It does not make sense to define the method on
  32. either.
  33. Furthermore, there's another object in play and that is the player/actor
  34. themselves who actually moves the object. In a MUD this may e.g.
  35. add fattigue to the player, like it does in real life.
  36. And then there is the environment in which these objects may be present,
  37. or even absent. In a MUD this will be a room in a zone in a land. That room,
  38. or even other adjacent rooms can be modified by the action of the actor.
  39. For example a text message may need to be displayed to all other actors in the
  40. room.
  41. All in all the OOP model is too simple because it put primacy on a single
  42. object, and defines the operation to one of the involved objects while
  43. treating the others as second class parameters.
  44. What I think would be better for SELSL is ACtor Oriented Programming (ACOP)
  45. where the actor defines all the operations, but where the environment is always
  46. an implicit parameter (may be expicit in the Go side). Like this actor
  47. permissions also become trivial because actors can be defined to only
  48. know about those actions they are allowed to perform, and furher permission
  49. checks can be done if necessary before even calling the action.
  50. This shifts the burden away from the actions themselves which might
  51. then be implemented ignoring permissions since that is checked an a higher
  52. level. The only exception to this would be commands that can afffect other
  53. actors.
  54. Of course, then typing does become relevant again, because opening a door
  55. is different from opening a container. Still it should me possible to overload
  56. these two operations based on the types of the objects involved. Having
  57. automatic overloading is easier and more flexible than having to manually
  58. extend the open operation every time it has to act on some different object.
  59. Of course, all this this goes for object simulation in a MUD-like world.
  60. For simpler operations like maths or string concatenation, or any pure
  61. functions without side effects for that matter, the result of the operation
  62. does not depend on the environment, only on the operands, so maybe a special
  63. scheme is needed for lower level pure functions or similar operations.
  64. These might be defined on some kind of "universe" level.
  65. Another aspect is that of pass by name versus pass by reference. High level
  66. actions which the actor performed are based on the name of the objects.
  67. SELSL is object oriented but not class based. In stead it is prototype
  68. based much like the SELF language. In SELSL, everything is an object.
  69. Objects have slots that can contain other values. There are basic objects
  70. which evaluate to themselves, and excutable objects which perform
  71. some computation to produce their result.
  72. An object also has an effect on computation. Normal objects have no effect,
  73. but a Return causes the block to end execution early. A Throw
  74. will keep on unless if it is stopped with a Catch.
  75. Variables, and also arguments are simply slots of the current activation
  76. record of an executable object. There are no stand alone variables.
  77. Eveything exists in something else, except for the top level "world".
  78. There is also a "me" object which represents the the current actor
  79. that is operating on the state of the world.
  80. A SELSL script consists of commands. Commands operate on the state of the
  81. world and may cause output to be produced as well.
  82. A command begins with a verb and is optionally followed by the objects the
  83. command perates on. If a command has no objects it will operate on the
  84. "me" object. Commands are separated from each other by one of
  85. the English prepositions or conjunctions that SELSL accepts. See below for
  86. the lists. Commands are also separated by the particles "a", "an", "the",
  87. or the demonstratives "this", "that", "those".
  88. A command is ended by a period. A column in a command announces the start of a
  89. block. The command end ends a block.
  90. Teach an actor to open a door do
  91. Check if door's open then
  92. Set door's open to false.
  93. Tell an actor to: Format "You close the %s" with door's name;
  94. else do
  95. Tell an actor to: Format "The %s is already closed" with door's name;
  96. end of check.
  97. End of teach.
  98. Set hp of me as add 1 with divide hp of me by 2 end end
  99. Create a red door as a door.
  100. open red door with green ke
  101. cast cure light at smart bob
  102. (This is (nestable)
  103. multi line comment)
  104. # This is single line comment for compatibility with shell scripts.
  105. end of command with `.` or newline
  106. start of block with `:`, do.
  107. end of block with 'end', ';', ''
  108. Syntactic sugar: `as` and `with` are translated to `to do`
  109. SCRIPT -> COMMAND eoc EOC SCRIPT | .
  110. EOC -> eoc EOC | .
  111. COMMAND -> word EXPRESSIONS .
  112. EXPRESSIONS -> EXPRESSION separator EXPRESSIONS | .
  113. EXPRESSION -> OBJECT | number | BLOCK.
  114. OBJECT-> word ATTRIBUTES .
  115. ATTRIBUTES -> OFS EXPRESSION | .
  116. OFS -> of | s .
  117. BLOCK -> ob SCRIPT END .
  118. END -> end COMMAND .
  119. Including queries:
  120. SCRIPT -> COMMAND eoc EOC SCRIPT | .
  121. EOC -> eoc EOC | .
  122. COMMAND -> word EXPRESSIONS .
  123. EXPRESSIONS -> EXPRESSION separator EXPRESSIONS | .
  124. EXPRESSION -> OBJECT | number | BLOCK | QUERY .
  125. QUERY -> ISQUERY | QWQUERY.
  126. ISQUERY -> is EXPRESSION qm .
  127. QWQUERY -> qw EXPRESSION qm .
  128. OBJECT-> word ATTRIBUTES .
  129. ATTRIBUTES -> OFS EXPRESSION | .
  130. OFS -> of | s .
  131. BLOCK -> ob SCRIPT END .
  132. END -> end COMMAND .
  133. Conjunction List
  134. After
  135. Although
  136. As
  137. Because
  138. Before
  139. Even
  140. If
  141. Inasmuch
  142. Lest
  143. Now
  144. Once
  145. Provided
  146. Rather
  147. Since
  148. So
  149. Supposing
  150. Than
  151. That
  152. Though
  153. Till
  154. Unless
  155. Until
  156. When
  157. Whenever
  158. Where
  159. Whereas
  160. Wherever
  161. Whether
  162. Which
  163. While
  164. Who
  165. Whoever
  166. Why
  167. Preposition List.
  168. about
  169. aboard
  170. above
  171. across
  172. after
  173. against
  174. along
  175. amid
  176. among
  177. around
  178. as
  179. at
  180. before
  181. behind
  182. below
  183. beneath
  184. beside
  185. between
  186. beyond
  187. but
  188. by
  189. concerning
  190. considering
  191. despite
  192. down
  193. during
  194. except
  195. following
  196. for
  197. from
  198. in
  199. inside
  200. into
  201. like
  202. minus
  203. near
  204. next
  205. of
  206. off
  207. on
  208. onto
  209. opposite
  210. out
  211. outside
  212. over
  213. past
  214. per
  215. plus
  216. regarding
  217. round
  218. save
  219. since
  220. than
  221. through
  222. till
  223. to
  224. toward
  225. under
  226. underneath
  227. unlike
  228. until
  229. up
  230. upon
  231. versus
  232. via
  233. with
  234. within
  235. without