Exemplo n.º 1
0
    Entry * createEntry()
    {
        Entry * entry = new Entry();

        entry->protection = Public ;
        entry->virt       = Normal;
        entry->stat       = false;
        entry->lang       = SrcLangExt_XML;
        entry->spec       = 0;

        entry->fileName  = m_fileName;
        entry->startLine = lineNumber();
        entry->bodyLine = lineNumber();

        entry->callGraph = false;
        entry->callerGraph = false;

        initGroupInfo(entry);

        m_currentEntry = entry;

        handleComment();

        return entry;
    }
Exemplo n.º 2
0
    bool comment(const QString & comment_)
    {
        if (m_currentComment)
        { handleComment(); }

        m_currentComment = new CommentData(m_fileName, lineNumber(), comment_.utf8());

        if (m_currentComment->shouldIgnore)
        {
            delete m_currentComment;
            m_currentComment = 0;
            return true;
        }

        if (m_currentComment->associateWithPrevious)
        { handleComment(); }

        return true;
    }
Exemplo n.º 3
0
Token Scanner::getToken()
{
	/*
		Reads the next available character and dispatches to the
		appropriate FSA for them to parse. 
	*/		


	// do not return MP_COMMENT to the parser
	do 
	{	
		// detect EOF and skip whitespace
		hasToken();	
		char next = peek();	

		// reset the TOKEN and LEXEME variables, FSA will set new values
		_token = MP_NULL;
		_lexeme = "";

		// which FSA to call 
		if (next == '\'') // handle strings, start with ' (single quote)
			handleString();
		else if (isdigit(next))
			handleNumberic();
		else if (isalpha(next) || next=='_' ) // check for identifier
			handleWord();
		else if (next == '{' || next == '}') // handle comments first becuase {} are considered punctation
			handleComment();
		else if (ispunct(next))
			handleSymbol();
		else if (next == EOF) {
			_token = MP_EOF;
			_lexeme = get();
		}
	} while (_token == MP_COMMENT);

	return _token; 
};
Exemplo n.º 4
0
void DOMSerializer::handleNode(const Node* pNode) const
{
	switch (pNode->nodeType())
	{
	case Node::ELEMENT_NODE:
		handleElement(static_cast<const Element*>(pNode)); 
		break;
	case Node::TEXT_NODE:
		handleCharacterData(static_cast<const Text*>(pNode)); 
		break;
	case Node::CDATA_SECTION_NODE:
		handleCDATASection(static_cast<const CDATASection*>(pNode)); 
		break;
	case Node::ENTITY_NODE:
		handleEntity(static_cast<const Entity*>(pNode));
		break;
	case Node::PROCESSING_INSTRUCTION_NODE:
		handlePI(static_cast<const ProcessingInstruction*>(pNode)); 
		break;
	case Node::COMMENT_NODE:
		handleComment(static_cast<const Comment*>(pNode)); 
		break;
	case Node::DOCUMENT_NODE:
		handleDocument(static_cast<const Document*>(pNode)); 
		break;
	case Node::DOCUMENT_TYPE_NODE:
		handleDocumentType(static_cast<const DocumentType*>(pNode));
		break;
	case Node::DOCUMENT_FRAGMENT_NODE:
		handleFragment(static_cast<const DocumentFragment*>(pNode));
		break;
	case Node::NOTATION_NODE:
		handleNotation(static_cast<const Notation*>(pNode));
		break;
	}
}
Exemplo n.º 5
0
/*  filePreset
 *
 *  Load a file containing presetting information (a configuration file).
 */
