Traductor e intérprete del lenguaje CL 1.23
CL_AST Class Reference

Nodos a medida del árbol de sintaxis abstracta. More...

Collaboration diagram for CL_AST:

List of all members.

Public Member Functions

CL_AST getChild (int i)
 Sobreescribe el método que obtiene el i-éesimo hijo del nodo actual del AST.
String toString ()
 Sobreescribe CommonTree.toString() para describir cómo debe aparecer como texto el nodo raiz del subárbol AST, no todo el subárbol.

Package Functions

 CL_AST (Token t)
 Constructor que crea un nodo de un árbol CL_AST a partir de un token t.
TypeTree getTypeTree ()
 Consulta el atributo tipus.
void setTypeTree (TypeTree t)
 Establece el atributo tipus.
void setTypeTree (int type)
 Establece el atributo tipus para tipos básicos.
void setTypeError ()
 Establece el atributo tipus al tipo error (TypeError, declarado en TypeCheck.g.
boolean getReferenciable ()
 Consulta el atributo esReferenciable.
void setReferenciable (boolean b)
 Establece el atributo esReferenciable.

Static Package Functions

static String toIndentedTreeString (CL_AST t)
 Describe cómo un subárbol AST debe aparecer como texto, en formato multilínea indentado.

Private Member Functions

String toNodeString ()
 Describe cómo debe aparecer como texto el nodo raiz del subárbol AST, no todo el subárbol.

Static Private Member Functions

static void toIndentedTreeString (CL_AST t, String s, StringBuffer sb)
 Describe cómo un subárbol AST debe aparecer como texto (en un StringBuffer), en formato multilínea indentado.

Private Attributes

TypeTree tipus
 Tipo de la expresión.
boolean esReferenciable
 La expresión es referenciable?.

Detailed Description

Nodos a medida del árbol de sintaxis abstracta.

Extiende la clase CommonTree que define árboles con nodos que contienen el tipo y texto del token (atributos type y text), y su localización (line y charPositionInLine). A estos se añaden nuevos atributos y otros métodos para trabajar con estos nuevos árboles.

The Definitive ANTLR Reference [pag. 157]:
If you'd like to use your own tree node type because you want to add some fields to each node, define your node as a subclass of CommonTree. Then, subclass CommonTreeAdaptor, and override create() so that it builds your special nodes. Finally, you must inform ANTLR that it should use your custom adaptor
ANTLR API Documentation [CommonTreeAdaptor Class]:
http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1tree_1_1_common_tree_adaptor.html#_details
To get your parser to build nodes of a different type, override create(Token), errorNode(), and to be safe, YourTreeClass.dupNode(). dupNode is called to duplicate nodes during rewrite operations.
ANTLR Wiki [Tree Construction. Heterogeneous tree nodes]:
http://www.antlr.org/wiki/display/ANTLR3/Tree+construction#Treeconstruction-Heterogeneoustreenodes
By default, with output=AST, ANTLR creates trees of type CommonTree. To create different nodes... you can override create(Token) and YourTreeClass.dupNode(Object) and errorNode() in a subclass of CommonTreeAdaptor.
See also:
CommonTree, TypeTree
Author:
José Miguel Rivero Almeida

Definition at line 61 of file CL_AST.java.


Constructor & Destructor Documentation

CL_AST.CL_AST ( Token  t) [package]

Constructor que crea un nodo de un árbol CL_AST a partir de un token t.

Además establece los valores por defecto para los atributos tipus y esReferenciable.

Parameters:
[in]ttoken que incorporar al nodo del CL_AST

Definition at line 87 of file CL_AST.java.

Here is the caller graph for this function:


Member Function Documentation

CL_AST CL_AST.getChild ( int  i)

Sobreescribe el método que obtiene el i-éesimo hijo del nodo actual del AST.

Para evitar tener que hacer castings de la forma: (CL_AST) getChild(i)

Parameters:
[in]inúmero de hijo a obtener, comenzando desde 0
Returns:
El i-ésimo subárbol hijo

Definition at line 152 of file CL_AST.java.

Here is the call graph for this function:

Here is the caller graph for this function:

boolean CL_AST.getReferenciable ( ) [package]

Consulta el atributo esReferenciable.

Returns:
el valor booleano del atributo esReferenciable

Definition at line 133 of file CL_AST.java.

TypeTree CL_AST.getTypeTree ( ) [package]

Consulta el atributo tipus.

Returns:
el atributo tipus, de tipo TypeTree

Definition at line 102 of file CL_AST.java.

void CL_AST.setReferenciable ( boolean  b) [package]

Establece el atributo esReferenciable.

Parameters:
[in]bvalor del atributo esReferenciable, de tipo booleano

Definition at line 141 of file CL_AST.java.

void CL_AST.setTypeError ( ) [package]

Establece el atributo tipus al tipo error (TypeError, declarado en TypeCheck.g.

See also:
TypeCheck.TypeError

Definition at line 126 of file CL_AST.java.

void CL_AST.setTypeTree ( TypeTree  t) [package]

Establece el atributo tipus.

Parameters:
[in]tvalor del atributo tipus, de tipo TypeTree

Definition at line 109 of file CL_AST.java.

void CL_AST.setTypeTree ( int  type) [package]

Establece el atributo tipus para tipos básicos.

Parameters:
[in]typetipo de token que representa un tipo básico (valores enteros INT o BOOL declarados en CL.g)

Definition at line 118 of file CL_AST.java.

static void CL_AST.toIndentedTreeString ( CL_AST  t,
String  s,
StringBuffer  sb 
) [static, private]

Describe cómo un subárbol AST debe aparecer como texto (en un StringBuffer), en formato multilínea indentado.

Parameters:
[in]tel AST a ser convertido en string (en un StringBuffer sb)
[in]sla indentación de los subárboles hijos
[in,out]sbel StringBuffer con el string correspondiente a t

Definition at line 211 of file CL_AST.java.

Here is the call graph for this function:

Here is the caller graph for this function:

static String CL_AST.toIndentedTreeString ( CL_AST  t) [static, package]

Describe cómo un subárbol AST debe aparecer como texto, en formato multilínea indentado.

Parameters:
[in]tel AST a ser convertido en string

Definition at line 238 of file CL_AST.java.

Here is the call graph for this function:

String CL_AST.toNodeString ( ) [private]

Describe cómo debe aparecer como texto el nodo raiz del subárbol AST, no todo el subárbol.

No tiene en cuenta la decoració del nodo.

Por defecto devuelve el text del token contenido en el nodo, pero en algunos casos también aparece su type (como texto). Por ejemplo, while, intconst(23) o ident(n1)

Returns:
el string correspondiente al nodo
See also:
CLParser

Definition at line 167 of file CL_AST.java.

Here is the caller graph for this function:

String CL_AST.toString ( )

Sobreescribe CommonTree.toString() para describir cómo debe aparecer como texto el nodo raiz del subárbol AST, no todo el subárbol.

Incluye la decoración cuando el nodo es la raiz de una expresión. Entonces se añade al string la decoración en los atributos tipus y esReferenciable

Returns:
el string correspondiente al nodo
See also:
TypeTree

Definition at line 189 of file CL_AST.java.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

boolean CL_AST.esReferenciable [private]

La expresión es referenciable?.

Muestra si una expresion es asignable/addressable, es decir, si puede recibir y guardar un valor, o si tiene sentido referirse a su dirección. Este atributo sólo se usa en subárboles que son (sub)expresiones. Por defecto, tiene el valor falso. Decoración que coloca el analizador semántico (TypeCheck)

Definition at line 79 of file CL_AST.java.

Tipo de la expresión.

Descripción del tipo CL del AST enraizado en este nodo. Este atributo sólo se usa en subárboles que son (sub)expresiones. Decoración que coloca el analizador semántico (TypeCheck)

Definition at line 69 of file CL_AST.java.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations