From 975d0da0f5640dc1e31f5d809245cf1388423cf1 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 10 May 2016 13:04:03 -0700 Subject: [PATCH] improve txtadv parser with hiding & splicing --- beautiful-racket/br/demo/txtadv/expander.rkt | 5 ----- beautiful-racket/br/demo/txtadv/parser.rkt | 10 ++++++++-- beautiful-racket/br/demo/txtadv/world-test.rkt | 1 - 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/beautiful-racket/br/demo/txtadv/expander.rkt b/beautiful-racket/br/demo/txtadv/expander.rkt index 6c714ab..a844056 100644 --- a/beautiful-racket/br/demo/txtadv/expander.rkt +++ b/beautiful-racket/br/demo/txtadv/expander.rkt @@ -58,11 +58,6 @@ (define #'(places-section (_place-id _place-desc [_place-item ...] [_actionname _actiondesc] ...) ...) #'(begin (define-place _place-id _place-desc [_place-item ...] ([_actionname _actiondesc] ...)) ...)) -(provide s-exp) -(define-cases-inverting #'s-exp - [#'(_ _sx) #'_sx] - [#'(_ _sx ... ) #'(_sx ...)]) - ;; todo: consolidate the game-starters. ;; `start-game-at` works with s-exp language, diff --git a/beautiful-racket/br/demo/txtadv/parser.rkt b/beautiful-racket/br/demo/txtadv/parser.rkt index 523d778..a0d41e1 100644 --- a/beautiful-racket/br/demo/txtadv/parser.rkt +++ b/beautiful-racket/br/demo/txtadv/parser.rkt @@ -20,10 +20,16 @@ places-section : !"===PLACES===" place-item+ !place-item : DASHED-NAME STRING place-items id-desc+ -!place-items : !"[" ([!","] ID)* !"]" +!place-items : !"[" [place next-place*] !"]" + +@place : ID + +@next-place: !"," place start-section : !"===START===" ID !id-desc : ID s-exp -s-exp : ID | STRING | !"(" s-exp* !")" \ No newline at end of file +@s-exp : ID | STRING | nested-s-exp + +!nested-s-exp : !"(" s-exp* !")" \ No newline at end of file diff --git a/beautiful-racket/br/demo/txtadv/world-test.rkt b/beautiful-racket/br/demo/txtadv/world-test.rkt index 80a4b04..82a94d7 100644 --- a/beautiful-racket/br/demo/txtadv/world-test.rkt +++ b/beautiful-racket/br/demo/txtadv/world-test.rkt @@ -20,7 +20,6 @@ "get key" "You now have the key.\n") - (check-cmd? "n" "You're standing in a meadow. There is a house to the north.\n")