Expressions in FSP are a subset of expressions in Java. This has the advantage of familiarity; however it has the disadvantage that some of the FSP process operators have a different meaning when used in the context of an expression. In particular, the priority operators << and >> mean shift left and shift right when used in an expression, the parallel composition operator || means logical or when used in an expression, the choice operator | means bit-wise or in an expression and the re-label operator / means division. Where confusion might arise, namely in constant and range definitions, expressions with the logical and shift operators must be bracketed. This is the reason why constant and range definitions are defined using SimpleExpression rather than Expression. The syntax of expressions used in FSP is specified by the following expressions.
SimpleExpression: AdditiveExpr Expression: OrExpr OrExpr: AndExpr OrExpr || AndExpr AndExpr: BitOrExpr AndExpr && BitOrExpr BitOrExpr: BitExclOrExpr BitOrExpr | BitExclOrExpr BitExclOrExpr: BitAndExpr BitExclOrExprˆBitAndExpr BitAndExpr: EqualityExpr BitAndExpr & EqualityExpr EqualityExpr: RelationalExpr EqualityExpr == RelationalExpr EqualityExpr != RelationalExpr RelationalExpr: ShiftExpr RelationalExpr < ShiftExpr RelationalExpr <= ShiftExpr RelationalExpr > ShiftExpr RelationalExpr >= ShiftExpr ShiftExpr: AdditiveExpr ShiftExpr >> AdditiveExpr ShiftExpr << AdditiveExpr AdditiveExpr: MultiplicativeExpr AdditiveExpr + MultiplicativeExpr AdditiveExpr - MultiplicativeExpr MultiplicativeExpr: UnaryExpr MultiplicativeExpr * UnaryExpr MultiplicativeExpr\UnaryExpr MultiplicativeExpr % UnaryExpr UnaryExpr: BaseExpr + BaseExpr - BaseExpr ! BaseExpr BaseExpr: IntegerLiteral Variable ConstantIdent 'ActionLabel # SetIdent @( SetIdent , Expression ) ( Expression )
FSP supports only integer and label expressions. Variables may take either an integer value or a label value. Label literals are formed by preceding an action label with a quote – this distinguishes a label value from a variable. The only valid operators on label values are equality and inequality.
The expression @(A, e) returns a label value which is the eth element of the set identified by A.
The expression # A returns as an integer value the cardinality of the set identified by A.
As in the programming language C, the results of boolean expressions in FSP are integer values. A false expression has the value 0 and a true expression the value 1.