1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "cx_c_sub.hxx"
30 
31 
32 
33 // NOT FULLY DECLARED SERVICES
34 #include <ctype.h>
35 #include "c_dealer.hxx"
36 #include <tokens/parseinc.hxx>
37 #include <x_parse.hxx>
38 #include "all_toks.hxx"
39 
40 
41 namespace cpp {
42 
43 
44 
45 void
46 Context_Comment::ReadCharChain( CharacterSource &	io_rText )
47 {
48 	// KORR_FUTURE
49 	//		Counting of lines must be implemented.
50 	if (bCurrentModeIsMultiline)
51 	{
52 		char cNext = NULCH;
53 
54 		do {
55 			do {
56                 cNext = jumpTo( io_rText,'*',char(10) );
57                 if (cNext == NULCH)
58     			    throw X_Parser( X_Parser::x_UnexpectedEOF, "", String::Null_(), 0 );
59                 else if ( cNext == char(10) )
60 				{
61 					jumpOverEol(io_rText);
62                     Dealer().Deal_Eol();
63 				}
64             }   while ( cNext != '*');
65 			cNext = jumpOver(io_rText,'*');
66 			if (cNext == NULCH)
67     			throw X_Parser( X_Parser::x_UnexpectedEOF, "", String::Null_(), 0 );
68 		} while (cNext != '/');
69 		io_rText.MoveOn();
70 		io_rText.CutToken();
71 		SetNewToken(0);
72 	}
73 	else //
74 	{
75         int o_rCount_BackslashedLineBreaks = 0;
76 	    jumpToEol(io_rText,o_rCount_BackslashedLineBreaks);
77         for ( ; o_rCount_BackslashedLineBreaks > 0; --o_rCount_BackslashedLineBreaks )
78             Dealer().Deal_Eol();
79 
80 		if (io_rText.CurChar() != NULCH)
81 			jumpOverEol(io_rText);
82 		io_rText.CutToken();
83         Dealer().Deal_Eol();
84 		SetNewToken(0);
85 	}  // endif
86 }
87 
88 
89 void
90 Context_ConstString::ReadCharChain( CharacterSource &	io_rText )
91 {
92 	char cNext = io_rText.MoveOn();
93 
94 	while (cNext != '"')
95 	{ 	// Get one complete string constant:  "...."
96 		while (cNext != '"' AND cNext != '\\')
97 		{	// Get string till next '\\'
98 			cNext = io_rText.MoveOn();
99 		}
100 		if (cNext == '\\')
101 		{
102 			io_rText.MoveOn();
103 			cNext = io_rText.MoveOn();
104 		}
105 	}
106 	io_rText.MoveOn();
107 	SetNewToken(new Tok_Constant(io_rText.CutToken()));
108 }
109 
110 void
111 Context_ConstChar::ReadCharChain( CharacterSource &	io_rText )
112 {
113 	char cNext = io_rText.MoveOn();
114 
115 	while (cNext != '\'')
116 	{ 	// Get one complete char constant:  "...."
117 		while (cNext != '\'' AND cNext != '\\')
118 		{	// Get string till next '\\'
119 			cNext = io_rText.MoveOn();
120 		}
121 		if (cNext == '\\')
122 		{
123 			io_rText.MoveOn();
124 			cNext = io_rText.MoveOn();
125 		}
126 	}
127 	io_rText.MoveOn();
128 	SetNewToken(new Tok_Constant(io_rText.CutToken()));
129 }
130 
131 void
132 Context_ConstNumeric::ReadCharChain(CharacterSource & io_rText)
133 {
134 	char cNext = 0;
135 
136 	do {
137 		do {
138 			cNext = static_cast<char>( tolower(io_rText.MoveOn()) );
139 		} while ( (cNext != 'e' AND isalnum(cNext)) OR cNext == '.');
140 		if (cNext == 'e')
141 		{
142 			cNext = io_rText.MoveOn();
143 			if (cNext == '+' OR cNext == '-')
144 				cNext = io_rText.MoveOn();
145 		}	// endif
146 	} while (isalnum(cNext) OR cNext == '.');     // Reicht aus, wenn Zahlen korrekt geschrieben sind
147 	SetNewToken(new Tok_Constant(io_rText.CutToken()));
148 }
149 
150 void
151 Context_UnblockMacro::ReadCharChain(CharacterSource & io_rText)
152 {
153 	jumpToWhite(io_rText);
154 	SetNewToken(new Tok_UnblockMacro( io_rText.CutToken() + strlen("#unblock-") ));
155 }
156 
157 }   // namespace cpp
158