org.nlogo.api

Syntax

case class Syntax(precedence: Int, left: Int, right: Array[Int], ret: Int, defaultOption: Option[Int], minimumOption: Option[Int], isRightAssociative: Boolean, agentClassString: String, blockAgentClassString: String, switches: Boolean) extends Product with Serializable

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);
 }

Source
Syntax.scala
See also

Primitive#getSyntax()

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Syntax
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Syntax(precedence: Int, left: Int = Syntax.VoidType, right: Array[Int] = ..., ret: Int = Syntax.VoidType, defaultOption: Option[Int] = scala.None, minimumOption: Option[Int] = scala.None, isRightAssociative: Boolean = false, agentClassString: String = "OTPL", blockAgentClassString: String = null, switches: Boolean = false)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. val agentClassString: String

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. val blockAgentClassString: String

  9. def canEqual(arg0: Any): Boolean

    Definition Classes
    Syntax → Equals
  10. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. val defaultOption: Option[Int]

  12. def dfault: Int

  13. def dump: String

  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Definition Classes
    Syntax → Equals → AnyRef → Any
  16. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  17. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  18. def hashCode(): Int

    Definition Classes
    Syntax → AnyRef → Any
  19. def isInfix: Boolean

    indicates whether this instruction should be parsed as infix.

    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.

    returns

    true if this instruction is infix, false otherwise.

  20. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  21. val isRightAssociative: Boolean

  22. val left: Int

  23. def minimum: Int

  24. val minimumOption: Option[Int]

  25. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  28. val precedence: Int

  29. def productArity: Int

    Definition Classes
    Syntax → Product
  30. def productElement(arg0: Int): Any

    Definition Classes
    Syntax → Product
  31. def productIterator: Iterator[Any]

    Definition Classes
    Product
  32. def productPrefix: String

    Definition Classes
    Syntax → Product
  33. val ret: Int

  34. val right: Array[Int]

  35. def rightDefault: Int

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

  36. val switches: Boolean

  37. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  38. def takesOptionalCommandBlock: Boolean

  39. def toString(): String

    Definition Classes
    Syntax → AnyRef → Any
  40. def totalDefault: Int

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

  41. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  42. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  43. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def productElements: Iterator[Any]

    Definition Classes
    Product
    Annotations
    @deprecated
    Deprecated

    (Since version 2.8.0) use productIterator instead

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any