예제 #1
0
파일: pvs.c 프로젝트: jff/mathspad
int init_library(void)
{
  Prototype *pt;

  pt = define_prototype(tlist[0],1, 0, call_int);
  define_function("pvs_check_hint", "Check the selected hint with PVS.",
		  pt, pvs_check_hint);
  pt = define_prototype(tlist[3],3,0,call_intintstr);
  define_function("pvs_construct_hint", "Construct a hint with PVS.",
		  pt, pvs_construct_hint);
  pt = define_prototype(tlist[1],1, 0, call_str);
  define_function("pvs_start", "Start the PVS system.",
		  pt, pvs_start);
  pt = define_prototype(tlist[2],3, 0, call_strstrint);
  define_function("pvs_add_keyword",
	      "Add a keyword to the list of keywords recognized in a hint.",
		  pt, pvs_add_keyword);
  define_program_variable(IntType, "pvs_initialized", &pvs_after_init);
  define_program_variable(IntType, "pvs_in_checker", &pvs_in_checker);
  define_program_variable(IntType, "pvs_before_realtime",
			  &pvs_before_realtime);
  define_program_variable(IntType, "pvs_do_leibnitz", &pvs_do_leibnitz);
  define_program_variable(IntType, "pvs_on_booleans", &using_booleans);
  define_program_variable(StringType, "pvs_context_dir", &pvs_context_dir);
  define_program_variable(StringType, "pvs_hint_file", &pvs_hint_file);
  define_program_variable(StringType, "pvs_lemma_name", &pvs_lemma_name);
  define_program_variable(StringType, "pvs_stencil_file", &pvs_stencil_file);
  return 1;
}
예제 #2
0
파일: parsertemp.c 프로젝트: jff/mathspad
int init_library(void)
{
  Prototype *pt;

  pt = define_prototype(tlist[0], 0,0, call_empty);
  define_function("parser_clear", "Clear the parser",
		  pt, clear_parser);
  define_function("parser_init", "Init the parser",
		  pt, parser_init);
  define_function("parse_selection", "Parse the selection",
		  pt, parse_selection);
  pt = define_prototype(tlist[1], 1,0,call_string);
  define_function("parser_add_file", "Add a file with templates to the parser",
		  pt, add_file_to_parser);
  pt = define_prototype(tlist[2],1,0,call_int);
  define_function("parser_case_insensitive",
		  "Set case insensitivity of the parser",
		  pt, set_parser_case);
  define_function("parser_space_insensitive",
		  "Set space insensitivity of the parser",
		  pt, set_parser_space);
}
예제 #3
0
파일: ptest.c 프로젝트: jff/mathspad
int main(int argc __attribute__((unused)), char *argv[])
{
    char *b;
    Prototype *pt;
    FuncRef fr;

    unitype_init();
    
    UConvLoadDatabase("UniConvert");
    
    variable_init();
    pt=define_prototype(tlist[0], 1, 0, call_intref);
    define_function("UpdateVar", "", pt, (Function) updatevar);
    define_function("UpdateEdit", "", pt, (Function) updateedit);
    pt=define_prototype(tlist[1], 2, 0, call_strint);
    define_function("PrintInt", "", pt, (Function) printint);
    pt=define_prototype(tlist[0], 2, 0, call_intintref);
    fr = define_function("Assign", "", pt, (Function) assign);
    define_operator(OPASSIGN, fr);
    pt=define_prototype(tlist[2], 2, IntType, call_intintresint);
    fr = define_function("IntAdd", "", pt, (Function) intadd);
    define_operator(OPADD, fr);
    fr = define_function("IntMin", "", pt, (Function) intminus);
    define_operator(OPSUB, fr);
    fr = define_function("IntGreater", "", pt, (Function) intgreater);
    define_operator(OPGREATER, fr);
    fr = define_function("IntLess", "", pt, (Function) intless);
    define_operator(OPLESS, fr);
    pt=define_prototype(tlist[4], 1, 0, call_lazy);
    fr = define_function("LazyEval", "", pt, (Function) calculate_lazy_expression);
    pt=define_prototype(tlist[5], 2, 0, call_lazylazyref);
    fr = define_function("AssignLazyEval", "", pt, (Function) assign_lazy);
    define_operator(OPASSIGN, fr);
    b=malloc(sizeof(char)*(strlen(argv[1])+1));
    strcpy(b,argv[1]);
    lex_open_file(b);
    parse_input();
    return 0;
}
예제 #4
0
int main(int argc, char *argv[])
{
int callrun;

#ifdef MTRACE_DEBUG
mtrace();
#endif
   /* Start initialisation:*/
   /* Pick out the number from the string "$Revision: 2.37 $":*/
   {/*Block begin*/
        char *tmp=currentrevision;
        for( tmp=currentrevision;(*tmp!=' ')&&(*tmp!='\0');tmp++);
        if(*tmp == ' ') tmp++;
        for( currentRevisionNumber=tmp;(*tmp!=' ')&&(*tmp!='\0');tmp++);
        *tmp='\0';
   }/*Block end*/

   /* Check here is there the request for the version information.
    * If so, output the revision number and quit, if there are no any
    * other option:
    */
   for(i=1; i<argc; i++)
      if( (s_cmp(argv[i],"-V")==0)||(s_cmp(argv[i],"-version")==0)){
        printf("%s\n",currentRevisionNumber);
        if(argc == 2) exit(0);
      }

   first_init();/*module init.c*/
   read_command_line(argc, argv);/*module cmd_line.c*/
   message(INITIALIZATION,NULL);
   /*End initialisation*/
   message(READINGCONFIG,config_name);
   scaner_init(config_name,cnf_comment);/*module init.c*/
   read_config_file_before_truns();/*module cnf_read.c*/
   if( is_bit_set(&mode,bitCHECKMOMENTABALANCE)&&
       (!is_bit_set(&mode,bitONLYINTERPRET))
    ){

       check_momenta_balance_on_each_topology();
   }
   message(DONE,NULL);

   /*Translation of the TM program:*/
   {char tmp[MAX_STR_LEN];

       if (
             (is_bit_set(&mode,bitONLYINTERPRET))||
             (!is_bit_set(&mode,bitBROWS))||
             (is_bit_set(&mode,bitVERIFY))||
             (is_bit_set(&mode,bitFORCEDTRUNSLATION))
          ){
             command_init();/*module truns.c*/
             if(!is_bit_set(&mode,bitONLYINTERPRET)){
                if (set_table==NULL)set_table=create_hash_table(
                      set_hash_size,str_hash,str_cmp,c_destructor);
                if(is_bit_set(&mode,bitBROWS))
                  install(new_str("_specmode"),new_str("browser"),set_table);
                else
                  install(new_str("_specmode"),new_str("common"),set_table);
             }
             message(BEGINTRUNS,NULL);
             do{
               if(truns(&current_number_of_trunslated_lines,
                           &current_array_of_trunslated_lines)){
                  number_of_trunslated_lines=
                                        current_number_of_trunslated_lines;
                  current_number_of_trunslated_lines=0;
                  array_of_trunslated_lines=
                                         current_array_of_trunslated_lines;
                  current_array_of_trunslated_lines=NULL;
               }
             }while(number_of_trunslated_lines==0);
             message(ENDTRUNS,NULL);
             mem_esc_char=esc_char;
             macro_done();/*module macro.c*/
             reject_proc();/*module truns.c*/
             command_done();/*module truns.c*/
             clear_defs();/*module truns.c*/
             clear_label_stack();/*module truns.c*/
             for_done();/*module truns.c*/
             IF_done();/*module truns.c*/
             if(s_scmp(sc_get_token(tmp),"translate"))
                halt(UNEXPECTED ,tmp);
       }
   }
   sc_done();/*module tools.c*/
   /*TM program is translated. The resulting code is in array_of_trunslated_lines*/

/*Keep the table up to the end of the program!:*/
#ifdef SKIP
   if (vectors_table!=NULL){
      hash_table_done(vectors_table);/*module hash.c*/
      vectors_table=NULL;
   }
#endif

   message(DONEINIT,NULL);

   if (is_bit_set(&mode,bitVERIFY)){
     message(ONLYVERIFY,NULL);
     errorlevel=0;halt(NOERROR,NULL);
   }

   if (g_ttnames != NULL){/*Topology tables were defined in the config file*/
      HASH_TABLE wrktrans;
      message(LOADINGTABLES,NULL);
      read_topology_tables();/*module utils.c*/
      free_mem(&g_ttnames);
      /*Create the working table:*/
      g_tt_wrk=tt_createNewTable(g_defaultTokenDictSize,g_defaultHashTableSize);

      /*Check success, if not, halt the system:*/
      checkTT(g_tt_wrk,FAILCREATINGWRKTABLE);

      /*Collect translations from all tables:*/
      wrktrans=tt_table[g_tt_wrk-1]->htrans;
      /*Full toplogies:*/
      for(i=0;i<g_tt_top_full;i++){
         HASH_TABLE  ttrans=tt_table[g_tt_full[i]-1]->htrans;
         if( ttrans!=NULL )
              binary_operations_under_hash_table(
                 ttrans,/*"from"*/
                 wrktrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/
      }/*for(i=0;i<g_tt_top_full;i++)*/
      /*Internal topologies:*/
      for(i=0;i<g_tt_top_int;i++){
         HASH_TABLE  ttrans=tt_table[g_tt_int[i]-1]->htrans;
         if( ttrans!=NULL )
              binary_operations_under_hash_table(
                 ttrans,/*"from"*/
                 wrktrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/
      }/*for(i=0;i<g_tt_top_int;i++)*/

      /*Override translations, if present, in wrk table; in loaded tables
        translations remain to be untranslated!:*/
      if( g_ttTokens_table!=NULL )
              binary_operations_under_hash_table(
                 g_ttTokens_table,/*"from"*/
                 wrktrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/

      /*Now wrk table is ready*/
      /*Override translations, if present, in full toplogies:*/
      if( g_ttTokens_table!=NULL )for(i=0;i<g_tt_top_full;i++){
         HASH_TABLE  ttrans=tt_table[g_tt_full[i]-1]->htrans;
         if( ttrans!=NULL )/*BTW, it CANNOT be a NULL! See, how tt_createNewTableis invoked
                             in the beginning of tt_loadTable, file tt_load.c*/
              binary_operations_under_hash_table(
                 g_ttTokens_table,/*"from"*/
                 ttrans,/*"to"*/
                 -1);/*see "hash.c"; op>0 -> add enties to "to" from "from", only if they
                 are absent in "to", op<0 -> rewrite entries in "to" by the corresponding
                 "from", op==0 -> remove all entries in "to" matching "from"*/
      }/*for(i=0;i<g_tt_top_full;i++)*/
      message(DONE,NULL);
   }/*if (g_ttnames != NULL)*/

   /*If only interpret, we need not analyse diagrams:*/
   if(is_bit_set(&mode,bitONLYINTERPRET)){
    int exitcode;
      run_init(1);/*module init.c*/
      esc_char=mem_esc_char;
      islast=1;
      g_nocurrenttopology=1;/*Similar to islast, but specially for topologies.*/
      message(CALLTOINTERPRETER,NULL);
      exitcode=run(number_of_trunslated_lines,array_of_trunslated_lines);
      message(DONE,NULL);
      {char endmessage[MAX_STR_LEN];
         sprintf(endmessage,EXITCODEFROMINTERPRETER,exitcode);
         errorlevel=exitcode;
         halt(endmessage,NULL);
      }
      /*Stop running...*/
   }/*if(is_bit_set(&mode,bitONLYINTERPRET)*/

   /*ok, if we are here then we have to read diagrams...*/
   detect_last_diagram_number();/*module last_num.c*/
   message(LOOKINGFORFIRRSTDIAGRAM,NULL);
   scaner_init(input_name,0);/*module init.c*/
   skip_until_first_actual_diagram();/*module read_inp.c*/
   create_table(&dbuf,&dtable,MAX_VERTEX,MAX_I_LINE,ext_lines);/*module utils.c*/
   create_table(&wrkbuf,&wrktable,MAX_VERTEX,MAX_I_LINE,ext_lines);
   message(DONE,NULL);
   message(READDIAGRAMS,NULL);

   for(i=start_diagram;!(i>finish_diagram);i++){/*begin main loop*/
      skip_to_new_diagram();/* module read_inp.c Reads until '['*/

      if(i % STEP_INDICATOR == 0){
        char mes[MAX_STR_LEN];
          sprintf(mes,INDICATE_MESSAGE,i,finish_diagram);
          message(mes,NULL);
      }/*if(i % STEP_INDICATOR == 0)*/

      /* Check should we process this diagram:*/
      if (set_in(i % 250,dmask[i / 250])) continue;

      new_diagram();/*module read_inp.c. Some initializations
                                                       before each diagram.*/

      detect_number_and_coefficient();/*module read_inp.c
                                        This function must receive from
                                        scaner exactly 'd###'*/
      if(i!=diagram_count)
         halt(CURRUPTEDINPUT,input_name);
      create_primary_diagram_table();/*module read_inp.c*/

      if ( skiptadpoles && thisistadpole )
         continue;
      define_topology();/*module read_inp.c*/
      /*compare_topology() returns 1 if topology is not actual.
      If topology is undefined, this procedure will call
      'out_undefined_topology();' (if bitBROWS is not set) and set bitTERROR.
      */
      if(compare_topology())/*module read_inp.c*/
         continue;

      create_diagram_table();/*module read_inp.c*/

      define_prototype();/*module read_inp.c*/
      if(!is_bit_set(&mode,bitFORCEDTRUNSLATION))
          if(skip_prototype())/*module utils.c*/
            continue;
      create_indices_table();/*module read_inp.c*/
      if(must_diagram_be_skipped())/*module utils.c*/
         continue;
      if (is_bit_set(&mode,bitBROWS))
         fill_up_diagram_array(count);/*module read_inp.c*/
      count++;
      if(is_bit_set(&mode,bitFORCEDTRUNSLATION)){
         if(g_tt_try_loaded>0)/*Automatic momenta distribution mechanism*/
            callrun=1;
         else if(   ( is_bit_set(&mode,bitTERROR) )&&(!is_bit_set(&mode,bitBROWS)))
           callrun=0;
         else
           callrun=1;
      }else{
         callrun=(
              (!is_bit_set(&mode,bitTERROR) )&&
              (!is_bit_set(&mode,bitBROWS) )
         );
      }
      /*Run the interpreter:*/
      if(callrun){
         build_form_input();/*module read_inp.c*/
         run_init(0);/*module init.c*/
         esc_char=mem_esc_char;
         if(run(number_of_trunslated_lines,array_of_trunslated_lines)==HALT)
             set_bit(&mode,bitRUNSIGNAL);
         run_clear();/*module init.c*/
         if(is_bit_set(&mode, bitSKIP)){
            unset_bit(&mode,bitSKIP);
            count--;
         }else if((is_bit_set(&mode,bitFORCEDTRUNSLATION))&&
                            (skip_prototype()/*module utils.c*/)){
            count--;
         }else{
            if(g_topologyLabel!=NULL){/*First occurence, otherwise will be NULL*/
               /*Mark topology as occurred*/
               set_bit(g_topologyLabel,0);
               if(g_tt_try_loaded>0){/*Table were loaded*/

                  if( topologies[cn_topol].orig==NULL )/*Undefined topology*/
                     process_topol_tables(0);/*try to find momenta, read_inp.c*/

                  if(topologies[cn_topol].coordinates_ok==0)/*No coords*/
                     process_topol_tables(1);/*try to find coordinates, read_inp.c*/
                  /*Now current topology is marked, and wrk toable is built.*/
               }else{
                  if( topologies[cn_topol].orig==NULL ){/*Undefined topology*/
                     if( automatic_momenta_group(NULL,cn_topol)==1)
                        /*Now momenta are distributed automatically:*/
                        set_bit(g_topologyLabel,2);
                        /*Bit 0: 0, if topology not occures, or 1;
                          bit 1: 1, if topology was produced form generic, or 0.
                          bit 2: 1, automatic momenta is implemented, or 0
                        */
                  }/*if( topologies[cn_topol].orig==NULL )*/
               }/*if(g_tt_try_loaded>0)...else...*/
            }/*if(g_topologyLabel!=NULL)*/
            output_common_protocol(count);/*module read_inp.c*/
         }/*if(is_bit_set(&mode, bitSKIP)) ... else ... else*/
         if(is_bit_set(&mode,bitRUNSIGNAL)){
            sc_done();
            errorlevel=0;
            halt(RUNSIGNAL,NULL);
         }/*if(is_bit_set(&mode,bitRUNSIGNAL))*/
      }/*if(callrun)*/
   }/*end main loop*/

   sc_done();
   message(DONEDIAGRAMS,NULL);

   /*Check should we run the interpreter once more:*/
   if(is_bit_set(&mode,bitEND)){
      /*To use some of specmode operators during "extra call":*/
      new_diagram();

      run_init(1);
      esc_char=mem_esc_char;
      islast=1;

      g_nocurrenttopology=1;/*Similar to islast, but specially for topologies.*/
      cn_topol=top_topol;/*Indicate that there is no special topology */
      message(EXTRACALL,NULL);
      if(run(number_of_trunslated_lines,array_of_trunslated_lines)==HALT){
         errorlevel=0;
         halt(RUNSIGNAL,NULL);
      }
      message(DONE,NULL);
   }/*if(is_bit_set(&mode,bitEND))*/

   if (is_bit_set(&mode,bitBROWS)){
      message(BROWSERMODEDETECT,NULL);
      out_browse_head(count);/*module browser.c*/
      message(SORTINGDIAGRAMS,NULL);
      sort_diargams(count);/*module browser.c*/
      message(DONE,NULL);
      message(PRINTINGDIAGRAMS,NULL);
      print_diagrams(count);/*module browser.c*/
      message(DONE,NULL);
      sort_prototypes();/*module browser.c*/
      print_prototypes();/*module browser.c*/
      print_all_found_topologies();/*module browser.c*/
      print_not_found_topologies();/*module browser.c*/
      print_undefined_topologies();/*module browser.c*/
   }/*if (is_bit_set(&mode,bitBROWS))*/
   errorlevel=0;
   halt(NOERROR,NULL);
   return(0);/*Actually, the control can't reach this point*/
}/*main*/