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 {
|
struct Footer {
|
||||||
FooterType type;
|
FooterType type;
|
||||||
union {
|
union {
|
||||||
std::vector<Choice*> choices;
|
std::vector<Choice*> *choices;
|
||||||
char *link;
|
char *link;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ std::vector<Page*> pages;
|
|||||||
|
|
||||||
Page *emit_ending();
|
Page *emit_ending();
|
||||||
Page *emit_goto(char*);
|
Page *emit_goto(char*);
|
||||||
Page *emit_choices();
|
Page *emit_choices(std::vector<Choice*>*);
|
||||||
|
|
||||||
void append_body(Page *page, char *str);
|
void append_body(Page *page, char *str);
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ TextLine = < (!Newline .)* Newline > { $$.string = strndup(yytext, yyleng);
|
|||||||
|
|
||||||
Footer = Ending { $$.page = emit_ending(); }
|
Footer = Ending { $$.page = emit_ending(); }
|
||||||
| g:Goto { $$.page = emit_goto(g.string); }
|
| 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
|
Goto = 'GOTO' Spacing < i:Identifier > Newline
|
||||||
@ -187,10 +187,10 @@ Page *emit_ending() {
|
|||||||
return mypage;
|
return mypage;
|
||||||
}
|
}
|
||||||
|
|
||||||
Page *emit_choices() {
|
Page *emit_choices(std::vector<Choice*> *choices) {
|
||||||
Page *mypage = new Page;
|
Page *mypage = new Page;
|
||||||
mypage->footer.type = FooterType::Choices;
|
mypage->footer.type = FooterType::Choices;
|
||||||
printf("page 0x%x\n", mypage);
|
mypage->footer.choices = choices;
|
||||||
return mypage;
|
return mypage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,9 @@ void print_page(Page *page) {
|
|||||||
break;
|
break;
|
||||||
case FooterType::Choices:
|
case FooterType::Choices:
|
||||||
printf("CHOICES:\n");
|
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