Skip to content

Support timer AFTER input (tim ? AFTER expr) #60

@associate-1

Description

@associate-1

Difficulty: Medium — Parser, AST, and codegen changes across timer input handling.

Summary

Occam's tim ? AFTER expr construct waits until the timer value exceeds expr. This is used for timed delays and is distinct from tim ? t (which just reads the current time).

Occam syntax

TIMER tim:
INT t:
SEQ
  tim ? t              -- read current time
  tim ? AFTER t PLUS delay  -- wait until time passes t + delay

Proposed Go mapping

t = time.Now().UnixMicro()
time.Sleep(time.Duration(t + delay - time.Now().UnixMicro()) * time.Microsecond)

Or possibly using AFTER comparison semantics (modular time comparison).

Affected files

  • bar.occ (lines 176, 189, 225, 373)
  • demo.occ (line 16)
  • sort_inside_2.occ (line 323)

Work required

  1. Parser: Detect AFTER keyword after ? in channel/timer input and parse the delay expression
  2. AST: Add an AfterExpr field (or similar) to the input node
  3. Codegen: Generate time.Sleep(...) or equivalent

Part of #43.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions