1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
|
#include <QString>
#include <cstdlib>
#include <kdevelop-pg-qt/kdev-pg-token-stream.h>
#include "kdev-pg-char-sets.h"
#include <iostream>
#include <string>
#include <QDebug>
using namespace std;
class TokenStream : public KDevPG::TokenStream, public QUtf8ToUcs4Iterator {
typedef QUtf8ToUcs4Iterator Iterator;
public:
TokenStream(const Iterator& iter) : Iterator(iter)
{}
inline KDevPG::Token& next() {
#define CURR_POS Iterator::plain()
#define NEXT_CHR __extension__( { if(!Iterator::hasNext()) goto _end; Iterator::next(); } )
const Iterator::InputInt *lpos = Iterator::plain();
Iterator::Int chr = 0;
int lstate = 0;
_state_0:
chr = NEXT_CHR;
if (chr < 98) {
if (chr < 32) {
if (chr == 9 || chr == 10) {/*1 action */
lpos = CURR_POS;
lstate = 1;
goto _state_37;
} else goto _end;
} else {
if (chr < 48) {
if (chr == 32) {/*1 action */
lpos = CURR_POS;
lstate = 1;
goto _state_37;
} else goto _end;
} else {
if (chr < 58) {/*2 action */
lpos = CURR_POS;
lstate = 2;
goto _state_36;
} else goto _end;
}
}
} else {
if (chr < 102) {
if (chr == 98) {
goto _state_31;
} else goto _end;
} else {
if (chr < 228) {
if (chr == 102) {
goto _state_34;
} else goto _end;
} else {
if (chr == 228) {
goto _state_23;
} else goto _end;
}
}
}
_state_1:
chr = NEXT_CHR;
if (chr == 115) {/*9 action */
lpos = CURR_POS;
lstate = 9;
goto _state_38;
} else goto _end;
_state_2:
chr = NEXT_CHR;
if (chr == 167) {
goto _state_1;
} else goto _end;
_state_3:
chr = NEXT_CHR;
if (chr == 32) {
goto _state_2;
} else goto _end;
_state_4:
chr = NEXT_CHR;
if (chr == 101) {
goto _state_3;
} else goto _end;
_state_5:
chr = NEXT_CHR;
if (chr == 107) {
goto _state_4;
} else goto _end;
_state_6:
chr = NEXT_CHR;
if (chr == 105) {
goto _state_5;
} else goto _end;
_state_7:
chr = NEXT_CHR;
if (chr == 108) {
goto _state_6;
} else goto _end;
_state_8:
chr = NEXT_CHR;
if (chr == 32) {
goto _state_7;
} else goto _end;
_state_9:
chr = NEXT_CHR;
if (chr == 116) {
goto _state_8;
} else goto _end;
_state_10:
chr = NEXT_CHR;
if (chr == 111) {
goto _state_9;
} else goto _end;
_state_11:
chr = NEXT_CHR;
if (chr == 110) {
goto _state_10;
} else goto _end;
_state_12:
chr = NEXT_CHR;
if (chr == 32) {
goto _state_11;
} else goto _end;
_state_13:
chr = NEXT_CHR;
if (chr == 111) {
goto _state_12;
} else goto _end;
_state_14:
chr = NEXT_CHR;
if (chr == 100) {
goto _state_13;
} else goto _end;
_state_15:
chr = NEXT_CHR;
if (chr == 32) {
goto _state_14;
} else goto _end;
_state_16:
chr = NEXT_CHR;
if (chr == 73) {
goto _state_15;
} else goto _end;
_state_17:
chr = NEXT_CHR;
if (chr == 32) {
goto _state_16;
} else goto _end;
_state_18:
chr = NEXT_CHR;
if (chr == 44) {
goto _state_17;
} else goto _end;
_state_19:
chr = NEXT_CHR;
if (chr == 104) {
goto _state_18;
} else goto _end;
_state_20:
chr = NEXT_CHR;
if (chr == 104) {
goto _state_19;
} else goto _end;
_state_21:
chr = NEXT_CHR;
goto _end;
_state_22:
chr = NEXT_CHR;
if (chr == 252) {/*8 action */
lpos = CURR_POS;
lstate = 8;
goto _state_21;
} else goto _end;
_state_23:
chr = NEXT_CHR;
if (chr == 246) {
goto _state_22;
} else goto _end;
_state_24:
chr = NEXT_CHR;
goto _end;
_state_25:
chr = NEXT_CHR;
goto _end;
_state_26:
chr = NEXT_CHR;
if (chr == 114) {/*6 action */
lpos = CURR_POS;
lstate = 6;
goto _state_25;
} else goto _end;
_state_27:
chr = NEXT_CHR;
if (chr == 97) {
goto _state_26;
} else goto _end;
_state_28:
chr = NEXT_CHR;
goto _end;
_state_29:
chr = NEXT_CHR;
goto _end;
_state_30:
chr = NEXT_CHR;
if (chr < 122) {
if (chr == 114) {/*4 action */
lpos = CURR_POS;
lstate = 4;
goto _state_29;
} else goto _end;
} else {
if (chr == 122) {/*5 action */
lpos = CURR_POS;
lstate = 5;
goto _state_28;
} else goto _end;
}
_state_31:
chr = NEXT_CHR;
if (chr < 228) {
if (chr == 97) {
goto _state_30;
} else goto _end;
} else {
if (chr == 228) {
goto _state_20;
} else goto _end;
}
_state_32:
chr = NEXT_CHR;
if (chr == 98) {
goto _state_27;
} else goto _end;
_state_33:
chr = NEXT_CHR;
if (chr < 114) {
if (chr == 111) {/*3 action */
lpos = CURR_POS;
lstate = 3;
goto _state_32;
} else goto _end;
} else {
if (chr == 114) {/*7 action */
lpos = CURR_POS;
lstate = 7;
goto _state_24;
} else goto _end;
}
_state_34:
chr = NEXT_CHR;
if (chr == 111) {
goto _state_33;
} else goto _end;
_state_35:
chr = NEXT_CHR;
if (chr >= 48 && chr < 58) {/*2 action */
lpos = CURR_POS;
lstate = 2;
goto _state_35;
} else goto _end;
_state_36:
chr = NEXT_CHR;
if (chr < 48) {
if (chr == 46) {/*2 action */
lpos = CURR_POS;
lstate = 2;
goto _state_35;
} else goto _end;
} else {
if (chr < 58) {/*2 action */
lpos = CURR_POS;
lstate = 2;
goto _state_36;
} else goto _end;
}
_state_37:
chr = NEXT_CHR;
if (chr < 32) {
if (chr == 9 || chr == 10) {/*1 action */
lpos = CURR_POS;
lstate = 1;
goto _state_37;
} else goto _end;
} else {
if (chr == 32) {/*1 action */
lpos = CURR_POS;
lstate = 1;
goto _state_37;
} else goto _end;
}
_state_38:
chr = NEXT_CHR;
goto _end;
_end:
KDevPG::Token t;
plain() = lpos;
switch (lstate) {
case 0:
_fail: qDebug() << "error" << *lpos; exit(-1); return t;
case 1: qDebug() << "whitespace"; return t;
case 2: qDebug() << "dec-number"; return t;
case 3: qDebug() << "foo"; return t;
case 4: qDebug() << "bar"; return t;
case 5: qDebug() << "baz"; return t;
case 6: qDebug() << "foobar"; return t;
case 7: qDebug() << "for"; return t;
case 8: qDebug() << "umlauts"; return t;
case 9: qDebug() << "anti-law"; return t;
}
}
};
int main()
{
string str;
getline(cin, str);
QByteArray qba(str.c_str(), str.size());
QUtf8ToUcs4Iterator iter(qba);
TokenStream stream(iter);
while(stream.hasNext())
stream.next();
}
|