org.nlogo.core.Syntax
See theSyntax companion 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 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
Members list
In this article