Announcing tree-sitter-ring — a Tree-sitter grammar for the Ring programming language

222 views
Skip to first unread message

Youssef Saeed

unread,
Aug 4, 2026, 2:28:00 AMAug 4
to The Ring Programming Language
Hello everyone,

I'm thrilled to share the release of tree-sitter-ring — a complete Tree-sitter grammar for the Ring programming language!

Tree-sitter is the parsing technology behind modern editor features in Neovim, Helix, Zed, and Emacs. It builds a real syntax tree of your code — fast, incremental, and error-tolerant (it keeps working even while you're mid-typing). With this grammar, Ring joins that ecosystem: accurate syntax highlighting, code navigation, and a solid foundation for a new generation of Ring developer tools.

Key Features:
  • Full Core Language: All three function styles, all statement terminators, classes, packages, anonymous functions, and typed parameters.
  • Rich Syntax Support: String interpolation, brace-object access, all comment forms.
  • Unicode Identifiers: Full support for international identifiers, including Arabic.
  • Battle-Tested: 142 corpus tests; verified against Ring's own test suite (973 files) and 2,295 samples — every valid non-DSL file parses.
Use Cases:
  • Modern Editor Support: Precise syntax highlighting, code folding, symbol outlines, and go-to-definition in Neovim, Helix, Zed, and Emacs.
  • Developer Tools: A ready-made foundation for building a Ring formatter, linter, or language server — no need to write a parser from scratch.
  • Code Intelligence: Structural search-and-replace, semantic git diffs, metrics, and documentation generators for Ring codebases.
  • AI-Friendly Code: Lets AI coding assistants and code indexers understand Ring projects, so they can navigate and modify your code accurately.
Editor integrations (highlight queries, registration in nvim-treesitter/Zed/Helix) are the natural next step — and now straightforward, since the grammar is the hard part.

Getting Started:

git clone https://github.com/ysdragon/tree-sitter-ring
cd tree-sitter-ring
bun install
bun run build   # tree-sitter generate
bun run test        # run the 142 corpus tests


# Parse any Ring file:
bun run parse yourfile.ring


Learn More:
Known Limitations:

Syntax that Ring defines at runtime can't be captured by any static grammar — this affects the NaturalLib natural-language DSL (I want window, ...) and keywords/operators remapped via ChangeRingKeyword/ChangeRingOperator. Also, the keywords Ring demotes only via runtime counters (ok/on/off/catch/done/again/but/else/other/case when used as plain names outside their construct) always stay keywords here — a static parser can't see runtime state. Everything in the core language is fully supported.

Contributions are welcome!

Have ideas or found a bug? Please open an issue or submit a pull request on GitHub.

Your feedback is greatly appreciated!

Hope you find tree-sitter-ring useful!

Best regards,
Youssef

Mahmoud Fayed

unread,
Aug 4, 2026, 3:57:42 AMAug 4
to The Ring Programming Language
Hello Youssef

Thank you very much, this is very useful for many tools :D

Keep up the GREAT WORK :D

Greetings,
Mahmoud  

Youssef Saeed

unread,
Aug 4, 2026, 4:50:50 AMAug 4
to The Ring Programming Language
Hello Mahmoud,

Thank you so much for your kind words!

Best regards,
Youssef

Mansour Ayouni

unread,
Aug 4, 2026, 5:03:34 AMAug 4
to Youssef Saeed, The Ring Programming Language
Hello Youssef,

Very useful !
I appreciate the direction you took to cover Ring development tooling around modern norms and practices.
This is critical to Ring adoption.
Looking forward to testing your tree-sitter and considering including it to my projects.

All the best,
Mansoiur

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/5ec10747-9614-41fb-b2fa-086ae035557dn%40googlegroups.com.

Youssef Saeed

unread,
Aug 4, 2026, 5:21:27 AMAug 4
to The Ring Programming Language
Hello Mansour,

Thanks a lot for the support! Looking forward to your feedback once you test it out.

Best regards,
Youssef

Gaiamap

unread,
Aug 4, 2026, 6:20:10 AMAug 4
to The Ring Programming Language

Hi Youssef,

Congratulations: tree-sitter-ring is an impressive piece of work, and the kind that widens what is possible around a language rather than just adding to it.

I spent some time inside the grammar rather than only reading the announcement, and what convinced me is a small thing: the identifier class defined by exclusion. It matches Ring's own scanner character for character (the sort of detail you only get right by reading the sources). The same care shows in using an external scanner for the same-line rules, and in putting your own corpus tests next to the real test suite and a few thousand samples.

I have been poking at Ring from a different angle for a while, and that has meant checking a good many of the language's finer points against the interpreter. Two of them touch your grammar, so let me put them on the table plainly.

1) The same-line rule for postfix. In Ring the end of a line does not always close an expression: after the closing parenthesis of a call, or the closing bracket of an index, the parser keeps looking for a further index or call on the lines that follow, and neither a semicolon nor a blank line stops it, since for the scanner they are the same token. After an identifier, a string, a number or a ++ it does stop; and the bracket that closes a list literal does not arm it either, which is why general/test110 in the suite parses the way it does. So the restriction you enforce holds in most positions and is a little too strict after those two closers. Nothing in the suite depends on the difference. It would begin to matter for the formatter and the structural search-and-replace you list among the use cases, where the tree decides what gets rewritten.

2) The counter-guarded keywords. I suspect that limitation may be removable. Ring blocks the demotion of ok, but, on, case, off, catch, done, again, else and other using the parser's own nesting counters (compile-time state, the same kind your external scanner already keeps for parentheses) rather than anything from the running program. The rule, as far as I have been able to check it, is that one of those words stays a keyword for the whole extent of the construct that uses it, its condition included, and it stays one inside nested constructs of other kinds; else and other need both the if and the switch nesting to be closed. There is one fixed exception: in load again "file.ring" the word again is always part of the command.

Best wishes for the editor integrations: that is where most people will feel the difference.

Cesare G. Fanelli
(the G could be Y :D )

Youssef Saeed

unread,
Aug 4, 2026, 8:33:59 AMAug 4
to The Ring Programming Language
Hello Cesare,

Thank you so much for taking the time to dive deep into the code and grammar! It means a lot to receive such a detailed, thoughtful, and high-quality review from someone who understands the inner workings of the Ring scanner and Compiler/VM so well.

Your points are extremely insightful:

1. Postfix Same-Line Rules: You're completely right. While the current restriction passes the existing test suite, accurate handling of continuations after closing parentheses and brackets across lines is crucial for formatters and structural search-and-replace tools. I'll be revisiting this rule to ensure the AST reflects those chained calls and indices correctly.

2. Counter-Guarded Keywords: This is a fantastic insight! I had previously assumed these demotions relied on runtime state, but your explanation of the parser's compile-time nesting counters makes total sense. Since Tree-sitter's external scanner can maintain state (similar to parenthesis depth tracking), this might actually be solvable statically. I'm definitely going to experiment with tracking construct depth in the external scanner to see if we can lift this limitation.

Thanks again for your kind words, encouraging feedback, and for sharing your deep knowledge of Ring's edge cases. Feedback like this makes building language tooling so much more rewarding!

Best regards,
Youssef

Gaiamap

unread,
Aug 4, 2026, 9:44:49 AMAug 4
to The Ring Programming Language

Hi Youssef,

Glad it was useful, and good luck with the work.

It is a pleasure to read the announcements of your projects: they are very interesting and useful, and I am already curious about the next one.

Best regards,

Cesare

Bert Mariani

unread,
Aug 4, 2026, 5:30:08 PMAug 4
to The Ring Programming Language
Hello Youssef

Got this error msg when following the install instruction ---  "bun"

C:\ring>git clone https://github.com/ysdragon/tree-sitter-ring
Cloning into 'tree-sitter-ring'...
remote: Enumerating objects: 74, done.
remote: Counting objects: 100% (74/74), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 74 (delta 36), reused 66 (delta 28), pack-reused 0 (from 0)                                               Receiving objects: 100% (74/74), 1.84 MiB | 2.04 MiB/s, done.

Resolving deltas: 100% (36/36), done.

C:\ring>cd tree-sitter-ring

C:\ring\tree-sitter-ring>bun install
'bun' is not recognized as an internal or external command,
operable program or batch file.


C:\ring\tree-sitter-ring>

===========================
C:\ring\tree-sitter-ring>dir
 Volume in drive C is Windows
 Volume Serial Number is D693-3EDC

 Directory of C:\ring\tree-sitter-ring

2026-08-04  05:23 PM    <DIR>          .
2026-08-04  05:23 PM    <DIR>          ..
2026-08-04  05:23 PM               597 .editorconfig
2026-08-04  05:23 PM             1,055 .gitattributes
2026-08-04  05:23 PM               391 .gitignore
2026-08-04  05:23 PM               414 bun.lock
2026-08-04  05:23 PM            21,010 grammar.js
2026-08-04  05:23 PM             1,070 LICENSE
2026-08-04  05:23 PM               850 package.json
2026-08-04  05:23 PM             2,803 README.md
2026-08-04  05:23 PM    <DIR>          src
2026-08-04  05:23 PM    <DIR>          test
2026-08-04  05:23 PM               988 tree-sitter.json
               9 File(s)         29,178 bytes
               4 Dir(s)  222,230,118,400 bytes free

C:\ring\tree-sitter-ring>
==============================

Regards
Bert Mariani

max

unread,
Aug 4, 2026, 9:13:21 PMAug 4
to The Ring Programming Language

For anyone new to Tree-sitter:

You can test your grammar using the Tree-sitter Playground.

  1. Open a terminal and navigate to your grammar's directory.

  2. Start the playground:

D:\tree-sitter-ring-master>tree-sitter playground
  1. In another terminal, build the WebAssembly version of the grammar:

D:\tree-sitter-ring-master>tree-sitter build --wasm
  1. Open your browser and go to:

http://127.0.0.1:8000/

You can now edit your grammar and test it interactively in the Tree-sitter Playground.


ssssssssss.PNG

max

unread,
Aug 4, 2026, 10:16:41 PMAug 4
to The Ring Programming Language
Hi Youssef,

plase check that,

function name is messing

dddddddd.jpg

max

unread,
Aug 4, 2026, 10:24:24 PMAug 4
to The Ring Programming Language
The parser should treat identifiers as non-keywords. Currently, the keyword class is incorrectly parsed as a function name.

Youssef Saeed

unread,
Aug 5, 2026, 1:49:01 AMAug 5
to The Ring Programming Language
Hello Bert,

First, please install Bun, which is the JavaScript runtime and package manager we use.

You can install it on Linux/macOS by running:
curl -fsSL https://bun.sh/install | bash

Or on Windows by running this command in Windows Terminal / PowerShell:
powershell -c "irm bun.sh/install.ps1 | iex"

Once Bun is installed, navigate to the tree-sitter-ring directory to install the dependencies and get started.

Next, install tree-sitter globally by running:
bun i -g tree-sitter

After that, you can use tree-sitter parse or tree-sitter playground. (Note: Before running the playground for the first time, compile our grammar/parser to WASM using tree-sitter build --wasm).

Best regards,
Youssef

Bert Mariani

unread,
Aug 5, 2026, 9:31:10 AMAug 5
to The Ring Programming Language
Thank you for the BUN install instructions Yousef !!
   Attached:  Details of the Steps and Output
                      Bun-Install-Run-Notes.txt

Had a Warning at the last step
c:\ring\tree-sitter-ring>bun run parse c:\ring\applications\analogclock\AnalogClock.ring  <<<===

Warning: You have not configured any parser directories!
Please run `tree-sitter init-config` and edit the resulting
configuration file to indicate where we should look for
language grammars.

----------------
c:\ring\tree-sitter-ring>tree-sitter init-config
'tree-sitter' is not recognized as an internal or external command,

operable program or batch file.

c:\ring\tree-sitter-ring>

========================================
Shortened Summary

C:\Users\bert_>cd c:\ring  <<<===
c:\ring>powershell -c "irm bun.sh/install.ps1 | iex"   <<<===

######################100.0%
Bun 1.3.14 was installed successfully!
The binary is located at C:\Users\bert_\.bun\bin\bun.exe
To get started, restart your terminal/editor, then type "bun"
c:\ring>

==============================
C:\Users\bert_>cd c:\ring  <<<===
c:\ring>bun    <<<===

Bun is a fast JavaScript runtime, package manager, bundler, and test runner. (1.3.14+0d9b296af)
Usage: bun <command> [...flags] [...args]
Commands:
  run       ./my-script.ts       Execute a file with Bun
 ....
Join our Discord community:      https://bun.com/discord
c:\ring>

====================
c:\ring>cd tree-sitter-ring     <<<===
c:\ring\tree-sitter-ring>bun i -g tree-sitter  <<<===

bun add v1.3.14 (0d9b296a)
installed tree-...@0.25.1
3 packages installed [3.41s]
c:\ring\tree-sitter-ring>

=======================
=======================
c:\ring>cd tree-sitter-ring  <<<===
c:\ring\tree-sitter-ring>
c:\ring\tree-sitter-ring>bun install  <<<===

bun install v1.3.14 (0d9b296a)
+ tree-si...@0.26.11
1 package installed [787.00ms]
c:\ring\tree-sitter-ring>

