Пример #1
0
bool TemplateParser::ParseIfNull()
{
	ignore_whitespaces();

	// Get the property
	wxString childName;
	PProperty property( GetProperty( &childName ) );
	if ( !property )
	{
		return false;
	}

	wxString inner_template = ExtractInnerTemplate();

	if ( property->IsNull() )
	{
		// Generate the code from the block
		PTemplateParser parser = CreateParser( this, inner_template );
		m_out << parser->ParseTemplate();
	}
	else
	{
		if ( !childName.empty() )
		{
			if ( property->GetChildFromParent( childName ).empty() )
			{
				// Generate the code from the block
				PTemplateParser parser = CreateParser( this, inner_template );
				m_out << parser->ParseTemplate();
			}
		}
	}

	return true;
}
Пример #2
0
bool TemplateParser::ParseForEach()
{
	// Whitespaces at the very start are ignored
	ignore_whitespaces();

	// parsing the property
	if (GetNextToken() == TOK_PROPERTY)
	{
		wxString propname = ParsePropertyName();
		wxString inner_template = ExtractInnerTemplate();

		PProperty property = m_obj->GetProperty(propname);
		wxString propvalue = property->GetValue();

		// Property value must be an string using ',' as separator.
		// The template will be generated nesting as many times as
		// tokens were found in the property value.

		if (property->GetType() == PT_INTLIST || property->GetType() == PT_UINTLIST)
		{
			// For doing that we will use wxStringTokenizer class from wxWidgets
			wxStringTokenizer tkz( propvalue, wxT(","));
			int i = 0;
			while (tkz.HasMoreTokens())
			{
				wxString token;
				token = tkz.GetNextToken();
				token.Trim(true);
				token.Trim(false);

				// Parsing the internal template
				{
					wxString code;
					PTemplateParser parser = CreateParser( this, inner_template );
					parser->SetPredefined( token, wxString::Format( wxT("%i"), i++ ) );
					code = parser->ParseTemplate();
					m_out << wxT("\n") << code;
				}
			}
		}
		else if (property->GetType() == PT_STRINGLIST)
		{
			wxArrayString array = property->GetValueAsArrayString();
			for ( unsigned int i = 0 ; i < array.Count(); i++ )
			{
				wxString code;
				PTemplateParser parser = CreateParser(this,inner_template);
				parser->SetPredefined( ValueToCode( PT_WXSTRING_I18N, array[i] ), wxString::Format( wxT("%i"), i ) );
				code = parser->ParseTemplate();
				m_out << wxT("\n") << code;
			}
		}
		else
			wxLogError(wxT("Property type not compatible with \"foreach\" macro"));
	}

	return true;
}
Пример #3
0
    VSCore::VSCore(uint32_t version) :
        m_Refs(0), m_Version(version), m_ConfigFile(nullptr)
    {
#if defined(VOODOO_DEBUG_MEMORY)
        _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
        _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
        _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
        _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
        _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
#endif

        // Set up the internal objects
        m_Logger = CreateLogger();
        m_Parser = CreateParser();
        m_Server = CreateServer();

        AddThisToDebugCache();
    };
Пример #4
0
bool TemplateParser::ParseIfTypeNotEqual()
{
    // get examined type name
    wxString type = ExtractLiteral();

    // get the template to generate if comparison is true
    wxString inner_template = ExtractInnerTemplate();

    // compare give type name with type of the wx parent object
    if( !IsEqual( m_obj->GetObjectTypeName(), type) )
    {
        // generate the code
		PTemplateParser parser = CreateParser( this, inner_template );
		m_out << parser->ParseTemplate();
		return true;
	}

    return false;
}
Пример #5
0
bool TemplateParser::ParseIfNotEqual()
{
	// ignore leading whitespace
	ignore_whitespaces();

	// Get the property
	wxString childName;
	PProperty property( GetProperty( &childName ) );
	if ( property )
	{
		// Get the value to compare to
		wxString value = ExtractLiteral();

		// Get the template to generate if comparison is false
		wxString inner_template = ExtractInnerTemplate();

		// Get the value of the property
		wxString propValue;
		if ( childName.empty() )
		{
			propValue = property->GetValue();
		}
		else
		{
			propValue = property->GetChildFromParent( childName );
		}

		// Compare
		if ( propValue != value )
		{
			// Generate the code
			PTemplateParser parser = CreateParser( this, inner_template );
			m_out << parser->ParseTemplate();;
			return true;
		}
	}

	return false;
}
Пример #6
0
cTSDemuxer::cTSDemuxer(cLiveStreamer *streamer, cStreamInfo::Type type, int pid) : cStreamInfo(pid, type), m_Streamer(streamer) {
  m_pesParser = CreateParser(m_type);
}
Пример #7
0
cTSDemuxer::cTSDemuxer(cLiveStreamer *streamer, const cStreamInfo& info) : cStreamInfo(info), m_Streamer(streamer) {
  m_pesParser = CreateParser(m_type);
  SetContent();
}
Пример #8
0
/* 
 * This application substitues in the FASTQ files, the DNA sequence the outside ACGT chars by random ACGT symbols.
 */
