Diff for /loncom/homework/CAPA-converter/capaGrammarDef.y between versions 1.1 and 1.4

version 1.1, 2000/04/12 20:06:16 version 1.4, 2001/12/04 15:17:57
Line 1 Line 1
   /* The LearningOnline Network with CAPA
    * CAPA parser (beaten into submission for conversion) 
    * $Id$
    *
    * Copyright Michigan State University Board of Trustees
    *
    * This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    *
    * LON-CAPA is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    *
    * LON-CAPA is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with LON-CAPA; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    *
    * /home/httpd/html/adm/gpl.txt
    *
    * http://www.lon-capa.org/
    */
   
 /* ========================================================================== */  /* ========================================================================== */
 /*            capaGrammarDef.y    created by Isaac Tsai                       */  /*            capaGrammarDef.y    created by Isaac Tsai                       */
 /*                                1998, 1999 copyrighted by Isaac Tsai        */  /*                                1998, 1999 copyrighted by Isaac Tsai        */
Line 15 Line 42
 #include "capaParser.h"   /* _symbol structure def */  #include "capaParser.h"   /* _symbol structure def */
 #include "capaCommon.h"  #include "capaCommon.h"
 #include "capaFunction.h"  #include "capaFunction.h"
 #include "capaRQO.h"  
 #ifdef __hpux  #ifdef __hpux
 #include <stdlib.h>  #include <stdlib.h>
 #include <alloca.h>  #include <alloca.h>
Line 60  extern int         Input_idx; Line 86  extern int         Input_idx;
 int                Current_line[MAX_OPENED_FILE];  int                Current_line[MAX_OPENED_FILE];
 extern int         Func_idx;  extern int         Func_idx;
 extern Symbol      FuncStack[MAX_FUNC_NEST];  extern Symbol      FuncStack[MAX_FUNC_NEST];
 extern int         IFstatus[MAX_FUNC_NEST];  /*extern int         IFstatus[MAX_FUNC_NEST];*/
 extern int         IFcount;  extern int         IFcount;
 /*extern int         gUnitError;*/  /*extern int         gUnitError;*/
   
Line 79  int                Answer_infospec; Line 105  int                Answer_infospec;
 void              (*Status_Func)();  void              (*Status_Func)();
 AnswerInfo_t       CurrAnsInfo;  AnswerInfo_t       CurrAnsInfo;
   
 RandQO_t          *QuestionOrder;  
 PointsList_t      *CurrPtsList;  PointsList_t      *CurrPtsList;
 PointsList_t      *LastPtsList;  PointsList_t      *LastPtsList;
   
Line 297  if_expr      :  CAPA_IF '(' calc_expr  ' Line 322  if_expr      :  CAPA_IF '(' calc_expr  '
                                           YYDBUG_PR2("(IF expr <IFcount=%d>)\n",IFcount);                                            YYDBUG_PR2("(IF expr <IFcount=%d>)\n",IFcount);
                                           switch($3->s_type) {                                            switch($3->s_type) {
                                             case IDENTIFIER:                                               case IDENTIFIER: 
                                                    IFstatus[IFcount] = IF_FALSE;             /*IFstatus[IFcount] = IF_FALSE;*/
                                                    begin_next_line();                                                     begin_next_line();
                                                    break;                                                     break;
                                             case I_CONSTANT: case I_VAR:                                               case I_CONSTANT: case I_VAR: 
                                                    if(!$3->s_int) {                                                     if(!$3->s_int) {
                                                       IFstatus[IFcount] = IF_FALSE;       /*IFstatus[IFcount] = IF_FALSE;
                                                       begin_if_skip();                                                        begin_if_skip();*/
                                                    } else {                                                     } else {
                                                       IFstatus[IFcount] = IF_TRUE;       /*IFstatus[IFcount] = IF_TRUE;*/
                                                       begin_next_line();                                                        begin_next_line();
                                                    }                                                      } 
                                                    break;                                                     break;
                                             case R_CONSTANT: case R_VAR:                                              case R_CONSTANT: case R_VAR:
                                                    if($3->s_real == 0.0) {                                                     if($3->s_real == 0.0) {
                                                       IFstatus[IFcount] = IF_FALSE;       /*IFstatus[IFcount] = IF_FALSE;
                                                       begin_if_skip();                                                        begin_if_skip();*/
                                                    }else{                                                     }else{
                                                       IFstatus[IFcount] = IF_TRUE;       /*IFstatus[IFcount] = IF_TRUE;*/
                                                       begin_next_line();                                                        begin_next_line();
                                                    }                                                     }
                                                    break;                                                     break;
Line 324  if_expr      :  CAPA_IF '(' calc_expr  ' Line 349  if_expr      :  CAPA_IF '(' calc_expr  '
                                                       capa_mfree($3->s_str);                                                        capa_mfree($3->s_str);
                                                    }                                                      } 
                                                    if(leng == 0) {                                                     if(leng == 0) {
                                                       IFstatus[IFcount] = IF_FALSE;       /*IFstatus[IFcount] = IF_FALSE;
                                                       begin_if_skip();                                                        begin_if_skip();*/
                                                    }else{                                                     }else{
                                                       IFstatus[IFcount] = IF_TRUE;       /*IFstatus[IFcount] = IF_TRUE;*/
                                                       begin_next_line();                                                        begin_next_line();
                                                    }                                                     }
                                                    break;                                                     break;
Line 337  if_expr      :  CAPA_IF '(' calc_expr  ' Line 362  if_expr      :  CAPA_IF '(' calc_expr  '
                                                       capa_mfree($3->s_str);                                                        capa_mfree($3->s_str);
                                                    }                                                     }
    if(leng == 0) {     if(leng == 0) {
                                                       IFstatus[IFcount] = IF_FALSE;       /*IFstatus[IFcount] = IF_FALSE;*/
                                                       begin_if_skip();                                                        /*begin_if_skip();*/
                                                    }else{                                                     }else{
                                                       IFstatus[IFcount] = IF_TRUE;       /*IFstatus[IFcount] = IF_TRUE;*/
                                                       begin_next_line();                                                        begin_next_line();
                                                    }                                                     }
                                                    break;                                                     break;
Line 710  term         : term '*' basic_constr   { Line 735  term         : term '*' basic_constr   {
                                          YYDBUG_PR1(" term <= basic_constr "); YYDBUG_SYM($1);   }                                           YYDBUG_PR1(" term <= basic_constr "); YYDBUG_SYM($1);   }
              ;               ;
   
 basic_constr : FUNCTION_ID '('  ')'   {  int tmp;  basic_constr : FUNCTION_ID '('  ')'   {  /*int tmp;*/
                                                                                     
                                          Func_idx--;                                           Func_idx--;
                                          if(Func_idx >= 0 ) {                                           if(Func_idx >= 0 ) {
Line 721  basic_constr : FUNCTION_ID '('  ')'   { Line 746  basic_constr : FUNCTION_ID '('  ')'   {
                                                                                     
                                       }                                        }
              | FUNCTION_ID '(' arg_list ')'               | FUNCTION_ID '(' arg_list ')'
                                       {  int  tmp;                                        {  /*int  tmp; */
                                                                               
                                          Func_idx--;                                           Func_idx--;
                                          YYDBUG_PR4(" basic_constr <= FUNCTION<%s><argc=%d> YYSTATE(%d) ",                                           YYDBUG_PR4(" basic_constr <= FUNCTION<%s><argc=%d> YYSTATE(%d) ",
Line 869  void free_calc_expr(Symbol *expr) Line 894  void free_calc_expr(Symbol *expr)
 Symbol* get_array_symbol ( name,index,free_symbols )   Symbol* get_array_symbol ( name,index,free_symbols ) 
 Symbol *name,*index;int free_symbols;  Symbol *name,*index;int free_symbols;
 {  {
   Symbol  *s_p, *a_p;    Symbol  *s_p/*, *a_p*/;
   char    *key, *tmp;    char    *key, *tmp;
   int      leng, idx_len;    int      leng, idx_len;
   leng = strlen(name->s_name)+8; /* [ ] */    leng = strlen(name->s_name)+8; /* [ ] */
Line 914  Symbol * build_array_list(ar_name,num_el Line 939  Symbol * build_array_list(ar_name,num_el
 Symbol *ar_name;int num_elem;  Symbol *ar_name;int num_elem;
 {  {
   int     i;    int     i;
   Symbol *arg_list,*a_p;    Symbol *arg_list/*,*a_p*/;
   char    idx_str[MAX_BUFFER_SIZE];    char    idx_str[MAX_BUFFER_SIZE];
       
   /*a_p = find_arrayid(ar_name->s_name);*/    /*a_p = find_arrayid(ar_name->s_name);*/

Removed from v.1.1  
changed lines
  Added in v.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>