Skip to content

bennettgoble/lsl.tmLanguage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

LSL TextMate Grammar

A TextMate grammar for LSL (Linden Scripting Language) syntax highlighting in editors that support TextMate grammars, including Visual Studio Code, Sublime Text, and Atom.

Overview

LSL (Linden Scripting Language) is the programming language used to create interactive content in Second Life. This grammar provides comprehensive syntax highlighting for LSL scripts, including:

  • Keywords: Control flow statements (if, else, for, while, return, etc.)
  • Data Types: LSL primitive types (integer, float, string, key, vector, rotation, list)
  • Events: All LSL event handlers (state_entry, touch_start, timer, collision, etc.)
  • Built-in Functions: LSL library functions (functions starting with ll)
  • Constants: Language constants (TRUE, FALSE, PI, ZERO_VECTOR, etc.)
  • States: LSL state machine syntax
  • Comments: Both single-line (//) and multi-line (/* */) comments
  • Strings: String literals with escape sequences
  • Numbers: Integer, float, and hexadecimal number formats
  • Operators: All LSL operators with proper precedence

Installation

Visual Studio Code

  1. Copy the lsl.tmLanguage.json file to your VS Code extensions directory:

    • Windows: %USERPROFILE%\.vscode\extensions\lsl-syntax\syntaxes\
    • macOS: ~/.vscode/extensions/lsl-syntax/syntaxes/
    • Linux: ~/.vscode/extensions/lsl-syntax/syntaxes/
  2. Create a package.json file in the extension directory with the following content:

{
    "name": "lsl-syntax",
    "displayName": "LSL Syntax Highlighting",
    "description": "Syntax highlighting for Linden Scripting Language (LSL)",
    "version": "1.0.0",
    "engines": {
        "vscode": "^1.0.0"
    },
    "categories": ["Programming Languages"],
    "contributes": {
        "languages": [{
            "id": "lsl",
            "aliases": ["LSL", "lsl"],
            "extensions": [".lsl"],
            "configuration": "./language-configuration.json"
        }],
        "grammars": [{
            "language": "lsl",
            "scopeName": "source.lsl",
            "path": "./syntaxes/lsl.tmLanguage.json"
        }]
    }
}

Sublime Text

  1. Copy lsl.tmLanguage.json to your Sublime Text Packages directory:

    • Windows: %APPDATA%\Sublime Text\Packages\User\
    • macOS: ~/Library/Application Support/Sublime Text/Packages/User/
    • Linux: ~/.config/sublime-text/Packages/User/
  2. Restart Sublime Text and the LSL syntax will be available for .lsl files.

Features

Syntax Elements Supported

  • Control Flow: if, else, for, do, while, jump, return
  • State Management: default, state declarations and transitions
  • Event Handlers: All LSL events including:
    • state_entry, state_exit
    • Touch events: touch_start, touch, touch_end
    • Collision events: collision_start, collision, collision_end
    • Timer and sensor events: timer, listen, sensor, no_sensor
    • And many more...
  • Built-in Functions: Automatic detection of LSL library functions (prefix ll)
  • Data Types: integer, float, string, key, vector, rotation, list
  • Constants: Mathematical constants (PI, TWO_PI), boolean values, null keys, etc.

Code Example

// Sample LSL script with syntax highlighting
default {
    state_entry() {
        llSay(0, "Hello, avatar!");
        llSetText("I'm a scripted object!", <1,1,1>, 1.0);
        llSetTimerEvent(5.0);
    }
    
    touch_start(integer total_number) {
        llOwnerSay("You touched me!");
        state active;
    }
    
    timer() {
        llSay(0, "Timer fired!");
    }
}

state active {
    state_entry() {
        llSay(0, "Now in active state");
    }
    
    touch_start(integer total_number) {
        state default;
    }
}

Contributing

Contributions are welcome! If you find any issues with syntax highlighting or want to add support for new LSL features:

  1. Fork this repository
  2. Make your changes to lsl.tmLanguage.json
  3. Test the grammar with various LSL scripts
  4. Submit a pull request

Grammar Scope Names

The grammar uses the following scope names for different syntax elements:

  • source.lsl - Root scope
  • comment.line.double-slash.lsl - Single-line comments
  • comment.block.lsl - Multi-line comments
  • keyword.control.lsl - Control flow keywords
  • keyword.control.state.lsl - State-related keywords
  • storage.type.lsl - Data types
  • entity.name.function.builtin.lsl - Built-in LSL functions
  • entity.name.function.event.lsl - Event handlers
  • constant.language.lsl - Language constants
  • string.quoted.double.lsl - String literals
  • constant.numeric.*.lsl - Numeric literals

License

This project is available under the MIT License.

Resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published