Choices as vector pointer (getting close!...)
This commit is contained in:
parent
2ad0587242
commit
8c729d5218
14
cyoa.leg
14
cyoa.leg
@ -44,7 +44,7 @@ enum class FooterType {
|
||||
struct Footer {
|
||||
FooterType type;
|
||||
union {
|
||||
std::vector<Choice*> choices;
|
||||
std::vector<Choice*> *choices;
|
||||
char *link;
|
||||
};
|
||||
|
||||
@ -65,7 +65,7 @@ std::vector<Page*> pages;
|
||||
|
||||
Page *emit_ending();
|
||||
Page *emit_goto(char*);
|
||||
Page *emit_choices();
|
||||
Page *emit_choices(std::vector<Choice*>*);
|
||||
|
||||
void append_body(Page *page, char *str);
|
||||
|
||||
@ -100,7 +100,7 @@ TextLine = < (!Newline .)* Newline > { $$.string = strndup(yytext, yyleng);
|
||||
|
||||
Footer = Ending { $$.page = emit_ending(); }
|
||||
| g:Goto { $$.page = emit_goto(g.string); }
|
||||
| c:ChoiceList { $$.page = emit_choices(); }
|
||||
| c:ChoiceList { $$.page = emit_choices(c.choices); }
|
||||
;
|
||||
|
||||
Goto = 'GOTO' Spacing < i:Identifier > Newline
|
||||
@ -187,10 +187,10 @@ Page *emit_ending() {
|
||||
return mypage;
|
||||
}
|
||||
|
||||
Page *emit_choices() {
|
||||
Page *emit_choices(std::vector<Choice*> *choices) {
|
||||
Page *mypage = new Page;
|
||||
mypage->footer.type = FooterType::Choices;
|
||||
printf("page 0x%x\n", mypage);
|
||||
mypage->footer.choices = choices;
|
||||
return mypage;
|
||||
}
|
||||
|
||||
@ -218,7 +218,9 @@ void print_page(Page *page) {
|
||||
break;
|
||||
case FooterType::Choices:
|
||||
printf("CHOICES:\n");
|
||||
break;
|
||||
for (Choice *c : *page->footer.choices) {
|
||||
printf("%d) %s\n", c->option, c->flavor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user