Skip to content

[NetLogo/Tortoise/Galapagos] Configurable Extensions for NetLogo; URL Extensions for NetLogo Web #434#2508

Draft
omargfh wants to merge 5 commits into
mainfrom
nl-extensions
Draft

[NetLogo/Tortoise/Galapagos] Configurable Extensions for NetLogo; URL Extensions for NetLogo Web #434#2508
omargfh wants to merge 5 commits into
mainfrom
nl-extensions

Conversation

@omargfh

@omargfh omargfh commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

[WIP] [NetLogo/Tortoise/Galapagos] Configurable Extensions for NetLogo; URL Extensions for NetLogo Web

Branches

Specification

  • Introduce a new keyword extension with the intention of allowing arbitrary modifiers to be used alongside the keyword. In practice, extensions either loads an extension similar to extensions or allows for a url modifier, which is only supported in NetLogo Web.
    • Syntax: extension [ <extensionName> [url <url literal>]? ]*
  • New extension keyword is dubbed ConfigurableExtensions

Implementation Details

  1. In Galapagos the tortoise.coffee file contains functions to compile NLogo and NLogoX files. Before compilation, and after rewrites, we extract the code from the .nlogo[x] file.The call stack from there is:
    1.Galapagos:NLWExtensionsLoader.loadURLExtensions
    2. which calls org.nlogo.tortoise:BroswerCompiler.listExtensions
    3. which calls org.nlogo.core:FrontEnd.findAllExtensions
    4. which calls org.nlogo.parse:StructureParser.findExtensions and org.nlogo.parse:StructureParser.findConfigurableExtensions
    5. which tokenizes the code and extracts the extension list
  2. The extension list is returned to Galapagos:NLWExtensionsLoader.loadURLExtensions which figures out the extension module URL and primitives JSON url by changing .js at the end of the URL to .json and creates a lazy loader for the module as well as fetching the primitives JSON and caching it in window.URLExtensionsRepo.
  3. Galapagos:NLWExtensionsLoader.getPrimitivesFromURL is exposed to org.nlogo.tortoise using scala.js, which uses it to get primitives if extURL is defined in org.nlogo.tortoise:NLWExtensionsManager.importExtension.

Current Work

NetLogo

  • Add new syntax and parser results to NetLogo.
  • Add methods in FrontEnd: findConfigurableExtensions and findAllExtensions
  • Add syntax, parser, and front-end tests.
  • Update ExtensionManager to support URL as a parameters (this throws on Desktop)

Tortoise

  • Add a new BrowserCompiler.listExtensions(source: String) that delegates to FrontEnd.findAllExtensions and returns a JSON [{ name: String, url: String?}].
  • Implement new ExtensionManager for NLWExtensionManager.

Galapagos

  • Add NLWExtensionsLoader to load URL extensions before compilation
  • Integrate NLWExtensionsLoader to the compilation function for .nlogox files.

@omargfh omargfh changed the title Configurable Extensions for NetLogo; URL Extensions for NetLogo Web [NetLogo/Tortoise/Galapagos] Configurable Extensions for NetLogo; URL Extensions for NetLogo Web #434 Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant