Skip to content

feat(flowc): top-level let, hex literals - #442

Merged
godofecht merged 1 commit into
mainfrom
work
Aug 12, 2026
Merged

godofecht merged 1 commit into
mainfrom
work

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Summary

  • Top-level let mut declarations are now parsed and emitted as static global variables in C output.
  • Hex integer literals (0xFF, 0x7FFFFF) are now lexed and parsed correctly.

Context

Many stdlib modules (ai.flow, automata.flow, font.flow, etc.) declare module-level mutable state with let mut var: type = value. Several also use hex literals for bitmasks and constants.

Test plan

  • ./flow run compiler/src/main.flow passes (flowc: PASS)
  • Three consecutive generation fixed-points pass (byte-identical)
  • let mut counter: i32 = 0 at top level compiles and runs
  • let x: i32 = 0xFF compiles and prints 255

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

Generated with Devin

compiler/src/parser.flow:
- Add flowc_parse_let function extracted from statement parser.
- Handle top-level let mut declarations in flowc_parse_program.
- Add hex literal parsing (0x...) to flowc_parse_int_span.

compiler/src/lexer.flow: add hex literal scanning. After consuming
the leading 0, if the next char is x or X, consume hex digits and
emit TOK_INT.

compiler/src/cgen.flow: emit top-level let as static global
variables (Pass 2.5, after consts and before functions).

compiler/src/typecheck.flow: bind top-level let names as value
bindings in flowc_tc_collect_globals and flowc_tc_seed_export.

compiler/bootstrap/flowc_stage_a.c: regenerated.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@godofecht
godofecht merged commit 1d56374 into main Aug 12, 2026
12 of 13 checks passed
@godofecht
godofecht deleted the work branch August 12, 2026 02:36
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