Syntax

org.nlogo.core.Syntax
See theSyntax companion object
case class Syntax

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 number arguments and returns a boolean, implement Primitive.getSyntax() as follows:

public Syntax getSyntax() {
 return Syntax.reporterSyntax(
   new int[] { Syntax.NumberType(), Syntax.NumberType() },
   Syntax.BooleanType());
}

An input can be made variadic, meaning that it can be repeated any number of times when enclosed in parentheses, if you add the RepeatableType flag. When using variadic inputs you should also define the default number of inputs, that is, the number of inputs expect if the user does not use parentheses. For example:

public Syntax getSyntax() {
  return Syntax.reporterSyntax(
    new int[] { Syntax.WildcardType() | Syntax.RepeatableType() },
    Syntax.ListType(), 2);
}

Attributes

See also

Primitive#getSyntax()

Companion
object
Source
Syntax.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def allArgs: List[Int]

Attributes

Source
Syntax.scala
def dfault: Int

Attributes

Source
Syntax.scala
def dump: String

Attributes

Source
Syntax.scala

indicates whether this instruction should be parsed as infix. Infix instructions expect exactly one argument on the left and should not be variadic on the right.

indicates whether this instruction should be parsed as infix. Infix instructions expect exactly one argument on the left and should not be variadic on the right.

Attributes

Returns

true if this instruction is infix, false otherwise.

Source
Syntax.scala

determines whether an instruction allows a variable number of args.

determines whether an instruction allows a variable number of args.

Attributes

Source
Syntax.scala
def minimum: Int

Attributes

Source
Syntax.scala

returns the number of args this instruction takes on the right by default.

returns the number of args this instruction takes on the right by default.

Attributes

Source
Syntax.scala

returns the total number of args, left and right, this instruction takes by default.

returns the total number of args, left and right, this instruction takes by default.

Attributes

Source
Syntax.scala

Attributes

Source
Syntax.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product