represents an application, in the abstract (either a reporter application of a command application).
An interface representing a node in the NetLogo abstract syntax tree (AKA parse tree, in NetLogo's case).
An interface representing a node in the NetLogo abstract syntax tree (AKA parse tree, in NetLogo's case).
Each AstNode, even if synthesized, should correspond to some particular source fragment, as indicated by the position and length. It's the compiler's job to make sure these values are always reasonable.
Transforms an AST to allow changes without mutation
The default AST tree-walker.
The default AST tree-walker. This simply visits each node of the tree, and visits any children of each node in turn. Subclasses can implement pre-order or post-order traversal, or a wide range of other strategies.
represents a block containing zero or more statements.
represents a block containing zero or more statements. Called a command block rather than a statement block for consistency with usual NetLogo jargon. Note that this is an Expression, and as such can be an argument to commands and reporters, etc.
Exception thrown by various methods that accept NetLogo code as input and cause that code to be compiled; indicates the code was invalid.
Exception thrown by various methods that accept NetLogo code as input and cause that code to be compiled; indicates the code was invalid. May be inspected to discover the location and nature of the error.
represents a NetLogo expression.
represents a NetLogo expression. An expression is either a block or a reporter application (variable references and constants (including lists), are turned into reporter applications).
Interface which all NetLogo objects defined in Extensions must support
Top-level interface for primitives (commands or reporters).
Top-level interface for primitives (commands or reporters). Not to be implemented directly; the
Command
or Reporter
interface should be used instead.
Reporter
Command
represents a single procedure definition.
represents a single procedure definition. really just a container for the procedure body, which is a Statements object.
represents a reporter application.
represents a reporter application. This is the typical kind of NetLogo expression, things like "round 5" and "3 + 4". However, this class also represents things like constants, which are converted into no-arg reporter applications as they're parsed.
represents a block containing exactly one expression.
represents a block containing exactly one expression. Called a reporter block rather than an expression block for consistency with usual NetLogo jargon. Note that this is an Expression, and as such can be an argument to commands and reporters, etc. However, it is a different expression from the expression it contains... Its "blockness" is significant.
represents a NetLogo statement.
represents a NetLogo statement. Statements only have one form: command application.
represents a chunk of zero or more NetLogo statements.
represents a chunk of zero or more NetLogo statements. Note that this is
not necessarily a "block" of statements, as block means something specific
(enclosed in [], in particular). This class is used to represent other
groups of statements as well, for instance procedure bodies.
nonLocalExit identifies that the statements contain one or more commands
(possibly nested) which may cause a non-local exit (like stop
or report
)
Specifies the arguments accepted by a primitive.
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); }
Primitive#getSyntax()
Java can't (I don't think) access Scala inner objects without reflection, so we provide these convenience vals for use from Java.
Java can't (I don't think) access Scala inner objects without reflection, so we provide these convenience vals for use from Java.
Legacy convenience methods for constructing Syntax objects, for use by extensions written in Java.
Java can't (I don't think) access Scala inner objects without reflection, so we provide these convenience vals for use from Java.
represents an application, in the abstract (either a reporter application of a command application). This is used when parsing arguments, when we don't care what kind of application the args are for.