Annotation of loncom/homework/CAPA-converter/capaParser.h, revision 1.2

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

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