static void
filePreset(
    tOptions*     pOpts,
    char const*   pzFileName,
    int           direction )
{
    tmap_info_t   cfgfile;
    tOptState     st = OPTSTATE_INITIALIZER(PRESET);
    char*         pzFileText =
        text_mmap( pzFileName, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile );

    if (TEXT_MMAP_FAILED_ADDR(pzFileText))
        return;

    if (direction == DIRECTION_CALLED) {
        st.flags  = OPTST_DEFINED;
        direction = DIRECTION_PROCESS;
    }

    /*
     *  IF this is called via "optionProcess", then we are presetting.
     *  This is the default and the PRESETTING bit will be set.
     *  If this is called via "optionFileLoad", then the bit is not set
     *  and we consider stuff set herein to be "set" by the client program.
     */
    if ((pOpts->fOptSet & OPTPROC_PRESETTING) == 0)
        st.flags = OPTST_SET;

    do  {
        while (isspace( (int)*pzFileText ))  pzFileText++;

        if (isalpha( (int)*pzFileText )) {
            pzFileText = handleConfig( pOpts, &st, pzFileText, direction );

        } else switch (*pzFileText) {
        case '<':
            if (isalpha( (int)pzFileText[1] ))
                pzFileText = handleStructure(pOpts, &st, pzFileText, direction);

            else switch (pzFileText[1]) {
            case '?':
                pzFileText = handleDirective( pOpts, pzFileText );
                break;

            case '!':
                pzFileText = handleComment( pzFileText );
                break;

            case '/':
                pzFileText = strchr( pzFileText+2, '>' );
                if (pzFileText++ != NULL)
                    break;

            default:
                goto all_done;
            }
            break;

        case '[':
            pzFileText = handleProgramSection( pOpts, pzFileText );
            break;

        case '#':
            pzFileText = strchr( pzFileText+1, '\n' );
            break;

        default:
            goto all_done; /* invalid format */
        }
    } while (pzFileText != NULL);

 all_done:
    text_munmap( &cfgfile );
}
Exemplo n.º 6
0
void POExtractor::handleLine(const char* data, uint32_t length)
{
    if (state == ERROR) return;
    if (state == WHITESPACE) {
        if (length == 0) return;
        if (data[0] != '#') {
            state = COMMENT; //this allows PO files w/o comments
        } else {
            handleComment(data, length);
            return;
        }
    }
    if (state == COMMENT) {
        if (length == 0) {
            state = WHITESPACE;
        } else if (data[0] == '#') {
            handleComment(data, length);
        } else if (length > 7 && strncmp("msgctxt", data, 7) == 0) {
            state = MSGCTXT;
        } else if (length > 7 && strncmp("msgid \"", data, 7) == 0) {
            state = MSGID;
        } else {
            state = ERROR;
        }
        return;
    } else if (length > 1 && data[0] == '"' && data[length-1] == '"'
            && (state == MSGCTXT || state == MSGID || state == MSGSTR
                || state == MSGID_PLURAL)) {
        // continued text field
        isTranslated = state == MSGSTR && length > 2;
    } else if (state == MSGCTXT
            && length > 7 && strncmp("msgid \"", data, 7) == 0) {
        state = MSGID;
    } else if (state == MSGID
            && length > 14 && strncmp("msgid_plural \"", data, 14) == 0) {
        state = MSGID_PLURAL;
    } else if ((state == MSGID || state == MSGID_PLURAL || state == MSGSTR)
            && length > 8 && strncmp("msgstr", data, 6) == 0) {
        state = MSGSTR;
        isTranslated = strncmp(data+length-3, " \"\"", 3) != 0;
    } else if (state == MSGSTR) {
        if (length == 0) {
            endMessage();
        } else if (data[0]=='#' || data[0]=='m') { //allow PO without empty line between entries
            endMessage();
            state = COMMENT;
            handleLine(data, length);
        } else {
            state = ERROR;
        }
    } else {
        state = ERROR;
    }
#if 0
    if (messages > 1 || state != MSGSTR) return;

    // handle special values in the first messsage
    // assumption is that value takes up only one line
    if (strncmp("\"POT-Creation-Date: ", data, 20) == 0) {
        result->add(Property::TranslationTemplateDate, QByteArray(data + 20, length - 21));
    } else if (strncmp("\"PO-Revision-Date: ", data, 19) == 0) {
        result->add(Property::TranslationLastUpDate, QByteArray(data + 19, length - 20));
    } else if (strncmp("\"Last-Translator: ", data, 18) == 0) {
        result->add(Property::TranslationLastAuthor, QByteArray(data + 18, length - 19));
    }
#endif
}
Exemplo n.º 7
0
    virtual void customSetup(void)
    {
        QMenu *edit = toMainWidget()->getEditMenu();

        edit->addSeparator();

        IncMenu = edit->addMenu(
                      qApp->translate("toEditExtensionTool", "Incremental Search"));

        IncrementalSearch = IncMenu->addAction(qApp->translate("toEditExtensionTool",
                                               "Forward"),
                                               &toEditExtensionsSingle::Instance(),
                                               SLOT(searchForward()));
        IncrementalSearch->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S);

        ReverseSearch = IncMenu->addAction(qApp->translate("toEditExtensionTool",
                                           "Backward"),
                                           &toEditExtensionsSingle::Instance(),
                                           SLOT(searchBackward()));
        ReverseSearch->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_R);

        // ------------------------------ indentation menu

        IndentMenu = edit->addMenu(
                         qApp->translate("toEditExtensionTool", "Auto Indent"));

        IndentBlock = IndentMenu->addAction(qApp->translate(
                                                "toEditExtensionTool",
                                                "Selection"),
                                            &toEditExtensionsSingle::Instance(),
                                            SLOT(autoIndentBlock()));
        IndentBlock->setShortcut(Qt::CTRL + + Qt::ALT + Qt::Key_I);

        IndentBuffer = IndentMenu->addAction(qApp->translate(
                "toEditExtensionTool",
                "Editor"),
                                             &toEditExtensionsSingle::Instance(),
                                             SLOT(autoIndentBuffer()));
        IndentBuffer->setShortcut(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_I);

        IndentMenu->addSeparator();

        ObsBlock = IndentMenu->addAction(qApp->translate(
                                             "toEditExtensionTool",
                                             "Obfuscate Selection"),
                                         &toEditExtensionsSingle::Instance(),
                                         SLOT(obfuscateBlock()));

        ObsBuffer = IndentMenu->addAction(qApp->translate("toEditExtensionTool",
                                          "Obfuscate Editor"),
                                          &toEditExtensionsSingle::Instance(),
                                          SLOT(obfuscateBuffer()));

        // ------------------------------ case menu

        CaseMenu = edit->addMenu(
                       qApp->translate("toEditExtensionTool", "Modify Case"));

        UpperCase = CaseMenu->addAction(qApp->translate("toEditExtensionTool",
                                        "Upper"),
                                        &toEditExtensionsSingle::Instance(),
                                        SLOT(upperCase()));
        UpperCase->setShortcut(Qt::CTRL + Qt::Key_U);

        LowerCase = CaseMenu->addAction(qApp->translate("toEditExtensionTool",
                                        "Lower"),
                                        &toEditExtensionsSingle::Instance(),
                                        SLOT(lowerCase()));
        LowerCase->setShortcut(Qt::CTRL + Qt::Key_L);

        // bookmark menu
        BookmarkMenu = edit->addMenu(qApp->translate("toEditExtensionTool", "Bookmarks"));
        BookmarkSwitchAct = BookmarkMenu->addAction("Add/Remove Bookmark",
                            &toEditExtensionsSingle::Instance(),
                            SLOT(bookmarkSwitch()));
        BookmarkSwitchAct->setShortcut(Qt::CTRL + Qt::Key_B);
        BookmarkPrevAct = BookmarkMenu->addAction("Go to previous Bookmark",
                          &toEditExtensionsSingle::Instance(),
                          SLOT(bookmarkPrev()));
        BookmarkPrevAct->setShortcut(Qt::ALT + Qt::Key_PageUp);
        BookmarkNextAct = BookmarkMenu->addAction("Go to next Bookmark",
                          &toEditExtensionsSingle::Instance(),
                          SLOT(bookmarkNext()));
        BookmarkNextAct->setShortcut(Qt::ALT + Qt::Key_PageDown);

        // EOL menu
        EolMenu = edit->addMenu(qApp->translate("toEditExtensionTool", "Convert End of Lines to"));
        EolUnixAct = EolMenu->addAction("UNIX", &toEditExtensionsSingle::Instance(), SLOT(convertEol()));
        EolMacAct = EolMenu->addAction("Mac OS X", &toEditExtensionsSingle::Instance(), SLOT(convertEol()));
        EolWindowsAct = EolMenu->addAction("MS Windows", &toEditExtensionsSingle::Instance(), SLOT(convertEol()));

        // ------------------------------ etc

        Indent = edit->addAction(
                     QIcon(QPixmap(const_cast<const char**>(indent_xpm))),
                     qApp->translate("toEditExtensionTool", "Indent Block"),
                     &toEditExtensionsSingle::Instance(),
                     SLOT(indentBlock()));
