asdlGen Reference Manual : Using the Code Produced : Constructing Data Structures
Previous: Cyclic Data Structures Caveat
Next: De-constructing Data Structures

4.3. Constructing Data Structures

By default all languages produce constructor functions for each type mentioned in the descriptions. For languages that support overloading (Java and C++) two constructors are produced for sum type constructors that contain attributes. One constructor contains attribute fields the other omits them. In languages that do not support overloading attribute fields are included in the arguments to the constructor functions. Some languages like C support different options for generating constructors. (See language-specific-options)

In ML an expression to create a sexpr described in rosetta-stone which represents the integer one would look like

M.Int(1)       
in C it would be
  
M_Int(1)
and in Java
new M.Int(1)

Constructors that are that are treated specially as enumerations enumerations are globally defined constant integers or objects of the appropriate name. So these constructors can be "called" without any arguments. For instance

Op_PLUS
rather than
Op_PLUS() /* Incorrect use */

Because Java does not have a name space where one can place globally visible constants. There is a special class named g which contains all constant objects/constructors for the package. The call in Java would be

import ast.*;
Op.op x = Op.g.PLUS;


asdlGen Reference Manual : Using the Code Produced : Constructing Data Structures
Previous: Cyclic Data Structures Caveat
Next: De-constructing Data Structures