diff --git a/src/base/cyoa.h b/src/base/cyoa.h index c7f3397..d2874d7 100644 --- a/src/base/cyoa.h +++ b/src/base/cyoa.h @@ -25,7 +25,7 @@ struct Choice { char *id; statchange_t *statchange; - Choice(char*, statcheck_t *statcheck, statchange_t *statchange); + Choice(int); }; typedef std::map ChoiceList; diff --git a/src/base/cyoa.leg b/src/base/cyoa.leg index 64b5cf9..f5d77be 100644 --- a/src/base/cyoa.leg +++ b/src/base/cyoa.leg @@ -60,20 +60,18 @@ Ending = 'THE END' Newline ChoiceList = c:Choice l:ChoiceList { $$ = l; (*$$.choices)[c.choice->option] = c.choice; } | c:Choice { $$.choices = new ChoiceList(); (*$$.choices)[c.choice->option] = c.choice; } -Choice = b:Bullet f:Freetext r:Redirect - { - $$ = r; - $$.choice->option = b.num; - $$.choice->flavor = f.string; - } +Choice = b:Bullet + f:Freetext { b.choice->flavor = f.string; } + (ck:StatCheck { b.choice->statcheck = ck.statcheck; })? + '[' i:Identifier ']' { b.choice->id = i.string; } - + (cg:StatChange { b.choice->statchange = cg.statchange; })? + Newline { $$ = b; } + ; -Bullet = < [0-9]+ > ')' - { $$.num = atoi(yytext); } +Bullet = < [0-9]+ > ')' - { $$.choice = new Choice(atoi(yytext)); } Freetext = < ([^[<])+ > { $$.string = strndup(yytext, yyleng); } -Redirect = ck:StatCheck? '[' i:Identifier ']' - cg:StatChange? Newline - { $$.choice = new Choice(i.string, ck.statcheck, cg.statchange); } - StatCheck = '<' n:StatName v:StatVal r:StatRel '>' - { $$.statcheck = new statcheck_t{n.string, v.num, r.num}; } @@ -96,10 +94,10 @@ Newline = '\r\n' | '\r' | '\n' %% -Choice::Choice(char *id, statcheck_t *statcheck, statchange_t *statchange) { - this->id = id; - this->statcheck = statcheck; - this->statchange = statchange; +Choice::Choice(int option) { + this->option = option; + this->statcheck = NULL; + this->statchange = NULL; } Footer::Footer() {