==============================
c:\ring\tree-sitter-ring>bun run build   <<<===
$ tree-sitter generate
c:\ring\tree-sitter-ring>
==============================
c:\ring\tree-sitter-ring>bun run test  <<<===

$ tree-sitter test
  advanced_features:
      1. ✓ Brace end method -- Warning: Slow parse rate (495.690 bytes/ms)
      2. ✓ Call on brace expression result
      3. ✓ Print object shorthand
       -----
    141. ✓ Decimals function
    142. ✓ Str2list and list2str
Total parses: 142; successful parses: 142; failed parses: 0; success percentage: 100.00%; average speed: 3482 bytes/ms
c:\ring\tree-sitter-ring>

=======================
TEST With AnalogClock

cd c:\ring\applications\analogclock>   <<<===  FAILS - Need to be in  c:\ring\tree-sitter-ring>
c:\ring\applications\analogclock>bun run parse AnalogClock.ring  <<<===
error: Script not found "parse"

c:\ring\applications\analogclock>

======================
cd c:\ring\tree-sitter-ring>    <<<=== WORKS

c:\ring\tree-sitter-ring>bun run parse c:\ring\applications\analogclock\AnalogClock.ring  <<<===
$ tree-sitter parse "c:\\ring\\applications\\analogclock\\AnalogClock.ring"

Warning: You have not configured any parser directories!
Please run `tree-sitter init-config` and edit the resulting
configuration file to indicate where we should look for
language grammars.

(source_file [0, 0] - [264, 0]
  (comment [0, 0] - [0, 45])
  (comment [1, 0] - [1, 24])
  (comment [2, 0] - [2, 43])
  ....
      (arguments [263, 22] - [263, 34]
        (identifier [263, 22] - [263, 34]))))
  (comment [263, 38] - [263, 76]))

c:\ring\tree-sitter-ring>

=============================
BUN-INSTALL-RUN-NOTES.txt
Message has been deleted
Message has been deleted
Message has been deleted

Azzeddine Remmal

unread,
Aug 6, 2026, 6:28:13 PMAug 6
to The Ring Programming Language
Hello Youssef

Thanks for sharing   tree-sitter-ring
I've made some improvements to the VS Code plugin
using your tree-sitter-ring library. https://github.com/azzeddine2017/extension
I hope it's correct.

Full Suite of 21 Features
🎨 1. Semantic Syntax Highlighting
AST-based token scope mapping for classes, functions, methods, variables, parameters, properties, keywords, strings, numbers, comments, and operators.

📐 2. Smart Code Folding
Intelligent folding ranges for all Ring block structures (func/end, class/end, if/ok, for/next, while/end, switch/end, try/catch/done).

🗂️ 3. Document Symbols & Outline
Navigate your codebase in VS Code's Outline panel with nested class/method/function hierarchies.

💡 4. Scope-Aware Auto-Completion
Context-sensitive completions: keyword snippets, document-level functions/classes, and visible identifiers.

🔴 5. Real-Time Diagnostics
Syntax error detection via Tree-Sitter ERROR and MISSING nodes with inline squiggly underlines.

🔗 6. Go to Definition
Ctrl+Click or F12 on any function or class name to jump directly to its declaration.

💬 7. Hover Information
Hover over a function or class to view its signature, method counts, and preceding documentation comments.

🔍 8. Find All References
Locate every usage of a symbol across the document.

✏️ 9. Rename Symbol
F2 symbol renaming — updates all occurrences simultaneously while protecting language keywords.

📝 10. Signature Help
Parameter hints appear automatically when typing function calls — highlights the active parameter.

🎯 11. Smart Selection
Ctrl+Shift+→ progressive selection expansion based on AST structure (identifier → expression → statement → block → function → class).

🔢 12. Code Lens
Live reference counts displayed directly above function and class declarations.

🔧 13. Code Formatting
Shift+Alt+F full-document formatting and Ctrl+K Ctrl+F range formatting according to Ring block indentation rules.

🌐 14. Workspace Symbols
Ctrl+T workspace-wide symbol search across all .ring, .rh, and .rform files.

🚀 15–21. Advanced Developer Tools

Feature
Description
15. Inlay Hints
Inline parameter name hints inside function calls (func(name: "Ring", year: 2026))
16. Call Hierarchy
Incoming & outgoing function call chains (Calls / Called by)
17. Type Hierarchy
Class inheritance tree viewer (superclasses & subclasses)
18. Quick Fixes & Code Actions
Auto-fix missing ok/end/done tags and refactor selection into try...catch
19. Interactive REPL Terminal
Dedicated terminal session to run Ring expressions interactively
20. File & Project Scaffolding
Commands to generate Class files, GUI Forms, and complete Ring Project templates
21. Ring Explorer Sidebar
Dedicated tree view in VS Code activity bar indexing all packages, classes, and functions
⌨️ Command Palette & Keybindings

