Browse Source

Ponder design of fields more.

Beoran 4 years ago
parent
commit
2f5cbd7491
2 changed files with 28 additions and 19 deletions
  1. 16 11
      design_muesli.muesli
  2. 12 8
      parser.go

+ 16 - 11
design_muesli.muesli

@@ -179,25 +179,30 @@ if (less a 10) {
 $foo 
 #
 
-# There are built in functions for getting, setting and invoking the fields 
+# There are built in functions for getting, setting the fields and for
+# sending messages to objects in Smalltalk style.
 # of object valued types:
-of $door1 name # "red door"
+take $door1 name # "red door"
 make $door1 name "green door"
-invoke $door1 open $key 
+send $door1 open $key 
 
+# /*-+&|@#'(^!,?.;=~
 # Since these three are common, there is syntax available to
-# abbreviate this, using ' or 's or ,  and ;  :
-door1's name # same as (of $door1 name)
-door1's name  "green door" # same as (make $door1 name "green door")
-door1, open $key1 # same as invoke $door1 open $key1, open must be a 
+# abbreviate this.
+?door1 's name # same as (take $door1 name)
+?name , door1 (take $door1 name)
+@door1's name  "green door" # same as (make $door1 name "green door")
+>door1, open $key1 # same as send $door1 open $key1, open must be a 
 # callable method
 
-
-# It is possible to define keywords. These get replaced by a single token.
+# Muesli default syntax heavily uses "line noise" characters to signify meaning
+# through a prefix, and has no key words in itself.  However, is possible to
+# define keywords. These get replaced by a single token to reduce the line noise.
 # This allows to have an English-like or other natural language-like syntax.
-# For example, openDoor above can also be defined as follows:
+# For example, with the default English key word list openDoor above can also 
+# be defined as follows:
 to openDoor list door Door key Item done Bool do
-    if as contains as of a door key so a key so do
+    if as contains as the door's key so a key so do
         make a door open true
     end
 end

+ 12 - 8
parser.go

@@ -86,25 +86,29 @@ as follows:
 
 or, yet again:
 
+# Type a grammar here:
+
 PROGRAM -> STATEMENTS.
 STATEMENTS -> STATEMENT eos STATEMENTS|.
 STATEMENT -> EXPRESSION OPERATION |.
 OPERATION -> operator STATEMENT |.
 EXPRESSION -> COMMAND | EVALUATION .
-COMMAND -> FIELD PARAMETERS. 
-FIELD -> NAME SELECTORS ASSIGNMENT.
-SELECTORS -> selector NAME SELECTORS |.
-ASSIGNMENT -> is PARAMETER |. 
+COMMAND -> NAME PARAMETERS. 
 PARAMETERS -> PARAMETER PARAMETERS |.
-PARAMETER -> FIELD | EVALUATION .
-EVALUATION -> LITERAL | BLOCK | GETTER | SETTER | LIST | PARENTHESIS  .
+PARAMETER -> EVALUATION |  NAME .
+EVALUATION -> LITERAL | BLOCK | GETTER | SETTER | LIST | PARENTHESIS  | TAKE | MAKE | METHOD .
 PARENTHESIS -> closeparen STATEMENT openparen.
 BLOCK -> openblock STATEMENTS closeblock.
 LIST -> openlist PARAMETERS closelist.
-LITERAL -> string | int | float.
-NAME -> word | symbol | type.
 SETTER -> set PARAMETER PARAMETER.
 GETTER -> get PARAMETER.
+MAKE -> make FIELD PARAMETER .
+TAKE -> take FIELD .
+METHOD -> call FIELD . 
+FIELD -> NAME SELECTORS.
+SELECTORS -> selector NAME SELECTORS |.
+LITERAL -> string | int | float.
+NAME -> word | symbol | type.
 
 
 */