示例#1
0
文件: MorkParser.cpp 项目: KDE/kdepim
bool MorkParser::parseTable()
{
    bool Result = true;
    QString TextId;
    int Id = 0, Scope = 0;

    char cur = nextChar();

    // Get id
    while (cur != '{' && cur != '[' && cur != '}' && cur) {
        if (!isWhiteSpace(cur)) {
            TextId += cur;
        }

        cur = nextChar();
    }

    parseScopeId(TextId, Id, Scope);

    // Parse the table
    while (Result && cur != '}' && cur) {
        if (!isWhiteSpace(cur)) {
            switch (cur) {
            case '{':
                Result = parseMeta('}');
                break;
            case '[':
                Result = parseRow(Id, Scope);
                break;
            case '-':
            case '+':
                break;
            default: {
                QString JustId;
                while (!isWhiteSpace(cur) && cur) {
                    JustId += cur;
                    cur = nextChar();

                    if (cur == '}') {
                        return Result;
                    }
                }

                int JustIdNum = 0, JustScopeNum = 0;
                parseScopeId(JustId, JustIdNum, JustScopeNum);

                setCurrentRow(Scope, Id, JustScopeNum, JustIdNum);
            }
            break;
            }
        }

        cur = nextChar();
    }

    return Result;
}
示例#2
0
bool MorkParser::parseRow( int TableId, int TableScope )
{
	bool Result = true;
	std::string TextId;
	int Id = 0, Scope = 0;
	nowParsing_ = NPRows;

	char cur = nextChar();

	// Get id
	while ( cur != '(' && cur != ']' && cur != '[' && cur )
	{
		if ( !isWhiteSpace( cur ) )
		{
			TextId += cur;
		}

		cur = nextChar();
	}

	parseScopeId( TextId, &Id, &Scope );
	setCurrentRow( TableScope, TableId, Scope, Id );

	// Parse the row
	while ( Result && cur != ']' && cur )
	{
		if ( !isWhiteSpace( cur ) )
		{
			switch ( cur )
			{
			case '(':
				Result = parseCell();
				break;
			case '[':
				Result = parseMeta( ']' );
				break;
			default:
				Result = false;
				break;
			}
		}

		cur = nextChar();
	}

	return Result;
}