Skip to content

feat(flowc): shift operators, compound assignments - #443

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

  • Bitwise shift operators << and >> are now lexed, parsed, and emitted in C output.
  • Compound assignment operators +=, -=, *=, /=, %= are now lexed and lowered to a = a op b in the AST.

Context

ai.flow uses >> for bit extraction from random numbers. Several stdlib modules use += and -= for accumulator updates.

Test plan

  • ./flow run compiler/src/main.flow passes (flowc: PASS)
  • Three consecutive generation fixed-points pass (byte-identical)
  • let x: i32 = 0xFF >> 4 compiles and prints 15
  • x += 5; x -= 3 compiles and prints 12

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

Generated with Devin

@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 force-pushed the work branch 3 times, most recently from de8abae to bd11807 Compare August 12, 2026 03:31
compiler/src/token.flow: add TOK_SHL (40), TOK_SHR (41),
TOK_PLUS_EQ (42), TOK_MINUS_EQ (43), TOK_STAR_EQ (44),
TOK_SLASH_EQ (45), TOK_PERCENT_EQ (46).

compiler/src/lexer.flow: lex << as TOK_SHL, >> as TOK_SHR,
+= as TOK_PLUS_EQ, -= as TOK_MINUS_EQ, *= as TOK_STAR_EQ,
/= as TOK_SLASH_EQ, %= as TOK_PERCENT_EQ.

compiler/src/parser.flow: add << and >> to binop kind and
precedence tables (precedence 3, same as & | ^). Compound
assignments are lowered to a = a op b (AST_ASSIGN with rhs
being AST_BINOP).

compiler/src/cgen.flow: emit " << " for TOK_SHL and " >> "
for TOK_SHR.

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>
@godofecht
godofecht merged commit ebc1068 into main Aug 12, 2026
14 checks passed
@godofecht
godofecht deleted the work branch August 12, 2026 04:00
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