#ifndef Q_WS_MAC
        Indent->setShortcut(Qt::ALT + Qt::Key_Right);
#endif

        Deindent = edit->addAction(
                       QIcon(QPixmap(const_cast<const char**>(deindent_xpm))),
                       qApp->translate("toEditExtensionTool", "De-indent Block"),
                       &toEditExtensionsSingle::Instance(),
                       SLOT(deindentBlock()));
#ifndef Q_WS_MAC
        Deindent->setShortcut(Qt::ALT + Qt::Key_Left);
#endif

        Quote = edit->addAction(qApp->translate("toEditExtensionTool",
                                                "Quote Selection"),
                                &toEditExtensionsSingle::Instance(),
                                SLOT(quoteBlock()));

        UnQuote = edit->addAction(qApp->translate("toEditExtensionTool",
                                  "UnQuote Selection"),
                                  &toEditExtensionsSingle::Instance(),
                                  SLOT(unquoteBlock()));

        Comment = edit->addAction(qApp->translate("toEditExtensionTool",
                                  "Comment or Uncomment"),
                                  &toEditExtensionsSingle::Instance(),
                                  SLOT(handleComment()),
                                  Qt::CTRL + Qt::Key_D);

        GotoLine = edit->addAction(qApp->translate("toEditExtensionTool",
                                   "Goto Line"),
                                   &toEditExtensionsSingle::Instance(),
                                   SLOT(gotoLine()));
        GotoLine->setShortcut(Qt::CTRL + Qt::Key_G);

        AutoComplete = edit->addAction(
                           qApp->translate("toEditExtensionTool",
                                           "Complete"),
                           &toEditExtensionsSingle::Instance(),
                           SLOT(autoComplete()));
        AutoComplete->setShortcut(Qt::CTRL + Qt::Key_Space);

        // add buttons to main window
        // disabled due the problems in the state of toolbars
//         toMainWidget()->addButtonApplication(Deindent);
//         toMainWidget()->addButtonApplication(Indent);

        toEditExtensionsSingle::Instance().receivedFocus(NULL);

        connect(toMainWidget(),
                SIGNAL(editEnabled(bool)),
                &toEditExtensionsSingle::Instance(),
                SLOT(editEnabled(bool)));
    }