Esempio n. 1
0
Lexer::Token Artlink::parse( Lexer* lexer )
{
    Lexer::Token tok( parseAttributes( lexer ) );
    while( tok != Lexer::END ) {
        if( tok == Lexer::TAG ) {
            if( lexer->tagId() == Lexer::LINK ) {
                Link* link( new Link( document, this, document->dataName(),
                            document->lexerLine(), document->lexerCol() ) );
                appendChild( link );
                link->setNoEndTag();
                link->setHypergraphic();
                tok = link->parse( lexer );
            }
            else if( lexer->tagId() == Lexer::EARTLINK || lexer->tagId() == Lexer::EUSERDOC )
                break;
            else
                parseCleanup( lexer, tok );
        }
        else {
            if( tok != Lexer::WHITESPACE )
                printError( ERR1_TAGCONTEXT );
            tok = document->getNextToken();
        }
    }
    return tok;
}
Esempio n. 2
0
Lexer::Token Hdref::parse( Lexer* lexer )
{
    std::wstring refid;
    std::wstring res;
    Lexer::Token tok( document->getNextToken() );
    while( tok != Lexer::TAGEND ) {
        //parse attributes
        if( tok == Lexer::ATTRIBUTE ) {
            std::wstring key;
            std::wstring value;
            splitAttribute( lexer->text(), key, value );
            if( key == L"res" )
                res = value;
            else if( key == L"refid" )
                refid = value;
            else
                document->printError( ERR1_ATTRNOTDEF );
        }
        else if( tok == Lexer::FLAG )
            document->printError( ERR1_ATTRNOTDEF );
        else if( tok == Lexer::ERROR_TAG )
            throw FatalError( ERR_SYNTAX );
        else if( tok == Lexer::END )
            throw FatalError( ERR_EOF );
        else
            document->printError( ERR1_TAGSYNTAX );
        tok = document->getNextToken();
    }
    std::wstring temp( L":link reftype=hd" );
    if( !refid.empty() ) {
        temp += L" refid=";
        temp += refid;
    }
    if( !res.empty() ) {
        temp += L" res=";
        temp += res;
    }
    temp += L'.';
    temp += document->reference();
    temp += L":elink.";
    if( !refid.empty() || !res.empty() ) {
        std::wstring* fname( new std::wstring() );
        prepBufferName( fname, *( document->dataName() ) );
        fname = document->addFileName( fname );
        document->pushInput( new IpfBuffer( fname, document->dataLine(), document->dataCol(), temp ) );
        bool oldBlockParsing( document->blockParsing() );
        document->setBlockParsing( true );
        tok = document->getNextToken(); //first token from buffer
        while( tok != Lexer::END ) {
            if( parseInline( lexer, tok ) )
                parseCleanup( lexer, tok );
        }
        document->setBlockParsing( oldBlockParsing );
        document->popInput();
    }
    return document->getNextToken();    //next token from stream
}
Esempio n. 3
0
Lexer::Token Xmp::parse( Lexer* lexer )
{
    Lexer::Token tok( parseAttributes( lexer ) );
    while( tok != Lexer::END && !( tok == Lexer::TAG && lexer->tagId() == Lexer::EUSERDOC)) {
        if( parseInline( lexer, tok ) ) {
            if( lexer->tagId() == Lexer::EXMP )
                break;
            else
                parseCleanup( lexer, tok );
            }
    }
    return tok;
}
Esempio n. 4
0
Lexer::Token Figcap::parse( Lexer* lexer )
{
    Lexer::Token tok( parseAttributes( lexer) );
    while( tok != Lexer::END ) {
        //may contain inline, not block
        if( tok == Lexer::WORD ) {
            Word* word( new Word( document, this, document->dataName(),
                document->dataLine(), document->dataCol() ) );
            appendChild( word );
            tok = word->parse( lexer );
        }
        else if( tok == Lexer::ENTITY ) {
            Entity* entity( new Entity( document, this, document->dataName(),
                document->dataLine(), document->dataCol() ) );
            appendChild( entity );
            tok = entity->parse( lexer );
        }
        else if( tok == Lexer::PUNCTUATION ) {
            Punctuation* punct( new Punctuation( document, this, document->dataName(),
                document->dataLine(), document->dataCol() ) );
            appendChild( punct );
            tok = punct->parse( lexer );
        }
        else if( tok == Lexer::WHITESPACE ) {
            WhiteSpace* ws( new WhiteSpace( document, this, document->dataName(),
                document->dataLine(), document->dataCol(), Tag::LITERAL ) );
            appendChild( ws );
            tok = ws->parse( lexer );
        }
        else if( tok == Lexer::COMMAND )
            tok = document->processCommand( lexer, this );
        else if( tok == Lexer::TAG ) {
            if( lexer->tagId() == Lexer::EUSERDOC || lexer->tagId() == Lexer::EFIG )
                break;
            else
                parseCleanup( lexer, tok );
        }
        else if( tok == Lexer::ERROR_TAG ) {
            document->printError( ERR1_TAGNOTDEF );
            tok = document->getNextToken();
        }
        else if( tok == Lexer::ERROR_ENTITY ) {
            document->printError( ERR1_TAGNOTDEF );
            tok = document->getNextToken();
        }
    }
    return tok;
}
Esempio n. 5
0
Lexer::Token Fn::parse( Lexer* lexer )
{
    Lexer::Token tok( parseAttributes( lexer ) );
//    bool done( false );
    while( tok != Lexer::END && !( tok == Lexer::TAG && lexer->tagId() == Lexer::EUSERDOC)) {
        if( lexer->tagId() == Lexer::EFN ) {
            tok = Tag::parseAttributes( lexer );
            break;
        }
        else if( parseInline( lexer, tok ) ) {
            if( parseBlock( lexer, tok ) ) {
                if( parseListBlock( lexer, tok ) )
                    parseCleanup( lexer, tok );
            }
        }
    }
    return tok;
}
Esempio n. 6
0
Lexer::Token Caution::parse( Lexer* lexer )
{
    std::wstring temp;
    std::wstring* fname( new std::wstring() );
    prepBufferName( fname, *( document->dataName() ) );
    fname = document->addFileName( fname );
    Lexer::Token tok( document->getNextToken() );
    while( tok != Lexer::TAGEND ) {
        if( tok == Lexer::ATTRIBUTE ) {
            std::wstring key;
            std::wstring value;
            splitAttribute( lexer->text(), key, value );
            if( key == L"text" ) {
                temp = L":hp2.";
                temp += value;
                temp += L":ehp2.\n";
            }
            else
                document->printError( ERR1_ATTRNOTDEF );
        }
        else if( tok == Lexer::FLAG )
            document->printError( ERR1_ATTRNOTDEF );
        else if( tok == Lexer::ERROR_TAG )
            throw FatalError( ERR_SYNTAX );
        else if( tok == Lexer::END )
            throw FatalError( ERR_EOF );
        else
            document->printError( ERR1_TAGSYNTAX );
        tok = document->getNextToken();
    }
    if( temp.empty() ) {
        temp = L":hp2.";
        temp += document->caution();
        temp += L":ehp2.\n";
    }
    document->pushInput( new IpfBuffer( fname, document->dataLine(),
        document->dataCol(), temp ) );
    bool oldBlockParsing( document->blockParsing() );
    document->setBlockParsing( true );
    whiteSpace = Tag::LITERAL;
    appendChild( new P( document, this, document->dataName(), document->lexerLine(),
        document->lexerCol() ) );
    tok = document->getNextToken(); //first token from buffer
    while( tok != Lexer::END ) {
        if( parseInline( lexer, tok ) )
            parseCleanup( lexer, tok );
    }
    whiteSpace = Tag::NONE;
    document->setBlockParsing( oldBlockParsing );
    document->popInput();
    tok = document->getNextToken(); //next token from main stream
    while( tok != Lexer::END && !( tok == Lexer::TAG && lexer->tagId() == Lexer::EUSERDOC)) {
        if( parseInline( lexer, tok ) ) {
            if( lexer->tagId() == Lexer::ECAUTION )
                    break;
            else if( lexer->tagId() == Lexer::H1 ||
                lexer->tagId() == Lexer::H2 ||
                lexer->tagId() == Lexer::H3 ||
                lexer->tagId() == Lexer::H4 ||
                lexer->tagId() == Lexer::H5 ||
                lexer->tagId() == Lexer::H6 ||
                lexer->tagId() == Lexer::ACVIEWPORT ||
                lexer->tagId() == Lexer::FN )
                    parseCleanup( lexer, tok );
            else if( parseBlock( lexer, tok ) ) {
                if( parseListBlock( lexer, tok ) )
                    parseCleanup( lexer, tok );
            }
        }
    }
    return tok;
}