ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Forth

by mitranim ST3 Needs Review

Sublime Text syntax for the Forth programming language

Details

Installs

  • Total 489
  • Win 177
  • Mac 131
  • Linux 181
Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Overview

Sublime Text syntax definition for Forth. Should be suitable for any Forth which is standard-adjacent. Tested with GForth and VfxForth.

Installation

Package Control

  1. Get Package Control.
  2. Open the command palette: ⇧⌘P or ⇧P.
  3. Package Control: Install Package.
  4. Forth.

Manual

Clone the repo and symlink it to your Sublime packages directory. Example for MacOS:

git clone https://github.com/mitranim/sublime-forth.git
cd sublime-forth
ln -sf "$(pwd)" "$HOME/Library/Application Support/Sublime Text/Packages/Forth"

To find the packages directory on your system, use Sublime Text menu → Preferences → Browse Packages.

Build Systems

Doesn't come with a build system, because there are many Forth implementations. Here's how to define one for GForth:

{
  "selector": "source.forth",
  "cmd": ["gforth", "$file", "-e", "bye"],
}

Customization

There are almost as many Forth dialects as there are Forth users. Many do not adhere to any standard. Additionally, even in a “standard” Forth, it's easy to define new parsing words, which may need special syntactic support.

Therefore, you may need to customize this syntax appropriately for your dialect.

dir="$HOME/Library/Application Support/Sublime Text/Packages/User"
mkdir -p "$dir/Forth"
touch "$dir/Forth/ForthX.sublime-syntax"

Open the resulting .sublime-syntax file and make it inherit from the “base” syntax:

%YAML 1.2
---
version: 2
scope: source.forth
extends: Packages/Forth/Forth.sublime-syntax
file_extensions: [f, fs, ft, fth]

# ... Add your overrides here.

You can then override variables, contexts, and so on. You do not need to copy-paste the rest of the syntax; only overrides need to be placed in the new file.

License

https://unlicense.org