commit 1b9a46ce622a18e8b294884b3b0c64066653b647
parent 490949ca474ba1a9e8ac2de101f47e568e3f01b1
Author: William Casarin <jb55@jb55.com>
Date: Mon, 9 Aug 2021 07:36:57 -0700
parse and describe spaces
Diffstat:
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/satoshis-citadel.space b/satoshis-citadel.space
@@ -1,4 +1,4 @@
-(room (shape rectangle)
+(space (shape rectangle)
(condition "clean")
(condition "shiny")
(material "solid gold")
diff --git a/src/describe.c b/src/describe.c
@@ -184,7 +184,7 @@ static int push_shape(struct describe *desc)
return 1;
}
-static int describe_room(struct describe *desc)
+static int describe_area(struct describe *desc, const char *name)
{
int ok;
@@ -198,7 +198,7 @@ static int describe_room(struct describe *desc)
ok = push_shape(desc);
if (!ok) return 0;
- ok = push_word(desc->strs, "room");
+ ok = push_word(desc->strs, name);
if (!ok) return 0;
ok = push_made_of(desc);
@@ -308,12 +308,6 @@ static int describe_object(struct describe *desc)
return 0;
}
-static int describe_space(struct describe *desc)
-{
- (void)desc;
- return 0;
-}
-
int describe_cell(struct cell *cell, struct parser *parsed, struct cursor *strbuf)
{
struct describe desc;
@@ -324,13 +318,13 @@ int describe_cell(struct cell *cell, struct parser *parsed, struct cursor *strbu
switch (cell->type) {
case C_ROOM:
- return describe_room(&desc);
+ return describe_area(&desc, "room");
+ case C_SPACE:
+ return describe_area(&desc, "space");
case C_GROUP:
return describe_group(&desc);
case C_OBJECT:
return describe_object(&desc);
- case C_SPACE:
- return describe_space(&desc);
}
return 1;
diff --git a/src/parse.c b/src/parse.c
@@ -1162,6 +1162,10 @@ static int parse_cell_by_name(struct parser *parser,
return 1;
}
+static int parse_space(struct parser *parser, u16 *index)
+{
+ return parse_cell_by_name(parser, index, "space", C_SPACE);
+}
static int parse_room(struct parser *parser, u16 *index)
{
@@ -1295,6 +1299,12 @@ int parse_cell(struct parser *parser, u16 *index)
goto close;
}
+ ok = parse_space(&backtracked, index);
+ if (ok) {
+ tokdebug("got parse_space\n");
+ goto close;
+ }
+
ok = parse_object(&backtracked, index);
if (ok) goto close;