Added InputBox
This commit is contained in:
parent
1923886d42
commit
2a2a386592
3 changed files with 51 additions and 0 deletions
|
|
@ -78,6 +78,8 @@ static const KeywordEntryT sKeywords[] = {
|
|||
{ "LOOP", TOK_LOOP },
|
||||
{ "ME", TOK_ME },
|
||||
{ "MOD", TOK_MOD },
|
||||
{ "INPUTBOX", TOK_INPUTBOX },
|
||||
{ "INPUTBOX$", TOK_INPUTBOX },
|
||||
{ "MSGBOX", TOK_MSGBOX },
|
||||
{ "NEXT", TOK_NEXT },
|
||||
{ "NOT", TOK_NOT },
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ typedef enum {
|
|||
TOK_LOOP,
|
||||
TOK_ME,
|
||||
TOK_MOD,
|
||||
TOK_INPUTBOX,
|
||||
TOK_MSGBOX,
|
||||
TOK_NEXT,
|
||||
TOK_NOT,
|
||||
|
|
|
|||
|
|
@ -1292,6 +1292,31 @@ static void parsePrimary(BasParserT *p) {
|
|||
return;
|
||||
}
|
||||
|
||||
// InputBox$(prompt [, title [, default]])
|
||||
if (tt == TOK_INPUTBOX) {
|
||||
advance(p);
|
||||
expect(p, TOK_LPAREN);
|
||||
parseExpression(p); // prompt
|
||||
|
||||
if (match(p, TOK_COMMA)) {
|
||||
parseExpression(p); // title
|
||||
} else {
|
||||
basEmit8(&p->cg, OP_PUSH_STR);
|
||||
basEmitU16(&p->cg, basAddConstant(&p->cg, "", 0));
|
||||
}
|
||||
|
||||
if (match(p, TOK_COMMA)) {
|
||||
parseExpression(p); // default
|
||||
} else {
|
||||
basEmit8(&p->cg, OP_PUSH_STR);
|
||||
basEmitU16(&p->cg, basAddConstant(&p->cg, "", 0));
|
||||
}
|
||||
|
||||
expect(p, TOK_RPAREN);
|
||||
basEmit8(&p->cg, OP_INPUTBOX);
|
||||
return;
|
||||
}
|
||||
|
||||
// MsgBox(message [, flags]) -- as function expression returning button ID
|
||||
if (tt == TOK_MSGBOX) {
|
||||
advance(p);
|
||||
|
|
@ -4900,6 +4925,29 @@ static void parseStatement(BasParserT *p) {
|
|||
}
|
||||
break;
|
||||
|
||||
case TOK_INPUTBOX:
|
||||
// InputBox$ prompt [, title [, default]] (statement form, discard result)
|
||||
advance(p);
|
||||
parseExpression(p); // prompt
|
||||
|
||||
if (match(p, TOK_COMMA)) {
|
||||
parseExpression(p); // title
|
||||
} else {
|
||||
basEmit8(&p->cg, OP_PUSH_STR);
|
||||
basEmitU16(&p->cg, basAddConstant(&p->cg, "", 0));
|
||||
}
|
||||
|
||||
if (match(p, TOK_COMMA)) {
|
||||
parseExpression(p); // default
|
||||
} else {
|
||||
basEmit8(&p->cg, OP_PUSH_STR);
|
||||
basEmitU16(&p->cg, basAddConstant(&p->cg, "", 0));
|
||||
}
|
||||
|
||||
basEmit8(&p->cg, OP_INPUTBOX);
|
||||
basEmit8(&p->cg, OP_POP); // discard result
|
||||
break;
|
||||
|
||||
case TOK_MSGBOX:
|
||||
// MsgBox message [, flags] (statement form, discard result)
|
||||
advance(p);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue