Esempio n. 1
0
bool cXMLDocument::ParseTagLine(char *OriginBuffer, unsigned int StartPosition, char *Buffer, cXMLEntry *XMLEntry)
{
	// 1 - получаем имя тэга (начинается сразу после символа <, а заканчивается пробелом, >, />, или символом таб)
	int TagNameEnd = FindSubString(Buffer, " ");
	if (TagNameEnd == -1 || (FindSubString(Buffer, "\t") != -1 && TagNameEnd > FindSubString(Buffer, "\t"))) TagNameEnd = FindSubString(Buffer, "\t");
	if (TagNameEnd == -1 || (FindSubString(Buffer, ">") != -1 && TagNameEnd > FindSubString(Buffer, ">"))) TagNameEnd = FindSubString(Buffer, ">");
	if (TagNameEnd == -1 || (FindSubString(Buffer, "/>") != -1 && TagNameEnd > FindSubString(Buffer, "/>"))) TagNameEnd = FindSubString(Buffer, "/>");
	XMLEntry->Name = CreateSubString(Buffer, 1, TagNameEnd);

	// 2 - проверяем наличие атрибутов и заносим их в динамический массив
	unsigned int i = TagNameEnd;
	while (((Buffer+i)[0] != '>') || ((Buffer+i)[0] != '\0'))
	{
		// пропускаем все пробелы и табы
		while ((((Buffer+i)[0] == ' ') || ((Buffer+i)[0] == '\t')) && ((Buffer+i)[0] != '\0')) i++;
		if ((Buffer+i)[0] == '\0') {fprintf(stderr, "XML file corrupted, line: %i.", GetLineNumber(OriginBuffer, StartPosition)); break;}
		// еще раз проверяем, возможно завершение тэга ставили через пробел или таб
		if (((Buffer+i)[0] == '>') || (!strncmp(Buffer+i, "/>", strlen("/>")))) break;

		// находим имя атрибута
		unsigned int AttribNameStart = i;
		while (((Buffer+i)[0] != '=') && ((Buffer+i)[0] != '\0')) i++;
		if ((Buffer+i)[0] == '\0') {fprintf(stderr, "XML file corrupted, line: %i.", GetLineNumber(OriginBuffer, StartPosition)); break;}
		unsigned int AttribNameEnd = i;
		// пропускаем все до кавычек (они у нас следующие, после знака равенства)
		i+=2;
		unsigned int AttribDataStart = i;
		while ((((Buffer+i)[0] != '\'') && ((Buffer+i)[0] != '\"')) && ((Buffer+i)[0] != '\0')) i++;
		if ((Buffer+i)[0] == '\0') {fprintf(stderr, "XML file corrupted, line: %i.", GetLineNumber(OriginBuffer, StartPosition)); break;}
		unsigned int AttribDataEnd = i;
		i++;

		// собираем новый атрибут и подключаем его к элементу
		cXMLAttribute *XMLAttribute = new cXMLAttribute;
		AttachXMLAttribute(XMLEntry, XMLAttribute);
		XMLAttribute->Name = CreateSubString(Buffer, AttribNameStart, AttribNameEnd);
		XMLAttribute->Data = CreateSubString(Buffer, AttribDataStart, AttribDataEnd);
	}


	// 3 - определяем и номер строки
	XMLEntry->LineNumber = GetLineNumber(OriginBuffer, StartPosition);


	// 4 - определить есть ли в ней атрибут закрытия '/', или у нас есть еще и контент и закрывающий тэг
	if (FindSubString(Buffer, "/>") != -1) return false;
	return true;
}
Esempio n. 2
0
void Dump_MasterIP_Trans(FILE *out)
{
    char	*tptr;
    char	*ptr;
    uint	ip,line;

    tptr = FileTop;
    line = 0;

    fprintf(out, "\nLINEIP\n");

    if (!AsmCharArray.array)
        return;

    for (ip=AsmCharArray.lo; ip<AsmCharArray.hi+1; ip++)
    {
        // n = ip

        ptr = (char *) ArrayGet(&AsmCharArray, ip);

        if (ptr)
        {
            if (tptr != ptr)
                line = GetLineNumber(FileTop, ptr);

            fprintf(out, "%d:%x\n", line, ip);
            tptr = ptr;
        }
    }

    return;
}
Esempio n. 3
0
string Element::ReadFrom(void) const
{
  ostringstream message;

  message << endl
          << "In file " << GetFileName() << ": line " << GetLineNumber()
          << endl;

  return message.str();
}
Esempio n. 4
0
wxString LLDBBreakpoint::ToString() const
{
    wxString str;
    str << "Breakpoint ID=" << m_id << ". ";
    if ( GetType() == kFileLine ) {
         str << "kFileLine " << GetFilename() << "," << GetLineNumber();

    } else if ( GetType() == kFunction ) {
        str << "kFunction " << GetName() << "()";
    }
    return str;
}
Esempio n. 5
0
 const std::wstring
 CommonExceptionBase::GetExceptionInfo() const
 {
     //Format the information to the following style:
     //ExceptionName at some_file_name.cpp: 453
     //Description: Some kind of explanation of the exception
     std::wostringstream out;
     out << GetName()
         << L" at "
         << GetFileName()
         << L": "
         << GetLineNumber() << std::endl
         << L"Description: "
         << GetMessage();
     return out.str();
 }
Esempio n. 6
0
void Element::MergeAttributes(Element* el)
{
  map<string, string>::iterator it;

  for (it=el->attributes.begin(); it != el->attributes.end(); ++it) {
    if (attributes.find(it->first) == attributes.end())
      attributes[it->first] = it->second;
    else {
      if (FGJSBBase::debug_lvl > 0)
        cout << el->ReadFrom() << " Attribute '" << it->first << "' is overridden in file "
             << GetFileName() << ": line " << GetLineNumber() << endl
             << " The value '" << attributes[it->first] << "' will be used instead of '"
             << it->second << "'." << endl;
    }
  }
}
Esempio n. 7
0
void SubhaloMatch(unsigned isnap){
  std::string filename = Folder("output") + Snaps(isnap) + "/ahf_out_mtree";
  unsigned dim=GetLineNumber(filename);
  std::cout<<filename << " has " << dim << " lines." << std::endl;
  unsigned hostno[dim], hostpop[dim], sharedpop[dim], subno[dim], subpop[dim];
  GetMtreeFile( filename, dim, &hostno[0], &hostpop[0], &sharedpop[0], &subno[0], &subpop[0] );
  WriteMtree2File( filename, dim, &hostno[0], &hostpop[0], &sharedpop[0], &subno[0], &subpop[0] );
  //for(int line=0; line<dim; ++line)
  //	std::cout<<subno[line]<<std::endl;

  //std::cout<<" * Building hostno <=> sharedpop map...";
  //std::map<unsigned, unsigned> hsmap;
  //for ( unsigned j = 0; j < dim; ++j )
  //	hsmap.insert( std::make_pair ( hostno[ j ], sharedpop[ j ] ) );
  //std::endl<<"done!"<<std::endl;

  // find number of halos
  unsigned count=0;
  for(unsigned sh=0; sh<dim; ++sh)
    if( hostno[sh] == subno[sh] )
      ++count;
  std::cout << " * Found " << count << " different halos." << std::endl;
  int hosts[count];


  unsigned shcount = 0;
  unsigned sucount = 0;
  unsigned hocount = 0;
  // run through all subhalos
  for( unsigned subhalo = 0; subhalo < dim; ++subhalo ){
    if( hostno[subhalo] != subno[subhalo] )
      continue;
    std::cout << " * * Looking at line " << subhalo << std::endl;
    sucount = 0;
    hocount = 0;
    //count how many times it appears in subno
    std::cout << "subhalo = " << hostno[subhalo] << std::endl;
    for(unsigned su=0; su<dim; ++su)
      if( subno[su] == hostno[subhalo] )
	++sucount;
    //count how many times it appears in hostno
    for(unsigned ho=0; ho < dim; ++ho)
      if( hostno[ho] == hostno[subhalo] )
	++hocount;
    // autocorrelation should yield same no. subhalos and host halos
    std::cout << "sucount = " << sucount << ", hocount = " << hocount << std::endl;
    if(sucount!=hocount)
      std::cerr << " * * Found wrong subhalo!" << std::endl;
    if(sucount<2){
      std::cout << " * * Subhalo occurs only once, it has no host." << std::endl;
      hosts[shcount] = -1;
      ++shcount;
      continue;
    }

    std::cout<<" * * Generating array with shared populations...";
    unsigned shpop[sucount][2]; // [][0] takes sharepop, [][1] takes hostno
    unsigned shpopcount=0;
    for( unsigned sc = 0; sc < dim; ++sc){
      if(subno[sc] == hostno[subhalo] && subpop[sc]<hostpop[sc]){ // found occurrence
	shpop[shpopcount][0] = sharedpop[sc];
	shpop[shpopcount][1] = hostno[sc];
	std::cout << shpop[shpopcount][1] << " " << shpop[shpopcount][0] << std::endl;
	++shpopcount;
      }
    }
    std::cout << shpopcount << " constituents, done!" << std::endl;
    if(shpopcount==0){
      hosts[shcount]=-2;
      ++shcount;
      continue;
    }
    std::cout<<" * * Getting maximum of shared populations...";
    unsigned scmax=0;
    for(unsigned sc=0; sc<shpopcount; ++sc){
      if(shpop[sc][0]>shpop[scmax][0])
	scmax=sc;
    }
    std::cout<<scmax<<", done!"<<std::endl;
		
    std::cout<<" * * Getting host corresponding to maximal shared population... ";
    hosts[shcount]=shpop[scmax][1];
    ++shcount;
    std::cout<<hosts[shcount-1]<<", done!"<<std::endl;
  }
  std::cout << shcount << " subhalos matched."<<std::endl;

  writedebug(DEBUG," * Creating _mtree_idx file...");
  std::ofstream fout;
  fout.open ( (filename+"_idx2").c_str(), std::ios_base::out );
  for(unsigned sc=0; sc<shcount; ++sc){
    fout << sc << " "<<hosts[sc] << std::endl;
  }
  fout.close();
  donedebug(DEBUG);
}
Esempio n. 8
0
File: linnum.c Progetto: JWasm/JWasm
void AddLinnumDataRef( unsigned srcfile, uint_32 line_num )
/*********************************************************/
{
    struct line_num_info    *curr;

#if COFF_SUPPORT
    /* COFF line number info is related to functions/procedures. Since
     * assembly allows code lines outside of procs, "dummy" procs must
     * be generated. A dummy proc lasts until
     * - a true PROC is detected or
     * - the source file changes or
     * - the segment/section changes ( added in v2.11 )
     */
    if ( Options.output_format == OFORMAT_COFF &&
        CurrProc == NULL &&
        ( dmyproc == NULL ||
        dmyproc->debuginfo->file != srcfile ||
        dmyproc->segment != (struct asym *)CurrSeg ) ) {
        char procname[12];
        if ( dmyproc ) {
            /**/myassert( dmyproc->segment );
            dmyproc->total_size =
                ((struct dsym *)dmyproc->segment)->e.seginfo->current_loc -
                dmyproc->offset;
        }
        sprintf( procname, "$$$%05u", procidx );
        DebugMsg1(("AddLinnumDataRef(src=%u.%u): CurrProc==NULL, dmyproc=%s searching proc=%s\n", srcfile, line_num, dmyproc ? dmyproc->name : "NULL", procname ));
        dmyproc = SymSearch( procname );

        /* in pass 1, create the proc */
        if ( dmyproc == NULL ) {
            dmyproc = CreateProc( NULL, procname, SYM_INTERNAL );
            DebugMsg1(("AddLinnumDataRef: new proc %s created\n", procname ));
            dmyproc->isproc = TRUE; /* flag is usually set inside ParseProc() */
            dmyproc->included = TRUE;
            AddPublicData( dmyproc );
        } else
            procidx++; /* for passes > 1, adjust procidx */

        /* if the symbols isn't a PROC, the symbol name has been used
         * by the user - bad! A warning should be displayed */
        if ( dmyproc->isproc == TRUE ) {
            SetSymSegOfs( dmyproc );
            dmyproc->Ofssize = ModuleInfo.Ofssize;
            dmyproc->langtype = ModuleInfo.langtype;
            if ( write_to_file == TRUE ) {
                curr = LclAlloc( sizeof( struct line_num_info ) );
                curr->sym = dmyproc;
                curr->line_number = GetLineNumber();
                curr->file = srcfile;
                curr->number = 0;
                DebugMsg1(("AddLinnumDataRef: CURRPROC=NULL, sym=%s, calling AddLinnumData(src=%u.%u)\n", curr->sym->name, curr->file, curr->line_number ));
                AddLinnumData( curr );
            }
        }
    }
#endif

    if(  line_num && ( write_to_file == FALSE || lastLineNumber == line_num )) {
#ifdef DEBUG_OUT
        if ( write_to_file == TRUE )
            DebugMsg1(("AddLinnumDataRef(src=%u.%u) line skipped, lastline=%u\n", srcfile, line_num, lastLineNumber ));
#endif
        return;
    }
    DebugMsg1(("AddLinnumDataRef(src=%u.%u): currofs=%Xh, CurrProc=%s, GeneratedCode=%u\n", srcfile, line_num, GetCurrOffset(), CurrProc ? CurrProc->sym.name : "NULL", ModuleInfo.GeneratedCode ));

    curr = LclAlloc( sizeof( struct line_num_info ) );
    curr->number = line_num;
#if COFF_SUPPORT
    if ( line_num == 0 ) { /* happens for COFF only */
        /* changed v2.03 (CurrProc might have been NULL) */
        /* if ( Options.output_format == OFORMAT_COFF && CurrProc->sym.public == FALSE ) { */
        /* v2.09: avoid duplicates, check for pass 1 */
        //if ( Options.output_format == OFORMAT_COFF && CurrProc && CurrProc->sym.public == FALSE ) {
        if ( Parse_Pass == PASS_1 &&
            Options.output_format == OFORMAT_COFF && CurrProc && CurrProc->sym.ispublic == FALSE ) {
            CurrProc->sym.included = TRUE;
            AddPublicData( (struct asym *)CurrProc );
        }
        /* changed v2.03 */
        /* curr->sym = (struct asym *)CurrProc; */
        curr->sym = ( CurrProc ? (struct asym *)CurrProc : dmyproc );
        curr->line_number = GetLineNumber();
        curr->file        = srcfile;
        /* set the function's size! */
        if ( dmyproc ) {
            /**/myassert( dmyproc->segment );
            dmyproc->total_size =
                ((struct dsym *)dmyproc->segment)->e.seginfo->current_loc -
                dmyproc->offset;
            dmyproc = NULL;
        }
        /* v2.11: write a 0x7fff line item if prologue exists */
        if ( CurrProc && CurrProc->e.procinfo->size_prolog ) {
            DebugMsg1(("AddLinnumDataRef: calling AddLinnumData(src=%u.%u) sym=%s\n", curr->file, curr->line_number, curr->sym->name ));
            AddLinnumData( curr );
            curr = LclAlloc( sizeof( struct line_num_info ) );
            curr->number = GetLineNumber();
            curr->offset = GetCurrOffset();
            curr->srcfile = srcfile;
        }
    } else {
#endif
        curr->offset = GetCurrOffset();
        curr->srcfile = srcfile;
#if COFF_SUPPORT
    }
#endif
    lastLineNumber = line_num;

    /* v2.11: added, improved multi source support for CV.
     * Also, the size of line number info could have become > 1024,
     * ( even > 4096, thus causing an "internal error in omfint.c" )
     */
    if ( Options.output_format == OFORMAT_OMF )
        omf_check_flush( curr );

    /* v2.10: warning if line-numbers for segments without class code! */
    if ( CurrSeg->e.seginfo->linnum_init == FALSE ) {
        CurrSeg->e.seginfo->linnum_init = TRUE;
        if ( TypeFromClassName( CurrSeg, CurrSeg->e.seginfo->clsym ) != SEGTYPE_CODE ) {
            EmitWarn( 2, LINNUM_INFO_FOR_SEGMENT_WITHOUT_CLASS_CODE, CurrSeg->sym.name );
        }
    }
    DebugMsg1(("AddLinnumDataRef: calling AddLinnumData(src=%u.%u ofs=%X)\n", curr->number == 0 ? curr->file : curr->srcfile, curr->number, curr->offset ));
    AddLinnumData( curr );

    return;
}
void ReadMaterialComp()
{
  char *input, fname[MAX_STR], word[MAX_STR], pname[MAX_STR], **params;
  long loc0, loc1, mat, mat0, iso, iso0, nuc, i0, i, np, j, n, line, r, g, b;
  double val, sum;
  FILE *fp;

  /* Get pointer to file list */

  if ((loc0 = (long)RDB[DATA_PTR_COMP_FILE]) < VALID_PTR)
    return;

  fprintf(out, "Overriding initial material compositions...\n");

  /* Reset previous pointer */

  mat0 = -1;

  /* Reset counters for line number calculation */

  WDB[DATA_LINE_NUM_N0] = 0.0;
  WDB[DATA_LINE_NUM_NL0] = 1.0;

  /* Loop over list */

  while (RDB[loc0] > VALID_PTR)
    {
      /* Get file name */

      sprintf(fname, "%s", GetText(loc0));

      /* Check that file exists */

      if ((fp = fopen(fname, "r")) != NULL)
	fclose(fp);
      else
	{
	  /* File not found */
	  
	  Error(0, "Material composition file \"%s\" does not exist", fname);
	}

      /* Read input file */
  
      input = ReadTextFile(fname);

      /* Avoid compiler warning */
      
      params = NULL;

      /* Loop over file */
      
      i0 = 0;
      while ((i = NextWord(&input[i0], word)) > 0)
	{
	  /* update pointer */
	  
	  i0 = i0 + i;

	  /* Get line number for error messages */
	  
	  line = GetLineNumber(input, i0);

	  /* Look for material definition */

	  if (!strcasecmp(word, "mat"))
	    {
	      /* Copy parameter name */

	      strcpy (pname, word);

	      /* Read parameters */

	      params = GetParams(word, input, &np, &i0, 4, 4*MAX_ISOTOPES + 8, 
				 fname);

	      /* Read data */

	      j = 0;

	      /* Find material (try starting from previous) */

	      mat = mat0;
	      while (mat > VALID_PTR)
		{
		  /* Compare */

		  if (!strcmp(params[j], GetText(mat + MATERIAL_PTR_NAME)))
		    break;

		  /* Next */

		  mat = NextItem(mat);
		}

	      /* Find material (start from beginning) */

	      if (mat < VALID_PTR)
		{
		  mat = (long)RDB[DATA_PTR_M0];
		  while (mat > VALID_PTR)
		    {
		      /* Compare */
		      
		      if (!strcmp(params[j], GetText(mat + MATERIAL_PTR_NAME)))
			break;
		      
		      /* Next */
		      
		      mat = NextItem(mat);
		    }
		}

	      /* Check */

	      if (mat < VALID_PTR)
		Error(-1, pname, fname, line, "Material %s is not defined",
		      params[j]);
	      else
		j++;

	      /* Remember previous */

	      mat0 = NextItem(mat);
	      
	      /* Material density */

	      if (!strcmp(params[j], "sum"))
		{
		  /* Set value to -inf to calculate sum from composition */
		  
		  WDB[mat + MATERIAL_ADENS] = -INFTY;
		  
		  j++;
		}
	      else
		{
		  /* Read value */
		  
		  WDB[mat + MATERIAL_ADENS] = 
		    TestParam(pname, fname, line, params[j++], PTYPE_REAL,
			      -1000.0, 1000.0);
		}

	      /* Reset sum */

	      sum = 0.0;

	      /* Reset previous pointer */

	      iso0 = -1;

	      /* Loop over parameters */
	  
	      while (j < np)
		{
		  /* Check parameter */
		  
		  if (!strcmp(params[j], "tmp"))
		    {
		      /***** Temperature for Doppler-breadening **************/
		  
		      j++;
		      
		      /* Get temperature */
		      
		      WDB[mat + MATERIAL_DOPPLER_TEMP] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);

		      /* Set option */
		      
		      WDB[DATA_USE_DOPPLER_PREPROCESSOR] = (double)YES;
		      
		      /*******************************************************/
		    }
		  if (!strcmp(params[j], "tms") || !strcmp(params[j], "ettm"))
		    {
		      /***** Temperature for TMS *****************************/
		  
		      j++;
		      
		      /* Get temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMIN] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);
		      
		      /* Copy to maximum */
		      
		      WDB[mat + MATERIAL_TMS_TMAX] = 
			RDB[mat + MATERIAL_TMS_TMIN];
		      
		      /* Set mode */
		      
		      WDB[DATA_TMS_MODE] = (double)TMS_MODE_CE;
		      WDB[mat + MATERIAL_TMS_MODE] = (double)YES;
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "rgb"))
		    {
		      /***** Material colour *********************************/

		      j++;
		      
		      /* Get r, b and g */
		      
		      r = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);
		      
		      g = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);

		      b = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);

		      /* Set color */
		      
		      WDB[mat + MATERIAL_RGB] = b + 1000.0*g + 1000000.0*r;
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "vol"))
		    {
		      /***** Material volume *********************************/
		      
		      j++;
		      
		      /* Get volume */
		      
		      WDB[mat + MATERIAL_VOLUME_GIVEN] =
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "fix"))
		    {
		      /***** Default library ID and temperature***************/

		      j++;
		  
		      /* Get default ID and temperature */
		      
		      WDB[mat + MATERIAL_DEFAULT_PTR_LIB_ID] = 
			PutText(params[j++]);
		      WDB[mat + MATERIAL_DEFAULT_TMP] = 
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "mass"))
		    {
		      /***** Material mass ***********************************/

		      j++;
		      
		      /* Get mass */
		      
		      WDB[mat + MATERIAL_MASS_GIVEN] = 
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);

		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "burn"))
		    {
		      /***** Burnable material *******************************/
		      
		      j++;
		      
		      /* Set burn flag */
		      
		      SetOption(mat + MATERIAL_OPTIONS, OPT_BURN_MAT);
		      
		      /* Set burn sort flag and materials flag */
		      
		      WDB[mat + MATERIAL_BURN_SORT_FLAG] = 1.0;
		      WDB[DATA_BURN_MATERIALS_FLAG] = (double)YES;
		      
		      /* Get number of rings */
		      
		      WDB[mat + MATERIAL_BURN_RINGS] = 
			(double)TestParam(pname, fname, line, params[j++], 
					  PTYPE_INT, 0, 10000000);
		  
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "moder"))
		    {
		      /***** Thermal scattering data *************************/

		      j++;
		      
		      /* Check number of parameters */
		      
		      if (j > np - 3)
			Error(mat, "Invalid number of parameters");
		      
		      /* Create new item (use the same structure as with */
		      /* the therm card) */
		      
		      WDB[mat + MATERIAL_PTR_SAB] = NULLPTR;
		      loc1 = NewItem(mat + MATERIAL_PTR_SAB, 
				     THERM_BLOCK_SIZE);

		      /* Read name */
		      
		      WDB[loc1 + THERM_PTR_ALIAS] = 
			(double)PutText(params[j++]);
		      
		      /* Read ZA */
		      
		      WDB[loc1 + THERM_ZA] =  
			(double)TestParam(pname, fname, line, params[j++], 
					  PTYPE_INT, 1001, 120000);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "tft"))
		    {
		      /***** Minimum and maximum temperatures for TMS ********/

		      j++;
		      
		      /* Get minimum temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMIN] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);
		      
		      /* Get maximum temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMAX] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, RDB[mat + MATERIAL_TMS_TMIN],
				  100000.0);
		      
		      /* Set mode */
		      
		      WDB[DATA_TMS_MODE] = (double)TMS_MODE_CE;
		      WDB[mat + MATERIAL_TMS_MODE] = (double)YES;
		      
		      /*******************************************************/
		    }
		  else 
		    {
		      /***** Composition *************************************/

		      /* Find nuclide in composition (start from previous) */

		      iso = iso0;
		      while (iso > VALID_PTR)
			{
			  /* Pointer to nuclide data */

			  nuc = (long)RDB[iso + COMPOSITION_PTR_NUCLIDE];
			  CheckPointer(FUNCTION_NAME, "(nuc)", DATA_ARRAY,nuc);

			  /* Compare */
			  
			  if (!strcmp(GetText(nuc + NUCLIDE_PTR_NAME),
				      params[j]))
			    break;

			  /* Next */

			  iso = NextItem(iso);
			}

		      /* Find nuclide in composition (start from beginning) */

		      if (iso < VALID_PTR)
			{			  
			  iso = (long)RDB[mat + MATERIAL_PTR_COMP];
			  while (iso > VALID_PTR)
			    {
			      /* Pointer to nuclide data */
			      
			      nuc = (long)RDB[iso + COMPOSITION_PTR_NUCLIDE];
			      CheckPointer(FUNCTION_NAME, "(nuc)", 
					   DATA_ARRAY,nuc);

			      /* Compare */
			  
			      if (!strcmp(GetText(nuc + NUCLIDE_PTR_NAME),
					  params[j]))
				break;
			      
			      /* Next */
			      
			      iso = NextItem(iso);
			    }
			}

		      /* Check pointer */
		      
		      if (iso < VALID_PTR)
			Error(-1, pname, fname, line, 
			      "Material %s has no nuclide %s in composition",
			      GetText(mat + MATERIAL_PTR_NAME), params[j]);
		      else
			j++;

		      /* Remember pointer */

		      iso0 = iso;
			      
		      /* Read fraction */
		  
		      val = TestParam(pname, fname, line, params[j++], 
				      PTYPE_REAL, -100.0, 1E+25);
		  
		      /* Put value */

		      WDB[iso + COMPOSITION_ADENS] = val;

		      /* Add to sum */
		      
		      sum = sum + val;
		      
		      /*******************************************************/
		    }
		}
	      
	      /* Set density if sum */

	      if (RDB[mat + MATERIAL_ADENS] == -INFTY)
		WDB[mat + MATERIAL_ADENS] = sum;

	      /* Calculate normalized fractions */
	      
	      IsotopeFractions(mat);
  	    }

	  /* Free parameter list */
      
	  if (np > 0)
	    for (n = 0; n < np + 1; n++)
	      Mem(MEM_FREE, params[n]);
	}

      /* Free memory */
  
      Mem(MEM_FREE, input);

      /* Next file */

      loc0++;
    }

  /* This must be called to get the divided compositions into material */
  /* structures */

  SumDivCompositions();
  
  fprintf(out, "OK.\n\n");
}
Esempio n. 10
0
int MacroExpand(int atom, yystypepp * yylvalpp)
{
    Symbol              *sym = LookUpSymbol(macros, atom);
    MacroInputSrc       *in;
    int i,j, token, depth=0;
    const char *message;
	if (atom == __LINE__Atom) {
        yylvalpp->sc_int = GetLineNumber();
        snprintf(yylvalpp->symbol_name, MAX_SYMBOL_NAME_LEN+1, "%d", yylvalpp->sc_int);
        UngetToken(CPP_INTCONSTANT, yylvalpp);
        return 1;
    }
    if (atom == __FILE__Atom) {
        yylvalpp->sc_int = GetStringNumber();
        snprintf(yylvalpp->symbol_name, MAX_SYMBOL_NAME_LEN+1, "%d", yylvalpp->sc_int);
        UngetToken(CPP_INTCONSTANT, yylvalpp);
        return 1;
    }
	if (atom == __VERSION__Atom) {
        strcpy(yylvalpp->symbol_name,ESSL_VERSION_STRING);
        yylvalpp->sc_int = atoi(yylvalpp->symbol_name);
        UngetToken(CPP_INTCONSTANT, yylvalpp);
        return 1;
    }
    if (!sym || sym->details.mac.undef) return 0;
    if (sym->details.mac.busy) return 0;        // no recursive expansions
    in = malloc(sizeof(*in));
    memset(in, 0, sizeof(*in));
    in->base.scan = (void *)macro_scan;
    in->base.line = cpp->currentInput->line;
    in->base.name = cpp->currentInput->name;
    in->mac = &sym->details.mac;
    if (sym->details.mac.args) {
        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
		if (token != '(') {
            UngetToken(token, yylvalpp);
            yylvalpp->sc_ident = atom;
            return 0;
        }
        in->args = malloc(in->mac->argc * sizeof(TokenStream *));
        for (i=0; i<in->mac->argc; i++)
            in->args[i] = NewTokenStream("macro arg", 0);
		i=0;j=0;
        do{
            depth = 0;
			while(1) {
                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
                if (token <= 0) {
                    StoreStr("EOF in Macro ");
                    StoreStr(GetStringOfAtom(atable,atom));
                    message=GetStrfromTStr();
                    CPPShInfoLogMsg(message);
                    ResetTString();
                    return 1;
                }
                if((in->mac->argc==0) && (token!=')')) break;
                if (depth == 0 && (token == ',' || token == ')')) break;
                if (token == '(') depth++;
                if (token == ')') depth--;
                RecordToken(in->args[i], token, yylvalpp);
                j=1;
			}
            if (token == ')') {
                if((in->mac->argc==1) &&j==0)
                    break;
                i++;
                break;
            }
            i++;
		}while(i < in->mac->argc);

        if (i < in->mac->argc) {
            StoreStr("Too few args in Macro ");
            StoreStr(GetStringOfAtom(atable,atom));
            message=GetStrfromTStr();
            CPPShInfoLogMsg(message);
            ResetTString();
        } else if (token != ')') {
            depth=0;
			while (token >= 0 && (depth > 0 || token != ')')) {
                if (token == ')') depth--;
                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
                if (token == '(') depth++;
            }
			
            if (token <= 0) {
                StoreStr("EOF in Macro ");
                StoreStr(GetStringOfAtom(atable,atom));
                message=GetStrfromTStr();
                CPPShInfoLogMsg(message);
                ResetTString();
                return 1;
            }
            StoreStr("Too many args in Macro ");
            StoreStr(GetStringOfAtom(atable,atom));
            message=GetStrfromTStr();
            CPPShInfoLogMsg(message);
            ResetTString();
		}
		for (i=0; i<in->mac->argc; i++) {
            in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);
        }
    }
#if 0
    printf("  <%s:%d>found macro %s\n", GetAtomString(atable, loc.file),
           loc.line, GetAtomString(atable, atom));
    for (i=0; i<in->mac->argc; i++) {
        printf("\targ %s = '", GetAtomString(atable, in->mac->args[i]));
        DumpTokenStream(stdout, in->args[i]);
        printf("'\n");
    }
#endif
	/*retain the input source*/
    in->base.prev = cpp->currentInput;
    sym->details.mac.busy = 1;
    RewindTokenStream(sym->details.mac.body);
    cpp->currentInput = &in->base;
    return 1;
} // MacroExpand
Esempio n. 11
0
Line* NSBContext::GetLine()
{
    return GetScript()->GetLine(GetLineNumber());
}
Esempio n. 12
0
bool cXMLDocument::ParseTagContent(char *OriginBuffer, unsigned int StartPosition, char *Buffer, cXMLEntry *ParentXMLEntry)
{
	// проверяем наличие вложенных тэгов
	bool ChildsFound = true;
	int DetectTagOpenSymbol = FindSubString(Buffer, "<");
	// если символа открытия в строке нет - это просто данные, иначе проверяем, что стоит до этого символа
	if (DetectTagOpenSymbol > 0)
	{
		int CurrentPos = 0;
		while(CurrentPos != DetectTagOpenSymbol)
		{
			// если до открывающего тэга идут не " ", "\t", "\r", "\n", значит у нас просто данные
			if (((Buffer+CurrentPos)[0] != ' ') &&
				((Buffer+CurrentPos)[0] != '\t') &&
				((Buffer+CurrentPos)[0] != '\r') &&
				((Buffer+CurrentPos)[0] != '\n'))
			{
				ChildsFound = false;
				break;
			}

			CurrentPos++;
		}

	}
	else ChildsFound = false;


	// 1 - это просто контент, заносим данные и выходи из рекурсии
	if (!ChildsFound)
	{
		ParentXMLEntry->Content = CreateSubString(Buffer, 0, strlen(Buffer));
		return true;
	}
	// 2 - если в строке нашли открывающий символ тэга - идем на рекурсивную обработку строки с хмл данными
	else
	{
		// в цикле, пока не достигнем конца обрабатываемой строки:
		unsigned int CurrentBufferPosition = 0;
		while(strlen(Buffer) > 0)
		{
			// находим положение открывающего тэг символа и закрывающего
			DetectTagOpenSymbol = FindSubString(Buffer, "<");

			// это может быть комментарий, проверяем
			if (!strncmp(Buffer+DetectTagOpenSymbol, "<!--", strlen("<!--")))
			{
				// ищем завершающую часть, и сразу перемещаемся к ней
				int DetectCommentCloseSymbol = FindSubString(Buffer, "-->");
				if (DetectCommentCloseSymbol == -1)
				{
					fprintf(stderr, "XML file corrupted, can't find comment end in line %i.\n", GetLineNumber(OriginBuffer, StartPosition+DetectTagOpenSymbol+CurrentBufferPosition));
					return false;
				}
				Buffer += DetectCommentCloseSymbol + strlen("-->");
				CurrentBufferPosition += DetectCommentCloseSymbol + strlen("-->");
				continue;
			}

			// если в строке уже нет открывающих символов - просто выходим, все проверили
			if (DetectTagOpenSymbol == -1) return true;
			int DetectTagCloseSymbol = FindSubString(Buffer, ">");
			// если был открывающий символ, но нет закрывающего - это ошибка структуры документа
			if (DetectTagCloseSymbol == -1)
			{
				fprintf(stderr, "XML file corrupted, can't find element end for element in line %i.\n", GetLineNumber(OriginBuffer, StartPosition+DetectTagOpenSymbol+CurrentBufferPosition));
				return false;
			}
			DetectTagCloseSymbol += strlen(">");

			// создаем новый элемент и подключаем его к родительскому
			cXMLEntry *XMLEntry = new cXMLEntry;
			AttachXMLChildEntry(ParentXMLEntry, XMLEntry);

			// полученные данные передаем на обработку и анализ строки элемента
			char *TagString = CreateSubString(Buffer, DetectTagOpenSymbol, DetectTagCloseSymbol);
			bool ElementHaveContent = ParseTagLine(OriginBuffer, StartPosition+DetectTagOpenSymbol+CurrentBufferPosition, TagString, XMLEntry);
			delete [] TagString;

			// если у нас закрытый тэг - с этим элементом закончили, идем искать дальше
			if (!ElementHaveContent)
			{
				Buffer += DetectTagCloseSymbol;
				CurrentBufferPosition += DetectTagCloseSymbol;
				continue;
			}

			// если тэг открытый - ищем завершающий тэг </имя>
			char *CloseElement = new char[strlen("</>")+strlen(XMLEntry->Name)+1];
			strcpy(CloseElement, "</"); strcat(CloseElement, XMLEntry->Name); strcat(CloseElement, ">");
			CloseElement[strlen("</>")+strlen(XMLEntry->Name)] = 0;
			int CloseElementPosition = FindSubString(Buffer, CloseElement);
			delete [] CloseElement;
			// если закрывающего элемента нет - значит файл поврежден
			if (CloseElementPosition == -1)
			{
				fprintf(stderr, "XML file corrupted, can't find element end: %s in line: %i\n", XMLEntry->Name, GetLineNumber(OriginBuffer, StartPosition+DetectTagOpenSymbol+CurrentBufferPosition));
				return false;
			}

			// передаем данные на рекурсивную обработку (если закрывающий тэг не стоит сразу после открывающего)
			if (DetectTagCloseSymbol < CloseElementPosition)
			{
				char *ElementContent = CreateSubString(Buffer, DetectTagCloseSymbol, CloseElementPosition);
				if (!ParseTagContent(OriginBuffer, DetectTagCloseSymbol+StartPosition+CurrentBufferPosition, ElementContent, XMLEntry))
				{
					// вернули с ошибкой, выходим
					delete [] ElementContent;
					return false;
				}
				delete [] ElementContent;
			}

			// смещаем буфер
			Buffer += CloseElementPosition + strlen(XMLEntry->Name) + strlen("</>");
			CurrentBufferPosition += CloseElementPosition + strlen(XMLEntry->Name) + strlen("</>");
		}
	}


	return false;
}