NetLogo API
version 2.0.2

org.nlogo.api
Class Syntax

java.lang.Object
  extended byorg.nlogo.api.Syntax

public class Syntax
extends Object

Specifies the arguments accepted by a primitive. Used by the compiler for type-checking.

You cannot instantiate this class directly. Instead, use the static construction methods Syntax.commandSyntax(...) or Syntax.reporterSyntax(...).

For example, in a Reporter that takes two integer arguments and returns a float, implement Primitive.getSyntax() as follows:

 Syntax getSyntax() {
   int[] right = new int[] { Syntax.TYPE_INTEGER, Syntax.TYPE_INTEGER };
   int ret = Syntax.TYPE_FLOAT;
   return Syntax.reporterSyntax( right, ret );
 }
 

See Also:
Primitive.getSyntax()

Field Summary
static int COMMAND_PRECEDENCE
           
static int MAX_PRECEDENCE
           
static int NORMAL_PRECEDENCE
           
static int TYPE_BOOLEAN
           
static int TYPE_BOOLEAN_BLOCK
           
static int TYPE_BRACKETED
           
static int TYPE_COMMAND_BLOCK
           
static int TYPE_FLOAT
           
static int TYPE_INTEGER
           
static int TYPE_LIST
           
static int TYPE_NUMBER
           
static int TYPE_NUMBER_BLOCK
           
static int TYPE_OTHER_BLOCK
           
static int TYPE_READABLE
           
static int TYPE_REFERENCE
           
static int TYPE_REPEATABLE
           
static int TYPE_REPORTER_BLOCK
           
static int TYPE_STRING
           
static int TYPE_VOID
           
static int TYPE_WILDCARD
           
 
Method Summary
static Syntax commandSyntax()
          Returns an EMPTY_SYNTAX Object for commands with no arguments.
static Syntax commandSyntax(int[] right)
          Returns a Syntax for commands with one or more right arguments.
static Syntax commandSyntax(int[] right, int dfault)
          Returns a Syntax for commands with a variable number of arguments.
 org.nlogo.compiler.Syntax getSyntax()
           
static Syntax reporterSyntax(int ret)
          Returns a Syntax for reporters with no arguments
static Syntax reporterSyntax(int[] right, int ret)
          Returns a Syntax for reporters with one or more right arguments
static Syntax reporterSyntax(int[] right, int ret, int dfault)
          Returns a Syntax for reporters with a variable number of arguments.
static Syntax reporterSyntax(int left, int[] right, int ret, int precedence)
          Returns a Syntax for reporters with infix arguments
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_VOID

public static final int TYPE_VOID
See Also:
Constant Field Values

TYPE_INTEGER

public static final int TYPE_INTEGER
See Also:
Constant Field Values

TYPE_FLOAT

public static final int TYPE_FLOAT
See Also:
Constant Field Values

TYPE_NUMBER

public static final int TYPE_NUMBER
See Also:
Constant Field Values

TYPE_BOOLEAN

public static final int TYPE_BOOLEAN
See Also:
Constant Field Values

TYPE_STRING

public static final int TYPE_STRING
See Also:
Constant Field Values

TYPE_LIST

public static final int TYPE_LIST
See Also:
Constant Field Values

TYPE_READABLE

public static final int TYPE_READABLE
See Also:
Constant Field Values

TYPE_WILDCARD

public static final int TYPE_WILDCARD
See Also:
Constant Field Values

TYPE_REFERENCE

public static final int TYPE_REFERENCE
See Also:
Constant Field Values

TYPE_COMMAND_BLOCK

public static final int TYPE_COMMAND_BLOCK
See Also:
Constant Field Values

TYPE_BOOLEAN_BLOCK

public static final int TYPE_BOOLEAN_BLOCK
See Also:
Constant Field Values

TYPE_NUMBER_BLOCK

public static final int TYPE_NUMBER_BLOCK
See Also:
Constant Field Values

TYPE_OTHER_BLOCK

public static final int TYPE_OTHER_BLOCK
See Also:
Constant Field Values

TYPE_REPORTER_BLOCK

public static final int TYPE_REPORTER_BLOCK
See Also:
Constant Field Values

TYPE_BRACKETED

public static final int TYPE_BRACKETED
See Also:
Constant Field Values

TYPE_REPEATABLE

public static final int TYPE_REPEATABLE
See Also:
Constant Field Values

MAX_PRECEDENCE

public static final int MAX_PRECEDENCE
See Also:
Constant Field Values

COMMAND_PRECEDENCE

public static final int COMMAND_PRECEDENCE
See Also:
Constant Field Values

NORMAL_PRECEDENCE

public static final int NORMAL_PRECEDENCE
See Also:
Constant Field Values
Method Detail

commandSyntax

public static Syntax commandSyntax()
Returns an EMPTY_SYNTAX Object for commands with no arguments.


commandSyntax

public static Syntax commandSyntax(int[] right)
Returns a Syntax for commands with one or more right arguments.

Parameters:
right - an array of TYPE flags that are to be to the right of the Primitive

commandSyntax

public static Syntax commandSyntax(int[] right,
                                   int dfault)
Returns a Syntax for commands with a variable number of arguments.

Parameters:
right - an array of TYPE flags that are to be to the right of the primitive
dfault - the default number of arguments if no parenthesis are used.

reporterSyntax

public static Syntax reporterSyntax(int ret)
Returns a Syntax for reporters with no arguments

Parameters:
ret - the return type

reporterSyntax

public static Syntax reporterSyntax(int left,
                                    int[] right,
                                    int ret,
                                    int precedence)
Returns a Syntax for reporters with infix arguments

Parameters:
left -
right -
ret - the return type
precedence -

reporterSyntax

public static Syntax reporterSyntax(int[] right,
                                    int ret)
Returns a Syntax for reporters with one or more right arguments

Parameters:
right - an array of TYPE flags that are to the be right of the Primitive
ret - the return type

reporterSyntax

public static Syntax reporterSyntax(int[] right,
                                    int ret,
                                    int dfault)
Returns a Syntax for reporters with a variable number of arguments.

Parameters:
right - an array of TYPE flags that are to the be right of the primitive
ret - the return type
dfault - the default number of arguments if no parenthesis are used.

getSyntax

public org.nlogo.compiler.Syntax getSyntax()

NetLogo API
version 2.0.2