Skip to content

Comments

Linearization token codegen#3504

Draft
martyall wants to merge 3 commits intomasterfrom
linearization-token-codegen
Draft

Linearization token codegen#3504
martyall wants to merge 3 commits intomasterfrom
linearization-token-codegen

Conversation

@martyall
Copy link
Contributor

No description provided.

martyall and others added 3 commits February 21, 2026 07:28
Add format_token, format_tokens_as_ocaml_array, and
linearization_token_strings functions that convert linearization
expressions to compact Polish notation token arrays (via to_polish())
formatted as OCaml array literals.

Exports fp_linearization_token_strings and fq_linearization_token_strings
as OCaml FFI functions, used by gen_scalars_tokens to generate
scalars_tokens.ml — a token-based alternative to the tree-walking
scalars.ml.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
IfFeature(f, e1, e2) was encoded as two SkipIfNot tokens with the
same flag. This meant both branches had the same skip polarity,
requiring interpreters to track pairing state to know which SkipIfNot
was the "first" (true branch) vs "second" (false branch).

Now the false branch uses SkipIf (skip if enabled), giving each
branch the correct polarity:
  - SkipIfNot(f, N) [e1] — skip true branch when disabled
  - SkipIf(f, M) [e2]    — skip false branch when enabled

Exactly one branch evaluates per IfFeature, producing one value on
the stack. Interpreters become stateless: each token independently
decides skip-or-advance based on the feature flag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ensures Bigint256.of_hex_string compatibility without per-callsite
workarounds in OCaml consumers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant