BNF:12: CAST ::= 'cast' '<' TYPE '>' '(' ASSIGN ')'
| 1558 | |
| 1559 | // BNF:12: CAST ::= 'cast' '<' TYPE '>' '(' ASSIGN ')' |
| 1560 | asCScriptNode *asCParser::ParseCast() |
| 1561 | { |
| 1562 | asCScriptNode *node = CreateNode(snCast); |
| 1563 | if( node == 0 ) return 0; |
| 1564 | |
| 1565 | sToken t1; |
| 1566 | GetToken(&t1); |
| 1567 | if( t1.type != ttCast ) |
| 1568 | { |
| 1569 | Error(ExpectedToken("cast"), &t1); |
| 1570 | Error(InsteadFound(t1), &t1); |
| 1571 | return node; |
| 1572 | } |
| 1573 | |
| 1574 | node->UpdateSourcePos(t1.pos, t1.length); |
| 1575 | |
| 1576 | GetToken(&t1); |
| 1577 | if( t1.type != ttLessThan ) |
| 1578 | { |
| 1579 | Error(ExpectedToken("<"), &t1); |
| 1580 | Error(InsteadFound(t1), &t1); |
| 1581 | return node; |
| 1582 | } |
| 1583 | |
| 1584 | // Parse the data type |
| 1585 | node->AddChildLast(ParseType(true)); |
| 1586 | if( isSyntaxError ) return node; |
| 1587 | |
| 1588 | GetToken(&t1); |
| 1589 | if( t1.type != ttGreaterThan ) |
| 1590 | { |
| 1591 | Error(ExpectedToken(">"), &t1); |
| 1592 | Error(InsteadFound(t1), &t1); |
| 1593 | return node; |
| 1594 | } |
| 1595 | |
| 1596 | GetToken(&t1); |
| 1597 | if( t1.type != ttOpenParenthesis) |
| 1598 | { |
| 1599 | Error(ExpectedToken("("), &t1); |
| 1600 | Error(InsteadFound(t1), &t1); |
| 1601 | return node; |
| 1602 | } |
| 1603 | |
| 1604 | node->AddChildLast(ParseAssignment()); |
| 1605 | if( isSyntaxError ) return node; |
| 1606 | |
| 1607 | GetToken(&t1); |
| 1608 | if( t1.type != ttCloseParenthesis) |
| 1609 | { |
| 1610 | Error(ExpectedToken(")"), &t1); |
| 1611 | Error(InsteadFound(t1), &t1); |
| 1612 | return node; |
| 1613 | } |
| 1614 | |
| 1615 | node->UpdateSourcePos(t1.pos, t1.length); |
| 1616 | |
| 1617 | return node; |
nothing calls this directly
no test coverage detected