-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Difficulty: Medium — Parser must accept expressions as array sizes; codegen must emit make() for non-literal sizes since Go arrays require compile-time constants.
Summary
Occam allows array sizes to be arbitrary expressions (typically referencing variables or constants), not just integer literals. Currently the parser only accepts literal integers as array sizes.
Occam syntax
VAL INT max.delay IS 100:
[max.delay]BYTE buffer:
[total - 1]BYTE temp:
Proposed Go mapping
maxDelay := 100
buffer := make([]byte, maxDelay)
temp := make([]byte, total - 1)Since Go arrays require compile-time constant sizes, expression-sized arrays should map to slices via make().
Affected files
sort_inside.occ(lines 309, 333, 336)
Work required
- Parser: Parse the array size as a full expression instead of requiring an integer literal
- Codegen: When array size is not a literal, generate
make([]type, expr)instead of a fixed-size array
Part of #43.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels