resume in s-exp parsing
This commit is contained in:
parent
e9f392b51f
commit
07871e5526
|
@ -51,6 +51,15 @@
|
||||||
(define-inverting #'(everywhere-action _name _desc)
|
(define-inverting #'(everywhere-action _name _desc)
|
||||||
#'(_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)
|
(provide desc)
|
||||||
(define #'(desc _d) #'_d)
|
(define #'(desc _d) #'_d)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#lang ragg
|
#lang ragg
|
||||||
|
|
||||||
txtadv-program : [verb-section] [everywhere-section]
|
txtadv-program : [verb-section] [everywhere-section] [things-section]
|
||||||
|
|
||||||
verb-section : "===VERBS===" verb-entry+
|
verb-section : "===VERBS===" verb-entry+
|
||||||
|
|
||||||
|
@ -12,6 +12,14 @@ everywhere-section : "===EVERYWHERE===" everywhere-action+
|
||||||
|
|
||||||
everywhere-action : ID desc
|
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
|
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)]
|
[(union #\tab #\space #\newline) (get-token input-port)]
|
||||||
[(repetition 1 +inf.0 (union upper-case (char-set "="))) lexeme]
|
[(repetition 1 +inf.0 (union upper-case (char-set "="))) lexeme]
|
||||||
[(seq "\"" (complement (seq any-string "\"" any-string)) "\"") (token 'STRING lexeme)]
|
[(seq "\"" (complement (seq any-string "\"" any-string)) "\"") (token 'STRING lexeme)]
|
||||||
[(char-set "()[]{},_") lexeme]
|
[(seq "---"
|
||||||
[(repetition 1 +inf.0 (union alphabetic numeric (char-set "-.")))
|
(repetition 1 +inf.0 (union alphabetic numeric punctuation))
|
||||||
(token 'ID (string->symbol lexeme))]))
|
"---") (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))
|
(get-token input-port))
|
||||||
next-token)
|
next-token)
|
||||||
|
|
|
@ -75,11 +75,20 @@ inventory
|
||||||
get
|
get
|
||||||
"Ouch!"
|
"Ouch!"
|
||||||
|
|
||||||
|
|
||||||
---door---
|
---door---
|
||||||
open
|
open
|
||||||
(if (have-thing? key)
|
(if
|
||||||
|
this
|
||||||
|
that)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
---door---
|
||||||
|
open
|
||||||
|
(if
|
||||||
(begin
|
(begin
|
||||||
(set-thing-state! door 'open)
|
(set-thing-state door open)
|
||||||
"The door is now unlocked and open.")
|
"The door is now unlocked and open.")
|
||||||
"The door is locked.")
|
"The door is locked.")
|
||||||
|
|
||||||
|
@ -114,6 +123,8 @@ get
|
||||||
(take-thing! trophy)
|
(take-thing! trophy)
|
||||||
"You win!")
|
"You win!")
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===PLACES===
|
===PLACES===
|
||||||
|
|
Loading…
Reference in New Issue
Block a user