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
10*78bc99aaSAndrew Rist  *
11*78bc99aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*78bc99aaSAndrew Rist  *
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.
19*78bc99aaSAndrew Rist  *
20*78bc99aaSAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include "cx_c_sub.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
28cdf0e10cSrcweir #include <ctype.h>
29cdf0e10cSrcweir #include "c_dealer.hxx"
30cdf0e10cSrcweir #include <tokens/parseinc.hxx>
31cdf0e10cSrcweir #include <x_parse.hxx>
32cdf0e10cSrcweir #include "all_toks.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace cpp {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir void
ReadCharChain(CharacterSource & io_rText)40cdf0e10cSrcweir Context_Comment::ReadCharChain( CharacterSource &	io_rText )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	// KORR_FUTURE
43cdf0e10cSrcweir 	//		Counting of lines must be implemented.
44cdf0e10cSrcweir 	if (bCurrentModeIsMultiline)
45cdf0e10cSrcweir 	{
46cdf0e10cSrcweir 		char cNext = NULCH;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 		do {
49cdf0e10cSrcweir 			do {
50cdf0e10cSrcweir                 cNext = jumpTo( io_rText,'*',char(10) );
51cdf0e10cSrcweir                 if (cNext == NULCH)
52cdf0e10cSrcweir     			    throw X_Parser( X_Parser::x_UnexpectedEOF, "", String::Null_(), 0 );
53cdf0e10cSrcweir                 else if ( cNext == char(10) )
54cdf0e10cSrcweir 				{
55cdf0e10cSrcweir 					jumpOverEol(io_rText);
56cdf0e10cSrcweir                     Dealer().Deal_Eol();
57cdf0e10cSrcweir 				}
58cdf0e10cSrcweir             }   while ( cNext != '*');
59cdf0e10cSrcweir 			cNext = jumpOver(io_rText,'*');
60cdf0e10cSrcweir 			if (cNext == NULCH)
61cdf0e10cSrcweir     			throw X_Parser( X_Parser::x_UnexpectedEOF, "", String::Null_(), 0 );
62cdf0e10cSrcweir 		} while (cNext != '/');
63cdf0e10cSrcweir 		io_rText.MoveOn();
64cdf0e10cSrcweir 		io_rText.CutToken();
65cdf0e10cSrcweir 		SetNewToken(0);
66cdf0e10cSrcweir 	}
67cdf0e10cSrcweir 	else //
68cdf0e10cSrcweir 	{
69cdf0e10cSrcweir         int o_rCount_BackslashedLineBreaks = 0;
70cdf0e10cSrcweir 	    jumpToEol(io_rText,o_rCount_BackslashedLineBreaks);
71cdf0e10cSrcweir         for ( ; o_rCount_BackslashedLineBreaks > 0; --o_rCount_BackslashedLineBreaks )
72cdf0e10cSrcweir             Dealer().Deal_Eol();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 		if (io_rText.CurChar() != NULCH)
75cdf0e10cSrcweir 			jumpOverEol(io_rText);
76cdf0e10cSrcweir 		io_rText.CutToken();
77cdf0e10cSrcweir         Dealer().Deal_Eol();
78cdf0e10cSrcweir 		SetNewToken(0);
79cdf0e10cSrcweir 	}  // endif
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 
83cdf0e10cSrcweir void
ReadCharChain(CharacterSource & io_rText)84cdf0e10cSrcweir Context_ConstString::ReadCharChain( CharacterSource &	io_rText )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	char cNext = io_rText.MoveOn();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	while (cNext != '"')
89cdf0e10cSrcweir 	{ 	// Get one complete string constant:  "...."
90cdf0e10cSrcweir 		while (cNext != '"' AND cNext != '\\')
91cdf0e10cSrcweir 		{	// Get string till next '\\'
92cdf0e10cSrcweir 			cNext = io_rText.MoveOn();
93cdf0e10cSrcweir 		}
94cdf0e10cSrcweir 		if (cNext == '\\')
95cdf0e10cSrcweir 		{
96cdf0e10cSrcweir 			io_rText.MoveOn();
97cdf0e10cSrcweir 			cNext = io_rText.MoveOn();
98cdf0e10cSrcweir 		}
99cdf0e10cSrcweir 	}
100cdf0e10cSrcweir 	io_rText.MoveOn();
101cdf0e10cSrcweir 	SetNewToken(new Tok_Constant(io_rText.CutToken()));
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir void
ReadCharChain(CharacterSource & io_rText)105cdf0e10cSrcweir Context_ConstChar::ReadCharChain( CharacterSource &	io_rText )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	char cNext = io_rText.MoveOn();
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	while (cNext != '\'')
110cdf0e10cSrcweir 	{ 	// Get one complete char constant:  "...."
111cdf0e10cSrcweir 		while (cNext != '\'' AND cNext != '\\')
112cdf0e10cSrcweir 		{	// Get string till next '\\'
113cdf0e10cSrcweir 			cNext = io_rText.MoveOn();
114cdf0e10cSrcweir 		}
115cdf0e10cSrcweir 		if (cNext == '\\')
116cdf0e10cSrcweir 		{
117cdf0e10cSrcweir 			io_rText.MoveOn();
118cdf0e10cSrcweir 			cNext = io_rText.MoveOn();
119cdf0e10cSrcweir 		}
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir 	io_rText.MoveOn();
122cdf0e10cSrcweir 	SetNewToken(new Tok_Constant(io_rText.CutToken()));
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir void
ReadCharChain(CharacterSource & io_rText)126cdf0e10cSrcweir Context_ConstNumeric::ReadCharChain(CharacterSource & io_rText)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	char cNext = 0;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	do {
131cdf0e10cSrcweir 		do {
132cdf0e10cSrcweir 			cNext = static_cast<char>( tolower(io_rText.MoveOn()) );
133cdf0e10cSrcweir 		} while ( (cNext != 'e' AND isalnum(cNext)) OR cNext == '.');
134cdf0e10cSrcweir 		if (cNext == 'e')
135cdf0e10cSrcweir 		{
136cdf0e10cSrcweir 			cNext = io_rText.MoveOn();
137cdf0e10cSrcweir 			if (cNext == '+' OR cNext == '-')
138cdf0e10cSrcweir 				cNext = io_rText.MoveOn();
139cdf0e10cSrcweir 		}	// endif
140cdf0e10cSrcweir 	} while (isalnum(cNext) OR cNext == '.');     // Reicht aus, wenn Zahlen korrekt geschrieben sind
141cdf0e10cSrcweir 	SetNewToken(new Tok_Constant(io_rText.CutToken()));
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir void
ReadCharChain(CharacterSource & io_rText)145cdf0e10cSrcweir Context_UnblockMacro::ReadCharChain(CharacterSource & io_rText)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	jumpToWhite(io_rText);
148cdf0e10cSrcweir 	SetNewToken(new Tok_UnblockMacro( io_rText.CutToken() + strlen("#unblock-") ));
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir }   // namespace cpp
152