Skip to content

Experimental: Extensions

Jason Bertsche edited this page Aug 17, 2017 · 24 revisions

The following describes the grammar for defining an extension's .json defs file.

type ArgType = "unit" ('void' type; only appears in return type; indicates that this is a command, not a reporter) | "agentset" | "agent" | "booleanblock" | "boolean" | "bracketed" | "codeblock" | "commandblock" | "command" | "linkset" | "link" | "list" | "nobody" | "numberblock" | "number" | "optional" | "otherblock" | "patchset" | "patch" | "readable" | "reference" | "reporterblock" | "reporter" | "string" | "symbol" | "turtleset" | "turtle" | "wildcard"

type PrimDef =
  {
    name: string (name in NetLogo)
  , actionName: string (name of property in the `prims` field of the object exported by the extension in JavaScript)
  , argTypes: array[NLType | { type: NLType, isRepeatable: boolean (default: false) }] (default: [])
  , returnType: NLType (default: "unit")
  , isInfix: boolean (default: false)
  , precedenceOffset: number (default: 0)
  }

type ExtDef =
  {
    name: string
  , prims: array[PrimDef]
  }