Ejemplo n.º 1
0
AuctionTransferAPICore::AuctionTransferAPICore(const char *hostName[], const short port[], int count, AuctionTransferAPI *api, const char *identifier[], unsigned identifierCount, unsigned reqTimeout, unsigned maxRecvMessageSizeInKB)
    : GenericAPICore(identifier[0], hostName, port, count, reqTimeout, 5, 0, 90, 32, 32, 1, maxRecvMessageSizeInKB),
      m_api(api),
      m_mappedServerTrack(1000)
      //////////////////////////////////////////////////////////////////////////////////////
{
    for(unsigned i = 0; i < identifierCount; i++)
        addIdentifier(identifier[i]);
}
Ejemplo n.º 2
0
		void startDocument()
		{
			// Set up the base URI resolver for the content handler and the XLink handler.
			if (outer.lock()->getURI().empty()) 
			{
				throw xercesc::SAXException("The document URI must not be null when setting up the base URI resolver.");
			}
			setBaseURISAXResolver(BaseURISAXResolver(outer.lock()->getURI()));
			getXLinkHandler().setBaseURISAXResolver(baseURISAXResolver);

			std::shared_ptr<XBRLXLinkIdentifier> xbrlLinkIdentifier(new XBRLXLinkIdentifier(outer.lock()));
			std::shared_ptr<SchemaIdentifier> schemaIdentifier(new SchemaIdentifier(outer.lock()));
			std::shared_ptr<XBRLIdentifier> xbrlIdentifier(new XBRLIdentifier(outer.lock()));
			std::shared_ptr<LanguageIdentifier> languageIdentifier(new LanguageIdentifier(outer.lock()));
			std::shared_ptr<ReferencePartIdentifier> referencePartIdentifier(new ReferencePartIdentifier(outer.lock()));
			std::shared_ptr<GenericDocumentRootIdentifier> genericDocumentRootIdentifier(new GenericDocumentRootIdentifier(outer.lock()));
			xbrlLinkIdentifier->initialize();
			schemaIdentifier->initialize();
			xbrlIdentifier->initialize();
			languageIdentifier->initialize();
			referencePartIdentifier->initialize();
			genericDocumentRootIdentifier->initialize();

			// Instantiate the fragment identifiers
			try 
			{
				addIdentifier(xbrlLinkIdentifier);
				addIdentifier(schemaIdentifier);
				addIdentifier(xbrlIdentifier);
				addIdentifier(languageIdentifier);
				addIdentifier(referencePartIdentifier);
				addIdentifier(genericDocumentRootIdentifier);
			}
			catch (const XBRLException& e) 
			{
				throw xercesc::SAXException(("One of the fragment identifiers could not be instantiated." 
					+ e.getMessage() ).c_str());
			}

		}
void AbstractDecorator::decorate(const QString &text, int state)
{
    if (text.contains("\n")) {
        qDebug() << "Wrong block found";
        return;
    }

    prepare(text);

    QmlJS::Scanner scanner;
    QList<QmlJS::Token> tokens = scanner(text, state);
    for (int i = 0; i < tokens.count(); i++) {
        const QmlJS::Token token = tokens.at(i);

        switch (token.kind) {
        case QmlJS::Token::Keyword:
            addKeyword(token.offset, token.length);
            break;
        case QmlJS::Token::Identifier: {
                QString entry = text.mid(token.offset, token.length);

                if (maybeQmlKeyword(entry)) {
                    // check the previous token
                    if (i == 0 || tokens.at(i - 1).isNot(QmlJS::Token::Dot)) {
                        if (i + 1 == tokens.count() || tokens.at(i + 1).isNot(QmlJS::Token::Colon)) {
                            addKeyword(token.offset, token.length);
                            break;
                        }
                    }
                } else if (i > 0 && maybeQmlBuiltinType(entry)) {
                    const QmlJS::Token &previousToken = tokens.at(i - 1);
                    if (previousToken.is(QmlJS::Token::Identifier)
                        && text.mid(previousToken.offset, previousToken.length) == QLatin1String("property")) {
                        addKeyword(token.offset, token.length);
                        break;
                    }
                }

                if (maybeMacro(entry)) {
                    addMacro(token.offset, token.length);
                    break;
                }

                if (entry.at(0).isUpper()) {
                    // Check if we are importing a module
                    if (i > 0) {
                        const QmlJS::Token &previousToken = tokens.first();
                        if (previousToken.is(QmlJS::Token::Identifier)
                            && text.mid(previousToken.offset, previousToken.length) == QLatin1String("import")) {
                            addKeyword(token.offset, token.length);
                            break;
                        }
                    }

                    addComponent(token.offset, token.length);
                    break;
                }

                // Try to find if it is a property
                // The easy ones are followed by a { or a :
                if (i + 1 < tokens.count()) {
                    const QmlJS::Token &nextToken = tokens.at(i + 1);
                    if (nextToken.is(QmlJS::Token::Colon)
                        || nextToken.is(QmlJS::Token::LeftBrace)) {
                        addIdentifier(token.offset, token.length);
                        break;
                    }
                }

                // A harder one is anchors.fill:
                if (i + 3 < tokens.count()) {
                    const QmlJS::Token &next1Token = tokens.at(i + 1);
                    const QmlJS::Token &next2Token = tokens.at(i + 2);
                    const QmlJS::Token &next3Token = tokens.at(i + 3);

                    if (next1Token.is(QmlJS::Token::Dot)
                        && next2Token.is(QmlJS::Token::Identifier)
                        && (next3Token.is(QmlJS::Token::Colon)
                            || next3Token.is(QmlJS::Token::LeftBrace))) {
                        addIdentifier(token.offset, token.length);
                        break;
                    }
                }
            }
            break;
        case QmlJS::Token::String:
            addString(token.offset, token.length);
            break;
        case QmlJS::Token::Comment:
            addComment(token.offset, token.length);
            break;
        case QmlJS::Token::Number:
            addNumber(token.offset, token.length);
            break;
        default:
            break;
        }
    }

    setState(scanner.state());
    finalize();
}
Ejemplo n.º 4
0
int lineToTokens(const char *line,const char *symtab,const char *outfile,NFA *N,int nfaCount){
	int lbegin=0;
	int bestmatch;
	int match1,match2;
	int Code[MAXNFACOUNT];
	int End[MAXNFACOUNT];
	attrType Attrib[MAXNFACOUNT];
	for(int i=0;i<MAXNFACOUNT;i++){
		Attrib[i].string=(char *)malloc(sizeof(char)*100);
	}
	while(1){
		for(int i=0;i<nfaCount;i++){
			simulate_NFA(&N[i],line,lbegin,&End[i],&Attrib[i]);
		}
		getBestMatch(End,nfaCount,&match1,&match2);
		printf("\nMatch1 = %d\tMatch2 = %d",match1,match2);
		if(match2==-1){
			bestmatch=match1;
		}else if(match1==match2){
			if(getNFAID(&N[match1])==IDNTIFIER){
				bestmatch=match2;
			}else{
				bestmatch=match1;
			}
		}else{
			printf("\nFatal error in matching !!\n");
			exit(-1);
		}
		lbegin=End[bestmatch];
		switch(Code[bestmatch]){
			case IDNTIFIER:{
				addIdentifier(&Attrib[bestmatch],symtab,outfile);
				break;
			}
			case INT_CONST:{
				add_Numerical(&Attrib[bestmatch],symtab,outfile,INT_CONST);
				break;	
			}
			case FLO_CONST:{
				add_Numerical(&Attrib[bestmatch],symtab,outfile,FLO_CONST);
				break;
			}
			case NOTOK:{
				printf("\nLexeme not detected in any of the NFA !!!\n");
				exit(-1);
				// break;
			}
			default:{
				if((Code[bestmatch]>=422)&&(Code[bestmatch]<=445)){
					// treat lexeme as keyword
					addKeyWord(&Attrib[bestmatch],symtab,outfile,code[bestmatch]);
				}else{
					// treat lexeme as symbol
					add_Symbol(&Attrib[bestmatch],symtab,outfile,code[bestmatch]);
				}
			}
		}
		lbegin=End[bestmatch];
		if(line[lbegin]=='\0'){
			// we have reached the End of the current line
			break;
		}
		if(line[lbegin]==' '){
			lbegin++;
			continue;
		}
	}

	for(int i=0;i<MAXNFACOUNT;i++){
		free(Attrib[i].string);
		Attrib[i].string=NULL;
	}
}