resume in s-exp parsing
This commit is contained in:
parent
e9f392b51f
commit
07871e5526
|
@ -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)
|
||||
|
||||
|
|
|
@ -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* ")"
|
||||
s-exp : ID | STRING | ("(" "[" "{") s-exp* (")" "]" "}")
|
|
@ -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)
|
||||
|
|
|
@ -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===
|
||||
|
|
Loading…
Reference in New Issue
Block a user