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
attributes grammar
 
An lvalue is an expression the refers to an object, and every lvalue comes with a set of attributes that can be accessed by Yoix programs by appending an @ and an attribute name to the lvalue. Most of the attributes can currently only be applied to readable objects, however access and name always work, even when the object is not readable. The names of the attributes associated with every lvalue are:
access An int indicating the access permissions of the object.
growable An int that is non-zero if the object's length can be increased by at least one element.
length An int indicating the total length of a pointer object regardless of the position of the offset pointer. See also offset and sizeof, below. It is zero when not applicable.
major An int indicating the object type. If the object is a pointer, a stream or some similar object, then the minor attribute may be needed to fully ascertain the type of the object.
minor An int indicating the object sub-type, if applicable.
nameof A String indicating the name that is associated with the object.
offset An int indicating the position of the offset pointer within the pointer object.
sizeof An int indicating the length of the pointer object starting from the offset pointer.
typename A String indicating the object's type.
Its usage description can be summarized as follows:
Attribute:
	LValue @ access
	LValue @ length
	LValue @ major
	LValue @ minor
	LValue @ nameof
	LValue @ offset
	LValue @ sizeof
	LValue @ typename
 
 Example:   The program,
import yoix.io.*;
import yoix.stdio.*;
import yoix.string.*;

String str        = "hello";
String ptr        = str;
const String cstr = str;
final String fstr = strdup(str);

modes(mode) {
    String md = "";

    if((mode&LOCK) == LOCK)
	md += "L";
    else md += "_";
    if((mode&READ) == READ)
	md += "R";
    else md += "_";
    if((mode&WRITE) == WRITE)
	md += "W";
    else md += "_";
    if((mode&EXECUTE) == EXECUTE)
	md += "X";
    else md += "_";

    return(md);
}

deflag(flag) {
    String perms = "";

    perms = modes(flag&(READ|WRITE|LOCK|EXECUTE));
    perms += "->";
    perms += modes((flag>>4)&(READ|WRITE|LOCK|EXECUTE));

    return(perms);
}

ptr++;

printf("The %s variable %s (%d/%d) with value '%s' has:\n\
\taccess: %d (%s)\n\tlength: %d\n\toffset: %d\n\tsizeof: %d\n",
       str@typename, str@nameof, str@major, str@minor, str,
       str@access, deflag(str@access),
       str@length, str@offset, str@sizeof);

printf("The %s variable %s (%d/%d) with value '%s' has:\n\
\taccess: %d (%s)\n\tlength: %d\n\toffset: %d\n\tsizeof: %d\n",
       ptr@typename, ptr@nameof, ptr@major, ptr@minor, ptr,
       ptr@access, deflag(ptr@access),
       ptr@length, ptr@offset, ptr@sizeof);

printf("The %s variable %s (%d/%d) with value '%s' has:\n\
\taccess: %d (%s)\n\tlength: %d\n\toffset: %d\n\tsizeof: %d\n",
       cstr@typename, cstr@nameof, cstr@major, cstr@minor, cstr,
       cstr@access, deflag(cstr@access),
       cstr@length, cstr@offset, cstr@sizeof);

printf("The %s variable %s (%d/%d) with value '%s' has:\n\
\taccess: %d (%s)\n\tlength: %d\n\toffset: %d\n\tsizeof: %d\n",
       fstr@typename, fstr@nameof, fstr@major, fstr@minor, fstr,
       fstr@access, deflag(fstr@access),
       fstr@length, fstr@offset, fstr@sizeof);
prints something like,
The String variable str (180/191) with value 'hello' has:
        access: 118 (_RW_->_RWX)
        length: 5
        offset: 0
        sizeof: 5
The String variable ptr (180/191) with value 'ello' has:
        access: 118 (_RW_->_RWX)
        length: 5
        offset: 1
        sizeof: 4
The String variable cstr (180/191) with value 'hello' has:
        access: 125 (LR_X->_RWX)
        length: 5
        offset: 0
        sizeof: 5
The String variable fstr (180/191) with value 'hello' has:
        access: 221 (LR_X->LR_X)
        length: 5
        offset: 0
        sizeof: 5
on standard output.
 
 See Also:   const, final, Object, Pointer, reference

 

Yoix is a registered trademark of AT&T Inc.