const char** words;
}} motion_t;
+typedef struct {{
+ const char** words;
+ const long message;
+}} action_t;
+
extern const location_t locations[];
extern const object_t objects[];
extern const char* arbitrary_messages[];
#define NCLASSES {}
#define NDEATHS {}
#define NTHRESHOLDS {}
-#define NVERBS {}
+#define NACTIONS {}
#define NTRAVEL {}
enum arbitrary_messages_refs {{
{}
}};
+enum action_refs {{
+{}
+}};
+
/* State definitions */
{}
{}
}};
+const action_t actions[] = {{
+{}
+}};
+
/* end */
"""
mot_str += template.format(words_str)
return mot_str
+def get_actions(actions):
+ template = """ {{
+ .words = {},
+ .message = {},
+ }},
+"""
+ act_str = ""
+ for action in actions:
+ contents = action[1]
+
+ if contents["words"] == None:
+ words_str = "NULL"
+ else:
+ c_words = [make_c_string(s) for s in contents["words"]]
+ words_str = "(const char* []) {" + ", ".join(c_words) + "}"
+
+ if contents["message"] == None:
+ message = "NO_MESSAGE"
+ else:
+ message = contents["message"]
+
+ act_str += template.format(words_str, message)
+ act_str = act_str[:-1] # trim trailing newline
+ return act_str
+
if __name__ == "__main__":
with open(yaml_name, "r") as f:
db = yaml.load(f)
get_condbits(db["locations"]),
get_actspk(db["actspk"]),
get_motions(db["motions"]),
+ get_actions(db["actions"]),
)
h = h_template.format(
get_refs(db["locations"]),
get_refs(db["objects"]),
get_refs(db["motions"]),
+ get_refs(db["actions"]),
statedefines,
)