| | 626 | #define UR_MAX_PATH_LEN 16 // LIMIT: Maximum path/typemask nodes. |
| | 627 | |
| | 628 | |
| | 629 | #define SET_PATH_NODE \ |
| | 630 | if( count == (UR_MAX_PATH_LEN - 1) ) \ |
| | 631 | return 0; \ |
| | 632 | if( *cp >= '0' && *cp <= '9' ) \ |
| | 633 | { \ |
| | 634 | node[ count ] = ur_stringToInt( cp, it, 0 ); \ |
| | 635 | } else { \ |
| | 636 | nodeType |= 1 << count; \ |
| | 637 | node[ count ] = ur_intern( cp, it - cp ); \ |
| | 638 | } \ |
| | 639 | ++count; |
| | 640 | |
| | 641 | |
| | 642 | /* |
| | 643 | Returns zero if spA is not a valid selector, datatype, or path. |
| | 644 | */ |
| 639 | | ur_setType( res, UT_SELECTOR ); |
| 640 | | |
| 641 | | cp = sep + 1; |
| 642 | | if( *cp >= '0' && *cp <= '9' ) |
| 643 | | { |
| 644 | | ur_selector(res) = ur_stringToInt( cp, end, 0 ); |
| 645 | | } |
| 646 | | else |
| 647 | | { |
| 648 | | res->id.flags |= UR_FLAG_SEL_ATOM; |
| 649 | | ur_selector(res) = ur_intern( cp, end - cp ); |
| 650 | | } |
| 651 | | |
| 652 | | res->word.valBlk = GLOBAL_VAL_BLKN; |
| 653 | | res->word.atom = ur_intern( spA, sep - spA ); |
| 654 | | res->word.index = ur_internWord( &ur_global, res->word.atom ); |
| 655 | | |
| 656 | | return 1; |
| | 669 | if( (nodeType & 1) == 0 ) // First node must be a word. |
| | 670 | return 0; |
| | 671 | |
| | 672 | SET_PATH_NODE |
| | 673 | |
| | 674 | // Check if path is a typemask. |
| | 675 | for( i = 0; i < count; ++i ) |
| | 676 | { |
| | 677 | if( (nodeType & (1 << i)) == 0 ) |
| | 678 | break; |
| | 679 | if( node[ i ] >= UT_COUNT ) |
| | 680 | break; |
| | 681 | } |
| | 682 | |
| | 683 | if( i == count ) |
| | 684 | { |
| | 685 | ur_setType( res, UT_DATATYPE ); |
| | 686 | ur_datatype(res) = UT_TYPEMASK; |
| | 687 | res->dt.bitCount = count; |
| | 688 | ur_setDatatypeMask( res, node[0] ); |
| | 689 | for( i = 1; i < count; ++i ) |
| | 690 | ur_setDatatypeBit( res, node[ i ] ); |
| | 691 | |
| | 692 | return 1; |
| | 693 | } |
| | 694 | |
| | 695 | if( count == 2 ) |
| | 696 | { |
| | 697 | ur_setType( res, UT_SELECTOR ); |
| | 698 | if( nodeType & 2 ) |
| | 699 | res->id.flags |= UR_FLAG_SEL_ATOM; |
| | 700 | res->word.valBlk = GLOBAL_VAL_BLKN; |
| | 701 | res->word.atom = node[0]; |
| | 702 | ur_selector(res) = node[1]; |
| | 703 | res->word.index = ur_internWord( &ur_global, res->word.atom ); |
| | 704 | |
| | 705 | return 1; |
| | 706 | } |
| | 707 | |
| | 708 | // TODO: make path! |
| | 709 | return 0; |