Repository navigation
Conversation
Port the require/prefer constraint parser from Python to Flow. The Python original uses regex; the Flow port does manual character scanning with ptr<u8> arithmetic since Flow string + is concat, not pointer math, so strncmp(s+i, ...) would silently break. Provides: - flowc_parse_require: parse require(resource op value) constraints - flowc_parse_prefer: parse prefer(objective) constraints - flowc_op_is_less / flowc_op_is_greater: operator classification - flowc_pick_tighter: pick the tighter budget value for a constraint - flowc_require_to_value: extract the integer value from a parsed require Test: tests/lang/test_constraints.flow has 22 checks, all pass under FLOW_HOST=python. The flowc Stage-A host cannot resolve the import yet; the test runs via the Python host, same as know_demo.flow and claim_address_demo.flow. Updated docs/project/python-in-flow.md to list the new port. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…415) Port the avoid-pattern matching core from Python to Flow. The Python original uses regex for patterns with metacharacters, then falls back to a case-insensitive substring match. Flow has no regex engine, so all patterns use the substring match. This is stricter for regex patterns (treats them as literals) and identical for plain patterns. Provides: - flowc_contains_ci: case-insensitive substring search - flowc_matches_pattern: match source against a single pattern - flowc_build_warning: format a warning message with reason/workaround - flowc_check_source: scan source against an array of avoid patterns TOML loading stays in Python (needs tomllib and filesystem walk). The Flow port owns the hot path: pattern matching and warning generation. Test: tests/lang/test_conventions.flow has 17 checks, all pass under FLOW_HOST=python. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the MISRA/CERT C source scanner from Python to Flow. The Python
original uses regex with word boundaries; the Flow port does manual
character scanning with a left word-boundary check and a trailing
'(' lookahead.
Provides:
- flowc_scan_c_source: scan C text for heap/stdio/abort calls
- flowc_count_violations / flowc_count_notes: tally findings
- find_keyword_call: word-boundary keyword search helper
Scans for:
- MISRA 21.3: malloc/calloc/realloc/free (VIOLATION)
- MISRA 21.6: printf/fprintf/sprintf/snprintf/scanf/gets (NOTE)
- MISRA 22.1: abort() (NOTE)
Skips lines starting with # or // (matching the Python original).
Block comments /* */ are not skipped, same as the Python version.
Test: tests/lang/test_misra_scan.flow has 18 checks, all pass under
FLOW_HOST=python. Covers heap calls, stdio calls, abort, comment
skipping, directive skipping, word boundaries (my_malloc does not
match malloc), and clean source.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the function attribute vocabulary from Python to Flow. The Python original uses regex for target spec validation; the Flow port does manual character scanning. Provides: - flowc_parse_attribute: split "name(args)" into name and args - flowc_is_known_attr: check if a name is a known attribute - flowc_attr_takes_args: check if an attribute accepts arguments - flowc_domain_rank: lifetime domain ordering (callback < frame < session < application) - flowc_validate_target_spec: validate @target(...) feature strings - flowc_normalize_target_spec: canonical comma-joined form Covers codegen (inline/noinline/always_inline/target), guard (only/guard/compile/jit/hot/interp/mlir/c), and semantic (gpu/rt_safe/safe/unsafe/flow_api/test/monomorphized/lifetime) attribute sets. Test: tests/lang/test_attributes.flow has 39 checks, all pass under FLOW_HOST=python. Covers bare and parenthesized attributes, whitespace handling, empty arg skipping, target spec validation (valid and invalid), normalization, and lifetime domain ranking. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…147) Port the matmul and reduce implementation cost models from Python to Flow. The Python original uses a callback-based registry with Facts as a dict; the Flow port uses a flat struct and pure functions. The selector registry stays in Python for now; the Flow port exposes the cost/applicability/scratch functions and a simple selector that picks the cheapest applicable implementation. Provides: - flowc_matmul_naive_applicable / cost / scratch - flowc_matmul_blocked_applicable / cost / scratch - flowc_reduce_sequential_applicable / cost / scratch - flowc_reduce_tree_applicable / cost / scratch - flowc_select_matmul: pick cheapest applicable matmul impl - flowc_select_reduce: pick cheapest applicable reduce impl Thresholds: MATMUL_BLOCK_THRESHOLD=64, REDUCE_TREE_THRESHOLD=1024. GPU backend is rejected for all four implementations. Memory constraint blocks blocked matmul when the tile buffer (8192 bytes) exceeds the budget. prefer=parallel flips reduce to tree regardless of size. Test: tests/lang/test_general_plans.flow has 21 checks, all pass under FLOW_HOST=python. Covers small/large selection, GPU rejection, memory constraints, prefer=parallel, and cost model sanity values. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Extend the premise instantiation port with generic {N} placeholder
replacement. The original port had hardcoded fills for known arg
values; the new flowc_instantiate_premise function splits args by
comma and fills {0} and {1} generically, matching the Python
instantiate_premise_latex behavior (minus the LaTeX conversion, which
stays in Python).
Also adds flowc_param_names_from_sig: parse "a: i32, b: i32" into
"a,b", matching the Python _param_names_from_sig helper.
Test: tests/lang/test_proof_sub_gen.flow has 10 checks, all pass
under FLOW_HOST=python. Covers one-arg and two-arg templates, unknown
claims, squaring, equality, and param name extraction with whitespace
and missing type annotations.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the FIR-G effect propagation and call-graph reachability from Python to Flow. The Python original operates on the FirG graph object; the Flow port works on flat arrays (CSR call graph + effect bitvectors) so a Flow caller can run the same fixpoint without the Python object graph. Provides: - flowc_propagate_effects: monotone OR-propagation to fixpoint - flowc_reachable_functions: forward DFS reachability from roots - flowc_is_pure: check if effect bits have no dirty flags - flowc_count_pure / flowc_count_dead: tally helpers Effect bit constants match fir_g.py: IO=1, FFI=2, GPU=4, WRITES_MEMORY=8, ALLOCATES=16, UNKNOWN=32. The dirty mask is 63. Test: tests/lang/test_fir_analysis.flow has 19 checks, all pass under FLOW_HOST=python. Builds a 4-function call graph, verifies effect inheritance (main inherits IO from io_func), purity counting, reachability from different roots, and dead function counting. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the FIR-G optimization candidate scoring formulas from Python to Flow. The Python original scans the FirG graph object; the Flow port exposes the deterministic scoring functions so a Flow caller can rank inline and dead-elim candidates without the Python graph. Provides: - flowc_score_dead_elim: base score + op count for unreachable funcs - flowc_score_inline: (max_ops - callee_ops + 1) / sites, with single-site bonus (*2.0) and pure callee bonus (*1.5) - flowc_is_inline_candidate: size and extern gate - flowc_is_dead_elim_candidate: unreachable and not-main gate - flowc_compare_candidates: sort by score desc, then kind, then id Constants match fir_opts.py: INLINE_MAX_CALLEE_OPS=16, INLINE_SINGLE_SITE_BONUS=2.0, INLINE_PURE_BONUS=1.5, DEAD_ELIM_BASE_SCORE=10.0. Test: tests/lang/test_fir_opts.flow has 22 checks, all pass under FLOW_HOST=python. Covers dead-elim scoring, inline scoring with all bonus combinations, candidate gating, and comparison sorting. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The effect bit values were wrong. The Python fir_g.py defines: EFF_READS_MEMORY=1, EFF_WRITES_MEMORY=2, EFF_ALLOCATES=4, EFF_IO=8, EFF_FFI=16, EFF_PANIC=32, EFF_ATOMIC=64, EFF_THREAD=128, EFF_GPU=256, EFF_UNKNOWN=32768 The Flow port had them as 1,2,4,8,16,32 (shifted by 2 bits from the correct values). Now matches the Python source exactly. The dirty mask for purity checking is now 33054 (IO|FFI|GPU|WRITES_MEMORY|ALLOCATES|UNKNOWN = 8|16|256|2|4|32768). Test passes with 19 checks under FLOW_HOST=python. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add the FIR-G OpCode enum values as Flow constants, matching the Python fir_g.py IntEnum. Add flowc_count_call_ops to count CALL opcodes in an opcode array, matching the Python analyse() summary. New exports: - FLOWC_OP_NOP/CONST/PARAM/LOAD/STORE/BINOP/UNOP/CALL/RET/BR/ COND_BR/PHI/ALLOCA/GEP/CAST/EFFECT/OTHER - flowc_count_call_ops Test: now 25 checks, all pass under FLOW_HOST=python. Added tests for OpCode constant values and call op counting. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the CPU vs bulk analysis routing decision from Python to Flow. The Python original does calibration timing and filesystem persistence; the Flow port exposes the pure routing decision so a Flow caller can pick cpu/numpy/mlx from thresholds without the Python timing machinery. Provides: - flowc_choose_analysis_backend: pick cpu/numpy/mlx from request, graph size, thresholds, and backend availability - flowc_route_thresholds_none: uncalibrated (always CPU) - flowc_route_thresholds_calibrated: build thresholds from sweep Routing rules match the Python choose_analysis_backend: - Explicit cpu/numpy/mlx requests pass through - auto with uncalibrated thresholds -> cpu - auto with calibrated thresholds: bulk if n_funcs or n_edges meets threshold, else cpu - mlx falls back to numpy if unavailable, then cpu - numpy falls back to cpu if unavailable Test: tests/lang/test_fir_route.flow has 14 checks, all pass under FLOW_HOST=python. Covers explicit requests, uncalibrated, small/large graphs, mlx fallback, numpy fallback, and boundary conditions. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…flow Extend the claim_path port with the morphism gloss table and the plain-text tier opening sentences from the Python original. New exports: - flowc_morphism_gloss: map morphism symbols (+, *, ||, =, out, fifo, vectorize, fuse) to human-readable glosses - flowc_tier_opening_plain: one-sentence proof-step table entry for definition/axiom/derived tiers, matching Python tier_opening_plain The definition tier mentions the stipulated law, structure, and carrier when an address is available. The axiom tier mentions the domain and "without proof". The derived tier mentions the proof target. Test: tests/lang/test_claim_path_tier.flow has 12 checks, all pass under FLOW_HOST=python. Covers morphism glossing for known and unknown symbols, and tier opening sentences for all three tiers. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Extend the math_prose port with the structure coordinate display table and the address coordinate line builders from the Python original. New exports: - flowc_structure_coordinate_display: plain English for geometry structures (triangle, circle, Euclid Book I, etc.), falls back to structure_mathematical for unknown names - flowc_addr_coordinate_display: "carrier . structure . law" line - flowc_addr_coordinate_latex: same with \cdot separators for PDF Renamed the internal str_append to mp_str_append to avoid a symbol collision with claim_path.flow's str_append when both modules are imported together. Test: tests/lang/test_math_prose_coord.flow has 11 checks, all pass under FLOW_HOST=python. Covers known geometry structures, fallback for unknown names, coordinate line content, and LaTeX dot separators. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the address_phrase function from Python to Flow. This maps known (carrier, structure, law) triples to plain English glosses for proof prose. Covers 18 known claims across Nat, Eq, Bool, Int, Geometry (triangle, isosceles, intersecting lines, right triangle, parallel lines, triangle congruence, circle), and Analysis (Taylor series, smooth functions). Falls back to the display string for unknown claims. Test: tests/lang/test_claim_address_phrase.flow has 8 checks, all pass under FLOW_HOST=python. Covers Nat addition, Eq equality, Bool disjunction, Int multiplication, Geometry triangle and circle, and the fallback for unknown claims. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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. |
compiler/src/lexer.flow: - Scientific notation in number literals (1e-9, 3.0e+300, 1E5). The exponent part is only consumed if followed by at least one digit; otherwise the position is restored and 'e'/'E' is left as the start of an identifier. - Add TOK_AT for the @ character. - Add "type" keyword (KW_TYPE). compiler/src/token.flow: add TOK_AT (37) and KW_TYPE (26). compiler/src/ast.flow: add AST_TYPE_ALIAS (37). compiler/src/parser.flow: - Skip @attr and @attr(args) annotations before top-level items. - Parse type alias declarations: type Name = BaseType. Stored as AST_TYPE_ALIAS with name span and base type in .a. compiler/src/cgen.flow: - Emit typedef BaseType Name; for AST_TYPE_ALIAS nodes (Pass 1.5, after struct typedefs and before consts). - Treat type alias names as known named types in flowc_cgen_is_struct_type so they are emitted by name. 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1e-9,3.0e+300,1E5). The exponent is only consumed if followed by at least one digit.@attrand@attr(args)annotations are skipped before top-level items.type Name = BaseTypealias declarations are parsed and emitted astypedef BaseType Name;in the C output.Context
Several stdlib modules use scientific notation for physical constants,
@gpu/@max_iterationsattributes for code generation hints, andtypealiases for readability. None of these were handled by the self-hosted compiler.Test plan
./flow run compiler/src/main.flowpasses (flowc: PASS)let x: f64 = 1.5e-10compiles and runs@gpu function foo(...)compiles and runstype UserId = i32compiles and runs, prints 42This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.
Generated with Devin