Alternatives alternative sourcealternative
Syntax
Alternative =
     "\{" PathList "}" |
      "{" PathList "}".

PathList = { Path ";" }.
Evaluation

The evaluation of a source \{Q1; Q2; ... Qn;} proceeds as follows. The paths Q1, Q2, ..., Qn are evaluated from left to right until the evaluation of a path succeeds.

More specifically, consider the result of evaluating the path Qj.

If the result is a ground expression Ge, then Ge is taken to be the result of the whole construct. If the result is $error(Ge), then $error(Ge) is the result of the whole construct. If the result is $fail(k+1), then $fail(k+1) is the result of the whole construct. And, finally, if the result is $fail(0), this failure is "caught", i.e. an attempt is made to evaluate the next path. If there exists no next path (i.e. j=n), the failure $fail(0) is the result of the whole construct.

An alternative {Q1; Q2; ... Qn;} is equivalent to the alternative \{Q1; Q2; ... Qn; $error(Fname "Unexpected fail");}, where Fname is the name of the function in which the construct appears.

{Q1; Q2; ... Qn;} =>=> \{Q1; Q2; ... Qn; $error(Fname "Unexpected fail");} Fname is the name of the function in which the construct appears. Env,m,St |- \{} => $fail(0),St Env,m,St |- Q1 => Ge,St' ---------------------------------------- Env,m,St |- \{Q1; Q2; ... Qn;} => Ge,St' Env,m,St |- Q1 => $fail(0),St' Env,m,St'|- \{Q2; ... Qn;} => X,St'' ---------------------------------------- Env,m,St |- \{Q1; Q2; ... Qn;} => X,St'' Env,m,St |- Q1 => $fail(k+1),St' ------------------------------------------------ Env,m,St |- \{Q1; Q2; ... Qn;} => $fail(k+1),St' Env,m,St |- Q1 => $error(Ge),St' ------------------------------------------------ Env,m,St |- \{Q1; Q2; ... Qn;} => $error(Ge),St'