Ejemplo n.º 1
0
int main(int argc, char*argv[])
{
	if(argc > 1)
		if (strncmp(argv[1], "-d", 2)==0)
			yydebug = 1;

	int status;
	
	YYSTYPE yylval;
	YYLTYPE yyloc = {0};
	int tok;
	
	yypstate *ps = yypstate_new ();
	do {
		tok = yylex (&yylval, &yyloc);
		status = yypush_parse (ps, tok, &yylval, &yyloc, tok);
	} while (status == YYPUSH_MORE);
	yypstate_delete (ps);

	return 0;
}
Ejemplo n.º 2
0
// Read one statement
Expr* IpeReader::readStmt()
{
  int   lexerStatus  = 100;
  int   parserStatus = YYPUSH_MORE;
  Expr* retval       = 0;

  mContext.latestComment = NULL;

  while (lexerStatus != 0 && parserStatus == YYPUSH_MORE && retval == 0)
  {
    YYSTYPE yylval;

    mContext.generatedStmt = NULL;

    lexerStatus            = yylex(&yylval, &mYYlloc, mContext.scanner);

    if (lexerStatus >= 0)
      parserStatus = yypush_parse(mParser, lexerStatus, &yylval, &mYYlloc, &mContext);

    else if (lexerStatus == YYLEX_BLOCK_COMMENT)
      mContext.latestComment = yylval.pch;

    if (mContext.generatedStmt != 0)
    {
      if (BlockStmt* bs = toBlockStmt(mContext.generatedStmt))
      {
        if (Expr* expr = bs->body.last())
          retval = expr;
      }
    }
  }

  if (retval != 0)
    insert_help(retval, NULL, NULL);

  return retval;
}