Ejemplo n.º 1
0
int fbtBuilder::parseFile(const fbtPath& id)
{
	fbtParser parser = fbtInitParse(id.c_str());
	fbt_includes.push_back(id);

	if (!parser)
	{
		fbtPrintf("Error : Parser initialization failed!\n");
		return -1;
	}

	int ret = doParse();
	fbtFreeParse(parser);
	return ret;
}
Ejemplo n.º 2
0
int fbtBuilder::parseBuffer(const fbtId& name, const char* ms)
{
	fbtParser parser = fbtInitParse(name.c_str(), ms);
	fbt_includes.push_back(name.c_str());

	if (!parser)
	{
		fbtPrintf("Error : Parser initialization failed!\n");
		return -1;
	}

	int ret = doParse();
	fbtFreeParse(parser);
	return ret;
}
Ejemplo n.º 3
0
bool ParseOS2( void )
/*******************/
{
    parse_stack resource_state;
    p_action    what;

    newParseStack( &resource_state );
    what = doParse( &resource_state );
    if( what == P_ERROR ) {
        RcError( ERR_PARSER_INTERNAL );
        ErrorHasOccured = true;
    }
    deleteStack( &resource_state );
    return( what != P_ACCEPT );
}
Ejemplo n.º 4
0
void D2StatData::parse(Array<D2ItemStat>& list, char const* str)
{
  D2ItemStat stat;
  re::Match match;
  if (doParse(str, stat))
    list.push(stat);
  else if (prog_EthSockets->run(str, -1, true, finder, &match))
  {
    stat.stat = &stats[359];
    stat.param = 0; stat.value1 = 1; stat.value2 = 0;
    list.push(stat);
    stat.stat = &stats[194];
    stat.param = 0; stat.value1 = atoi(match.start[1]); stat.value2 = 0;
    list.push(stat);
  }
}
Ejemplo n.º 5
0
void Parser::parse()
{
    parseHead();

    if (!_parsed)
    {
        try {
            Object::ParsingContext context(object());
            doParse();
            _parsed = true;
        } catch (const ParsingException& exception) {
            handleParsingException(exception);
        } catch (const Object::ParsingContext::LockException&) {

        }
    }
}
Ejemplo n.º 6
0
void EBNFParser::parse()
{
    QTime time;
    time.start();

    QFile grammarFile("/home/rovshan/Projects/Qt/OraExp/grammars/pl_sql");
    if(grammarFile.open(QFile::ReadOnly)){
        QTextStream strm(&grammarFile);
        scanner=new EBNFScanner(&strm);
        doParse();
    }

    qDebug() << "parsed ebnf rules in" << time.elapsed() << "ms";
    qDebug() << "rule count:" << rules.size();

    EBNFToken errToken;
    errToken.tokenType=EBNFToken::ERR;
    errToken.lexeme="PLS_ERROR";
    errToken.isLiteralTerminal=false;
    registerTargetScannerToken(errToken);

    EBNFToken eofToken=EBNFScanner::createEOFToken();
    eofToken.lexeme="PLS_E_O_F";
    registerTargetScannerToken(eofToken);

    printTargetScannerTokens();

    registerTargetScannerKeywordsFromFile("keywords", targetScannerKeywords);
    qSort(targetScannerKeywords.begin(), targetScannerKeywords.end(), caseInsensitiveLessThan);
    printTargetScannerKeywords("keywords", targetScannerKeywords,FileWriter::Keywords);

    registerTargetScannerKeywordsFromFile("reserved_words", reservedWords);
    qSort(reservedWords.begin(), reservedWords.end(), caseInsensitiveLessThan);
    printTargetScannerKeywords("reservedWords", reservedWords, FileWriter::ReservedWords);

    time.restart();
    findMissingRuleDefinitions();
    qDebug() << "checked rules in" << time.elapsed() << "ms";

    qDebug() << "---------rules----------";
    printoutRules();
    qDebug() << "-------end rules--------";
}
Ejemplo n.º 7
0
bool SchemaParser::parse(const std::string &configPath, const std::string &masterConfigFile, const std::map<std::string, std::string> &cfgParms)
{
    bool rc = true;
    try
    {
        auto pluginPathsIt = cfgParms.find("plugin_paths");
        if (pluginPathsIt != cfgParms.end())
        {
            m_pluginPaths = splitString(pluginPathsIt->second, ",");
        }
        doParse(configPath, masterConfigFile, cfgParms);
    }
    catch (const ParseException &pe)
    {
        m_message = "The following error was detected while parsing the configuration: " + static_cast<std::string>(pe.what());
        rc = false;
    }
    return rc;
}
Ejemplo n.º 8
0
void XercesParser::parseXML(XMLHandler& handler, const RawDataContainer& source, const String& schemaName)
{
    XERCES_CPP_NAMESPACE_USE;

    XercesHandler xercesHandler(handler);

    // create parser
    SAX2XMLReader* reader = createReader(xercesHandler);

    CEGUI_TRY
    {
        // set up schema
        initialiseSchema(reader, schemaName);
        // do parse
        doParse(reader, source);
    }
    CEGUI_CATCH(const XMLException& exc)
    {
        if (exc.getCode() != XMLExcepts::NoError)
        {
            delete reader;

            char* excmsg = XMLString::transcode(exc.getMessage());
            String message("An error occurred at line nr. " + PropertyHelper<uint>::toString((uint)exc.getSrcLine()) + " while parsing XML.  Additional information: ");
            message += excmsg;
            XMLString::release(&excmsg);

            CEGUI_THROW(FileIOException(message));
        }

    }
    CEGUI_CATCH(const SAXParseException& exc)
    {
        delete reader;

        char* excmsg = XMLString::transcode(exc.getMessage());
        String message("An error occurred at line nr. " + PropertyHelper<uint>::toString((uint)exc.getLineNumber()) + " while parsing XML.  Additional information: ");
        message += excmsg;
        XMLString::release(&excmsg);

        CEGUI_THROW(FileIOException(message));
    }
Ejemplo n.º 9
0
int _tmain(int argc, _TCHAR* argv[])
{
	std::cout << "mongoODBC connector" << std::endl << "sql [q/Q to quit] >> ";

	bool ok;
	std::string sqlinput;
	while (std::getline(std::cin,sqlinput))
	{
		if (sqlinput.empty() || sqlinput[0] == 'q' || sqlinput[0] == 'Q')
			break;

		// = "select id, name, price from books, authors where books.author_id = authors.id;";

		ok = doParse(sqlinput, qi::space);

		std::cout << std::endl << "sql [q/Q to quit] >> ";
	}

    return 0;
}
Ejemplo n.º 10
0
bool http_servlet::doBody(acl::HttpServletRequest& req,
	acl::HttpServletResponse& res)
{
	// 当未读完数据体时,需要异步读 HTTP 请求数据体
	if (content_length_ > read_length_)
	{
		if (doUpload(req, res) == false)
			return false;
	}

	if (content_length_ > read_length_)
		return true;

	// 当已经读完 HTTP 请求数据体时,则开始分析上传的数据
	bool ret = doParse(req, res);

	// 处理完毕,需重置 HTTP 会话状态,以便于处理下一个 HTTP 请求
	reset();
	return ret;
}
Ejemplo n.º 11
0
/* attempts to load from a file on disk. if the file doesn't exist then
 * parse it for real and save it to disk.
 */
Util::ReferenceCount<Ast::AstParse> Parser::loadFile(const Filesystem::AbsolutePath & path){
    try{
        return loadCached(path);
    } catch (const TokenException & fail){
        Global::debug(1, "mugen-parse-cache") << "Cache load warning: " << fail.getTrace() << endl;
    } catch (const MugenException & fail){
        Global::debug(1, "mugen-parse-cache") << "Cache load warning: " << fail.getTrace() << endl;
    } catch (const Filesystem::Exception & fail){
        Global::debug(1, "mugen-parse-cache") << "Cache load warning: " << fail.getTrace() << endl;
    }

    Global::debug(1, "mugen-parse-cache") << "Parsing " << path.path() << endl;
    Util::ReferenceCount<Ast::AstParse> out = doParse(path);
    try{
        saveCached(out, path);
    } catch (...){
        Global::debug(0) << "Failed to save cached file " << path.path() << endl;
        /* failed for some reason */
    }

    return out;
}
Ejemplo n.º 12
0
S32 LLSDNotationParser::parseArray(std::istream& istr, LLSD& array) const
{
	// array: [ object, object, object ]
	array = LLSD::emptyArray();
	S32 parse_count = 0;
	char c = get(istr);
	if(c == '[')
	{
		// eat commas, white
		c = get(istr);
		while((c != ']') && istr.good())
		{
			LLSD child;
			if(isspace(c) || (c == ','))
			{
				c = get(istr);
				continue;
			}
			putback(istr, c);
			S32 count = doParse(istr, child);
			if(PARSE_FAILURE == count)
			{
				return PARSE_FAILURE;
			}
			else
			{
				parse_count += count;
				array.append(child);
			}
			c = get(istr);
		}
		if(c != ']')
		{
			return PARSE_FAILURE;
		}
	}
	return parse_count;
}
Ejemplo n.º 13
0
STATIC void parseString( const char *str ) {

/**/myassert( str != NULL );
    for(;;) {
        while( isspace( *str ) ) ++str;
        switch( *str ) {
        case 0:
            return;
        case SWCHAR:
        case '-':
            str += 2;
            switch( str[-1] ) {
            case 'o':   str = doOutput( str );      break;
            case 'd':   str = doDebug( str );       break;
            case 'p':   str = doParse( str );       break;
            case 'f':   str = doFile( str );        break;
            case 'q':   /* FALL THROUGH */
#if 0
            case 'l':
#endif
            case 'b':   str = doToggle( str );      break;
            default:    usage();
            }
            if( !isBreakChar( *str ) ) usage();
            break;
        case INCCHAR:
            str = doInclude( str + 1 );
            break;
        case CMTCHAR:
            str = doComment( str + 1 );
            break;
        default:
            str = addFile( str );
            break;
        }
    }

}
Ejemplo n.º 14
0
S32 LLSDBinaryParser::parseArray(std::istream& istr, LLSD& array) const
{
	array = LLSD::emptyArray();
	U32 value_nbo = 0;
	read(istr, (char*)&value_nbo, sizeof(U32));		 /*Flawfinder: ignore*/
	S32 size = (S32)ntohl(value_nbo);

	// *FIX: This would be a good place to reserve some space in the
	// array...

	S32 parse_count = 0;
	S32 count = 0;
	char c = istr.peek();
	while((c != ']') && (count < size) && istr.good())
	{
		LLSD child;
		S32 child_count = doParse(istr, child);
		if(PARSE_FAILURE == child_count)
		{
			return PARSE_FAILURE;
		}
		if(child_count)
		{
			parse_count += child_count;
			array.append(child);
		}
		++count;
		c = istr.peek();
	}
	c = get(istr);
	if((c != ']') || (count < size))
	{
		// Make sure it is correctly terminated and we parsed as many
		// as were said to be there.
		return PARSE_FAILURE;
	}
	return parse_count;
}
Ejemplo n.º 15
0
	bool StreamParser::parse(StreamSource& prg) {
		source_ = &prg;
		return doParse();
	}
Ejemplo n.º 16
0
// Parse using routine to get() lines, faster than parse()
S32 LLSDParser::parseLines(std::istream& istr, LLSD& data)
{
	mCheckLimits = false;
	mParseLines = true;
	return doParse(istr, data);
}
Ejemplo n.º 17
0
S32 LLSDParser::parse(std::istream& istr, LLSD& data, S32 max_bytes)
{
	mCheckLimits = (LLSDSerialize::SIZE_UNLIMITED == max_bytes) ? false : true;
	mMaxBytesLeft = max_bytes;
	return doParse(istr, data);
}
Ejemplo n.º 18
0
  XPathStepId XPathParser::doParseAVT ( char* expr )
  {
    if ( strncmp ( expr, "{f", 2 ) == 0 ) Bug ( "." );
    Log_XPathParser_AVT ( "Parsing AVT !\n" );
    Log_XPathParser_AVT ( "Expr '%s'\n", expr );
    AssertBug ( expr && *expr, "Empty expr !\n" );

    XPathStepId stepList[256];
    int stepListIndex = 0;
#define appendStep(__stepId) stepList[stepListIndex++] = __stepId

    /*
     * Embdedded XPath parsing logic
     * General XPath embedded parsing format is as follows :
     * [<text>* '{' <xpath expression> '}' ]+
     * text may contain '{{' and '}}' sequences, which must be converted to '{' and '}', respectively.
     * xpath expressions may contain matching '{' and '}', which must be provided as-is to the XPath expression parser (doParse())
     * 
     * Important note for XPath indirections :
     * xpath expressions in Xem are extended to handle indirections, id est sub-xpath expression fetching.
     * For example, "element/{@xpath-query}" will use the @xpath-query attribute as an XPath expression to continue
     * evaluation based on the 'element' Element.
     * Xem handles recursive XPath indirections.
     *
     * For embedded XPath expressions, XPath indirections can not start by two '{', because they will be converted to a single '{' and
     * handled as text.
     * As a result, '{{@id}}' will be converted to '{@id}', whereas '{ {@id}}' will be handled as a two-level XPath indirection.
     *
     * XPath parsing is performed in two distinct steps :
     * -# First, the expression is linearly parsed, building a list of XPath steps from textual resources and XPath expressions
     *    These steps are stored orderly in stepList.
     * -# Then, the global XPath expression is built, concatenating all the steps parsed.
     */
    
    int inExpressionDepth = 0; //!< 0 if we are outside of an expression, count number of unclosed '{' otherwise.
    char* segmentHead = expr;
    char* segmentTail = expr;
    
#define __copyChar() \
    if ( current == segmentTail ) { segmentTail++; } \
    else { *segmentTail = *current; segmentTail++; }
#define __endSegment() { *segmentTail = '\0'; }

    for ( char* current = expr ; *current ; current++ )
      {
        Log_XPathParser_AVT ( "Expr=%p / current=%p %c, inExprDepth=%d\n",
            expr, current, *current, inExpressionDepth );
        switch ( *current )
        {
        case '{':
          if ( current[1] == '{' )
            {
              Log_XPathParser_AVT ( "Reduced '{{' to '{' in text.\n" );
              __copyChar();
              current++;
              continue;            
            }
          if ( inExpressionDepth )
            {
              inExpressionDepth++; continue;
            }
          __endSegment();
          if ( *segmentHead )
            {
              appendStep ( allocStepResource ( segmentHead ) );
            }
          inExpressionDepth ++;
          segmentHead = &(current[1]);
          segmentTail = segmentHead;
          break;
        case '}':
          if ( inExpressionDepth )
            {
              inExpressionDepth--;
              if ( ! inExpressionDepth )
                {
                  __endSegment ();
                  appendStep ( doParse ( segmentHead ) );
                  segmentHead = segmentTail = &(current[1]);
                }
              else
                {
                  __copyChar ();
                }
              continue;
            }
          if ( current[1] == '}' )
            {
              Log_XPathParser_AVT ( "Reduced '}}' to '}' in text.\n" );
              __copyChar ();
              current++;
              continue;
            }
          throwXPathException ( "Invalid out-of-expression single closing curly brace : next character=%c.\n", current[1] );
        default:
          __copyChar();
        }
      }
    if ( inExpressionDepth )
      {
        throwXPathException ( "Unbalanced curly braces in XPath AVT expression.\n" );
      }

    Log_XPathParser_AVT ( "Post parse expr=%p : seg head=%p %c, tail=%p %c\n", expr, segmentHead, *segmentHead, segmentTail, *segmentTail );
    __endSegment();
    if ( *segmentHead )
      {
        appendStep ( allocStepResource ( segmentHead ) );
      }
      
    if ( stepListIndex == 0 )
      {
        throwXPathException ( "Empty Step List !\n" );
      }
    if ( stepListIndex == 1 )
      {
        return stepList[0];
      }

    XPathStepId headStepId = allocStep ();
    XPathStep* currentStep = getStep ( headStepId );
    currentStep->action = XPathFunc_Concat;
    for ( int ustep = 0 ; ustep < XPathStep_MaxFuncCallArgs ; ustep++ )
      currentStep->functionArguments[ustep] = XPathStepId_NULL;
    int currentArg = 0;
    for ( int step = 0 ; step < stepListIndex ; step++ )
      {
        if ( ( currentArg == XPathStep_MaxFuncCallArgs-1 )
             && ( step < (stepListIndex-1) ) )
          {
            XPathStepId nextStepId = allocStep ();
            currentStep->functionArguments[currentArg] = nextStepId;
            XPathStep* currentStep = getStep ( nextStepId );
            currentStep->action = XPathFunc_Concat;
            for ( int ustep = 0 ; ustep < XPathStep_MaxFuncCallArgs ; ustep++ )
              currentStep->functionArguments[ustep] = XPathStepId_NULL;
            currentArg = 0;
          }
        currentStep->functionArguments[currentArg] = stepList[step];
        currentArg++;
      }
    return headStepId;
  }
Ejemplo n.º 19
0
bool ProgramBuilder::parseProgram(StreamSource& prg) {
	CLASP_ASSERT_CONTRACT(ctx_ && !frozen());
	return doParse(prg);
}
Ejemplo n.º 20
0
bool parseQfBoost(std::string& input, std::string& output) {
  boost::regex re(NUMBERS_REGEX_STRING); //TODO: make compile time
  
  return doParse(input, re, output);
}
Ejemplo n.º 21
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main()
{
    bool ok = doParse("label1 up");
    return ok? 0 : 255;
}
Ejemplo n.º 22
0
std::error_code File::parse() {
  std::lock_guard<std::mutex> lock(_parseMutex);
  if (!_lastError.hasValue())
    _lastError = doParse();
  return _lastError.getValue();
}
Ejemplo n.º 23
0
int CNod1300PacketParser::doParse( const char* pData, int len )
{	
	char * buff = const_cast<char *>(pData);
	//处理一个新的包 
	if(m_ulBuffIndexTCP<=ADV_PACKET_HEADLEN)
	{
		int iTruelen=0; //实际UDP包的长度,包括不同设备自定义的包头(不包括ADV_PACKET_HEADERLEN)
		if(m_ulTCPHeadReserved+len < 16 )//不够一个头
		{
			//ATLTRACE("---应用头缓冲区 reservedlen= %d ,len=%d\n",m_ulTCPHeadReserved, len);
			memcpy(m_TCPBuffHead+m_ulTCPHeadReserved,buff,len);
			m_ulTCPHeadReserved +=len;
			return len;
		}
		else //够一个头 此处是临时copy,不用改变m_ulTCPHeadReserved
		{
			memcpy(m_TCPBuffHead+m_ulTCPHeadReserved,buff,16-m_ulTCPHeadReserved);
		}

		{
			iTruelen=(USHORT)*((USHORT*)((PBYTE)m_TCPBuffHead+8));
			if(iTruelen==0)
			{
				iTruelen=36;
			}
			//			  ATLASSERT(iTruelen<2000);
			if (iTruelen>2000)
			{
				//			  DispError(NULL, "iTruelen<2000 接收数据出现异常!!");
				return 0;
			}
		}

		MakeAdvPacketHeader(m_TCPBuff,iTruelen);
		if(iTruelen <= len+m_ulTCPHeadReserved ) //可结束一包
		{
			int iLastLen;
			if(m_ulTCPHeadReserved > 0) //头有剩余
			{
				ATLASSERT(m_ulTCPHeadReserved < 16);
				ATLASSERT(m_ulBuffIndexTCP==24);
				//ATLTRACE("IndexTCP=%d hresv=%d itruelen=%d\n",m_ulBuffIndexTCP,m_ulTCPHeadReserved,iTruelen);

				if(iTruelen>=m_ulTCPHeadReserved) //实际长度可能会大或等于已经缓存在包头里的长度
				{
					memcpy(m_TCPBuff+m_ulBuffIndexTCP,m_TCPBuffHead,m_ulTCPHeadReserved);
					m_ulBuffIndexTCP+=m_ulTCPHeadReserved;
					memcpy(m_TCPBuff+m_ulBuffIndexTCP,buff,iTruelen-m_ulTCPHeadReserved);
					iLastLen=len-iTruelen+m_ulTCPHeadReserved;//剩余的数据
					m_ulBuffIndexTCP=ADV_PACKET_HEADLEN;
					m_ulReservedLenTCP=0;
					m_ulTCPHeadReserved=0;
				}
				else //实际长度可能会小于已经缓存在包头里的长度
				{

					memcpy(m_TCPBuff+m_ulBuffIndexTCP,m_TCPBuffHead,iTruelen);
					m_ulTCPHeadReserved-=iTruelen;//包头还有剩余
					if(m_ulTCPHeadReserved >= 0)
					{
						//把剩余的包头缓冲复制到包头缓冲的顶端
						ATLTRACE("测试区1\n");
						memcpy(m_TCPBuffHead,m_TCPBuffHead+iTruelen,m_ulTCPHeadReserved);
						iLastLen=len;//剩余的数据不变
						m_ulBuffIndexTCP=ADV_PACKET_HEADLEN;
						m_ulReservedLenTCP=0;
					}
					else
					{
						ATLTRACE("测试区2\n");
						iLastLen=len+m_ulTCPHeadReserved;//此时m_ulTCPHeadReserved<0
						m_ulTCPHeadReserved=0;

						m_ulBuffIndexTCP=ADV_PACKET_HEADLEN;
						m_ulReservedLenTCP=0;
					}
				}
			}
			else
			{

				memcpy(m_TCPBuff+m_ulBuffIndexTCP,buff,iTruelen);
				iLastLen=len-iTruelen;//剩余的数据
				m_ulBuffIndexTCP=ADV_PACKET_HEADLEN;
				m_ulReservedLenTCP=0;
			}
			EndaPack();
			if(iLastLen >0) //有可能相等
			{
				doParse(buff+len-iLastLen,iLastLen);//递归
			}
		}
		else
		{
			if(m_ulTCPHeadReserved > 0) //头有剩余
			{
				ATLASSERT(m_ulTCPHeadReserved < 16);
				memcpy(m_TCPBuff+m_ulBuffIndexTCP,m_TCPBuffHead,m_ulTCPHeadReserved);
				m_ulBuffIndexTCP+=m_ulTCPHeadReserved;
				m_ulReservedLenTCP-= m_ulTCPHeadReserved;
				memcpy(m_TCPBuff+m_ulBuffIndexTCP,buff,len);
				m_ulBuffIndexTCP+=len;
				m_ulReservedLenTCP-=len;
				m_ulTCPHeadReserved=0;
			}
			else
			{
				memcpy(m_TCPBuff+m_ulBuffIndexTCP,buff,len);
				m_ulBuffIndexTCP+=len;
				m_ulReservedLenTCP-=len;
			}
		}

	}
	else //处理剩余的包
	{
		if((int)m_ulReservedLenTCP <= len)  //可结束一包
		{
			memcpy(m_TCPBuff+m_ulBuffIndexTCP,buff,m_ulReservedLenTCP);
			int iLastLen=len-m_ulReservedLenTCP;//剩余的数据
			m_ulBuffIndexTCP=ADV_PACKET_HEADLEN;
			m_ulReservedLenTCP=0;
			EndaPack();
			if(iLastLen >0) //有可能相等
			{
				doParse(buff+len-iLastLen,iLastLen);
			}
		}
		else
		{
			memcpy(m_TCPBuff+m_ulBuffIndexTCP,buff,len);
			m_ulBuffIndexTCP+=len;
			m_ulReservedLenTCP-=len;
		}

	}	
	return len;
}
Ejemplo n.º 24
0
bool Parser::doParseSome(int /*hint*/)
{
    doParse();
    return true;
}
Ejemplo n.º 25
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main()
{
    bool ok = doParse("@anything but &at; followed of the string .PV@");
    return ok? 0 : 255;
}
Ejemplo n.º 26
0
// Called from clipboard SGF import
bool SGFParser::parseString(const QString &toParse)
{
	if (toParse.isNull() || toParse.isEmpty() || !initGame(toParse, NULL))
		return corruptSgf();
	return doParse(toParse);
}