AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
tokenAssociativity (int token) yoix.parser
 
Returns an int that is -1 when token represents a left associative Yoix operator, 1 when it represents a right associatve operator, and 0 when token does not represent an operator. The constants associated with Yoix operators are defined in the yoix.parser.YoixConstants dictionary. This built-in probably will only be used by specialized Yoix applications, like a program checker, that examine parse trees associated with other Yoix programs.
 
 Example:   The program,
import yoix.parser.*;
import yoix.parser.YoixConstants.*;
import yoix.stdio.*;

Array tokens = {PLUSEQ, LOGICALAND, LEFTSHIFT, WHILE};

for (; tokens@sizeof > 0; tokens++) {
    switch (tokenAssociativity(*tokens)) {
        case -1:
            printf("%s is left associative\n", tokenImage(*tokens));
            break;

        case 0:
            printf("%s is not an operator\n", tokenImage(*tokens));
            break;

        case 1: 
            printf("%s is right associative\n", tokenImage(*tokens));
            break;
    }   
}
prints
+= is right associative
&& is left associative
<< is left associative
while is not an operator
on standard output.
 
 Return:   int
 
 See Also:   ParseTree, tokenImage, tokenPrecedence, tokenValue

 

Yoix is a registered trademark of AT&T Inc.