Command
Title
ring.run
Run current .ring file (Ctrl+I Ctrl+I)
ring.clock
Run current file with execution timer (Ctrl+I Ctrl+C)
ring.ring2exe
Create executable from current file (Ctrl+I Ctrl+D)
ring.ring2exe_static
Create static executable (Ctrl+I Ctrl+E)
ring.ring2exe_dist
Distribute executable (Ctrl+I Ctrl+F)
ring.ring2exe_dist_allruntime
Distribute executable with full runtime (Ctrl+I Ctrl+G)
ring.startREPL
Start Interactive Ring REPL Terminal
ring.sendToREPL
Send Selection/Line to REPL
ring.createClass
Create New Class File
ring.createForm
Create New GUI Form
ring.newProject
Create New Ring Project Template

Regards, Azzeddine

max

unread,
Aug 6, 2026, 6:33:08 PMAug 6
to The Ring Programming Language
hallo  Azzeddine Remmal,

The URL appears to be not accessible. I couldn't verify or retrieve the repository at https://github.com/azzeddine2017/extension, which typically means it may have been deleted, made private, or the URL is incorrect.
Message has been deleted

max

unread,
Aug 6, 2026, 6:44:31 PMAug 6
to The Ring Programming Language
hallo Azzeddine Remmal,

Thank you. I now have access. Could you please explain how to install or run the add-on for testing purposes?

Azzeddine Remmal

unread,
Aug 6, 2026, 7:02:06 PMAug 6
to The Ring Programming Language
Hello Max.
I've updated the Redmi file with all the necessary information. I hope you like it.

Mahmoud Fayed

unread,
Aug 7, 2026, 11:06:28 AMAug 7
to The Ring Programming Language
Hello Azzeddine

>> "I've made some improvements to the VS Code plugin"

Very nice direction, Thanks for working on this :D

Report: When I click the (+/-) before (function definition) I still see the content of the function not encapsulated (just part of it)

Greetings,
Mahmoud  

Youssef Saeed

unread,
Aug 7, 2026, 12:05:15 PMAug 7
to The Ring Programming Language
Hello Max,

Thank you for testing the grammar in the playground and for reporting this!

While you are completely right that it looks strange in the AST, this is actually expected behavior for Tree-sitter by design. The snippet you provided isn't valid Ring code—the Ring compiler itself will reject it with "Error (C6): Error in function name" because the `class` keyword cannot be used as a function name.

Unlike a strict compiler, Tree-sitter grammars are designed to "over-accept" invalid input to provide graceful error recovery in editors. Because the keyword token isn't valid (shiftable) in the function name slot, Tree-sitter's lexer falls back to treating it as an identifier rather than completely breaking the syntax tree. This keeps syntax highlighting and other editor features working while the user is actively typing.

Best regards,
Youssef
On Friday, August 7, 2026 at 1:28:13 AM UTC+3 Azzeddine Remmal wrote:

Youssef Saeed

unread,
Aug 7, 2026, 12:07:24 PMAug 7
to The Ring Programming Language
Hello Azzeddine,

Thanks for sharing this! It's amazing to see the community using tree-sitter-ring to build such advanced tooling so quickly.

I am actually working on a VSCode extension for Ring from scratch, and I will definitely be looking at your version as a reference.

Best regards,
Youssef
On Friday, August 7, 2026 at 1:28:13 AM UTC+3 Azzeddine Remmal wrote:

max

unread,
Aug 7, 2026, 1:09:39 PMAug 7
to The Ring Programming Language

Hi Youssef,

Thanks for the explanation. That makes sense.

I was wondering whether it might be possible to exclude keywords such as class from being lexed as identifiers by using an external scanner in Tree-sitter. I'm not sure if that would work well with Tree-sitter's error recovery, but I thought it might be worth considering.

In any case, thanks for taking the time to explain the behavior.

Best regards,

Max

Mahmoud Fayed

unread,
Aug 28, 2026, 12:08:10 PMAug 28
to The Ring Programming Language
Hello Youssef

>> "I am actually working on a VSCode extension for Ring from scratch, and I will definitely be looking at your version as a reference."

This is a nice direction, thanks for working on this :D

Greetings,
Mahmoud
Reply all
Reply to author
Forward
0 new messages