1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include <precomp.h> 29*cdf0e10cSrcweir #include "cx_c_std.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES 33*cdf0e10cSrcweir #include "all_toks.hxx" 34*cdf0e10cSrcweir #include "cx_c_pp.hxx" 35*cdf0e10cSrcweir #include "cx_c_sub.hxx" 36*cdf0e10cSrcweir #include <tools/tkpchars.hxx> 37*cdf0e10cSrcweir #include <tokens/tkpstama.hxx> 38*cdf0e10cSrcweir #include <x_parse.hxx> 39*cdf0e10cSrcweir #include "c_dealer.hxx" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir namespace cpp { 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir const intt C_nCppInitialNrOfStati = 600; 46*cdf0e10cSrcweir const intt C_nStatusSize = 128; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir const uintt nF_fin_Error = 1; 51*cdf0e10cSrcweir const uintt nF_fin_CreateWithoutText = 2; 52*cdf0e10cSrcweir const uintt nF_fin_CreateWithText = 3; 53*cdf0e10cSrcweir const uintt nF_fin_Ignore = 4; 54*cdf0e10cSrcweir const uintt nF_fin_EOL = 5; 55*cdf0e10cSrcweir const uintt nF_fin_EOF = 6; 56*cdf0e10cSrcweir const uintt nF_fin_Bezeichner = 7; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir const uintt nF_goto_Preprocessor = 10; 59*cdf0e10cSrcweir const uintt nF_goto_Comment = 11; 60*cdf0e10cSrcweir const uintt nF_goto_Docu = 12; 61*cdf0e10cSrcweir const uintt nF_goto_Const = 13; 62*cdf0e10cSrcweir const uintt nF_goto_UnblockMacro = 14; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // Token create functions for the state machine: 65*cdf0e10cSrcweir DYN TextToken * TCF_Identifier(const char * text) { return new Tok_Identifier(text); } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir DYN TextToken * TCF_operator(const char *) { return new Tok_operator; } 68*cdf0e10cSrcweir DYN TextToken * TCF_class(const char *) { return new Tok_class; } 69*cdf0e10cSrcweir DYN TextToken * TCF_struct(const char *) { return new Tok_struct; } 70*cdf0e10cSrcweir DYN TextToken * TCF_union(const char *) { return new Tok_union; } 71*cdf0e10cSrcweir DYN TextToken * TCF_enum(const char *) { return new Tok_enum; } 72*cdf0e10cSrcweir DYN TextToken * TCF_typedef(const char *) { return new Tok_typedef; } 73*cdf0e10cSrcweir DYN TextToken * TCF_public(const char *) { return new Tok_public; } 74*cdf0e10cSrcweir DYN TextToken * TCF_protected(const char *) { return new Tok_protected; } 75*cdf0e10cSrcweir DYN TextToken * TCF_private(const char *) { return new Tok_private; } 76*cdf0e10cSrcweir DYN TextToken * TCF_template(const char *) { return new Tok_template; } 77*cdf0e10cSrcweir DYN TextToken * TCF_virtual(const char *) { return new Tok_virtual; } 78*cdf0e10cSrcweir DYN TextToken * TCF_friend(const char *) { return new Tok_friend; } 79*cdf0e10cSrcweir DYN TextToken * TCF_Tilde(const char *) { return new Tok_Tilde; } 80*cdf0e10cSrcweir DYN TextToken * TCF_const(const char *) { return new Tok_const; } 81*cdf0e10cSrcweir DYN TextToken * TCF_volatile(const char *) { return new Tok_volatile; } 82*cdf0e10cSrcweir DYN TextToken * TCF_extern(const char *) { return new Tok_extern; } 83*cdf0e10cSrcweir DYN TextToken * TCF_static(const char *) { return new Tok_static; } 84*cdf0e10cSrcweir DYN TextToken * TCF_mutable(const char *) { return new Tok_mutable; } 85*cdf0e10cSrcweir DYN TextToken * TCF_register(const char *) { return new Tok_register; } 86*cdf0e10cSrcweir DYN TextToken * TCF_inline(const char *) { return new Tok_inline; } 87*cdf0e10cSrcweir DYN TextToken * TCF_explicit(const char *) { return new Tok_explicit; } 88*cdf0e10cSrcweir DYN TextToken * TCF_namespace(const char *) { return new Tok_namespace; } 89*cdf0e10cSrcweir DYN TextToken * TCF_using(const char *) { return new Tok_using; } 90*cdf0e10cSrcweir DYN TextToken * TCF_throw(const char *) { return new Tok_throw; } 91*cdf0e10cSrcweir DYN TextToken * TCF_SwBracketOpen(const char *) { return new Tok_SwBracket_Left; } 92*cdf0e10cSrcweir DYN TextToken * TCF_SwBracketClose(const char *) { return new Tok_SwBracket_Right; } 93*cdf0e10cSrcweir DYN TextToken * TCF_ArBracketOpen(const char *) { return new Tok_ArrayBracket_Left; } 94*cdf0e10cSrcweir DYN TextToken * TCF_ArBracketClose(const char *) { return new Tok_ArrayBracket_Right; } 95*cdf0e10cSrcweir DYN TextToken * TCF_BracketOpen(const char *) { return new Tok_Bracket_Left; } 96*cdf0e10cSrcweir DYN TextToken * TCF_BracketClose(const char *) { return new Tok_Bracket_Right; } 97*cdf0e10cSrcweir DYN TextToken * TCF_DblColon(const char *) { return new Tok_DoubleColon; } 98*cdf0e10cSrcweir DYN TextToken * TCF_Semikolon(const char *) { return new Tok_Semicolon; } 99*cdf0e10cSrcweir DYN TextToken * TCF_Komma(const char *) { return new Tok_Comma; } 100*cdf0e10cSrcweir DYN TextToken * TCF_Colon(const char *) { return new Tok_Colon; } 101*cdf0e10cSrcweir DYN TextToken * TCF_Zuweisung(const char *) { return new Tok_Assign; } 102*cdf0e10cSrcweir DYN TextToken * TCF_Smaller(const char *) { return new Tok_Less; } 103*cdf0e10cSrcweir DYN TextToken * TCF_Bigger(const char *) { return new Tok_Greater; } 104*cdf0e10cSrcweir DYN TextToken * TCF_Stern(const char *) { return new Tok_Asterix; } 105*cdf0e10cSrcweir DYN TextToken * TCF_Ampersand(const char *) { return new Tok_AmpersAnd; } 106*cdf0e10cSrcweir DYN TextToken * TCF_Ellipse(const char *) { return new Tok_Ellipse; } 107*cdf0e10cSrcweir DYN TextToken * TCF_typename(const char *) { return new Tok_typename; } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir // Operators 110*cdf0e10cSrcweir DYN TextToken * TCF_Operator(const char * text) { return new Tok_Operator(text); } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir DYN TextToken * TCF_BuiltInType(const char * text) { return new Tok_BuiltInType(text); } 113*cdf0e10cSrcweir DYN TextToken * TCF_TypeModifier(const char * text) { return new Tok_TypeSpecializer(text); } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir DYN TextToken * TCF_Eof(const char *) { return new Tok_Eof; } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir Context_CppStd::Context_CppStd( DYN autodoc::TkpDocuContext & let_drContext_Docu ) 120*cdf0e10cSrcweir : Cx_Base(0), 121*cdf0e10cSrcweir aStateMachine(C_nStatusSize,C_nCppInitialNrOfStati), 122*cdf0e10cSrcweir pDocuContext(&let_drContext_Docu), 123*cdf0e10cSrcweir pContext_Comment(0), 124*cdf0e10cSrcweir pContext_Preprocessor(0), 125*cdf0e10cSrcweir pContext_ConstString(0), 126*cdf0e10cSrcweir pContext_ConstChar(0), 127*cdf0e10cSrcweir pContext_ConstNumeric(0), 128*cdf0e10cSrcweir pContext_UnblockMacro(0) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir pDocuContext->SetParentContext(*this,"*/"); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir pContext_Comment = new Context_Comment(*this); 133*cdf0e10cSrcweir pContext_Preprocessor = new Context_Preprocessor(*this); 134*cdf0e10cSrcweir pContext_ConstString = new Context_ConstString(*this); 135*cdf0e10cSrcweir pContext_ConstChar = new Context_ConstChar(*this); 136*cdf0e10cSrcweir pContext_ConstNumeric = new Context_ConstNumeric(*this); 137*cdf0e10cSrcweir pContext_UnblockMacro = new Context_UnblockMacro(*this); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir SetupStateMachine(); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir Context_CppStd::~Context_CppStd() 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir void 147*cdf0e10cSrcweir Context_CppStd::ReadCharChain( CharacterSource & io_rText ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir SetNewToken(0); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir TextToken::F_CRTOK fTokenCreateFunction = 0; 152*cdf0e10cSrcweir StmBoundsStatus & rBound = aStateMachine.GetCharChain(fTokenCreateFunction, io_rText); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // !!! 155*cdf0e10cSrcweir // The order of the next two lines is essential, because 156*cdf0e10cSrcweir // pFollowUpContext may be changed by PerformStatusFunction() also, 157*cdf0e10cSrcweir // which then MUST override the previous assignment. 158*cdf0e10cSrcweir SetFollowUpContext(rBound.FollowUpContext()); 159*cdf0e10cSrcweir PerformStatusFunction(rBound.StatusFunctionNr(), fTokenCreateFunction, io_rText); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir void 163*cdf0e10cSrcweir Context_CppStd::AssignDealer( Distributor & o_rDealer ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir Cx_Base::AssignDealer(o_rDealer); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir pDocuContext->AssignDealer(o_rDealer); 168*cdf0e10cSrcweir pContext_Comment->AssignDealer(o_rDealer); 169*cdf0e10cSrcweir pContext_Preprocessor->AssignDealer(o_rDealer); 170*cdf0e10cSrcweir pContext_ConstString->AssignDealer(o_rDealer); 171*cdf0e10cSrcweir pContext_ConstChar->AssignDealer(o_rDealer); 172*cdf0e10cSrcweir pContext_ConstNumeric->AssignDealer(o_rDealer); 173*cdf0e10cSrcweir pContext_UnblockMacro->AssignDealer(o_rDealer); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir void 177*cdf0e10cSrcweir Context_CppStd::PerformStatusFunction( uintt i_nStatusSignal, 178*cdf0e10cSrcweir F_CRTOK i_fTokenCreateFunction, 179*cdf0e10cSrcweir CharacterSource & io_rText ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir switch (i_nStatusSignal) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir case nF_fin_CreateWithoutText: 184*cdf0e10cSrcweir io_rText.CutToken(); 185*cdf0e10cSrcweir csv_assert(i_fTokenCreateFunction != 0); 186*cdf0e10cSrcweir SetNewToken( (*i_fTokenCreateFunction)(0) ); 187*cdf0e10cSrcweir break; 188*cdf0e10cSrcweir case nF_fin_CreateWithText: 189*cdf0e10cSrcweir csv_assert(i_fTokenCreateFunction != 0); 190*cdf0e10cSrcweir SetNewToken( (*i_fTokenCreateFunction)(io_rText.CutToken()) ); 191*cdf0e10cSrcweir break; 192*cdf0e10cSrcweir case nF_fin_Ignore: 193*cdf0e10cSrcweir io_rText.CutToken(); 194*cdf0e10cSrcweir SetNewToken(0); 195*cdf0e10cSrcweir break; 196*cdf0e10cSrcweir case nF_fin_EOL: 197*cdf0e10cSrcweir io_rText.CutToken(); 198*cdf0e10cSrcweir SetNewToken(0); 199*cdf0e10cSrcweir Dealer().Deal_Eol(); 200*cdf0e10cSrcweir break; 201*cdf0e10cSrcweir case nF_fin_EOF: 202*cdf0e10cSrcweir io_rText.CutToken(); 203*cdf0e10cSrcweir SetNewToken( TCF_Eof(0) ); 204*cdf0e10cSrcweir break; 205*cdf0e10cSrcweir case nF_fin_Bezeichner: 206*cdf0e10cSrcweir SetNewToken( TCF_Identifier(io_rText.CutToken()) ); 207*cdf0e10cSrcweir break; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir case nF_goto_Preprocessor: 210*cdf0e10cSrcweir io_rText.CutToken(); 211*cdf0e10cSrcweir SetNewToken(0); 212*cdf0e10cSrcweir break; 213*cdf0e10cSrcweir case nF_goto_Comment: 214*cdf0e10cSrcweir SetNewToken(0); 215*cdf0e10cSrcweir pContext_Comment->SetMode_IsMultiLine( io_rText.CutToken()[1] == '*' ); 216*cdf0e10cSrcweir break; 217*cdf0e10cSrcweir case nF_goto_Docu: 218*cdf0e10cSrcweir SetNewToken(0); 219*cdf0e10cSrcweir pDocuContext->SetMode_IsMultiLine( io_rText.CutToken()[1] == '*' ); 220*cdf0e10cSrcweir break; 221*cdf0e10cSrcweir case nF_goto_Const: 222*cdf0e10cSrcweir SetNewToken(0); 223*cdf0e10cSrcweir break; 224*cdf0e10cSrcweir case nF_goto_UnblockMacro: 225*cdf0e10cSrcweir SetNewToken(0); 226*cdf0e10cSrcweir break; 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir case nF_fin_Error: 229*cdf0e10cSrcweir default: 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir char cCC = io_rText.CurChar(); 232*cdf0e10cSrcweir String sCurChar( &cCC, 1 ); 233*cdf0e10cSrcweir throw X_Parser( X_Parser::x_InvalidChar, sCurChar, String::Null_(), 0 ); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir } // end switch (i_nStatusSignal) 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir void 239*cdf0e10cSrcweir Context_CppStd::SetupStateMachine() 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir // Besondere Array-Stati (kein Tokenabschluss oder Kontextwechsel): 242*cdf0e10cSrcweir // const INT16 top = 0; // Top-Status 243*cdf0e10cSrcweir const INT16 wht = 1; // Whitespace-�berlese-Status 244*cdf0e10cSrcweir const INT16 bez = 2; // Bezeichner-lese-Status 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir // Tokenfinish-Stati: 247*cdf0e10cSrcweir const INT16 finError = 3; 248*cdf0e10cSrcweir const INT16 finIgnore = 4; 249*cdf0e10cSrcweir const INT16 finBezeichner = 5; 250*cdf0e10cSrcweir const INT16 finKeyword = 6; 251*cdf0e10cSrcweir const INT16 finPunctuation = 7; 252*cdf0e10cSrcweir const INT16 finBiType = 8; 253*cdf0e10cSrcweir const INT16 finTypeModifier = 9; 254*cdf0e10cSrcweir const INT16 finEOL = 10; 255*cdf0e10cSrcweir const INT16 finEOF = 11; 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir // Kontextwechsel-Stati: 258*cdf0e10cSrcweir const INT16 gotoComment = 12; 259*cdf0e10cSrcweir const INT16 gotoDocu = 13; 260*cdf0e10cSrcweir const INT16 gotoPreprocessor = 14; 261*cdf0e10cSrcweir const INT16 gotoConstString = 15; 262*cdf0e10cSrcweir const INT16 gotoConstChar = 16; 263*cdf0e10cSrcweir const INT16 gotoConstNumeric = 17; 264*cdf0e10cSrcweir const INT16 gotoUnblockMacro = 18; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir // Abbreviations to be used in status tables: 267*cdf0e10cSrcweir const INT16 err = finError; 268*cdf0e10cSrcweir const INT16 fig = finIgnore; 269*cdf0e10cSrcweir const INT16 fbz = finBezeichner; 270*cdf0e10cSrcweir const INT16 fof = finEOF; 271*cdf0e10cSrcweir const INT16 cst = gotoConstString; 272*cdf0e10cSrcweir const INT16 cch = gotoConstChar; 273*cdf0e10cSrcweir const INT16 cnr = gotoConstNumeric; 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir /// Zeros - '0' - will be replaced by AddToken(). 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir const INT16 A_nTopStatus[C_nStatusSize] = 279*cdf0e10cSrcweir // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 280*cdf0e10cSrcweir {fof,err,err,err,err,err,err,err,err,wht, 0,wht,wht, 0,err,err, 281*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,fof,err,err,err,err,err, // 16 ... 282*cdf0e10cSrcweir wht, 0,cst, 0,err, 0, 0,cch, 0, 0, 0, 0, 0, 0, 0, 0, 283*cdf0e10cSrcweir cnr,cnr,cnr,cnr,cnr,cnr,cnr,cnr,cnr,cnr, 0, 0, 0, 0, 0, 0, // 48 ... 284*cdf0e10cSrcweir 0,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 285*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 0, 0, 0, 0,bez, // 80 ... 286*cdf0e10cSrcweir 0,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 287*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 0, 0, 0, 0,err, // 80 ... 288*cdf0e10cSrcweir }; 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir const INT16 A_nWhitespaceStatus[C_nStatusSize] = 291*cdf0e10cSrcweir // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 292*cdf0e10cSrcweir {fof,err,err,err,err,err,err,err,err,wht,fig,wht,wht,fig,err,err, 293*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,fof,err,err,err,err,err, // 16 ... 294*cdf0e10cSrcweir wht,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig, 295*cdf0e10cSrcweir fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig, // 48 ... 296*cdf0e10cSrcweir fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig, 297*cdf0e10cSrcweir fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig, // 80 ... 298*cdf0e10cSrcweir fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig, 299*cdf0e10cSrcweir fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,err 300*cdf0e10cSrcweir }; 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir const INT16 A_nBezeichnerStatus[C_nStatusSize] = 303*cdf0e10cSrcweir // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 304*cdf0e10cSrcweir {fbz,err,err,err,err,err,err,err,err,fbz,fbz,fbz,fbz,fbz,err,err, 305*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,fbz,err,err,err,err,err, // 16 ... 306*cdf0e10cSrcweir fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz, 307*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,fbz,fbz, // 48 ... 308*cdf0e10cSrcweir fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 309*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,bez, // 80 ... 310*cdf0e10cSrcweir fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 311*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,err 312*cdf0e10cSrcweir }; 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir const INT16 A_nOperatorDefStatus[C_nStatusSize] = 316*cdf0e10cSrcweir // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 317*cdf0e10cSrcweir {err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, 318*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 16 ... 319*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, 320*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 48 ... 321*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, 322*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 80 ... 323*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, 324*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err 325*cdf0e10cSrcweir }; 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir const INT16 A_nBezDefStatus[C_nStatusSize] = 328*cdf0e10cSrcweir // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 329*cdf0e10cSrcweir {fbz,err,err,err,err,err,err,err,err,fbz,fbz,fbz,fbz,fbz,err,err, 330*cdf0e10cSrcweir err,err,err,err,err,err,err,err,err,err,fbz,err,err,err,err,err, // 16 ... 331*cdf0e10cSrcweir fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz, 332*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,fbz,fbz, // 48 ... 333*cdf0e10cSrcweir fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 334*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,bez, // 80 ... 335*cdf0e10cSrcweir fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez, 336*cdf0e10cSrcweir bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,err 337*cdf0e10cSrcweir }; 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir DYN StmArrayStatus * dpStatusTop 340*cdf0e10cSrcweir = new StmArrayStatus( C_nStatusSize, A_nTopStatus, 0, true); 341*cdf0e10cSrcweir DYN StmArrayStatus * dpStatusWhite 342*cdf0e10cSrcweir = new StmArrayStatus( C_nStatusSize, A_nWhitespaceStatus, 0, true); 343*cdf0e10cSrcweir DYN StmArrayStatus * dpStatusBez 344*cdf0e10cSrcweir = new StmArrayStatus( C_nStatusSize, A_nBezeichnerStatus, TCF_Identifier, true); 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finError 347*cdf0e10cSrcweir = new StmBoundsStatus( *this, TkpContext::Null_(), nF_fin_Error, true ); 348*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finIgnore 349*cdf0e10cSrcweir = new StmBoundsStatus( *this, *this, nF_fin_Ignore, true ); 350*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finBezeichner 351*cdf0e10cSrcweir = new StmBoundsStatus( *this, *this, nF_fin_Bezeichner, true ); 352*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finKeyword 353*cdf0e10cSrcweir = new StmBoundsStatus( *this, *this, nF_fin_CreateWithoutText, false ); 354*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finPunctuation 355*cdf0e10cSrcweir = new StmBoundsStatus( *this, *this, nF_fin_CreateWithText, false ); 356*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finBiType 357*cdf0e10cSrcweir = new StmBoundsStatus( *this, *this, nF_fin_CreateWithText, false ); 358*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finTypeModifier 359*cdf0e10cSrcweir = new StmBoundsStatus( *this, *this, nF_fin_CreateWithText, false ); 360*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finEOL 361*cdf0e10cSrcweir = new StmBoundsStatus( *this, *this, nF_fin_EOL, false ); 362*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_finEOF 363*cdf0e10cSrcweir = new StmBoundsStatus( *this, TkpContext::Null_(), nF_fin_EOF, false ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_gotoComment 366*cdf0e10cSrcweir = new StmBoundsStatus( *this, *pContext_Comment, nF_goto_Comment, false ); 367*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_gotoDocu 368*cdf0e10cSrcweir = new StmBoundsStatus( *this, *pDocuContext, nF_goto_Docu, false ); 369*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_gotoPreprocessor 370*cdf0e10cSrcweir = new StmBoundsStatus( *this, *pContext_Preprocessor, nF_goto_Preprocessor, false ); 371*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_gotoConstString 372*cdf0e10cSrcweir = new StmBoundsStatus( *this, *pContext_ConstString, nF_goto_Const, false ); 373*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_gotoConstChar 374*cdf0e10cSrcweir = new StmBoundsStatus( *this, *pContext_ConstChar, nF_goto_Const, false ); 375*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_gotoConstNumeric 376*cdf0e10cSrcweir = new StmBoundsStatus( *this, *pContext_ConstNumeric, nF_goto_Const, false ); 377*cdf0e10cSrcweir DYN StmBoundsStatus * dpBst_gotoUnblockMacro 378*cdf0e10cSrcweir = new StmBoundsStatus( *this, *pContext_UnblockMacro, nF_goto_UnblockMacro, false ); 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir // dpMain aufbauen: 381*cdf0e10cSrcweir aStateMachine.AddStatus(dpStatusTop); 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir aStateMachine.AddStatus(dpStatusWhite); 384*cdf0e10cSrcweir aStateMachine.AddStatus(dpStatusBez); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finError); 387*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finIgnore); 388*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finBezeichner); 389*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finKeyword); 390*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finPunctuation); 391*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finBiType); 392*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finTypeModifier); 393*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finEOL); 394*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_finEOF); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_gotoComment); 397*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_gotoDocu); 398*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_gotoPreprocessor); 399*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_gotoConstString); 400*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_gotoConstChar); 401*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_gotoConstNumeric); 402*cdf0e10cSrcweir aStateMachine.AddStatus(dpBst_gotoUnblockMacro); 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir // Identifier 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // Keywords and other unique Tokens 407*cdf0e10cSrcweir aStateMachine.AddToken("operator",TCF_operator,A_nBezDefStatus,finKeyword); 408*cdf0e10cSrcweir aStateMachine.AddToken("class",TCF_class,A_nBezDefStatus,finKeyword); 409*cdf0e10cSrcweir aStateMachine.AddToken("struct",TCF_struct,A_nBezDefStatus,finKeyword); 410*cdf0e10cSrcweir aStateMachine.AddToken("union",TCF_union,A_nBezDefStatus,finKeyword); 411*cdf0e10cSrcweir aStateMachine.AddToken("enum",TCF_enum,A_nBezDefStatus,finKeyword); 412*cdf0e10cSrcweir aStateMachine.AddToken("typedef",TCF_typedef,A_nBezDefStatus,finKeyword); 413*cdf0e10cSrcweir aStateMachine.AddToken("public",TCF_public,A_nBezDefStatus,finKeyword); 414*cdf0e10cSrcweir aStateMachine.AddToken("protected",TCF_protected,A_nBezDefStatus,finKeyword); 415*cdf0e10cSrcweir aStateMachine.AddToken("private",TCF_private,A_nBezDefStatus,finKeyword); 416*cdf0e10cSrcweir aStateMachine.AddToken("template",TCF_template,A_nBezDefStatus,finKeyword); 417*cdf0e10cSrcweir aStateMachine.AddToken("virtual",TCF_virtual,A_nBezDefStatus,finKeyword); 418*cdf0e10cSrcweir aStateMachine.AddToken("friend",TCF_friend,A_nBezDefStatus,finKeyword); 419*cdf0e10cSrcweir aStateMachine.AddToken("~",TCF_Tilde,A_nOperatorDefStatus,finKeyword); 420*cdf0e10cSrcweir aStateMachine.AddToken("const",TCF_const,A_nBezDefStatus,finKeyword); 421*cdf0e10cSrcweir aStateMachine.AddToken("volatile",TCF_volatile,A_nBezDefStatus,finKeyword); 422*cdf0e10cSrcweir aStateMachine.AddToken("extern",TCF_extern,A_nBezDefStatus,finKeyword); 423*cdf0e10cSrcweir aStateMachine.AddToken("static",TCF_static,A_nBezDefStatus,finKeyword); 424*cdf0e10cSrcweir aStateMachine.AddToken("mutable",TCF_mutable,A_nBezDefStatus,finKeyword); 425*cdf0e10cSrcweir aStateMachine.AddToken("register",TCF_register,A_nBezDefStatus,finKeyword); 426*cdf0e10cSrcweir aStateMachine.AddToken("inline",TCF_inline,A_nBezDefStatus,finKeyword); 427*cdf0e10cSrcweir aStateMachine.AddToken("explicit",TCF_explicit,A_nBezDefStatus,finKeyword); 428*cdf0e10cSrcweir aStateMachine.AddToken("namespace",TCF_namespace,A_nBezDefStatus,finKeyword); 429*cdf0e10cSrcweir aStateMachine.AddToken("using",TCF_using,A_nBezDefStatus,finKeyword); 430*cdf0e10cSrcweir aStateMachine.AddToken("throw",TCF_throw,A_nBezDefStatus,finKeyword); 431*cdf0e10cSrcweir aStateMachine.AddToken("{",TCF_SwBracketOpen,A_nOperatorDefStatus,finKeyword); 432*cdf0e10cSrcweir aStateMachine.AddToken("}",TCF_SwBracketClose,A_nOperatorDefStatus,finKeyword); 433*cdf0e10cSrcweir aStateMachine.AddToken("[",TCF_ArBracketOpen,A_nOperatorDefStatus,finKeyword); 434*cdf0e10cSrcweir aStateMachine.AddToken("]",TCF_ArBracketClose,A_nOperatorDefStatus,finKeyword); 435*cdf0e10cSrcweir aStateMachine.AddToken("(",TCF_BracketOpen,A_nOperatorDefStatus,finKeyword); 436*cdf0e10cSrcweir aStateMachine.AddToken(")",TCF_BracketClose,A_nOperatorDefStatus,finKeyword); 437*cdf0e10cSrcweir aStateMachine.AddToken("::",TCF_DblColon,A_nOperatorDefStatus,finKeyword); 438*cdf0e10cSrcweir aStateMachine.AddToken(";",TCF_Semikolon,A_nOperatorDefStatus,finKeyword); 439*cdf0e10cSrcweir aStateMachine.AddToken(",",TCF_Komma,A_nOperatorDefStatus,finKeyword); 440*cdf0e10cSrcweir aStateMachine.AddToken(":",TCF_Colon,A_nOperatorDefStatus,finKeyword); 441*cdf0e10cSrcweir aStateMachine.AddToken("=",TCF_Zuweisung,A_nOperatorDefStatus,finKeyword); 442*cdf0e10cSrcweir aStateMachine.AddToken("<",TCF_Smaller,A_nOperatorDefStatus,finKeyword); 443*cdf0e10cSrcweir aStateMachine.AddToken(">",TCF_Bigger,A_nOperatorDefStatus,finKeyword); 444*cdf0e10cSrcweir aStateMachine.AddToken("*",TCF_Stern,A_nOperatorDefStatus,finKeyword); 445*cdf0e10cSrcweir aStateMachine.AddToken("&",TCF_Ampersand,A_nOperatorDefStatus,finKeyword); 446*cdf0e10cSrcweir aStateMachine.AddToken("...",TCF_Ellipse,A_nOperatorDefStatus,finKeyword); 447*cdf0e10cSrcweir aStateMachine.AddToken("typename",TCF_typename,A_nOperatorDefStatus,finKeyword); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir // Operators 450*cdf0e10cSrcweir aStateMachine.AddToken("==",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 451*cdf0e10cSrcweir aStateMachine.AddToken("!=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 452*cdf0e10cSrcweir aStateMachine.AddToken("<=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 453*cdf0e10cSrcweir aStateMachine.AddToken(">=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 454*cdf0e10cSrcweir aStateMachine.AddToken("&&",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 455*cdf0e10cSrcweir aStateMachine.AddToken("||",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 456*cdf0e10cSrcweir aStateMachine.AddToken("!",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 457*cdf0e10cSrcweir aStateMachine.AddToken("new",TCF_Operator,A_nBezDefStatus,finPunctuation); 458*cdf0e10cSrcweir aStateMachine.AddToken("delete",TCF_Operator,A_nBezDefStatus,finPunctuation); 459*cdf0e10cSrcweir aStateMachine.AddToken("sizeof",TCF_Operator,A_nBezDefStatus,finPunctuation); 460*cdf0e10cSrcweir aStateMachine.AddToken("typeid",TCF_Operator,A_nBezDefStatus,finPunctuation); 461*cdf0e10cSrcweir aStateMachine.AddToken("+",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 462*cdf0e10cSrcweir aStateMachine.AddToken("-",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 463*cdf0e10cSrcweir aStateMachine.AddToken("/",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 464*cdf0e10cSrcweir aStateMachine.AddToken("%",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 465*cdf0e10cSrcweir aStateMachine.AddToken("^",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 466*cdf0e10cSrcweir aStateMachine.AddToken("|",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 467*cdf0e10cSrcweir aStateMachine.AddToken("<<",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 468*cdf0e10cSrcweir aStateMachine.AddToken(">>",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 469*cdf0e10cSrcweir aStateMachine.AddToken(".",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 470*cdf0e10cSrcweir aStateMachine.AddToken("->",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 471*cdf0e10cSrcweir aStateMachine.AddToken("?",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 472*cdf0e10cSrcweir aStateMachine.AddToken("+=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 473*cdf0e10cSrcweir aStateMachine.AddToken("-=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 474*cdf0e10cSrcweir aStateMachine.AddToken("*=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 475*cdf0e10cSrcweir aStateMachine.AddToken("/=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 476*cdf0e10cSrcweir aStateMachine.AddToken("%=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 477*cdf0e10cSrcweir aStateMachine.AddToken("&=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 478*cdf0e10cSrcweir aStateMachine.AddToken("|=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 479*cdf0e10cSrcweir aStateMachine.AddToken("^=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 480*cdf0e10cSrcweir aStateMachine.AddToken("<<=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 481*cdf0e10cSrcweir aStateMachine.AddToken(">>=",TCF_Operator,A_nOperatorDefStatus,finPunctuation); 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir // Builtin types 484*cdf0e10cSrcweir aStateMachine.AddToken("char", TCF_BuiltInType, A_nBezDefStatus, finBiType); 485*cdf0e10cSrcweir aStateMachine.AddToken("short", TCF_BuiltInType, A_nBezDefStatus, finBiType); 486*cdf0e10cSrcweir aStateMachine.AddToken("int", TCF_BuiltInType, A_nBezDefStatus, finBiType); 487*cdf0e10cSrcweir aStateMachine.AddToken("long", TCF_BuiltInType, A_nBezDefStatus, finBiType); 488*cdf0e10cSrcweir aStateMachine.AddToken("float", TCF_BuiltInType, A_nBezDefStatus, finBiType); 489*cdf0e10cSrcweir aStateMachine.AddToken("double",TCF_BuiltInType, A_nBezDefStatus, finBiType); 490*cdf0e10cSrcweir aStateMachine.AddToken("wchar_t",TCF_BuiltInType, A_nBezDefStatus, finBiType); 491*cdf0e10cSrcweir aStateMachine.AddToken("size_t",TCF_BuiltInType, A_nBezDefStatus, finBiType); 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir // Type modifiers 494*cdf0e10cSrcweir aStateMachine.AddToken("signed", TCF_TypeModifier, A_nBezDefStatus, finTypeModifier); 495*cdf0e10cSrcweir aStateMachine.AddToken("unsigned", TCF_TypeModifier, A_nBezDefStatus, finTypeModifier); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir // To ignore 498*cdf0e10cSrcweir aStateMachine.AddToken("auto", 0, A_nBezDefStatus, finIgnore); 499*cdf0e10cSrcweir aStateMachine.AddToken("_cdecl", 0, A_nBezDefStatus, finIgnore); 500*cdf0e10cSrcweir aStateMachine.AddToken("__cdecl", 0, A_nBezDefStatus, finIgnore); 501*cdf0e10cSrcweir aStateMachine.AddToken("__stdcall", 0, A_nBezDefStatus, finIgnore); 502*cdf0e10cSrcweir aStateMachine.AddToken("__fastcall",0, A_nBezDefStatus, finIgnore); 503*cdf0e10cSrcweir aStateMachine.AddToken("/**/", 0, A_nOperatorDefStatus,finIgnore); 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir // Context changers 506*cdf0e10cSrcweir aStateMachine.AddToken("#", 0, A_nOperatorDefStatus, gotoPreprocessor); 507*cdf0e10cSrcweir aStateMachine.AddToken("#undef",0, A_nOperatorDefStatus, gotoPreprocessor); 508*cdf0e10cSrcweir aStateMachine.AddToken("#unblock-", 509*cdf0e10cSrcweir 0, A_nOperatorDefStatus, gotoUnblockMacro); 510*cdf0e10cSrcweir aStateMachine.AddToken("/*", 0, A_nOperatorDefStatus, gotoComment); 511*cdf0e10cSrcweir aStateMachine.AddToken("//", 0, A_nOperatorDefStatus, gotoComment); 512*cdf0e10cSrcweir aStateMachine.AddToken("/**", 0, A_nOperatorDefStatus, gotoDocu); 513*cdf0e10cSrcweir aStateMachine.AddToken("///", 0, A_nOperatorDefStatus, gotoDocu); 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir // Line ends 516*cdf0e10cSrcweir // regular 517*cdf0e10cSrcweir aStateMachine.AddToken("\r\n", 0, A_nOperatorDefStatus, finEOL); 518*cdf0e10cSrcweir aStateMachine.AddToken("\n", 0, A_nOperatorDefStatus, finEOL); 519*cdf0e10cSrcweir aStateMachine.AddToken("\r", 0, A_nOperatorDefStatus, finEOL); 520*cdf0e10cSrcweir // To ignore in some cases(may be only at preprocessor?), but 521*cdf0e10cSrcweir // linecount has to be incremented. 522*cdf0e10cSrcweir aStateMachine.AddToken("\\\r\n",0, A_nOperatorDefStatus, finEOL); 523*cdf0e10cSrcweir aStateMachine.AddToken("\\\n", 0, A_nOperatorDefStatus, finEOL); 524*cdf0e10cSrcweir aStateMachine.AddToken("\\\r", 0, A_nOperatorDefStatus, finEOL); 525*cdf0e10cSrcweir }; 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir } // namespace cpp 529*cdf0e10cSrcweir 530