--- capa/capa51/pProj/capaGrammarDef.y 1999/10/18 20:58:33 1.4 +++ capa/capa51/pProj/capaGrammarDef.y 1999/11/08 22:30:02 1.6 @@ -375,8 +375,7 @@ if_expr : CAPA_IF '(' calc_expr ' leng = strlen($3->s_str); capa_mfree($3->s_str); } - leng = strlen($3->s_str); - if(leng == 0) { + if(leng == 0) { IFstatus[IFcount] = IF_FALSE; begin_if_skip(); }else{ @@ -555,54 +554,64 @@ pt_list : pt_list ',' point_coo | pt_range { } ; -pt_range : point_coord ':' point_coord '#' IDENTIFIER { PointsList_t *pt; - - if( LastPtsList != NULL ) { - LastPtsList->pts_next = gen_ptslist( $1, $3, $5 ); - pt = LastPtsList->pts_next; - while( pt->pts_next != NULL ) { - pt = pt->pts_next; - } - LastPtsList = pt; - } else { - CurrPtsList = gen_ptslist( $1, $3, $5 ); - LastPtsList = CurrPtsList; - } - if( $1->s_type == S_CONSTANT ) { - capa_mfree($1->s_str); capa_mfree((char *)$1); - } - if( $3->s_type == S_CONSTANT ) { - capa_mfree($3->s_str); capa_mfree((char *)$3); - } - } - | point_coord ':' point_coord '#' a_number { PointsList_t *pt; - - if( LastPtsList != NULL ) { - LastPtsList->pts_next = gen_ptslist( $1, $3, $5 ); - pt = LastPtsList->pts_next; - while( pt->pts_next != NULL ) { - pt = pt->pts_next; - } - LastPtsList = pt; - } else { - CurrPtsList = gen_ptslist( $1, $3, $5 ); - LastPtsList = CurrPtsList; - } - if( $1->s_type == S_CONSTANT ) { - capa_mfree($1->s_str); capa_mfree((char *)$1); - } - if( $3->s_type == S_CONSTANT ) { - capa_mfree($3->s_str); capa_mfree((char *)$3); - } - if( $5->s_type == I_CONSTANT || $5->s_type == R_CONSTANT) { - capa_mfree((char *)$5); - } - } +pt_range : point_coord ':' point_coord '#' IDENTIFIER + { + assign_pts($1,$3,$5); + /*PointsList_t *pt; + if( LastPtsList != NULL ) { + LastPtsList->pts_next = gen_ptslist( $1, $3, $5 ); + pt = LastPtsList->pts_next; + while( pt->pts_next != NULL ) { + pt = pt->pts_next; + } + LastPtsList = pt; + } else { + CurrPtsList = gen_ptslist( $1, $3, $5 ); + LastPtsList = CurrPtsList; + } + if( $1->s_type == S_CONSTANT ) { + capa_mfree($1->s_str); capa_mfree((char *)$1); + } + if( $3->s_type == S_CONSTANT ) { + capa_mfree($3->s_str); capa_mfree((char *)$3); + } + */ + } + | point_coord ':' point_coord '#' ARRAY_ID '[' calc_expr ']' + { assign_pts($1,$3,get_array_symbol($5,$7,1)); } + | point_coord ':' point_coord '#' a_number + { + assign_pts($1,$3,$5); + /*PointsList_t *pt; + + if( LastPtsList != NULL ) { + LastPtsList->pts_next = gen_ptslist( $1, $3, $5 ); + pt = LastPtsList->pts_next; + while( pt->pts_next != NULL ) { + pt = pt->pts_next; + } + LastPtsList = pt; + } else { + CurrPtsList = gen_ptslist( $1, $3, $5 ); + LastPtsList = CurrPtsList; + } + if( $1->s_type == S_CONSTANT ) { + capa_mfree($1->s_str); capa_mfree((char *)$1); + } + if( $3->s_type == S_CONSTANT ) { + capa_mfree($3->s_str); capa_mfree((char *)$3); + } + if( $5->s_type == I_CONSTANT || $5->s_type == R_CONSTANT) { + capa_mfree((char *)$5); + } + */ + } ; -point_coord : IDENTIFIER { $$ = $1; } - | S_CONSTANT { $$ = $1; } +point_coord : IDENTIFIER { $$ = $1; } + | ARRAY_ID '[' calc_expr ']' { $$ = get_array_symbol($1,$3,1); } + | S_CONSTANT { $$ = $1; } ; @@ -1790,6 +1799,30 @@ assign_id_list( s ) Symbol *s; } } +void assign_pts ( Symbol* coord1, Symbol* coord2, Symbol* num) { + PointsList_t *pt; + if( LastPtsList != NULL ) { + LastPtsList->pts_next = gen_ptslist( coord1, coord2, num ); + pt = LastPtsList->pts_next; + while( pt->pts_next != NULL ) { + pt = pt->pts_next; + } + LastPtsList = pt; + } else { + CurrPtsList = gen_ptslist( coord1, coord2, num ); + LastPtsList = CurrPtsList; + } + if(coord1->s_type == S_CONSTANT) { + capa_mfree(coord1->s_str); capa_mfree((char *)coord1); + } + if(coord2->s_type == S_CONSTANT) { + capa_mfree(coord2->s_str); capa_mfree((char *)coord2); + } + if(num->s_type == I_CONSTANT || num->s_type == R_CONSTANT) { + capa_mfree((char *)num); + } +} + /* =========================================================================== */