docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Grammar

    Represents a TextMate grammar for tokenizing source code

    Inheritance
    object
    Grammar
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.TextMateLib
    Assembly: Unity.AppUI.TextMateLib.dll
    Syntax
    public class Grammar : IDisposable

    Properties

    ScopeName

    Gets the scope name of the grammar (e.g., "source.js")

    Declaration
    public string ScopeName { get; }
    Property Value
    Type Description
    string

    Methods

    Dispose()

    Releases the managed handle reference. The underlying native Grammar is owned and disposed by the Registry.

    Declaration
    public void Dispose()

    ~Grammar()

    Finalizer to ensure resources are released

    Declaration
    protected ~Grammar()

    TokenizeLine(string, IntPtr)

    Tokenizes a line of text

    Declaration
    public TokenizeResult TokenizeLine(string lineText, IntPtr prevState)
    Parameters
    Type Name Description
    string lineText

    The line to tokenize

    IntPtr prevState

    Previous state stack (use IntPtr.Zero for initial state)

    Returns
    Type Description
    TokenizeResult

    Tokenization result with tokens and state

    TokenizeLine2(string, IntPtr)

    Tokenizes a line of text with binary/themed output (encoded tokens). Requires a theme to be set on the registry via SetThemeFromJson.

    Declaration
    public TokenizeResult2 TokenizeLine2(string lineText, IntPtr prevState)
    Parameters
    Type Name Description
    string lineText

    The line to tokenize.

    IntPtr prevState

    Previous state stack (use IntPtr.Zero for the initial state).

    Returns
    Type Description
    TokenizeResult2

    The themed tokenization result with encoded tokens and end-of-line state.

    TokenizeLines(string[])

    Tokenizes multiple lines sequentially

    Declaration
    public TokenizeResult[] TokenizeLines(string[] lines)
    Parameters
    Type Name Description
    string[] lines

    Array of lines to tokenize

    Returns
    Type Description
    TokenizeResult[]

    Array of tokenization results, one per line

    TokenizeLines2(string[])

    Tokenizes multiple lines with encoded/themed output in a single batch call. Requires a theme to be set on the registry via SetThemeFromJson.

    Declaration
    public TokenizeResult2[] TokenizeLines2(string[] lines)
    Parameters
    Type Name Description
    string[] lines

    The lines to tokenize.

    Returns
    Type Description
    TokenizeResult2[]

    An array of themed tokenization results, one per input line.

    Implements

    IDisposable
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)