mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 10:21:31 +00:00
DIRECTOR: LINGO: Reimplement when
This commit is contained in:
parent
3f1df58337
commit
a5865079a1
@ -45,6 +45,7 @@ struct NextRepeatNode;
|
||||
struct ExitRepeatNode;
|
||||
struct ExitNode;
|
||||
struct TellNode;
|
||||
struct WhenNode;
|
||||
struct AssertErrorNode;
|
||||
struct IntNode;
|
||||
struct FloatNode;
|
||||
@ -94,6 +95,7 @@ enum NodeType {
|
||||
kExitRepeatNode,
|
||||
kExitNode,
|
||||
kTellNode,
|
||||
kWhenNode,
|
||||
kAssertErrorNode,
|
||||
kIntNode,
|
||||
kFloatNode,
|
||||
@ -137,6 +139,7 @@ public:
|
||||
virtual void visitExitRepeatNode(ExitRepeatNode *node) = 0;
|
||||
virtual void visitExitNode(ExitNode *node) = 0;
|
||||
virtual void visitTellNode(TellNode *node) = 0;
|
||||
virtual void visitWhenNode(WhenNode *node) = 0;
|
||||
virtual void visitAssertErrorNode(AssertErrorNode *node) = 0;
|
||||
virtual void visitIntNode(IntNode *node) = 0;
|
||||
virtual void visitFloatNode(FloatNode *node) = 0;
|
||||
@ -496,6 +499,23 @@ struct TellNode : StmtNode {
|
||||
}
|
||||
};
|
||||
|
||||
/* WhenNode */
|
||||
|
||||
struct WhenNode : StmtNode {
|
||||
Common::String *event;
|
||||
Node *code;
|
||||
|
||||
WhenNode(Common::String *eventIn, Node *codeIn)
|
||||
: StmtNode(kWhenNode), event(eventIn), code(codeIn) {}
|
||||
virtual ~WhenNode() {
|
||||
delete event;
|
||||
delete code;
|
||||
}
|
||||
virtual void accept(NodeVisitor *visitor) {
|
||||
visitor->visitWhenNode(this);
|
||||
}
|
||||
};
|
||||
|
||||
/* AssertErrorNode */
|
||||
|
||||
struct AssertErrorNode : StmtNode {
|
||||
|
@ -732,6 +732,14 @@ void LingoCompiler::visitTellNode(TellNode *node) {
|
||||
code1(LC::c_telldone);
|
||||
}
|
||||
|
||||
/* WhenNode */
|
||||
|
||||
void LingoCompiler::visitWhenNode(WhenNode *node) {
|
||||
compile(node->code);
|
||||
code1(LC::c_whencode);
|
||||
codeString(node->event->c_str());
|
||||
}
|
||||
|
||||
/* AssertErrorNode */
|
||||
|
||||
void LingoCompiler::visitAssertErrorNode(AssertErrorNode *node) {
|
||||
|
@ -96,6 +96,7 @@ public:
|
||||
virtual void visitExitRepeatNode(ExitRepeatNode *node);
|
||||
virtual void visitExitNode(ExitNode *node);
|
||||
virtual void visitTellNode(TellNode *node);
|
||||
virtual void visitWhenNode(WhenNode *node);
|
||||
virtual void visitAssertErrorNode(AssertErrorNode *node);
|
||||
virtual void visitIntNode(IntNode *node);
|
||||
virtual void visitFloatNode(FloatNode *node);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -166,7 +166,7 @@ static void checkEnd(Common::String *token, Common::String *expect, bool require
|
||||
// STATEMENT
|
||||
%type<node> stmt stmtoneliner
|
||||
%type<node> proc asgn definevars
|
||||
%type<node> ifstmt ifelsestmt loop tell
|
||||
%type<node> ifstmt ifelsestmt loop tell when
|
||||
%type<nodelist> cmdargs frameargs stmtlist nonemptystmtlist
|
||||
%type<node> stmtlistline
|
||||
|
||||
@ -331,7 +331,7 @@ ID: tVARID
|
||||
| tTO { $$ = new Common::String("to"); }
|
||||
| tASSERTERROR { $$ = new Common::String("scummvmAssertError"); }
|
||||
| tSPRITE { $$ = new Common::String("sprite"); }
|
||||
| tWHEN { $$ = new Common::String("when"); }
|
||||
// | tWHEN { $$ = new Common::String("when"); }
|
||||
| tWHILE { $$ = new Common::String("while"); }
|
||||
| tWINDOW { $$ = new Common::String("window"); }
|
||||
| tWITH { $$ = new Common::String("with"); }
|
||||
@ -362,6 +362,7 @@ stmt: stmtoneliner
|
||||
| ifelsestmt
|
||||
| loop
|
||||
| tell
|
||||
| when
|
||||
;
|
||||
|
||||
stmtoneliner: proc
|
||||
@ -503,6 +504,8 @@ tell: tTELL expr tTO stmtoneliner {
|
||||
$$ = new TellNode($expr, $stmtlist); }
|
||||
;
|
||||
|
||||
when: tWHEN ID tTHEN expr { $$ = new WhenNode($ID, $expr); } ;
|
||||
|
||||
stmtlist: /* empty */ { $$ = new NodeList; }
|
||||
| nonemptystmtlist
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user