1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include <precomp.h>
23 #include "cx_c_sub.hxx"
24
25
26
27 // NOT FULLY DECLARED SERVICES
28 #include <ctype.h>
29 #include "c_dealer.hxx"
30 #include <tokens/parseinc.hxx>
31 #include <x_parse.hxx>
32 #include "all_toks.hxx"
33
34
35 namespace cpp {
36
37
38
39 void
ReadCharChain(CharacterSource & io_rText)40 Context_Comment::ReadCharChain( CharacterSource & io_rText )
41 {
42 // KORR_FUTURE
43 // Counting of lines must be implemented.
44 if (bCurrentModeIsMultiline)
45 {
46 char cNext = NULCH;
47
48 do {
49 do {
50 cNext = jumpTo( io_rText,'*',char(10) );
51 if (cNext == NULCH)
52 throw X_Parser( X_Parser::x_UnexpectedEOF, "", String::Null_(), 0 );
53 else if ( cNext == char(10) )
54 {
55 jumpOverEol(io_rText);
56 Dealer().Deal_Eol();
57 }
58 } while ( cNext != '*');
59 cNext = jumpOver(io_rText,'*');
60 if (cNext == NULCH)
61 throw X_Parser( X_Parser::x_UnexpectedEOF, "", String::Null_(), 0 );
62 } while (cNext != '/');
63 io_rText.MoveOn();
64 io_rText.CutToken();
65 SetNewToken(0);
66 }
67 else //
68 {
69 int o_rCount_BackslashedLineBreaks = 0;
70 jumpToEol(io_rText,o_rCount_BackslashedLineBreaks);
71 for ( ; o_rCount_BackslashedLineBreaks > 0; --o_rCount_BackslashedLineBreaks )
72 Dealer().Deal_Eol();
73
74 if (io_rText.CurChar() != NULCH)
75 jumpOverEol(io_rText);
76 io_rText.CutToken();
77 Dealer().Deal_Eol();
78 SetNewToken(0);
79 } // endif
80 }
81
82
83 void
ReadCharChain(CharacterSource & io_rText)84 Context_ConstString::ReadCharChain( CharacterSource & io_rText )
85 {
86 char cNext = io_rText.MoveOn();
87
88 while (cNext != '"')
89 { // Get one complete string constant: "...."
90 while (cNext != '"' AND cNext != '\\')
91 { // Get string till next '\\'
92 cNext = io_rText.MoveOn();
93 }
94 if (cNext == '\\')
95 {
96 io_rText.MoveOn();
97 cNext = io_rText.MoveOn();
98 }
99 }
100 io_rText.MoveOn();
101 SetNewToken(new Tok_Constant(io_rText.CutToken()));
102 }
103
104 void
ReadCharChain(CharacterSource & io_rText)105 Context_ConstChar::ReadCharChain( CharacterSource & io_rText )
106 {
107 char cNext = io_rText.MoveOn();
108
109 while (cNext != '\'')
110 { // Get one complete char constant: "...."
111 while (cNext != '\'' AND cNext != '\\')
112 { // Get string till next '\\'
113 cNext = io_rText.MoveOn();
114 }
115 if (cNext == '\\')
116 {
117 io_rText.MoveOn();
118 cNext = io_rText.MoveOn();
119 }
120 }
121 io_rText.MoveOn();
122 SetNewToken(new Tok_Constant(io_rText.CutToken()));
123 }
124
125 void
ReadCharChain(CharacterSource & io_rText)126 Context_ConstNumeric::ReadCharChain(CharacterSource & io_rText)
127 {
128 char cNext = 0;
129
130 do {
131 do {
132 cNext = static_cast<char>( tolower(io_rText.MoveOn()) );
133 } while ( (cNext != 'e' AND isalnum(cNext)) OR cNext == '.');
134 if (cNext == 'e')
135 {
136 cNext = io_rText.MoveOn();
137 if (cNext == '+' OR cNext == '-')
138 cNext = io_rText.MoveOn();
139 } // endif
140 } while (isalnum(cNext) OR cNext == '.'); // Reicht aus, wenn Zahlen korrekt geschrieben sind
141 SetNewToken(new Tok_Constant(io_rText.CutToken()));
142 }
143
144 void
ReadCharChain(CharacterSource & io_rText)145 Context_UnblockMacro::ReadCharChain(CharacterSource & io_rText)
146 {
147 jumpToWhite(io_rText);
148 SetNewToken(new Tok_UnblockMacro( io_rText.CutToken() + strlen("#unblock-") ));
149 }
150
151 } // namespace cpp
152