README 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 fatigue 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. Lower level functions on the other hand have to operate on references to
  68. the objects or copies of the objects themselves. The named objects therefore
  69. need to be looked up by name, and then, if found, handled by reference
  70. or by copy.
  71. SELSL does have simplified objects, but without inheritance, only with
  72. message passing. Every object can also evaluate itself in a context.
  73. There are basic objects which evaluate to themselves, and excutable objects
  74. which perform some computation to produce their result.
  75. An object also has an effect on computation. Normal objects have no effect,
  76. but a Break causes the block to end execution early, a Return causes the
  77. wrapping function of mehod toreturn a value, and a Throw will keep on
  78. breaking out of scopes and bublle back to the top unless if it is stopped with
  79. a Catch.
  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. Text in the SELSL input that is not a quoted string or a number is normally
  89. a name. However, if it is peceed by a or an, it is a type, and if preceded by
  90. this, that, those, or such, it is a variable. If it is preceded by "the",
  91. it is explicitly a name.
  92. Selsl is case insensitive, by folding every character to lower case.
  93. This also goes for names, so internally Bob should be referred to as bob.
  94. A command is ended by a period. A column in a command announces the start of a
  95. block. The command end ends a block.
  96. Teach an actor to open a door do
  97. Check is that door's open then
  98. Set that door's open to false.
  99. Order that actor to: Format "You close the %s" with name of that door;
  100. else do
  101. Order that actor to: Format "The %s is already closed" with name of that door;
  102. end of check.
  103. End of teach.
  104. Set hp of me as add 1 with divide hp of me by 2 end end
  105. Create a red door as a door.
  106. open red door with green key
  107. cast cure light at smart bob
  108. SELSL sytax is configurable in that the key words can be configured before
  109. parsing. This could allow key words from non-English languages to be used.
  110. (This is (nestable)
  111. multi line comment)
  112. # This is single line comment for compatibility with shell scripts.
  113. end of command with `.` or newline
  114. start of block with `:`, do, then, else .
  115. end of block with 'end', ';', ''
  116. Syntactic sugar: `as` and `with` are translated to `to do`
  117. SCRIPT -> COMMAND eoc EOC SCRIPT | .
  118. EOC -> eoc EOC | .
  119. COMMAND -> word EXPRESSIONS .
  120. EXPRESSIONS -> EXPRESSION separator EXPRESSIONS | .
  121. EXPRESSION -> OBJECT | number | BLOCK | QUERY .
  122. QUERY -> ISQUERY | QWQUERY.
  123. ISQUERY -> is EXPRESSION qm .
  124. QWQUERY -> qw EXPRESSION qm .
  125. OBJECT-> word ATTRIBUTES .
  126. ATTRIBUTES -> OFS EXPRESSION | .
  127. OFS -> of | s .
  128. BLOCK -> ob SCRIPT END .
  129. END -> end COMMANDOFS .
  130. COMMANDOFS -> COMMAND | OFS .
  131. SCRIPT -> COMMAND eoc EOC SCRIPT | .
  132. EOC -> eoc EOC | .
  133. COMMAND -> word EXPRESSIONS .
  134. EXPRESSIONS -> EXPRESSION separator EXPRESSIONS | .
  135. EXPRESSION -> OBJECT | string | number | BLOCK | QUERY .
  136. QUERY -> ISQUERY | QWQUERY. ISQUERY -> is EXPRESSION qm .
  137. QWQUERY -> qw EXPRESSION qm . OBJECT-> WORD ATTRIBUTES .
  138. WORD -> name | variable .
  139. ATTRIBUTES -> OFS EXPRESSION | . OFS -> of | s .
  140. BLOCK -> ob SCRIPT END .
  141. END -> end COMMANDOFS .
  142. COMMANDOFS -> COMMAND | OFS .
  143. Conjunction List
  144. After
  145. Although
  146. As
  147. Because
  148. Before
  149. Even
  150. If
  151. Inasmuch
  152. Lest
  153. Now
  154. Once
  155. Provided
  156. Rather
  157. Since
  158. So
  159. Supposing
  160. Than
  161. That
  162. Though
  163. Till
  164. Unless
  165. Until
  166. When
  167. Whenever
  168. Where
  169. Whereas
  170. Wherever
  171. Whether
  172. Which
  173. While
  174. Who
  175. Whoever
  176. Why
  177. Preposition List.
  178. about
  179. aboard
  180. above
  181. across
  182. after
  183. against
  184. along
  185. amid
  186. among
  187. around
  188. as
  189. at
  190. before
  191. behind
  192. below
  193. beneath
  194. beside
  195. between
  196. beyond
  197. but
  198. by
  199. concerning
  200. considering
  201. despite
  202. down
  203. during
  204. except
  205. following
  206. for
  207. from
  208. in
  209. inside
  210. into
  211. like
  212. minus
  213. near
  214. next
  215. of
  216. off
  217. on
  218. onto
  219. opposite
  220. out
  221. outside
  222. over
  223. past
  224. per
  225. plus
  226. regarding
  227. round
  228. save
  229. since
  230. than
  231. through
  232. till
  233. to
  234. toward
  235. under
  236. underneath
  237. unlike
  238. until
  239. up
  240. upon
  241. versus
  242. via
  243. with
  244. within
  245. without