return NUM;
}
+else: {
+ /* Hack to distinguish if..else from else: in case */
+ return ELSECOL;
+}
+
({ALPHA}{ALNUM}*|[']({ALNUM}|[-])*[']) {
if(*yytext == '\'') {
yytext[yyleng-1] = 0;
struct timeformat *tf;
}
-%token END CLI_MARKER INVALID_TOKEN
+%token END CLI_MARKER INVALID_TOKEN ELSECOL
%token GEQ LEQ NEQ AND OR
%token PO PC
%token <i> NUM ENUM
<M>command_1</M>; <M>command_2</M>; <M>...</M> }</cf> instead of either command. The <cf>else</cf>
clause may be omitted. If the <cf><m>boolean expression</m></cf> is true, <cf><m>command1</m></cf> is executed, otherwise <cf><m>command2</m></cf> is executed.
-<p>The <cf>case</cf> is similar to case from Pascal. Syntax is <cf>case <m/expr/ { else |
+<p>The <cf>case</cf> is similar to case from Pascal. Syntax is <cf>case <m/expr/ { else: |
<m/num_or_prefix [ .. num_or_prefix]/: <m/statement/ ; [ ... ] }</cf>. The expression after
<cf>case</cf> can be of any type which can be on the left side of the ˜ operator and anything that could
be a member of a set is allowed before <cf/:/. Multiple commands are allowed without <cf/{}/ grouping.
$$->data = $4;
$$->left = $1;
}
- | switch_body ELSE ':' cmds {
+ | switch_body ELSECOL cmds {
$$ = f_new_tree();
$$->from.type = T_VOID;
$$->to.type = T_VOID;
- $$->data = $4;
+ $$->data = $3;
$$->left = $1;
}
;
int local2;
int i;
{
- printn "Function callme called arguments ", arg1, " and ", arg2, ":" ;
+ printn "Function callme called arguments ", arg1, " and ", arg2, ": " ;
i = arg2;
case arg1 {
- 2: print "dva"; print "jeste jednou dva";
- 3 .. 5: print "tri az pet";
- else: print "neco jineho";
- }
+ 2: printn "dva, "; printn "jeste jednou dva";
+ 3 .. 5: if arg2 < 3 then printn "tri az pet";
+ else: printn "neco jineho";
+ }
+ print;
}
function fifteen()
callme ( 2, 2 );
callme ( 2, 2 );
callme ( 3, 2 );
- callme ( 4, 2 );
+ callme ( 4, 4 );
callme ( 7, 2 );
i = fifteen();