Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Grule Rule Language (GRL) Syntax & SnippetsNew to Visual Studio Code? Get it now.
Grule Rule Language (GRL) Syntax & Snippets

Grule Rule Language (GRL) Syntax & Snippets

Ton That Vu

|
8 installs
| (1) | Free
VS Code extension for Grule Rule Language (.grl) syntax highlighting and snippets
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

GRL Syntax Highlighting for VS Code

A professional Visual Studio Code extension for Grule Rule Language (GRL) syntax highlighting, auto-completion, and rule authoring.
Designed for Rust Rule Engine, Drools-compatible workflows, and advanced business rule systems.


✨ Features

Phase 1: Syntax Highlighting & Snippets

  • Syntax Highlighting: Full GRL keyword, attribute, function, action, and pattern highlighting.
  • Auto-complete Snippets: Quickly insert rule templates, attributes (no-loop, agenda-group, activation-group, etc.), actions, and patterns.
  • Function Detection: Automatically highlights function names (e.g. log, update, sendEmail) before (.
  • Advanced Attribute Support: Supports all Drools-style attributes: no-loop, agenda-group, activation-group, lock-on-active, date-effective, date-expires, salience.
  • Auto-closing Brackets: Automatically closes {, [, (, ", '
  • Code Folding: Fold/unfold rule blocks for better readability
  • Comment Shortcuts: Use Ctrl+/ (line) or Ctrl+Shift+A (block) for comments
  • Works with .grl files: Just open or create a .grl file and start writing!

Phase 2: Advanced IDE Features (NEW in v0.1.0)

  • 🔍 Hover Documentation: Hover over keywords like rule, when, then, salience, exists, forall to see instant documentation
  • ⚠️ Real-time Diagnostics: Automatic syntax validation that highlights missing when/then blocks and unclosed braces
  • 🎯 Context-aware Auto-completion:
    • Suggests rule attributes when typing rule
    • Suggests patterns (exists, forall, !exists) when inside when block
    • Suggests action functions (log, update, insert, retract, sendEmail) when inside then block

Phase 3: Cloud Test Execution & Improved Snippets (NEW in v0.2.1) 🚀

  • ▶️ Test Rule (CodeLens): Click the "▶ Test Rule" button above any rule to execute it via the cloud execution API.
  • Remote evaluation (Test Rule): Use the "▶️ Test Rule" CodeLens to run rules via remote evaluation. The backend/service is responsible for generating test data; the extension does not prompt for or send client-side test facts by default. This README does not expose any service endpoints.
  • Backend-generated test facts: The extension no longer prompts for test facts and does not send client-side facts by default — the backend will auto-generate/infer test data for execution. Sample/inferred facts are shown locally in the output only for visibility.
  • Simplified UI: Debug/Test Data buttons have been removed; testing is now a single streamlined "Test Rule" action that calls the cloud service.
  • Updated grammar & snippets: Highlighting, attributes, and snippets were refreshed to match the rules in the repository (improved entity/action detection and many new action snippets).
  • 📊 Output Channel: Execution results are rendered in the "GRL Rule Execution" output panel (console-style summary and detailed rule logs).

📸 Screenshots

Syntax Highlighting Example


🚀 Quick Start

  1. Install:
    • Download from VS Code Marketplace (after publish).
    • Or run:
      code --install-extension grl-syntax-highlighting-<version>.vsix
      
  2. Open a .grl file:
    • Start typing GRL rules, attributes, actions, and functions.
    • Use auto-complete for fast rule authoring.

📝 Example

// Based on Rust Rule Engine v0.10.2 syntax
rule "GoldCustomerDiscount" salience 10 {
    when
        customer.tier == "gold" && order.amount > 1000
    then
        order.discount = order.amount * 0.15;
        Log("Applied 15% gold customer discount");
}

// NEW in v0.10.0: Function calls in WHEN clause
rule "FraudDetection" salience 200 {
    when
        detectFraud(Transaction.amount, Transaction.userId) == true
    then
        set(Transaction.status, "blocked");
        Alert("Fraud detected!");
}

NEW in v0.2.1: Click the ▶ Test Rule button above any rule to execute it in the cloud (backend will infer/generate test facts; extension does not prompt for facts).


⚡ Supported GRL Features

Compatible with Rust Rule Engine v0.10.2 (GitHub)

  • Keywords: rule, when, then, salience, exists, forall, not, true, false
  • Attributes: agenda-group, activation-group, lock-on-active, no-loop, date-effective, date-expires
  • Actions: Log(), set(), insert(), update(), retract(), SendEmail(), Alert()
  • AI Functions (v0.10.0): detectFraud(), analyzeSentiment(), predictTier() - Call directly in WHEN clause
  • Pattern Matching: exists(...), forall(...), !exists(...)
  • Plugin System: 44+ actions, 33+ functions
  • String & Number Highlighting
  • ~97% Drools Compatibility

🔧 Requirements

  • Visual Studio Code v1.60 or higher
  • No additional dependencies

⚙️ Extension Settings

This extension does not add custom settings.
Just install and use!


🐞 Known Issues

  • If you find any issues, please report them on GitHub Issues.

📦 Release Notes

0.2.1 (Latest) 🚀

Cloud Test Execution & Snippets Refresh

  • ▶️ Click the "Test Rule" CodeLens above a rule to execute it via the cloud execution API.
  • The extension will NOT send client-side facts by default; the backend will infer/generate test data for evaluation.
  • Updated TextMate grammar and snippets to reflect entities/actions found in the repository's rules.
  • Removed the separate Debug/Test Data UI in favor of a single streamlined Test Rule workflow.

0.2.0

Phase 3: Run & Debug Features (prior release)

  • ▶️ Run Rule (local execution) and debug helpers
  • 📝 Test Data generator (local templates)
  • 🔧 Auto-detects Rust workspace and Cargo examples
  • 📊 Dedicated output channel for execution results
  • ⚙️ Auto-creates launch.json for debugging

0.1.0

Phase 2 Features:

  • 🔍 Hover documentation for all GRL keywords and attributes
  • ⚠️ Real-time syntax diagnostics (validates rule structure, missing blocks)
  • 🎯 Context-aware auto-completion (suggests attributes, patterns, actions based on cursor position)
  • 🐛 Bug fixes and performance improvements

0.0.1

Phase 1 Features:

  • Initial release: syntax highlighting, auto-complete snippets, advanced attribute support
  • Auto-closing brackets, code folding, comment shortcuts
  • Support for all Drools-style rule attributes

🤝 Contributing

Pull requests and feedback are welcome!
See CONTRIBUTING.md for details.


📚 More Information

  • Grule Rule Engine
  • Rust Rule Engine
  • Drools Documentation

**Enjoy professional GRL authoring in VS

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft