File:  [LON-CAPA] / capa / capa51 / pProj / capaParser.h
Revision 1.7: download - view: text, annotated - select for diffs
Fri Jun 30 21:36:16 2000 UTC (23 years, 11 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- gave everyone the GPL header

    1: /* definitions of all parser constants/structs
    2:    Copyright (C) 1992-2000 Michigan State University
    3: 
    4:    The CAPA system is free software; you can redistribute it and/or
    5:    modify it under the terms of the GNU Library General Public License as
    6:    published by the Free Software Foundation; either version 2 of the
    7:    License, or (at your option) any later version.
    8: 
    9:    The CAPA system is distributed in the hope that it will be useful,
   10:    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12:    Library General Public License for more details.
   13: 
   14:    You should have received a copy of the GNU Library General Public
   15:    License along with the CAPA system; see the file COPYING.  If not,
   16:    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   17:    Boston, MA 02111-1307, USA.  */
   18: 
   19: /* <==================================================================> */
   20: /*  by Isaac Tsai @ 1994                                                */
   21: 
   22: #ifndef _CAPA_PARSER_H_
   23: #define _CAPA_PARSER_H_
   24: 
   25: #include  <stdio.h>    /* for FILE *  */
   26: #ifdef DMALLOC
   27: #include <dmalloc.h>
   28: #endif
   29: #ifdef __STDC__   /* sun ansi cc compiler use this flag */
   30: #define  CAPA_ARG(x)  x
   31: #else
   32: #define  CAPA_ARG(x)  ()
   33: #endif
   34: 
   35: #define  CAPA_ERROR(xx)   {             }
   36: #define  CAPA_WARNING(xx) {             }
   37: #define  MESSAGE_WARN 1
   38: #define  MESSAGE_ERROR 2
   39: 
   40: 
   41: #ifdef   SYMBOL_DBUG
   42: #define  SSDBUG_PR1(xx)        { printf(xx);       fflush(stdout); }
   43: #define  SSDBUG_PR2(xx,yy)     { printf(xx,yy);    fflush(stdout); }
   44: #define  SSDBUG_PR3(xx,yy,zz)  { printf(xx,yy,zz); fflush(stdout); }
   45: #else
   46: #define  SSDBUG_PR1(xx)        { }
   47: #define  SSDBUG_PR2(xx,yy)     { }
   48: #define  SSDBUG_PR3(xx,yy,zz)  { }
   49: 
   50: #endif
   51: 
   52: 
   53: 
   54: /* Some useful numbers */
   55: 
   56: /*#define  EIGHT                8*/
   57: /*#define  SIXTEEN             16*/
   58: /*#define  THIRTY_TWO          32*/
   59: /*#define  SIXTY_FOUR          64*/
   60: #define  ONE_TWO_EIGHT      128
   61: #define  QUARTER_K          256
   62: #define  HALF_K             512
   63: #define  ONE_K             1024
   64: #define  TWO_K             2048
   65: #define  FOUR_K            4096
   66: 
   67: 
   68: 
   69: #define    ANSWER_STRING_LENG       81
   70: #define  MAX_OPENED_FILE   4096    /* maximum number of files opened */
   71: #define  MAX_SYMB_COUNT    4096    /* symbol table size    */
   72: #define  MAX_FUNC_NAME      256    /* function name length */
   73: #define  MAX_FUNC_NEST     1024    /* sin(cos(tan(...)))   */
   74: /*#define  MAX_QTEXT_LEN     4096     overall question text in a set *NO LONGER NEEDED */
   75: #define  WARN_MSG_LENGTH   1024    /* for warning messages */
   76: 
   77: 
   78: #define  ASCII_MODE           1
   79: #define  TeX_MODE             2
   80: #define  HTML_MODE            3
   81: #define  BUBBLE_MODE          4
   82: 
   83: #define  ANSWER_STRING_MODE   5   /* used in answers_string() */
   84: 
   85: 
   86: /* parameters used in array_sorted_index() */
   87: 
   88: #define  ASCEND_SORT          1
   89: #define  DESCEND_SORT         2
   90: #define  NUMERICAL_SORT       3
   91: 
   92: 
   93: 
   94: typedef struct _symbol {
   95:   char              *s_name;           /* IDENTIFIER or FUNCTION_ID  or ARRAY_ID name */
   96:   int                s_type;
   97:   int                s_array_cnt;
   98:   int                s_argc;
   99:   struct _argNode   *s_argp;
  100:   struct _treeNode  *s_treep;
  101:   struct _symbol    *s_nextp;
  102:   struct _symbol    *s_prevp;
  103:   struct _symbol    *s_arrayp;
  104:   struct _pts_list  *s_ptslist;
  105:   int                s_access_cnt;
  106:   int                s_distype;
  107:   char              *s_format;
  108:   union {  char      *s_sval;
  109:            long       s_ival;
  110:            double     s_rval;
  111:         } s_val;
  112: } Symbol;
  113: 
  114: typedef Symbol *Symbol_p;
  115: 
  116: #define s_int   s_val.s_ival
  117: #define s_real  s_val.s_rval
  118: #define s_str   s_val.s_sval
  119: 
  120: #define  E_FORMAT             1
  121: #define  F_FORMAT             3
  122: #define  DEFAULT_FORMAT       9
  123: 
  124: typedef struct _argNode {
  125:     Symbol          *a_sp;
  126:     int              a_idx; 
  127:     struct _argNode *a_next;
  128:     struct _argNode *a_prev;
  129:  } ArgNode_t;
  130:  
  131: #define   FIRST_SYMBOLP(aaa)      (aaa->a_sp)
  132: #define   SECOND_SYMBOLP(aaa)   ( (aaa->a_next)->a_sp )
  133: #define   THIRD_SYMBOLP(aaa)    ( ((aaa->a_next)->a_next)->a_sp )
  134: #define   FOURTH_SYMBOLP(aaa)   ( (((aaa->a_next)->a_next)->a_next)->a_sp )
  135: #define   FIFTH_SYMBOLP(aaa)    ( ((((aaa->a_next)->a_next)->a_next)->a_next)->a_sp )
  136: #define   FIRST_ARGNAME(aaa)    ( FIRST_SYMBOLP(aaa)->s_name )
  137: #define   FIRST_ARGTYPE(aaa)    ( FIRST_SYMBOLP(aaa)->s_type )
  138: #define   FIRST_ARGINT(aaa)     ( FIRST_SYMBOLP(aaa)->s_int )
  139: #define   FIRST_ARGREAL(aaa)    ( FIRST_SYMBOLP(aaa)->s_real )
  140: #define   FIRST_ARGSTR(aaa)     ( FIRST_SYMBOLP(aaa)->s_str )
  141: #define   SECOND_ARGNAME(aaa)   ( SECOND_SYMBOLP(aaa)->s_name )
  142: #define   SECOND_ARGTYPE(aaa)   ( SECOND_SYMBOLP(aaa)->s_type)
  143: #define   SECOND_ARGINT(aaa)    ( SECOND_SYMBOLP(aaa)->s_int)
  144: #define   SECOND_ARGREAL(aaa)   ( SECOND_SYMBOLP(aaa)->s_real)
  145: #define   SECOND_ARGSTR(aaa)    ( SECOND_SYMBOLP(aaa)->s_str)
  146: #define   THIRD_ARGNAME(aaa)    ( THIRD_SYMBOLP(aaa)->s_name )
  147: #define   THIRD_ARGTYPE(aaa)    ( THIRD_SYMBOLP(aaa)->s_type)
  148: #define   THIRD_ARGINT(aaa)     ( THIRD_SYMBOLP(aaa)->s_int)
  149: #define   THIRD_ARGREAL(aaa)    ( THIRD_SYMBOLP(aaa)->s_real)
  150: #define   THIRD_ARGSTR(aaa)     ( THIRD_SYMBOLP(aaa)->s_str)
  151: #define   FOURTH_ARGTYPE(aaa)   ( FOURTH_SYMBOLP(aaa)->s_type)
  152: #define   FOURTH_ARGNAME(aaa)   ( FOURTH_SYMBOLP(aaa)->s_name )
  153: #define   FOURTH_ARGINT(aaa)    ( FOURTH_SYMBOLP(aaa)->s_int)
  154: #define   FOURTH_ARGREAL(aaa)   ( FOURTH_SYMBOLP(aaa)->s_real)
  155: #define   FOURTH_ARGSTR(aaa)    ( FOURTH_SYMBOLP(aaa)->s_str)
  156: #define   FIFTH_ARGTYPE(aaa)    ( FIFTH_SYMBOLP(aaa)->s_type)
  157: #define   FIFTH_ARGNAME(aaa)    ( FIFTH_SYMBOLP(aaa)->s_name )
  158: #define   FIFTH_ARGINT(aaa)     ( FIFTH_SYMBOLP(aaa)->s_int)
  159: #define   FIFTH_ARGREAL(aaa)    ( FIFTH_SYMBOLP(aaa)->s_real)
  160: #define   FIFTH_ARGSTR(aaa)     ( FIFTH_SYMBOLP(aaa)->s_str)
  161: 
  162: 
  163: 
  164: 
  165: 
  166: typedef struct _treeNode {
  167:     Symbol           *t_sp;
  168:     int               t_idx;
  169:     struct _treeNode *t_left;
  170:     struct _treeNode *t_right;
  171:  } TreeNode_t;
  172: 
  173: typedef struct _expNode {
  174:     int              e_type;
  175:     struct _expNode *e_parentp;
  176:     struct _expNode *e_lsibp;
  177:     struct _expNode *e_rsibp;
  178:     Symbol          *e_sp;
  179:  } ExpNode;
  180:  
  181: typedef ExpNode  *ExpNode_p;
  182: 
  183: /* ================================================================ */
  184: /*   While loop data structure */
  185: 
  186: typedef struct _WhileLoop {
  187:     int             input_idx; /* stores Input_idx */
  188:     int             line_idx;  /* stores Current_line[Input_idx] */
  189:     long int        pos_idx;   /* stores next line position in the input stream */
  190:  } WhileLoop_t;
  191: 
  192: 
  193: /* ================================================================ */
  194: /*    Warning message data structure */
  195: 
  196: typedef  struct  _WarnMsg {
  197:     int              warn_type;
  198:     char            *warn_str;
  199:     struct _WarnMsg *warn_next;
  200:   } WarnMsg_t;
  201: 
  202: 
  203: 
  204: 
  205: 
  206: 
  207: /* ================================================================ */
  208: 
  209: #define    SYMBOL_MAXLEN     16      /* unit symbol name length */
  210: #define    NAME_MAXLEN       48      /* unit name length */
  211: #define    BASEUNIT_LIMIT    32      /* maximum number of base units */
  212: #define    ONE_K_SIZE        1024 
  213: 
  214: /* ================================================================ */
  215: 
  216: typedef  struct  _unit_elem {
  217:   struct  _unit_elem  *ue_nextp;
  218:   char    ue_symbol[SYMBOL_MAXLEN];
  219:   int     ue_index;   /* -1 means this is composite */
  220: #define          UE_COMPOSITE     -1
  221:   double  ue_scale;
  222:   double  ue_exp;
  223: } Unit_E;
  224: 
  225: typedef struct  _unit_t {
  226:   char       u_symbol[SYMBOL_MAXLEN];
  227:   char       u_name[NAME_MAXLEN];
  228:   char      *u_comment;
  229:   int        u_index;
  230:   struct _unit_t  *u_left;
  231:   struct _unit_t  *u_right;
  232:   int        u_type;
  233: #define          U_BASE            1
  234: #define          U_DERIVED         2
  235: #define          U_PREFIX          3
  236: #define          U_CONSTANT        4
  237: #define          U_OP_POWER        5
  238: #define          U_OP_TIMES        6
  239: #define          U_OP_PLUS         7
  240: #define          U_OP_MINUS        8
  241: #define          U_OP_DIVIDE       9
  242: #define          U_UNKNOWN         10
  243: #define          U_DEFAULT         11
  244:   double     u_scale;
  245:   double     u_offset;
  246:   int        u_count;
  247:   Unit_E    *u_list;
  248: }  Unit_t;
  249: 
  250: #define   U_LEFT(x)   ((x)->u_left)
  251: #define   U_RIGHT(x)  ((x)->u_right)
  252: #define   U_SYMB(x)   ((x)->u_symbol)
  253: #define   U_NAME(x)   ((x)->u_name)
  254: #define   U_COUNT(x)  ((x)->u_count)
  255: #define   U_TYPE(x)   ((x)->u_type)
  256: #define   U_SCALE(x)  ((x)->u_scale)
  257: 
  258: /* ==================================================================== */
  259: /* Answer    tolerance    sig     string   */
  260: /*  int        abs/rel                     */
  261: /*  real       abs/rel    [l,u]            */
  262: /*  string                         cs/ci   */
  263: /*                                 mc      */
  264: 
  265: typedef struct _problem {
  266:    char               *question;    /* Question text                   */
  267:    char               *answer;      /* Answer string                   */
  268:    char               *hint;        /* Hint text                       */
  269:    char               *explain;     /* Explain text                    */
  270:    char               *capaidplus;  /* Quizzes extra unique identifier 
  271:                                        Only set in the first problem   */
  272:    int                 ans_cnt;     
  273:    int                 weight;
  274:    int                 tol_type;
  275:    double              tolerance;
  276:    int                 ans_type;    /* Type of answer expecting        */
  277:    int                 sig_ubound;
  278:    int                 sig_lbound;
  279:    int                 partial_cdt;
  280:    
  281:    int                 calc;         /* calculate correct answers based on 
  282:                                        formated/unformated exact answer */
  283:    int                 tries;       /* Number of tries allowed         */
  284:    int                 show_hint;
  285:    int                 show_explain;
  286:    int                 show_br;      /* web only, <BR> on is by default */
  287:    int                 show_ans_box; /* web only, answer box is shown by default */
  288:    int                 verbatim; /* do verbatim protection around answers */
  289:    int                 ans_op;   /* ANS_AND or ANS_OR */
  290:    char               *id_list;
  291:    struct   _pts_list *pts_list;
  292:    char                ans_fmt[ANSWER_STRING_LENG];
  293:    char                unit_str[ANSWER_STRING_LENG];
  294:    Unit_t              *ans_unit;
  295:    struct _answer_info *ans_list;
  296:    struct _answer_info *ans_list_last;
  297:    struct _problem     *next;        /* Pointer to next problem         */
  298: } Problem_t;
  299: 
  300: #define   P_TOLTYPE(p)  ((p)->tol_type)
  301: 
  302: 
  303: typedef struct _pts_list {
  304:    char     *pts_str;
  305:    int       pts_idx;
  306:    struct   _pts_list *pts_next;
  307: } PointsList_t;
  308: 
  309: 
  310: 
  311: /* Answer related data structure */
  312: /* 
  313:    char     *ans_str
  314:    int       ans_type
  315:    int       ans_calc
  316:    int       ans_tol_type
  317:    double    ans_tol
  318:    int       ans_sig_ub
  319:    int       ans_sig_lb
  320:    char     *ans_id_list;
  321:    struct   _pts_list *ans_pts_list;
  322:    char      ans_fmt
  323:    char      ans_unit_str
  324:    
  325: */
  326: /* 
  327:     some information in the answer specification should be 
  328:     problem-wise, such as problem weight, problem tries
  329:     
  330: */
  331: 
  332: typedef struct _answer_info {
  333:    char     *ans_str;           /* correct answer in string form */
  334:    int       ans_type;          /* answer type */
  335:    int       ans_calc;
  336:    int       ans_tol_type;      /* answer tolerence type */
  337:    double    ans_tol;           /* the tolerence itself */
  338:    int       ans_sig_ub;
  339:    int       ans_sig_lb;
  340:    char     *ans_id_list;
  341:    struct   _pts_list *ans_pts_list;
  342:    char      ans_fmt[ANSWER_STRING_LENG];
  343:    char      ans_unit_str[ANSWER_STRING_LENG];
  344:    Unit_t   *ans_unit;
  345:    struct   _answer_info *ans_next;
  346: } AnswerInfo_t;
  347: 
  348: 
  349: 
  350: /******************************************************************************/
  351: /* STRUCTURE FOR A PROBLEM                                                    */
  352: /******************************************************************************/
  353: 
  354: #define    SPEC_TOLERANCE       1
  355: #define    SPEC_SIG             2
  356: #define    SPEC_WEIGHT          4
  357: #define    SPEC_TYPE            8
  358: #define    SPEC_PCREDIT         16
  359: #define    SPEC_TRY             32
  360: #define    SPEC_UNIT            64
  361: 
  362: /* ---------------------------- tol_type -------------------------- */
  363: #define    TOL_ABSOLUTE         1
  364: #define    TOL_PERCENTAGE       2
  365: 
  366: /* ------------------------------------------ */
  367: #define    CALC_UNFORMATED      1
  368: #define    CALC_FORMATED        2
  369: 
  370: #define    CALC_DEFAULT         CALC_UNFORMATED  /* for answer calculation */
  371: 
  372: /* ----------------------------------------  web option only */
  373: #define    DO_SHOW              1
  374: #define    DONOT_SHOW           0
  375: 
  376: #define    DO_VERBATIM          1
  377: #define    DONOT_VERBATIM       0
  378: 
  379: #define    SHOW_BR_DEFAULT      DO_SHOW
  380: #define    VERBATIM_DEFAULT     DO_VERBATIM
  381: #define    SHOW_ANSBOX_DEFAULT  DO_SHOW
  382: 
  383: #define    SIG_LB_DEFAULT       0        /* ---- sig_lbound ------- */
  384: #define    SIG_UB_DEFAULT       15       /* ---- sig_ubound ------- */
  385: #define    PCREDIT_DEFAULT      0        /* ---- partial_cdt ------ */
  386: #define    TOL_DEFAULT          (0.0)    /* ---- tolerance  ------- */
  387: #define    WEIGHT_DEFAULT       1        /* ---- weight     ------- */
  388: #define    NO_LIMIT_TRY         (0)      /* ---- tries      ------- */
  389: #define    MAX_TRIES            99       /* ---- tries ------------ */
  390: #define    SHOW_HINT_DEFAULT    1        /* show hints immediately */
  391: 
  392: /* ---------------------------  ans_type -------------------------- */
  393: #define    ANSWER_IS_INTEGER       1
  394: #define    ANSWER_IS_FLOAT         2
  395: #define    ANSWER_IS_STRING_CI     3
  396: #define    ANSWER_IS_STRING_CS     4
  397: #define    ANSWER_IS_CHOICE        5
  398: #define    ANSWER_IS_ARITH         6
  399: #define    ANSWER_IS_SUBJECTIVE    7
  400: #define    ANSWER_IS_FORMULA       8
  401: #define    ANSWER_IS_EXTERNAL      9
  402: 
  403: #define    YAK                     1
  404: #define    NAY                     0
  405: 
  406: /* -------- results given by capa_check_answer() and capa_check_answers() */
  407: 
  408: #define    EXACT_ANS           1
  409: #define    APPROX_ANS          2 
  410: #define    SIG_FAIL            3
  411: #define    UNIT_FAIL           4
  412: #define    NO_UNIT             5
  413: #define    UNIT_OK             6
  414: #define    INCORRECT           7
  415: #define    UNIT_NOTNEEDED      8
  416: #define    ANS_CNT_NOT_MATCH   9
  417: #define    SUB_RECORDED        10
  418: #define    BAD_FORMULA         11
  419: #define    WANTED_NUMERIC      12
  420: 
  421: 
  422: 
  423: /* =============================================================== */
  424: 
  425: #define    T_SPACE           9
  426: #define    T_PREFIX          8
  427: #define    T_NUMBER          7
  428: #define    T_BASIC_UNIT      6
  429: #define    T_DERIVED_UNIT    5
  430: #define    T_LP              4
  431: #define    T_RP              3
  432: #define    T_MULTIPLY        2
  433: #define    T_POWER           1
  434: #define    T_END             0
  435: 
  436: /* for IFstatus[] */
  437: 
  438: #define    IF_FALSE          0
  439: #define    IF_TRUE           1
  440: #define    IF_DONT_CARE      2
  441: 
  442: /* for IFcurrent[] */
  443: #define    RUN_IF_PORTION    1
  444: #define    RUN_ELSE_PORTION  2
  445: 
  446: /* ================================================================ */
  447: /********************** for random(), /MAP(), capa_PIN() */
  448: /* BETA_DIS is used for genbet() */
  449: /* CHI_DIS  is for genchi() */
  450: /* EXPONENTIAL_DIS    genexp() */
  451: /* GAMMA_DIS    gengam() */
  452: /* MULTI_NORM_DIS    genmn() */
  453: /* NONCEN_CHI_DIS    gennch() */
  454: /* NORMAL_DIS        gennor() */
  455: /* POISSON_DIS       long ignpoi(float mu) */
  456: 
  457: #define    RANDOM_G          1L
  458: #define    PERMUTATION_G     2L
  459: #define    PIN_G             3L
  460: 
  461: #define    NORMAL_DIS          10 
  462: #define    POISSON_DIS         11
  463: #define    EXPONENTIAL_DIS     12 
  464: #define    BETA_DIS            13
  465: #define    GAMMA_DIS           14
  466: #define    CHI_DIS             15
  467: #define    NONCENTRAL_CHI_DIS  16
  468: #define    FORMULA_PICK_POINTS 17
  469: 
  470: #define    GET_GENERATOR     0L
  471: #define    SET_GENERATOR     1L
  472: 
  473: #define    FORWARD_MAP        0
  474: #define    REVERSE_MAP        1
  475: 
  476: 
  477: 
  478: /* ---------------------------------------------- capaLexerDef.flex */ 
  479: void        begin_if_skip      CAPA_ARG(());
  480: void        begin_while_skip   CAPA_ARG(());
  481: void        begin_next_line    CAPA_ARG(());
  482: void        begin_var          CAPA_ARG(());
  483: void        begin_let          CAPA_ARG(());
  484: void        begin_def          CAPA_ARG(()); 
  485: void        begin_ans          CAPA_ARG(());     
  486: void        begin_map          CAPA_ARG(()); 
  487: void        begin_ignore       CAPA_ARG(());    
  488: void        begin_text         CAPA_ARG(());    
  489: void        begin_question     CAPA_ARG(());
  490: void        end_problemset     CAPA_ARG(());
  491: int         match_keyword      CAPA_ARG((char *key));
  492: int         match_functionid   CAPA_ARG((char *key));    
  493: void        init_funcstack     CAPA_ARG(()); 
  494: 
  495: #ifdef DMALLOC
  496: #define strsave(s) strcpy(capa_malloc(strlen(s)+1,1),s)
  497: #define capa_malloc(num,sz) memset(calloc(num,sz),'\0',num*sz)
  498: #define capa_mfree(p) free(p);
  499: #else
  500: char       *strsave             CAPA_ARG((char *s));          
  501: char       *capa_malloc         CAPA_ARG((unsigned int num, unsigned int sz));
  502: void        capa_mfree          CAPA_ARG((char *p));
  503: #endif
  504: void        capa_msg            CAPA_ARG((int type, char *p));
  505: void        capa_warn_header    CAPA_ARG(()); 
  506: void        parse_filename      CAPA_ARG((char *line));
  507: void        parse_import_id     CAPA_ARG((char *line));
  508: char       *parse_endinput      CAPA_ARG((char *line));
  509: void        append_dynamic_buf  CAPA_ARG((char *new_str));
  510: char*       parser_status       CAPA_ARG((void));
  511: /*------------------------------------------------- capaGrammarDef.y */
  512: 
  513: ExpNode_p   mk_node             CAPA_ARG((int op, ExpNode_p left, ExpNode_p right));
  514: ExpNode_p   mk_leaf             CAPA_ARG((int type, Symbol_p valp));
  515: void        append_text         CAPA_ARG((char *str));
  516: void        append_hint         CAPA_ARG((char *str));
  517: void        append_explain      CAPA_ARG((char *str));
  518: void        append_error        CAPA_ARG((char *str));
  519: void        append_warn         CAPA_ARG((int type, char *str));
  520: Symbol     *symbols_op          CAPA_ARG((Symbol *a, Symbol *b, int op));
  521: char       *format_toTeX        CAPA_ARG((char *real));
  522: char       *format_toHTML       CAPA_ARG((char *real));
  523: void        init_answerinfo     CAPA_ARG(());
  524: void        display_var         CAPA_ARG((Symbol *s));
  525: void        assign_answer       CAPA_ARG((Symbol *s));
  526: void        assign_tolerance    CAPA_ARG((int tol_type, Symbol *s));
  527: void        assign_weight       CAPA_ARG((Symbol *s));
  528: void        assign_try_limits   CAPA_ARG((Symbol *s));
  529: void        assign_hint         CAPA_ARG((Symbol *s));
  530: void        assign_units        CAPA_ARG((Symbol *s));
  531: void        assign_sigs         CAPA_ARG((int lb, int ub));
  532: void        assign_id_list      CAPA_ARG((Symbol *s));
  533: void        init_new_prob       CAPA_ARG(());
  534: void        add_answer_cnt      CAPA_ARG((int op));
  535: void        finish_answer_info  CAPA_ARG(());
  536: void        start_question_over CAPA_ARG(());
  537: 
  538: Symbol*     get_array_symbol    CAPA_ARG((Symbol* name,Symbol* index,int free_symbols));
  539: Symbol*     build_array_list    CAPA_ARG((Symbol* ar_name,int num_elem)); 
  540: /*---------------------------------------------------- capaParserUtils.c */ 
  541: void        problem_default     CAPA_ARG((Problem_t  *p));
  542: int         comp_name           CAPA_ARG((char *a,char *b));
  543: int         comp_namesymbol     CAPA_ARG((char *a, Symbol *b));
  544: int         itis_empty          CAPA_ARG((TreeNode_t *root_p));
  545: void        print_symb_stat     CAPA_ARG(());
  546: int         preorder_tree       CAPA_ARG((TreeNode_t *node_p));
  547: int         inorder_tree        CAPA_ARG((TreeNode_t *node_p));
  548: int         postorder_tree      CAPA_ARG((TreeNode_t *node_p));
  549: int         destroy_tree        CAPA_ARG((TreeNode_t *node_p));
  550: int         free_symtree        CAPA_ARG(());
  551: char       *btree_search        CAPA_ARG((char *key,TreeNode_t  **root_pp,int  (*compar)()));
  552: Symbol     *find_identifier     CAPA_ARG((register char *name));  
  553: 
  554: ArgNode_t  *new_arglist         CAPA_ARG((Symbol *sp));
  555: ArgNode_t  *addto_arglist       CAPA_ARG((ArgNode_t *argp, Symbol *sp));
  556: void        walk_arglist        CAPA_ARG((ArgNode_t *argp));
  557: void        free_arglist        CAPA_ARG((ArgNode_t *argp));
  558: int         purge_tree          CAPA_ARG((TreeNode_t  **root_pp));
  559: int         calc_sig            CAPA_ARG((char *a_num ));
  560: int         endian              CAPA_ARG(());
  561: TreeNode_t *new_treenode        CAPA_ARG((char *name_p, int type));
  562: TreeNode_t *new_formulanode     CAPA_ARG((char *name_p, double val));
  563: 
  564: TreeNode_t *t_splay             CAPA_ARG((char *name, TreeNode_t *t));
  565: void        print_array_element CAPA_ARG((Symbol *array_p));
  566: Symbol     *find_arrayid        CAPA_ARG((char *name_p));
  567: Symbol     *find_array_by_index CAPA_ARG((Symbol *array_p,char *idx_p));
  568: int         free_array          CAPA_ARG((char *name_p));
  569: Symbol     *array_min_max       CAPA_ARG((char *name_p,int min));
  570: Symbol     *array_moments       CAPA_ARG((char *result_p,char *name_p));
  571: 
  572: Symbol     *gen_random_by_selector  CAPA_ARG((char *output_p,int sel,char *seed,int item_cnt,float p1,float p2));
  573: int         setup_formula_id    CAPA_ARG((char *v_str, char *pt_str));
  574: void        free_formula_tree   CAPA_ARG(());
  575: 
  576: Symbol     *find_formula_id     CAPA_ARG((char *name_p));
  577: int         f_eval_formula      CAPA_ARG((double *f_val,char *f_str,char *v_str, char *pt_str));
  578: 
  579: int         f_u_parse_formula   CAPA_ARG((char *f_str));
  580: int         f_str_to_numbers    CAPA_ARG((double **f_ar, char *n_str));
  581: int         f_str_to_ids        CAPA_ARG((char ***v_ar, char *n_str));
  582: 
  583: PointsList_t *f_gen_pts         CAPA_ARG((char *ap, char *bp, int n));
  584: PointsList_t *gen_ptslist_str   CAPA_ARG((char *range_str ));
  585: char   *eval_formula_range_str  CAPA_ARG((char *f_str,char *var_list,char *range_str));
  586: 
  587: PointsList_t *gen_ptslist       CAPA_ARG((Symbol *ap,Symbol *bp,Symbol *np));
  588: PointsList_t *new_ptslist       CAPA_ARG((Symbol *sp ));
  589: void          free_ptslist      CAPA_ARG((PointsList_t *pts_p)) ;
  590: /* ====================================== capaUnit.c */
  591: 
  592: void        c_ignorewhite       CAPA_ARG((FILE *f));
  593: double      c_getdouble         CAPA_ARG((FILE *f));
  594: int         c_getint            CAPA_ARG((FILE *f));
  595: int         c_getsec_range      CAPA_ARG((FILE *f,int *low,int *high));
  596: char       *c_getword           CAPA_ARG((FILE *f));
  597: char       *c_getstring         CAPA_ARG((FILE *f));
  598: char       *c_getcomment        CAPA_ARG((FILE *f));
  599: int         c_gettype           CAPA_ARG((FILE *f));
  600: 
  601: Unit_t     *u_find_symb         CAPA_ARG((char *name, Unit_t *t, int *result));
  602: void        u_find_name         CAPA_ARG((Unit_t *t));
  603: void        print_matches       CAPA_ARG((Unit_t *t));
  604: double      u_squared_diff      CAPA_ARG((Unit_t *a, Unit_t *b));
  605: double      u_sq_diff           CAPA_ARG((Unit_t *b));
  606: 
  607: void        print_unit_tree     CAPA_ARG(());
  608: int         alphaorder_utree    CAPA_ARG((Unit_t *node_p));
  609: int         inorder_diff        CAPA_ARG((Unit_t *node_p));
  610: int         inorder_utree       CAPA_ARG((Unit_t *node_p));
  611: int         postorder_utree     CAPA_ARG((Unit_t *node_p));
  612: int         postwalk_utree      CAPA_ARG((Unit_t *n_p));
  613: void        process_op          CAPA_ARG((int op));
  614: void        process_utree       CAPA_ARG((Unit_t *t));
  615: int         check_correct_unit  CAPA_ARG((char *u_symb,Unit_t *t,double *scale));
  616: int         free_utree          CAPA_ARG((Unit_t *t));
  617: int         u_postfree          CAPA_ARG((Unit_t *t));
  618: void        print_unit_t        CAPA_ARG((Unit_t *t));
  619: void        u_copy_unit         CAPA_ARG((Unit_t *a_p,Unit_t *b_p,double exp_scale));
  620: int         u_pm_op             CAPA_ARG((Unit_t *a_p, Unit_t *b_p, int op));
  621: 
  622: int         u_parsepower        CAPA_ARG((char *unit_str));
  623: double      s_scan_number       CAPA_ARG((char *buf, int idx, int *r_idx));
  624: double      s_scan_symbol       CAPA_ARG((char *buf,char *symb_p,int idx,int *r_idx));
  625: int         s_process_symb      CAPA_ARG((char *symb_str, Unit_t  *cu_p,double exp));
  626: Unit_t     *u_parse_unit        CAPA_ARG((char *unit_str));
  627: int         comp_unit_symb      CAPA_ARG((char *a,char *b));
  628: Unit_t     *u_splay             CAPA_ARG((char *name, Unit_t *t));
  629: int         u_insert_baseunit   CAPA_ARG((char *n_p,char *s_p,char *c_p));
  630: int         u_insert_derived    CAPA_ARG((char *n_p,char *s_p,char *c_p,char *u_p));
  631: void        u_getunit           CAPA_ARG((FILE *f));
  632: void        simplify_unit       CAPA_ARG((Unit_t *u_p));
  633: void        freelist_unit_e     CAPA_ARG((Unit_E *ue_p));
  634: int         is_units_equal      CAPA_ARG((Unit_t *u1_p, Unit_t *u2_p));
  635: double      units_ratio         CAPA_ARG((Unit_t *u1_p, Unit_t *u2_p));
  636: Unit_t     *p_new_op            CAPA_ARG((Unit_t *left_p, int op, Unit_t *right_p));
  637: Unit_t     *p_new_num           CAPA_ARG((Unit_t *left_p, double num, Unit_t *right_p));
  638: Unit_t     *p_new_unit          CAPA_ARG((Unit_t *left_p, Unit_t *right_p));
  639: int         s_getnext           CAPA_ARG(());
  640: int         s_peeknext          CAPA_ARG(());
  641: double      scan_FLOAT          CAPA_ARG(());
  642: Unit_t     *scan_num_item       CAPA_ARG(());
  643: Unit_t     *scan_unit_item      CAPA_ARG(());
  644: Unit_t     *scan_basic_term     CAPA_ARG(());
  645: Unit_t     *scan_num_term       CAPA_ARG(());
  646: Unit_t     *scan_basic_block    CAPA_ARG(());
  647: Unit_t     *scan_num_block      CAPA_ARG(());
  648: Unit_t     *scan_unit_expr      CAPA_ARG(());
  649: Unit_t     *scan_num_expr       CAPA_ARG(());
  650: Unit_t     *parse_unit_expr     CAPA_ARG((char *symb_str));
  651: void        print_remains       CAPA_ARG(());
  652: /* =================================================  capaMapExpr.c */
  653: 
  654: int         do_map             CAPA_ARG((char *seed,ArgNode_t *varp,ArgNode_t *argp,int argc, int dir));
  655: 
  656: /* ===============================================  capaFormulaLexer.c -- */
  657: double      f_get_float         CAPA_ARG(());
  658: char       *f_get_id            CAPA_ARG(());
  659: int         f_peek_next_token   CAPA_ARG(());
  660: int         fml_lex             CAPA_ARG(());
  661: 
  662: /* ===============================================  capaFormula.y      == */
  663: int         fml_parse           CAPA_ARG(()); 
  664: Symbol     *f_symbol_pow        CAPA_ARG((Symbol *ap, Symbol *bp));
  665: /* ====================================================================== */
  666: 
  667: #ifdef  __sun
  668: #define index(xx,cc)  strchr(xx,cc)
  669: #define rindex(xx,cc) strrchr(xx,cc)
  670: #endif
  671: 
  672: #endif  /* _CAPA_PARSER_H_ */
  673: 

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