Skip to content

VM: Support Custom Syntax - #1173

Open
schungx wants to merge 1 commit into
mainfrom
vm-support-custom-syntax
Open

schungx wants to merge 1 commit into
mainfrom
vm-support-custom-syntax

Conversation

@schungx

@schungx schungx commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Introduction

Custom syntax is a unique feature of Rhai, one used by many domain-specific applications to simplify code by providing new syntax suited to the domain usage.

Grain Support

Previously, Grain rejects all custom syntax as fragments. This PR adds support for custom syntax that does not touch the scope.

Custom syntax that touches the scope, like eval, remain non-lowerable. These cases are extremely rare.

Implementation

Grain implements custom syntax via a new Opcode Op::CustomSyntax and a custom_syntax pool.

no_ast

Finally, no_ast works with custom syntax, disabling only the parser half of it, but allows the execution part to work with Grain.

@schungx
schungx requested a review from ImTheSquid September 21, 2026 08:48
@schungx schungx added enhancement vm Issues related to the Rhai Grain bytecodes compiler and VM. labels Sep 21, 2026
@schungx
schungx force-pushed the main branch 2 times, most recently from e211101 to 8a0f5ed Compare September 21, 2026 09:39
@schungx
schungx force-pushed the vm-support-custom-syntax branch 3 times, most recently from 90df3c8 to b21221b Compare September 21, 2026 14:21
@schungx schungx closed this Sep 21, 2026
@schungx
schungx force-pushed the vm-support-custom-syntax branch from b21221b to 8a0f5ed Compare September 21, 2026 14:30
@schungx schungx reopened this Sep 21, 2026
@schungx
schungx force-pushed the vm-support-custom-syntax branch from 37342b5 to ce9b758 Compare September 21, 2026 15:14
@schungx
schungx force-pushed the vm-support-custom-syntax branch from ce9b758 to 09d85a0 Compare September 21, 2026 15:24
@schungx

schungx commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

@ImTheSquid Finally got all the CI tests to pass and all the feature combinations properly gated!

Pls take a read thru this... This look like a larger PR but really not so. One new opcode, one new pool, and the relevant implementation.

All other file changes are properly gating the no_ast feature, which used to automatically turn on no_custom_syntax but now needs to co-exist with custom syntax (because Grain can run it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement vm Issues related to the Rhai Grain bytecodes compiler and VM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant