mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Whoops, lets try that again.
This commit is contained in:
@@ -750,25 +750,10 @@ static Toy_Opcode decrementInfix(Toy_Parser* parser, Toy_ASTNode** nodeHandle) {
|
|||||||
static Toy_Opcode fnCall(Toy_Parser* parser, Toy_ASTNode** nodeHandle) {
|
static Toy_Opcode fnCall(Toy_Parser* parser, Toy_ASTNode** nodeHandle) {
|
||||||
//wait - is the previous token a type? this should be casting instead
|
//wait - is the previous token a type? this should be casting instead
|
||||||
if (parser->previous.type >= TOY_TOKEN_NULL && parser->previous.type <= TOY_TOKEN_ANY) {
|
if (parser->previous.type >= TOY_TOKEN_NULL && parser->previous.type <= TOY_TOKEN_ANY) {
|
||||||
//casting type
|
|
||||||
Toy_ASTNode* lhsNode = NULL;
|
|
||||||
castingPrefix(parser, &lhsNode);
|
|
||||||
advance(parser);
|
|
||||||
|
|
||||||
//casting value
|
//casting value
|
||||||
Toy_ASTNode* rhsNode = NULL;
|
parsePrecedence(parser, nodeHandle, PREC_TERM);
|
||||||
parsePrecedence(parser, &rhsNode, PREC_TERNARY);
|
|
||||||
|
|
||||||
//emit the cast node
|
return TOY_OP_TYPE_CAST; //opcode value
|
||||||
|
|
||||||
Toy_emitASTNodeBinary(&lhsNode, rhsNode, TOY_OP_TYPE_CAST);
|
|
||||||
|
|
||||||
//pass it off to the caller
|
|
||||||
*nodeHandle = lhsNode;
|
|
||||||
|
|
||||||
consume(parser, TOY_TOKEN_PAREN_RIGHT, "Expected ')' at end of cast grouping");
|
|
||||||
|
|
||||||
return TOY_OP_GROUPING_BEGIN; //dummy value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
advance(parser); //skip the left paren
|
advance(parser); //skip the left paren
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//test for casting + grouping, see #67
|
//test for casting + grouping, see #67
|
||||||
{
|
{
|
||||||
assert string(10 % 4) == "2", "basic group casting failed";
|
assert string(10 % 4) == "2", "basic group casting failed";
|
||||||
assert string 4 == "4", "Normal casting failed";
|
assert string 4 == "4", "normal casting failed";
|
||||||
|
|
||||||
assert typeof string(10 % 4) == string, "group casting type failed";
|
assert typeof string(10 % 4) == string, "group casting type failed";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user