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

Forth

by mitranim ST3

Sublime Text syntax for the Forth programming language

Details

Installs

  • Total 483
  • Win 175
  • Mac 129
  • Linux 179
Feb 1 Jan 31 Jan 30 Jan 29 Jan 28 Jan 27 Jan 26 Jan 25 Jan 24 Jan 23 Jan 22 Jan 21 Jan 20 Jan 19 Jan 18 Jan 17 Jan 16 Jan 15 Jan 14 Jan 13 Jan 12 Jan 11 Jan 10 Jan 9 Jan 8 Jan 7 Jan 6 Jan 5 Jan 4 Jan 3 Jan 2 Jan 1 Dec 31 Dec 30 Dec 29 Dec 28 Dec 27 Dec 26 Dec 25 Dec 24 Dec 23 Dec 22 Dec 21 Dec 20 Dec 19
Windows 0 0 0 0 1 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 1 0 0 0 0 0 0 0 0 0 0
Mac 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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