diff --git a/beautiful-racket/br/demo/txtadv/expander.rkt b/beautiful-racket/br/demo/txtadv/expander.rkt index 45ac649..d5b3560 100644 --- a/beautiful-racket/br/demo/txtadv/expander.rkt +++ b/beautiful-racket/br/demo/txtadv/expander.rkt @@ -51,6 +51,15 @@ (define-inverting #'(everywhere-action _name _desc) #'(_name _desc)) +(provide things-section) +(define-inverting #'(things-section _heading _thing ...) + #'(begin _thing ...)) + +(provide thing-entry) +(define #'(thing-entry (thing-id _thingname) (thing-action _actionname _actiondesc) ...) + #''(define-thing _thingname [_actionname _actiondesc] ...)) + + (provide desc) (define #'(desc _d) #'_d) diff --git a/beautiful-racket/br/demo/txtadv/parser.rkt b/beautiful-racket/br/demo/txtadv/parser.rkt index f265cac..eb19d0c 100644 --- a/beautiful-racket/br/demo/txtadv/parser.rkt +++ b/beautiful-racket/br/demo/txtadv/parser.rkt @@ -1,6 +1,6 @@ #lang ragg -txtadv-program : [verb-section] [everywhere-section] +txtadv-program : [verb-section] [everywhere-section] [things-section] verb-section : "===VERBS===" verb-entry+ @@ -12,6 +12,14 @@ everywhere-section : "===EVERYWHERE===" everywhere-action+ everywhere-action : ID desc +things-section : "===THINGS===" thing-entry+ + +thing-entry : thing-id thing-action+ + +thing-id : THING-NAME + +thing-action : ID desc + desc : s-exp -s-exp : ID | STRING | "(" s-exp* ")" \ No newline at end of file +s-exp : ID | STRING | ("(" "[" "{") s-exp* (")" "]" "}") \ No newline at end of file diff --git a/beautiful-racket/br/demo/txtadv/tokenizer.rkt b/beautiful-racket/br/demo/txtadv/tokenizer.rkt index e38cef6..637ccc7 100644 --- a/beautiful-racket/br/demo/txtadv/tokenizer.rkt +++ b/beautiful-racket/br/demo/txtadv/tokenizer.rkt @@ -16,8 +16,11 @@ [(union #\tab #\space #\newline) (get-token input-port)] [(repetition 1 +inf.0 (union upper-case (char-set "="))) lexeme] [(seq "\"" (complement (seq any-string "\"" any-string)) "\"") (token 'STRING lexeme)] - [(char-set "()[]{},_") lexeme] - [(repetition 1 +inf.0 (union alphabetic numeric (char-set "-."))) - (token 'ID (string->symbol lexeme))])) + [(seq "---" + (repetition 1 +inf.0 (union alphabetic numeric punctuation)) + "---") (token 'THING-NAME (string-trim lexeme "-" #:repeat? #t))] + [(repetition 1 +inf.0 (union alphabetic numeric punctuation)) + (token 'ID (string->symbol lexeme))] + [any-char lexeme])) (get-token input-port)) next-token) diff --git a/beautiful-racket/br/demo/txtadv/world.rkt b/beautiful-racket/br/demo/txtadv/world.rkt index e9435af..94503cb 100644 --- a/beautiful-racket/br/demo/txtadv/world.rkt +++ b/beautiful-racket/br/demo/txtadv/world.rkt @@ -75,11 +75,20 @@ inventory get "Ouch!" + ---door--- open - (if (have-thing? key) + (if + this + that) + + +/* +---door--- +open + (if (begin - (set-thing-state! door 'open) + (set-thing-state door open) "The door is now unlocked and open.") "The door is locked.") @@ -114,6 +123,8 @@ get (take-thing! trophy) "You win!") +*/ + /* ===PLACES===