Skip to content

Support SIZE of direction-annotated channel name #63

@associate-1

Description

@associate-1

Difficulty: Easy — Strip trailing ?/! direction suffix when parsing SIZE operand.

Summary

When a channel parameter has a direction annotation (e.g., monitor?), the SIZE operator should work on it by stripping the direction suffix. Currently SIZE monitor? fails to parse.

Occam syntax

PROC foo([]CHAN OF INT monitor?)
  SEQ i = 0 FOR SIZE monitor?
    ...

Proposed Go mapping

func foo(monitor []chan int) {
    for i := 0; i < len(monitor); i++ {
        ...
    }
}

The ? suffix is purely a direction annotation and should be stripped when generating the len() call.

Affected files

  • sort_inside_2.occ (line 294)

Work required

  1. Parser: When parsing SIZE, handle the case where the operand identifier has a trailing ? or ! direction annotation
  2. Codegen: Generate len(name) with the direction suffix stripped

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