int main(int argc, char *argv[])
{
  uint32_t streamSize, index, seed = 0;
  uint8_t  value, line = 0;
  char     *bases = "ACGT";
  PARSER *Parser = CreateParser();
  BUF *Buffer;
  srand(seed);

  char *programName = argv[0];
  struct argparse_option options[] = {
        OPT_HELP(),
        OPT_GROUP("Basic options"),
        OPT_BUFF('<', "input.fastq", "Input FASTQ file format (stdin)"),
        OPT_BUFF('>', "output.fastq", "Output FASTQ file format (stdout)"),
        OPT_END(),
  };
  struct argparse argparse;

  char usage[250] = "\nExample: "; 
  strcat(usage, programName);
  strcat(usage, " < input.fastq > output.fastq\n");

  argparse_init(&argparse, options, NULL, programName, 0);
  argparse_describe(&argparse, "\nIt substitues in the FASTQ files, the DNA sequence the outside ACGT chars by random ACGT symbols.", usage);
  argc = argparse_parse(&argparse, argc, argv);

  if(argc != 0)
    argparse_help_cb(&argparse, options);

  FileType(Parser, stdin);
  if(Parser->type != 2)
  {
    fprintf(stderr, "ERROR: This is not a FASTQ file!\n");
    exit(1);
  }

  Buffer = CreateBuffer(BUF_SIZE);

  while((streamSize = fread(Buffer->buf, 1, Buffer->size, stdin)))
    for(index = 0 ; index < streamSize ; ++index)
    {
      value = Buffer->buf[index];
      switch(line)
      {
        case 0:
          putchar(value);
          if(value == '\n') line = 1;
          break;

        case 1: 
          if(value == '\n')
          {
            putchar('\n');
            line = 2;
            break;
          }
          RandIfExtra(value, bases);
          break;

        case 2:
          putchar(value); 
          if(value == '\n') line = 3; 
          break;
        
        case 3: 
          putchar(value);
          if(value == '\n') line = 0; 
          break;
      } 
    }

  RemoveBuffer(Buffer); 
  return EXIT_SUCCESS;
}
Пример #9
0
static void GenerateCalEntries(int col)
{
    int r;
    Token tok;
    char const *s;
    Parser p;

/* Do some initialization first... */
    ClearGlobalOmits();
    DestroyOmitContexts();
    DestroyVars(0);
    NumTriggered = 0;

    r=IncludeFile(InitialFile);
    if (r) {
	fprintf(ErrFp, "%s %s: %s\n", ErrMsg[E_ERR_READING], InitialFile, ErrMsg[r]);
	exit(1);
    }

    while(1) {
	r = ReadLine();
	if (r == E_EOF) return;
	if (r) {
	    Eprint("%s: %s", ErrMsg[E_ERR_READING], ErrMsg[r]);
	    exit(1);
	}
	s = FindInitialToken(&tok, CurLine);

	/* Should we ignore it? */
	if (NumIfs &&
	    tok.type != T_If &&
	    tok.type != T_Else &&
	    tok.type != T_EndIf &&
	    tok.type != T_IfTrig &&
	    ShouldIgnoreLine())
	{
	    /* DO NOTHING */
	}
	else {
	    /* Create a parser to parse the line */
	    CreateParser(s, &p);

	    switch(tok.type) {

	    case T_Empty:
	    case T_Comment:
		break;

	    case T_ErrMsg:  r=DoErrMsg(&p);  break;
	    case T_Rem:     r=DoCalRem(&p, col); break;
	    case T_If:      r=DoIf(&p);      break;
	    case T_IfTrig:  r=DoIfTrig(&p);  break;
	    case T_Else:    r=DoElse(&p);    break;
	    case T_EndIf:   r=DoEndif(&p);   break;
	    case T_Include: r=DoInclude(&p); break;
	    case T_Exit:    DoExit(&p);	     break;
	    case T_Set:     r=DoSet(&p);     break;
	    case T_Fset:    r=DoFset(&p);    break;
	    case T_UnSet:   r=DoUnset(&p);   break;
	    case T_Clr:     r=DoClear(&p);   break;
	    case T_Flush:   r=DoFlush(&p);   break;
	    case T_Debug:   break;  /* IGNORE DEBUG CMD */
	    case T_Dumpvars: break; /* IGNORE DUMPVARS CMD */
	    case T_Banner:  break;  /* IGNORE BANNER CMD */
	    case T_Omit:    r=DoOmit(&p);
		if (r == E_PARSE_AS_REM) {
		    DestroyParser(&p);
		    CreateParser(s, &p);
		    r=DoCalRem(&p, col);
		}
		break;
	    case T_Pop:     r=PopOmitContext(&p);     break;
	    case T_Push:    r=PushOmitContext(&p);    break;
	    case T_Preserve: r=DoPreserve(&p);        break;
	    case T_RemType: if (tok.val == RUN_TYPE) {
		r=DoRun(&p);
		break;
	    } else {
		CreateParser(CurLine, &p);
		r=DoCalRem(&p, col);
		break;
	    }

	    /* If we don't recognize the command, do a REM by default */
	    /* Note:  Since the parser hasn't been used yet, we don't */
	    /* need to destroy it here. */

	    default:        CreateParser(CurLine, &p);
		r=DoCalRem(&p, col);
		break;
	    }
	    if (r && (!Hush || r != E_RUN_DISABLED)) Eprint("%s", ErrMsg[r]);

	    /* Destroy the parser - free up resources it may be tying up */
	    DestroyParser(&p);
	}
    }
}