Splits script source into segments and tokenizes them.
Segments:
{:mustache, tokens, {line, col}}— one{{ ... }}construct{:text, string, {line, col}}— raw text between mustaches (only meaningful insideendpoint/vars/outputsblocks; must be whitespace everywhere else)
Comments ({{!-- ... --}} and {{! ... }}) are stripped here.
Tokens are {kind, value, {line, col}} with kind :ident | :string | :number | :punct. No atoms are ever created from input (S2): idents and
strings stay binaries.
Summary
Functions
Tokenize a raw-text segment (endpoint/vars/outputs bodies) starting at the given position.
Types
@type segment() :: {:mustache, [token()], {pos_integer(), pos_integer()}} | {:text, String.t(), {pos_integer(), pos_integer()}}
@type token() :: {:ident | :string | :number | :punct, term(), {pos_integer(), pos_integer()}}
Functions
@spec segments(String.t()) :: {:ok, [segment()]} | {:error, GenAI.Approval.Error.t()}
@spec tokenize( String.t(), {pos_integer(), pos_integer()} ) :: {:ok, [token()]} | {:error, GenAI.Approval.Error.t()}
Tokenize a raw-text segment (endpoint/vars/outputs bodies) starting at the given position.