git @ Cat's Eye Technologies Xoomonk / c99e998
Keep updating README. Remove ^ from language. catseye 8 years ago
2 changed file(s) with 17 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
448448
449449 Repetition is also accomplished with a built-in store, `$.loop`. This store
450450 contains an unassigned variable called `do`. When it is assigned a value,
451 assumed to be an unsaturated store, a copy of it is made. The variable
452 `x` inside that copy is assigned the value 0. This is supposed to saturate
453 the store. The variable `continue` is then accessed from the store. If
454 it is nonzero, the process repeats, with another copy of the `do` store
455 getting 0 assigned to its `x`, and so forth.
451 assumed to be an unsaturated store, a copy of that unsaturated store is made.
452 The variable `x` inside that copy is assigned the value 0. This is supposed
453 to saturate the store. The variable `continue` is then accessed from the
454 store. If it is nonzero, the process repeats, with another copy of the `do`
455 store getting 0 assigned to its `x`, and so forth.
456456
457457 | l := $.loop*
458458 | $.counter := 5
478478 `repeat` loop. It can be used in conjunction with `$.if` to simulate a
479479 so-called `while` loop. With this loop, the built-in operations provided,
480480 and variables which may contain unbounded integer values, Xoomonk should
481 be uncontroversially Turing-complete.
481 be uncontroversially Turing-complete. (Although admittedly, using an unbounded
482 integer or two to simulate a Turing machine's tape, especially with Xoomonk's
483 arithmetic operations, would be fairly cumbersome.)
482484
483485 Finally, there is no provision for defining functions or procedures, because
484486 malingering stores can act as these constructs.
516518 Expr ::= (Block | Ref | Const) ["*"].
517519 Block ::= "{" { Stmt } "}".
518520 Ref ::= Name {"." Name}.
519 Name ::= "^" | "$" | <alphanumeric>.
521 Name ::= "$" | <alphanumeric>.
520522 Const ::= <integer-literal>.
521523
522524 Discussion
544546 g := perimeter* & { x := 13 y := 6 }
545547 print g.result
546548
549 Xoomonk 0.1 had slightly more sophisticated semantics for unsaturated stores.
550 (TODO: describe them here.) `$` was an prefix operator rather than a
551 Special Name, but having `$` refer to a global namespace was both simpler and
552 allowed the Special Name `^` for accessing the lexically enclosing store to be
553 removed.
554
547555 Xoomonk, as a project, is also an experiment in _test-driven language
548556 design_. As you can see, I've described the language with a series of
549557 examples, written in (something close to) Falderal format, each of which
8888 self.token = None
8989 self.type = 'EOF'
9090 return
91 if self.scan_pattern(r':=|\;|\{|\}|\*|\.|\^|\$', 'operator'):
91 if self.scan_pattern(r':=|\;|\{|\}|\*|\.|\$', 'operator'):
9292 return
9393 if self.scan_pattern(r'\d+', 'integer literal'):
9494 return
221221 return r
222222
223223 def name(self):
224 if self.scanner.consume("^"):
225 return AST('Upvalue')
226 elif self.scanner.consume("$"):
224 if self.scanner.consume("$"):
227225 return AST('Identifier', value='$')
228226 else:
229227 self.scanner.check_type("identifier")