[BACK]Return to parse.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_toolkit

Diff for /OpenXM/src/ox_toolkit/parse.c between version 1.10 and 1.11

version 1.10, 2003/02/03 23:13:23 version 1.11, 2003/03/23 20:17:35
Line 1 
Line 1 
 /* -*- mode: C; coding: euc-japan -*- */  /* -*- mode: C; coding: euc-japan -*- */
 /* $OpenXM: OpenXM/src/ox_toolkit/parse.c,v 1.9 2003/01/13 12:03:12 ohara Exp $ */  /* $OpenXM: OpenXM/src/ox_toolkit/parse.c,v 1.10 2003/02/03 23:13:23 ohara Exp $ */
   
 /*  /*
    This module is a parser for OX/CMO expressions.     This module is a parser for OX/CMO expressions.
Line 52  static void parse_error(char *s);
Line 52  static void parse_error(char *s);
 static void parse_right_parenthesis();  static void parse_right_parenthesis();
 static void parse_left_parenthesis();  static void parse_left_parenthesis();
 static void parse_comma();  static void parse_comma();
 static mpz_ptr parse_integer();  #if defined(WITH_GMP)
   static mpz_ptr parse_mpz_integer();
   #endif /* WITH_GMP */
   static int   parse_integer();
 static char *parse_string();  static char *parse_string();
 static cmo  *parse_cmo_null();  static cmo  *parse_cmo_null();
 static cmo  *parse_cmo_int32();  static cmo  *parse_cmo_int32();
Line 60  static cmo  *parse_cmo_string();
Line 63  static cmo  *parse_cmo_string();
 static cmo  *parse_cmo_mathcap();  static cmo  *parse_cmo_mathcap();
 static cmo  *parse_cmo_list();  static cmo  *parse_cmo_list();
 static cmo  *parse_cmo_monomial32();  static cmo  *parse_cmo_monomial32();
   #if defined(WITH_GMP)
 static cmo  *parse_cmo_zz();  static cmo  *parse_cmo_zz();
   #endif /* WITH_GMP */
 static cmo  *parse_cmo_zero();  static cmo  *parse_cmo_zero();
 static cmo  *parse_cmo_dms_generic();  static cmo  *parse_cmo_dms_generic();
 static cmo  *parse_cmo_ring_by_name();  static cmo  *parse_cmo_ring_by_name();
Line 217  static cmo *parse_cmo()
Line 222  static cmo *parse_cmo()
         token = lex();          token = lex();
         m = parse_cmo_monomial32();          m = parse_cmo_monomial32();
         break;          break;
   #if defined(WITH_GMP)
     case TOKEN(CMO_ZZ):      case TOKEN(CMO_ZZ):
         token = lex();          token = lex();
         m = parse_cmo_zz();          m = parse_cmo_zz();
         break;          break;
   #endif /* WITH_GMP */
     case TOKEN(CMO_ZERO):      case TOKEN(CMO_ZERO):
         token = lex();          token = lex();
         m = parse_cmo_zero();          m = parse_cmo_zero();
Line 275  static void parse_comma()
Line 282  static void parse_comma()
     token = lex();      token = lex();
 }  }
   
   #if defined(WITH_GMP)
 static mpz_ptr new_mpz_set_str(char *s)  static mpz_ptr new_mpz_set_str(char *s)
 {  {
     mpz_ptr z = malloc(sizeof(mpz_t));      mpz_ptr z = malloc(sizeof(mpz_t));
Line 287  static mpz_ptr my_mpz_neg(mpz_ptr src)
Line 295  static mpz_ptr my_mpz_neg(mpz_ptr src)
     mpz_ptr z = malloc(sizeof(mpz_t));      mpz_ptr z = malloc(sizeof(mpz_t));
     mpz_init(z);      mpz_init(z);
     mpz_neg(z, src);      mpz_neg(z, src);
 #ifndef DEBUG  #ifdef DEBUG
     free(src);      free(src);
 #endif  #endif
     return z;      return z;
 }  }
   
 static mpz_ptr parse_integer()  static mpz_ptr parse_mpz_integer()
 {  {
     int sign = 1;      int sign = 1;
     mpz_ptr val;      mpz_ptr val;
Line 312  static mpz_ptr parse_integer()
Line 320  static mpz_ptr parse_integer()
     if (sign == -1) {      if (sign == -1) {
         val = my_mpz_neg(val);          val = my_mpz_neg(val);
     }      }
 #ifndef DEBUG  #ifdef DEBUG
     free(yylval.sym);      free(yylval.sym);
 #endif  #endif
     token = lex();      token = lex();
     return val;      return val;
 }  }
   #endif /* WITH_GMP */
   
   static int parse_integer()
   {
   #if defined(WITH_GMP)
       return mpz_get_si(parse_mpz_integer());
   #else
       abort(); /* not implemented */
   #endif
   }
   
 static char *parse_string()  static char *parse_string()
 {  {
     char *s;      char *s;
Line 338  static cmo *parse_cmo_null()
Line 356  static cmo *parse_cmo_null()
   
 static cmo *parse_cmo_int32()  static cmo *parse_cmo_int32()
 {  {
     mpz_ptr z;      int z;
   
     parse_comma();      parse_comma();
     z = parse_integer();      z = parse_integer();
     parse_right_parenthesis();      parse_right_parenthesis();
     return (cmo *)new_cmo_int32(mpz_get_si(z));      return (cmo *)new_cmo_int32(z);
 }  }
   
 static cmo *parse_cmo_string()  static cmo *parse_cmo_string()
Line 414  static cmo *parse_cmo_monomial32()
Line 432  static cmo *parse_cmo_monomial32()
     int tag;      int tag;
   
     parse_comma();      parse_comma();
     size = mpz_get_si(parse_integer());      size = parse_integer();
     if (size < 0) {      if (size < 0) {
         parse_error("invalid value.");          parse_error("invalid value.");
     }      }
Line 422  static cmo *parse_cmo_monomial32()
Line 440  static cmo *parse_cmo_monomial32()
   
     for(i=0; i<size; i++) {      for(i=0; i<size; i++) {
         parse_comma();          parse_comma();
         m->exps[i] = mpz_get_si(parse_integer());          m->exps[i] = parse_integer();
     }      }
     parse_comma();      parse_comma();
     parse_left_parenthesis();      parse_left_parenthesis();
Line 438  static cmo *parse_cmo_monomial32()
Line 456  static cmo *parse_cmo_monomial32()
     return (cmo *)m;      return (cmo *)m;
 }  }
   
   #if defined(WITH_GMP)
 /* the following function rewrite internal data of mpz/cmo_zz. */  /* the following function rewrite internal data of mpz/cmo_zz. */
 static cmo *parse_cmo_zz()  static cmo *parse_cmo_zz()
 {  {
Line 447  static cmo *parse_cmo_zz()
Line 466  static cmo *parse_cmo_zz()
     mpz_ptr z;      mpz_ptr z;
   
     parse_comma();      parse_comma();
     z = parse_integer();      z = parse_mpz_integer();
     if (token == ',') {      if (token == ',') {
         length = mpz_get_si(z);          length = mpz_get_si(z);
         m = new_cmo_zz_size(length);          m = new_cmo_zz_size(length);
Line 455  static cmo *parse_cmo_zz()
Line 474  static cmo *parse_cmo_zz()
         length = abs(length);          length = abs(length);
         for(i=0; i<length; i++) {          for(i=0; i<length; i++) {
             parse_comma();              parse_comma();
             m->mpz->_mp_d[i] = mpz_get_si(parse_integer());              m->mpz->_mp_d[i] = parse_integer();
         }          }
     }else if (pflag_cmo_addrev) {      }else if (pflag_cmo_addrev) {
         m = new_cmo_zz_set_mpz(z);          m = new_cmo_zz_set_mpz(z);
Line 466  static cmo *parse_cmo_zz()
Line 485  static cmo *parse_cmo_zz()
     parse_right_parenthesis();      parse_right_parenthesis();
     return (cmo *)m;      return (cmo *)m;
 }  }
   #endif /* WITH_GMP */
   
 static cmo *parse_cmo_zero()  static cmo *parse_cmo_zero()
 {  {
Line 724  static int token_of_symbol(char *key)
Line 744  static int token_of_symbol(char *key)
         yylval.d = symp->tag;          yylval.d = symp->tag;
         return symp->token;          return symp->token;
     }      }
 #if DEBUG  
     ox_printf("lex error:: \"%s\" is unknown symbol.\n", key);      ox_printf("lex error:: \"%s\" is unknown symbol.\n", key);
 #endif  
     return 0;      return 0;
 }  }
   

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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