add parsing for things

dev-elider-3
Matthew Butterick 9 years ago
parent 07871e5526
commit 8be93208a2

@ -30,8 +30,8 @@
#''(define-verbs all-verbs
_verb-entry ...))
(provide verb-entry)
(define-inverting #'(verb-entry (_name0 _transitive0?) (_name _transitive?) ... _desc)
(provide verb-item)
(define-inverting #'(verb-item (_name0 _transitive0?) (_name _transitive?) ... _desc)
#`[_name0 #,@(if (syntax->datum #'_transitive0?) #'(_) #'()) (= _name ...) _desc])
(provide verb-name)
@ -47,18 +47,21 @@
#''(define-everywhere everywhere-actions
([_name _desc] ...)))
(provide everywhere-action)
(define-inverting #'(everywhere-action _name _desc)
(provide everywhere-item)
(define-inverting #'(everywhere-item _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) ...)
(provide thing-item)
(define-inverting #'(thing-item (thing-id _thingname) (_actionname _actiondesc) ...)
#''(define-thing _thingname [_actionname _actiondesc] ...))
(provide thing-action)
(define-inverting #'(thing-action _actionname _actiondesc)
#'(_actionname _actiondesc))
(provide desc)
(define #'(desc _d) #'_d)

@ -2,19 +2,19 @@
txtadv-program : [verb-section] [everywhere-section] [things-section]
verb-section : "===VERBS===" verb-entry+
verb-section : "===VERBS===" verb-item+
verb-entry : verb-name+ desc
verb-item : verb-name+ desc
verb-name : [","] ID ["_"]
everywhere-section : "===EVERYWHERE===" everywhere-action+
everywhere-section : "===EVERYWHERE===" everywhere-item+
everywhere-action : ID desc
everywhere-item : ID desc
things-section : "===THINGS===" thing-entry+
things-section : "===THINGS===" thing-item+
thing-entry : thing-id thing-action+
thing-item : thing-id thing-action+
thing-id : THING-NAME
@ -22,4 +22,4 @@ thing-action : ID desc
desc : s-exp
s-exp : ID | STRING | ("(" "[" "{") s-exp* (")" "]" "}")
s-exp : ID | STRING | ("(" | "[" | "{") s-exp* (")" | "]" | "}")

@ -18,9 +18,9 @@
[(seq "\"" (complement (seq any-string "\"" any-string)) "\"") (token 'STRING 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))]
"---") (token 'THING-NAME (string->symbol (string-trim lexeme "-" #:repeat? #t)))]
[(repetition 1 +inf.0 (union alphabetic numeric (char-set "-!?.#")))
(token 'ID (read (open-input-string lexeme)))]
[any-char lexeme]))
(get-token input-port))
next-token)

@ -66,7 +66,6 @@ look
inventory
(show-inventory)
*/
===THINGS===
@ -76,22 +75,16 @@ get
"Ouch!"
---door---
open
(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.")
close
(begin
(set-thing-state! door #f)
@ -123,10 +116,11 @@ get
(take-thing! trophy)
"You win!")
*/
/*
===PLACES===
---meadow---
@ -176,5 +170,3 @@ west
out
house-front
*/
Loading…
Cancel
Save