class ast_family

Enumeration class for AST family.

Each language dependent AST module will define its own AST families.

ast_family Details

class cs.ast_family

Enumeration class for AST family.

static from_integer(_inner)

Construct an instance from an integer representation.

Parameters:_inner (int) – The integer representation, as returned by ast_family.as_integer().
Return type:ast_family
Raises:result.ERROR_INVALID_ARGUMENT if _inner is not a valid integer representation for a ast_family instance.

Invariant: For ast_family x, ast_family.from_integer(x.as_integer()) == x

>>> f = ast_family.C_UNNORMALIZED.as_integer()
>>> f
1
>>> ast_family.from_integer(f)
<cs.ast_family unnormalized>
__cmp__(other)

Comparison function for ast_family , with respect to a stable overall ordering.

Parameters:other (ast_family) – The ast_family object to compare against.
Return type:int
Returns:An integer N such that:
  • N==0 if the two objects compare equal
  • N<0 if self < other
  • N>0 if self > other
>>> ast_family.C_NORMALIZED.__cmp__(ast_family.C_UNNORMALIZED)
-1
__eq__(b)

Equality operator for ast_family .

Parameters:b (ast_family) – The ast_family object to compare against.
Return type:bool
Returns:True if self and b compare equal, False otherwise.
>>> ast_family.C_NORMALIZED == ast_family.C_NORMALIZED
True
__ge__(b)

Greater-than-or-equal operator for ast_family .

Parameters:b (ast_family) – The ast_family object to compare against.
Return type:bool
Returns:True if self >= b , False otherwise.
>>> ast_family.C_UNNORMALIZED >= ast_family.C_NORMALIZED
True
__gt__(b)

Greater-than operator for ast_family .

Parameters:b (ast_family) – The ast_family object to compare against.
Return type:bool
Returns:True if self > b , False otherwise.
>>> ast_family.C_UNNORMALIZED > ast_family.C_NORMALIZED
True
__hash__()

Hash function for ast_family .

Return type:int
>>> hash(ast_family.C_UNNORMALIZED)
1
__le__(b)

Less-than-or-equal operator for ast_family .

Parameters:b (ast_family) – The ast_family object to compare against.
Return type:bool
Returns:True if self <= b , False otherwise.
>>> ast_family.C_NORMALIZED <= ast_family.C_UNNORMALIZED
True
__lt__(b)

Less-than operator for ast_family .

Parameters:b (ast_family) – The ast_family object to compare against.
Return type:bool
Returns:True if self < b , False otherwise.
>>> ast_family.C_NORMALIZED < ast_family.C_UNNORMALIZED
True
__ne__(b)

Inequality operator for ast_family .

Parameters:b (ast_family) – The ast_family object to compare against.
Return type:bool
Returns:False if self and b compare equal, True otherwise.
>>> ast_family.C_NORMALIZED != ast_family.C_UNNORMALIZED
True
__repr__()

Get a representation of a ast_family object that includes information useful for debugging.

Return type:str
Returns:The string representation.
>>> repr(ast_family.C_NORMALIZED)
'<cs.ast_family normalized>'
__str__()

Get a simple string representation of a ast_family object.

Return type:str
Returns:The string representation.
>>> str(ast_family.C_UNNORMALIZED)
'unnormalized'
as_integer()

Get an integer representation of self.

Return type:int
Returns:An integer suitable for use with ast_family.from_integer().

Invariant: For ast_family x, ast_family.from_integer(x.as_integer()) == x

>>> f = ast_family.C_UNNORMALIZED.as_integer()
>>> f
1
>>> ast_family.from_integer(f)
<cs.ast_family unnormalized>
name()

Get the name of a ast_family object.

Return type:str
Returns:The name.
>>> ast_family.C_NORMALIZED.name()
'normalized'
C_NORMALIZED

Normalized C/C++ AST.

>>> ast_family.C_NORMALIZED
<cs.ast_family normalized>
C_UNNORMALIZED

Unnormalized C/C++ AST.

>>> ast_family.C_UNNORMALIZED
<cs.ast_family unnormalized>
DEFAULT

Represents the first AST family, whatever it might be.

Used as a default in the API if the user does not specify a particular family.

>>> ast_family.DEFAULT # there is a one-to-many relationship between ast_family slots and names
<cs.ast_family normalized>