1*78bc99aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*78bc99aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*78bc99aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*78bc99aaSAndrew Rist * distributed with this work for additional information 6*78bc99aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*78bc99aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*78bc99aaSAndrew Rist * "License"); you may not use this file except in compliance 9*78bc99aaSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*78bc99aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*78bc99aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*78bc99aaSAndrew Rist * software distributed under the License is distributed on an 15*78bc99aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*78bc99aaSAndrew Rist * KIND, either express or implied. See the License for the 17*78bc99aaSAndrew Rist * specific language governing permissions and limitations 18*78bc99aaSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*78bc99aaSAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22cdf0e10cSrcweir #include <precomp.h> 23cdf0e10cSrcweir #include <s2_dsapi/cx_docu2.hxx> 24cdf0e10cSrcweir 25cdf0e10cSrcweir 26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 27cdf0e10cSrcweir #include <../../parser/inc/tokens/parseinc.hxx> 28cdf0e10cSrcweir #include <s2_dsapi/tokrecv.hxx> 29cdf0e10cSrcweir #include <s2_dsapi/tk_html.hxx> 30cdf0e10cSrcweir #include <s2_dsapi/tk_xml.hxx> 31cdf0e10cSrcweir #include <s2_dsapi/tk_docw2.hxx> 32cdf0e10cSrcweir #include <x_parse2.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace csi 37cdf0e10cSrcweir { 38cdf0e10cSrcweir namespace dsapi 39cdf0e10cSrcweir { 40cdf0e10cSrcweir 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir bool 44cdf0e10cSrcweir Cx_Base::PassNewToken() 45cdf0e10cSrcweir { 46cdf0e10cSrcweir if (pNewToken) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir rReceiver.Receive(*pNewToken.Release()); 49cdf0e10cSrcweir 50cdf0e10cSrcweir return true; 51cdf0e10cSrcweir } 52cdf0e10cSrcweir return false; 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir TkpContext & 56cdf0e10cSrcweir Cx_Base::FollowUpContext() 57cdf0e10cSrcweir { 58cdf0e10cSrcweir csv_assert(pFollowUpContext != 0); 59cdf0e10cSrcweir return *pFollowUpContext; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir void 63cdf0e10cSrcweir Cx_Base::Handle_DocuSyntaxError( CharacterSource & io_rText ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir // KORR_FUTURE 66cdf0e10cSrcweir // Put this into Error Log File 67cdf0e10cSrcweir 68cdf0e10cSrcweir Cerr() << "Error: Syntax error in documentation within " 69cdf0e10cSrcweir << "this text:\n\"" 70cdf0e10cSrcweir << io_rText.CutToken() 71cdf0e10cSrcweir << "\"." 72cdf0e10cSrcweir << Endl(); 73cdf0e10cSrcweir SetToken( new Tok_Word(io_rText.CurToken()) ); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir void 77cdf0e10cSrcweir Cx_EoHtml::ReadCharChain( CharacterSource & io_rText ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir if ( NULCH == jumpTo(io_rText,'>') ) 80cdf0e10cSrcweir throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); 81cdf0e10cSrcweir io_rText.MoveOn(); 82cdf0e10cSrcweir SetToken(new Tok_HtmlTag(io_rText.CutToken(),bToken_IsStartOfParagraph)); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir void 86cdf0e10cSrcweir Cx_EoXmlConst::ReadCharChain( CharacterSource & io_rText ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir char c = jumpTo(io_rText,'>','*'); 89cdf0e10cSrcweir if ( NULCH == c OR '*' == c ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 92cdf0e10cSrcweir return; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir io_rText.MoveOn(); 96cdf0e10cSrcweir io_rText.CutToken(); 97cdf0e10cSrcweir SetToken(new Tok_XmlConst(eTokenId)); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir void 101cdf0e10cSrcweir Cx_EoXmlLink_BeginTag::ReadCharChain( CharacterSource & io_rText ) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir String sScope; 104cdf0e10cSrcweir String sDim; 105cdf0e10cSrcweir 106cdf0e10cSrcweir do { 107cdf0e10cSrcweir char cReached = jumpTo(io_rText,'"','>','*'); 108cdf0e10cSrcweir switch (cReached) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir case '"': 111cdf0e10cSrcweir { 112cdf0e10cSrcweir io_rText.MoveOn(); 113cdf0e10cSrcweir io_rText.CutToken(); 114cdf0e10cSrcweir char c = jumpTo(io_rText,'"','*', '>'); 115cdf0e10cSrcweir if ( NULCH == c OR '*' == c OR '>' == c) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir if ( '>' == c ) 118cdf0e10cSrcweir io_rText.MoveOn(); 119cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 120cdf0e10cSrcweir return; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir const char * pAttribute = io_rText.CutToken(); 124cdf0e10cSrcweir if ( *pAttribute != '[' ) 125cdf0e10cSrcweir sScope = pAttribute; 126cdf0e10cSrcweir else 127cdf0e10cSrcweir sDim = pAttribute; 128cdf0e10cSrcweir 129cdf0e10cSrcweir io_rText.MoveOn(); 130cdf0e10cSrcweir break; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir case '>': 133cdf0e10cSrcweir break; 134cdf0e10cSrcweir case '*': 135cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 136cdf0e10cSrcweir return; 137cdf0e10cSrcweir default: 138cdf0e10cSrcweir throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); 139cdf0e10cSrcweir } // end switch 140cdf0e10cSrcweir } while ( io_rText.CurChar() != '>' ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir io_rText.MoveOn(); 143cdf0e10cSrcweir io_rText.CutToken(); 144cdf0e10cSrcweir SetToken( new Tok_XmlLink_BeginTag(eTokenId, sScope.c_str(), sDim.c_str()) ); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir void 148cdf0e10cSrcweir Cx_EoXmlLink_EndTag::ReadCharChain( CharacterSource & io_rText ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir char c = jumpTo(io_rText,'>','*'); 151cdf0e10cSrcweir if ( NULCH == c OR '*' == c ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 154cdf0e10cSrcweir return; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir io_rText.MoveOn(); 158cdf0e10cSrcweir io_rText.CutToken(); 159cdf0e10cSrcweir SetToken(new Tok_XmlLink_EndTag(eTokenId)); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir void 163cdf0e10cSrcweir Cx_EoXmlFormat_BeginTag::ReadCharChain( CharacterSource & io_rText ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir String sDim; 166cdf0e10cSrcweir 167cdf0e10cSrcweir char cReached = jumpTo(io_rText,'"','>','*'); 168cdf0e10cSrcweir switch (cReached) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir case '"': 171cdf0e10cSrcweir { 172cdf0e10cSrcweir io_rText.MoveOn(); 173cdf0e10cSrcweir io_rText.CutToken(); 174cdf0e10cSrcweir 175cdf0e10cSrcweir char c = jumpTo(io_rText,'"','*','>'); 176cdf0e10cSrcweir if ( NULCH == c OR '*' == c OR '>' == c ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir if ('>' == c ) 179cdf0e10cSrcweir io_rText.MoveOn(); 180cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 181cdf0e10cSrcweir return; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir sDim = io_rText.CutToken(); 185cdf0e10cSrcweir 186cdf0e10cSrcweir c = jumpTo(io_rText,'>','*'); 187cdf0e10cSrcweir if ( NULCH == c OR '*' == c ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 190cdf0e10cSrcweir return; 191cdf0e10cSrcweir } 192cdf0e10cSrcweir break; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir case '>': 195cdf0e10cSrcweir break; 196cdf0e10cSrcweir case '*': 197cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 198cdf0e10cSrcweir return; 199cdf0e10cSrcweir default: 200cdf0e10cSrcweir throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); 201cdf0e10cSrcweir } // end switch 202cdf0e10cSrcweir 203cdf0e10cSrcweir io_rText.MoveOn(); 204cdf0e10cSrcweir io_rText.CutToken(); 205cdf0e10cSrcweir SetToken(new Tok_XmlFormat_BeginTag(eTokenId, sDim)); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir void 209cdf0e10cSrcweir Cx_EoXmlFormat_EndTag::ReadCharChain( CharacterSource & io_rText ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir char c = jumpTo(io_rText,'>','*'); 212cdf0e10cSrcweir if ( NULCH == c OR '*' == c ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir Handle_DocuSyntaxError(io_rText); 215cdf0e10cSrcweir return; 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir io_rText.MoveOn(); 219cdf0e10cSrcweir io_rText.CutToken(); 220cdf0e10cSrcweir SetToken(new Tok_XmlFormat_EndTag(eTokenId)); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir void 224cdf0e10cSrcweir Cx_CheckStar::ReadCharChain( CharacterSource & io_rText ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir bEndTokenFound = false; 227cdf0e10cSrcweir if (bIsEnd) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir char cNext = jumpOver(io_rText,'*'); 230cdf0e10cSrcweir if ( NULCH == cNext ) 231cdf0e10cSrcweir throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); 232cdf0e10cSrcweir if (cNext == '/') 233cdf0e10cSrcweir { 234cdf0e10cSrcweir io_rText.MoveOn(); 235cdf0e10cSrcweir SetToken(new Tok_DocuEnd); 236cdf0e10cSrcweir bEndTokenFound = true; 237cdf0e10cSrcweir } 238cdf0e10cSrcweir else 239cdf0e10cSrcweir { 240cdf0e10cSrcweir SetToken( new Tok_Word(io_rText.CutToken()) ); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir } 243cdf0e10cSrcweir else 244cdf0e10cSrcweir { 245cdf0e10cSrcweir jumpToWhite(io_rText); 246cdf0e10cSrcweir SetToken( new Tok_Word(io_rText.CutToken()) ); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir TkpContext & 251cdf0e10cSrcweir Cx_CheckStar::FollowUpContext() 252cdf0e10cSrcweir { 253cdf0e10cSrcweir if (bEndTokenFound) 254cdf0e10cSrcweir return *pEnd_FollowUpContext; 255cdf0e10cSrcweir else 256cdf0e10cSrcweir return Cx_Base::FollowUpContext(); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir } // namespace dsapi 260cdf0e10cSrcweir } // namespace csi 261cdf0e10cSrcweir 262