Changeset 616

Show
Ignore:
Timestamp:
07/28/08 11:26:35 (4 months ago)
Author:
weyrick
Message:

parameterize the string/char types in the lexer to implement unicode and std::string versions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rphp/compiler/pDriver.cpp

    r614 r616  
    66;; as published by the Free Software Foundation; either version 2 
    77;; of the License, or (at your option) any later version. 
    8 ;;  
     8;; 
    99;; This program is distributed in the hope that it will be useful, 
    1010;; but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1111;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1212;; GNU General Public License for more details. 
    13 ;;  
     13;; 
    1414;; You should have received a copy of the GNU General Public License 
    1515;; along with this program; if not, write to the Free Software 
     
    3737    * the result of get_token_all (see test-tokenize.php) 
    3838    **/ 
    39     void printToken(int token, const Lexer& lexer, const UnicodeString& content) 
     39    void printToken(int token, const ULexer& lexer, const UnicodeString& content) 
    4040    { 
    4141        int begin = lexer.tokenBegin(); 
     
    339339        } 
    340340    } 
    341      
     341 
    342342    void pDriver::dumpTokens(string fileName) { 
    343343 
    344344        ifstream inFile; 
    345      
     345 
    346346        inFile.open(fileName.c_str(), ifstream::in); 
    347347        if (!inFile) { 
     
    357357            contents += buf; 
    358358        } 
    359          
     359 
    360360        inFile.close(); 
    361          
    362         Lexer lexer(0, contents); 
     361 
     362        ULexer lexer(0, contents); 
    363363        int token; 
    364         while ((token = lexer.nextTokenKind())) { 
     364        while (token = lexer.nextTokenKind()) { 
    365365            printToken(token, lexer, contents); 
    366366        } 
  • trunk/rphp/compiler/parser/php.g

    r609 r616  
    2323[: 
    2424 
    25 #include <unistr.h> 
     25#include <unicode/unistr.h> 
    2626#include <string> 
    2727#include <iostream> 
     
    3333namespace rphp 
    3434{ 
    35     class Lexer; 
     35    //template <typename StringClass, typename CharClass> class Lexer; 
    3636    enum NumericType  { 
    3737        LongNumber, 
     
    730730{ 
    731731    m_contents = contents; 
    732     Lexer lexer( this, contents ); 
     732    Lexer<UnicodeString, UChar32> lexer( this, contents ); 
    733733    int kind = parser::Token_EOF; 
    734734 
  • trunk/rphp/compiler/parser/phplexer.cpp

    r614 r616  
    2828#include <iostream> 
    2929#include <string> 
     30#include <algorithm> 
     31#include <cctype> 
    3032#include "unicode/utypes.h" 
    3133#include "unicode/uchar.h" 
     
    3436// TODO pos and m_curpos the same? 
    3537 
    36     namespace rphp 
    37     { 
    38  
    39         Lexer::Lexer( parser* _parser, const UnicodeString& content ): 
     38namespace rphp 
     39
     40 
     41// generic helpers 
     42bool C_isAlNum(char c) { return isalnum(c); } 
     43bool C_isDigit(char c) { return isdigit(c); } 
     44bool C_isHigh(char c) { return false; } 
     45char C_toLower(char c) { return tolower(c); } 
     46void S_toLower(std::string& s) { 
     47  std::transform(s.begin(), s.end(), s.begin(), 
     48                 (int(*)(int)) std::tolower); 
     49
     50 
     51bool C_isAlNum(UChar32 c) { return u_isalnum(c); } 
     52bool C_isDigit(UChar32 c) { return u_isdigit(c); } 
     53UChar32 C_toLower(UChar32 c) { return u_tolower(c); } 
     54void S_toLower(UnicodeString& s) { s.toLower(); } 
     55// 
     56 
     57template <typename StringClass, typename CharClass> 
     58Lexer<StringClass, CharClass>::Lexer( parser* _parser, const StringClass& content ): 
    4059        m_content( content ), m_parser( _parser ), 
    4160        m_curpos( 0 ), m_contentSize( m_content.length() ), 
     
    4665} 
    4766 
    48 int Lexer::state(int deepness) const 
     67template <typename StringClass, typename CharClass> 
     68int Lexer<StringClass, CharClass>::state(int deepness) const 
    4969{ 
    5070 
     
    5272    return m_state[ m_state.size() - deepness - 1 ]; 
    5373} 
    54 void Lexer::printState() 
     74 
     75template <typename StringClass, typename CharClass> 
     76void Lexer<StringClass, CharClass>::printState() 
    5577{ 
    5678    int s = state(); 
     
    79101} 
    80102 
    81 void Lexer::pushState( int state ) 
     103template <typename StringClass, typename CharClass> 
     104void Lexer<StringClass, CharClass>::pushState( int state ) 
    82105{ 
    83106    m_state.push_back( state ); 
     
    85108} 
    86109 
    87 void Lexer::popState() 
     110template <typename StringClass, typename CharClass> 
     111void Lexer<StringClass, CharClass>::popState() 
    88112{ 
    89113    m_state.pop_back(); 
     
    91115} 
    92116 
    93 int Lexer::nextTokenKind() 
     117template <typename StringClass, typename CharClass> 
     118int Lexer<StringClass, CharClass>::nextTokenKind() 
    94119{ 
    95120    int token = parser::Token_INVALID; 
     
    151176                m_curpos--; 
    152177            } 
    153             else if (u_isdigit( lookAt( pos ) ) 
    154                     || ( lookAt( pos )  == '.' && u_isdigit( lookAt( pos + 1 ) ) )) 
    155             { 
    156                 UnicodeString num;bool hasPoint = false; 
     178            else if (C_isDigit( lookAt( pos ) ) 
     179                    || ( lookAt( pos )  == '.' && C_isDigit( lookAt( pos + 1 ) ) )) 
     180            { 
     181                StringClass num; 
     182                bool hasPoint = false; 
    157183                bool hex = false; 
    158184                if ( lookAt( pos ) == '0' && ( lookAt( pos + 1 )) == 'x') { 
     
    162188                } 
    163189                while (m_curpos < m_contentSize && ( 
    164                             u_isdigit( lookAt( pos ) ) 
     190                            C_isDigit( lookAt( pos ) ) 
    165191                        || (!hex && !hasPoint && lookAt( pos ) == '.') 
    166                         || (hex && (u_tolower( lookAt( pos ) ) == 'a' || u_tolower( lookAt( pos ) ) == 'b' || 
    167                                     u_tolower( lookAt( pos ) ) == 'c' || u_tolower( lookAt( pos ) ) == 'd' || 
    168                                     u_tolower( lookAt( pos ) ) == 'e' || u_tolower( lookAt( pos ) ) == 'f')))) 
     192                        || (hex && (C_toLower( lookAt( pos ) ) == 'a' || C_toLower( lookAt( pos ) ) == 'b' || 
     193                                    C_toLower( lookAt( pos ) ) == 'c' || C_toLower( lookAt( pos ) ) == 'd' || 
     194                                    C_toLower( lookAt( pos ) ) == 'e' || C_toLower( lookAt( pos ) ) == 'f')))) 
    169195                { 
    170196                    if (lookAt( pos ) == '.') hasPoint = true; 
    171                     num.append(lookAt( pos )); 
    172                     pos++; 
    173                     m_curpos++; 
    174                 } 
    175                 if (!hex && u_tolower( lookAt( pos ) ) == 'e' && 
    176                         (u_isdigit( lookAt( pos ) ) || 
    177                             ((lookAt( pos + 1 ) == '-' || lookAt( pos + 1 ) == '+') && u_isdigit( lookAt( pos + 2 ) ) ))) 
     197                    //num.append(lookAt( pos )); 
     198                    num += lookAt( pos ); 
     199                    pos++; 
     200                    m_curpos++; 
     201                } 
     202                if (!hex && C_toLower( lookAt( pos ) ) == 'e' && 
     203                        (C_isDigit( lookAt( pos ) ) || 
     204                            ((lookAt( pos + 1 ) == '-' || lookAt( pos + 1 ) == '+') && C_isDigit( lookAt( pos + 2 ) ) ))) 
    178205                { 
    179206                    //exponential number 
     
    185212                        m_curpos++; 
    186213                    } 
    187                     while (m_curpos < m_contentSize && ( u_isdigit( lookAt( pos ) ) )) { 
     214                    while (m_curpos < m_contentSize && ( C_isDigit( lookAt( pos ) ) )) { 
    188215                        pos++; 
    189216                        m_curpos++; 
     
    247274                    _pos++; 
    248275                } 
    249                 UnicodeString name; 
    250                 while (_pos < m_contentSize && u_isalnum( lookAt( pos ) )) 
    251                 { 
    252                     name.append( lookAt( pos ) ); 
     276                StringClass name; 
     277                while (_pos < m_contentSize && C_isAlNum( lookAt( pos ) )) 
     278                { 
     279                    //name.append( lookAt( pos ) ); 
     280                    name += lookAt( pos ); 
    253281                    pos++; 
    254282                    _pos++; 
     
    259287                    _pos++; 
    260288                } 
    261                 name = name.toLower(); 
     289                //name = name.toLower(); 
     290                S_toLower(name); 
    262291                if (lookAt( pos ) == ')') 
    263292                { 
     
    356385                        int _pos = 3; 
    357386                        while (m_curpos+_pos < m_contentSize && 
    358                                ( u_isalnum( lookAt( pos + _pos ) ) == ' ' || u_isalnum( lookAt( pos + _pos ) ) == '\t')) 
     387                               ( C_isAlNum( lookAt( pos + _pos ) ) == ' ' || C_isAlNum( lookAt( pos + _pos ) ) == '\t')) 
    359388                        { 
    360389                            _pos++; 
    361390                        } 
    362                         if ( u_isalnum( lookAt( pos + _pos ) ) || lookAt( pos + _pos ) == '_') //identifier must start with a letter 
     391                        if ( C_isAlNum( lookAt( pos + _pos ) ) || lookAt( pos + _pos ) == '_') //identifier must start with a letter 
    363392                        { 
    364                             m_heredocIdentifier.remove(); 
     393                            //m_heredocIdentifier.remove(); 
     394                            m_heredocIdentifier = ""; 
    365395                            while (m_curpos+_pos < m_contentSize && 
    366                                 ( u_isdigit( lookAt( pos + _pos ) ) || u_isalnum( lookAt( pos + _pos ) ) || lookAt( pos + _pos ) == '_')) 
     396                                ( C_isDigit( lookAt( pos + _pos ) ) || C_isAlNum( lookAt( pos + _pos ) ) || lookAt( pos + _pos ) == '_')) 
    367397                            { 
    368                                 m_heredocIdentifier.append( lookAt( pos + _pos ) ); 
     398                                //m_heredocIdentifier.append( lookAt( pos + _pos ) ); 
     399                                m_heredocIdentifier += lookAt( pos + _pos ); 
    369400                                _pos++; 
    370401                            } 
     
    630661                    if (lookAt( pos ) == '$'  && !isEscapedWithBackslash(lookAt( pos ), m_curpos+i, m_curpos, pos) 
    631662                            && (lookAt( pos + 1 ) == '{' 
    632                                    || (isValidVariableIdentifier( lookAt( pos + 1 ) ) && ! u_isdigit( lookAt( pos + 1 ) )))) { 
     663                                   || (isValidVariableIdentifier( lookAt( pos + 1 ) ) && ! C_isDigit( lookAt( pos + 1 ) )))) { 
    633664                        foundVar = true; 
    634665                    } 
     
    677708                } 
    678709            } 
    679             else if (isValidVariableIdentifier(lookAt( pos )) && !u_isdigit( lookAt( pos ) )) 
    680             { 
    681                 UnicodeString name; 
     710            else if (isValidVariableIdentifier(lookAt( pos )) && !C_isDigit( lookAt( pos ) )) 
     711            { 
     712                StringClass name; 
    682713                while (m_curpos < m_contentSize && (isValidVariableIdentifier(lookAt( pos )))) { 
    683                     name.append(lookAt( pos )); 
     714                    //name.append(lookAt( pos )); 
     715                    name += lookAt( pos ); 
    684716                    pos++; 
    685717                    m_curpos++; 
    686718                } 
    687719                m_curpos--; 
    688                 name = name.toLower(); 
     720                //name = name.toLower(); 
     721                S_toLower(name); 
    689722                if (name == "echo") { 
    690723                    token = parser::Token_ECHO; 
     
    856889                pos += 2; 
    857890                //check if a valid variable follows 
    858                 if ((isValidVariableIdentifier(lookAt( pos )) && ! u_isdigit( lookAt( pos ) ))) 
     891                if ((isValidVariableIdentifier(lookAt( pos )) && ! C_isDigit( lookAt( pos ) ))) 
    859892                { 
    860893                    pushState(StringVarname); 
     
    868901            } 
    869902            else if (state() != StringVariable && lookAt( pos ) == '{' && lookAt( pos + 1 ) == '$' 
    870                     && (isValidVariableIdentifier( lookAt( pos + 2 ) ) && ! u_isdigit( lookAt( pos + 2 ) ) || lookAt( pos + 2 ) == '{')) 
     903                    && (isValidVariableIdentifier( lookAt( pos + 2 ) ) && ! C_isDigit( lookAt( pos + 2 ) ) || lookAt( pos + 2 ) == '{')) 
    871904            { 
    872905                token = parser::Token_CURLY_OPEN; 
     
    875908            else if (state() == StringVariable 
    876909                    && lookAt( pos ) == '-' && lookAt( pos + 1 ) == '>' 
    877                     && isValidVariableIdentifier( lookAt( pos + 2 ) ) && ! u_isdigit( lookAt( pos + 2 ) )) 
     910                    && isValidVariableIdentifier( lookAt( pos + 2 ) ) && ! C_isDigit( lookAt( pos + 2 ) )) 
    878911            { 
    879912                token = parser::Token_OBJECT_OPERATOR; 
     
    892925                         (lookAt( pos ) == '$' && lookAt( pos + 1 ) == '{' || 
    893926                          lookAt( pos ) == '{' && lookAt( pos + 1 ) == '$' || 
    894                           lookAt( pos ) == '$' && isValidVariableIdentifier( lookAt( pos + 1 ) ) && ! u_isdigit( lookAt( pos + 1 ) ))) 
     927                          lookAt( pos ) == '$' && isValidVariableIdentifier( lookAt( pos + 1 ) ) && ! C_isDigit( lookAt( pos + 1 ) ))) 
    895928                    { 
    896929                        //variable is next ${var} or {$var} 
     
    932965                popState(); 
    933966            } 
    934             else if ( u_isdigit( lookAt( pos ) )) 
     967            else if ( C_isDigit( lookAt( pos ) )) 
    935968            { 
    936969                token = parser::Token_NUM_STRING; 
    937                 while (m_curpos < m_contentSize && u_isdigit( lookAt( pos ) )) 
     970                while (m_curpos < m_contentSize && C_isDigit( lookAt( pos ) )) 
    938971                { 
    939972                    pos++; 
     
    10111044} 
    10121045 
    1013 rint64 Lexer::tokenBegin() const 
     1046template <typename StringClass, typename CharClass> 
     1047rint64 Lexer<StringClass, CharClass>::tokenBegin() const 
    10141048{ 
    10151049    return m_tokenBegin; 
    10161050} 
    10171051 
    1018 rint64 Lexer::tokenEnd() const 
     1052template <typename StringClass, typename CharClass> 
     1053rint64 Lexer<StringClass, CharClass>::tokenEnd() const 
    10191054{ 
    10201055    return m_tokenEnd; 
    10211056} 
    10221057 
    1023 bool Lexer::isHeredocEnd(const UChar32& it, int pos) 
     1058template <typename StringClass, typename CharClass> 
     1059bool Lexer<StringClass, CharClass>::isHeredocEnd(const CharClass& it, int pos) 
    10241060{ 
    10251061    int identiferLen = m_heredocIdentifier.length(); 
    1026     UnicodeString lineStart; 
     1062    StringClass lineStart; 
    10271063    for (int i = 0; i < identiferLen; i++) { 
    10281064        if (m_curpos+i >= m_contentSize) break; 
    1029         lineStart.append( lookAt( pos + i ) ); 
     1065        //lineStart.append( lookAt( pos + i ) ); 
     1066        lineStart += lookAt( pos + i ); 
    10301067    } 
    10311068    if (lineStart == m_heredocIdentifier && 
     
    10401077 
    10411078//used for strings, to check if " is escaped (\" is, \\" not) 
    1042 bool Lexer::isEscapedWithBackslash(const UChar32& it, int curPos, int startPos, int pos) 
     1079template <typename StringClass, typename CharClass> 
     1080bool Lexer<StringClass, CharClass>::isEscapedWithBackslash(const CharClass& it, int curPos, int startPos, int pos) 
    10431081{ 
    10441082    int cnt = 0; 
     
    10511089} 
    10521090 
    1053 bool Lexer::processVariable(int pos) 
    1054 
    1055     UChar32 c2 = lookAt( pos + 1 ); 
    1056     if ( lookAt( pos ) == '$' && (isValidVariableIdentifier(c2) && ! u_isdigit( c2 ))) 
     1091template <typename StringClass, typename CharClass> 
     1092bool Lexer<StringClass, CharClass>::processVariable(int pos) 
     1093
     1094    CharClass c2 = lookAt( pos + 1 ); 
     1095    if ( lookAt( pos ) == '$' && (isValidVariableIdentifier(c2) && ! C_isDigit( c2 ))) 
    10571096    { 
    10581097        pos++; 
     
    10721111    } 
    10731112} 
    1074 bool Lexer::isValidVariableIdentifier(const UChar32& it) 
     1113template <typename StringClass, typename CharClass> 
     1114bool Lexer<StringClass, CharClass>::isValidVariableIdentifier(const CharClass& it) 
    10751115{ 
    10761116    // TODO check: it > 0x7f 
    1077     return u_isalnum( it ) || u_isdigit( it ) || it == '_' || it > 0x7f; 
    1078 
    1079  
    1080 void Lexer::createNewline( int pos ) 
     1117    return C_isAlNum( it ) || C_isDigit( it ) || it == '_' || C_isHigh(it); 
     1118
     1119 
     1120template <typename StringClass, typename CharClass> 
     1121void Lexer<StringClass, CharClass>::createNewline( int pos ) 
    10811122{ 
    10821123    #ifdef PENDING_THOMAS 
     
    10871128} 
    10881129 
    1089 
    1090  
     1130// implement supported types 
     1131template class Lexer<UnicodeString, UChar32>; 
     1132template class Lexer<std::string, char>; 
     1133 
     1134
     1135 
  • trunk/rphp/compiler/parser/phplexer.h

    r614 r616  
    2424#include "rphp_ast.h" 
    2525#include <vector> 
    26 #include <unistr.h> 
     26#include <string> 
     27#include <unicode/unistr.h> 
    2728 
    2829namespace rphp 
    2930{ 
    3031 
    31 class parser; 
     32       class parser; 
    3233 
    33 /** 
    34  * Hand-written Lexer that generates the same tokens as php uses. 
    35  * This includes also a whitespace and comment token. 
    36  * 
    37  * For debugging output can be compared to php-tokens using the 
    38  * test/test-tokenize.php script 
    39  **/ 
    40 class Lexer { 
    41 public: 
    42     Lexer(parser* _parser, const UnicodeString& contents); 
     34        /** 
     35         * Hand-written Lexer that generates the same tokens as php uses. 
     36         * This includes also a whitespace and comment token. 
     37         * 
     38         * For debugging output can be compared to php-tokens using the 
     39         * test/test-tokenize.php script 
     40         **/ 
     41        template <typename StringClass, typename CharClass> 
     42        class Lexer { 
     43        public: 
     44                Lexer(parser* _parser, const StringClass& contents); 
    4345 
    44     int nextTokenKind(); 
    45     rint64 tokenBegin() const; 
    46     rint64 tokenEnd() const; 
     46               int nextTokenKind(); 
     47               rint64 tokenBegin() const; 
     48               rint64 tokenEnd() const; 
    4749 
    48 private: 
    49     UnicodeString m_content; 
    50     parser* m_parser; 
    51     int m_curpos; 
    52     int m_contentSize; 
    53     rint64 m_tokenBegin; 
    54     rint64 m_tokenEnd; 
     50       private: 
     51               StringClass m_content; 
     52               parser* m_parser; 
     53               int m_curpos; 
     54               int m_contentSize; 
     55               rint64 m_tokenBegin; 
     56               rint64 m_tokenEnd; 
    5557 
    56     int state(int deepness = 0) const; 
    57     void pushState(int state); 
    58     void popState(); 
    59     void printState(); 
     58               int state(int deepness = 0) const; 
     59               void pushState(int state); 
     60               void popState(); 
     61               void printState(); 
    6062 
    61     bool processVariable(int pos); 
    62     bool isValidVariableIdentifier(const UChar32& it); 
    63     void createNewline( int pos ); 
    64     bool isEscapedWithBackslash(const UChar32& it, int curPos, int startPos, int pos); 
    65     bool isHeredocEnd(const UChar32& it, int pos); 
     63               bool processVariable(int pos); 
     64               bool isValidVariableIdentifier(const CharClass& it); 
     65               void createNewline( int pos ); 
     66               bool isEscapedWithBackslash(const CharClass& it, int curPos, int startPos, int pos); 
     67               bool isHeredocEnd(const CharClass& it, int pos); 
    6668 
    67     UChar32 lookAt( int pos ){ return m_content.char32At( pos ); } 
     69                CharClass inline lookAt( int pos ){ 
     70            return m_content[pos]; 
     71        } 
    6872 
    69     std::vector<int> m_state; // was: QStack<int> 
    70     enum State 
    71     { 
    72         ErrorState = -1, 
    73         HtmlState = 0, 
    74         DefaultState = 1, 
    75         String = 2, 
    76         StringVariable = 3, 
    77         StringVariableBracket = 4, 
    78         StringVariableObjectOperator = 5, 
    79         StringVariableCurly = 6, 
    80         StringVarname = 7, 
    81         StringHeredoc = 8, 
    82         StringBacktick = 9 
    83     }; 
    84     UnicodeString m_heredocIdentifier; 
    85     int m_haltCompiler; 
    86 }; 
     73                std::vector<int> m_state; // was: QStack<int> 
     74                enum State 
     75                { 
     76                        ErrorState = -1, 
     77                        HtmlState = 0, 
     78                        DefaultState = 1, 
     79                        String = 2, 
     80                        StringVariable = 3, 
     81                        StringVariableBracket = 4, 
     82                        StringVariableObjectOperator = 5, 
     83                        StringVariableCurly = 6, 
     84                        StringVarname = 7, 
     85                        StringHeredoc = 8, 
     86                        StringBacktick = 9 
     87                }; 
     88                StringClass m_heredocIdentifier; 
     89                int m_haltCompiler; 
     90        }; 
     91 
     92        // define the two lexers we support: Unicode and std::string based 
     93        typedef Lexer<UnicodeString, UChar32> ULexer; 
     94        typedef Lexer<std::string, char> BLexer; 
    8795 
    8896} 
  • trunk/rphp/compiler/parser/rphp_ast.h

    r609 r616  
    99 
    1010 
    11 #include <unistr.h> 
     11#include <unicode/unistr.h> 
    1212#include <string> 
    1313#include <iostream> 
     
    1919namespace rphp 
    2020  { 
    21  
    22   class Lexer; 
     21  //template <typename StringClass, typename CharClass> class Lexer; 
    2322  enum NumericType  { 
    2423    LongNumber, 
     
    3938 
    4039  struct additiveExpression_ast; 
    41  
    4240  struct additiveExpressionRest_ast; 
    43  
    4441  struct arrayPairValue_ast; 
    45  
    4642  struct assignmentExpression_ast; 
    47  
    4843  struct assignmentExpressionCheckIfVariable_ast; 
    49  
    5044  struct assignmentExpressionEqual_ast; 
    51  
    5245  struct assignmentList_ast; 
    53  
    5446  struct assignmentListElement_ast; 
    55  
    5647  struct baseVariable_ast; 
    57  
    5848  struct baseVariableWithFunctionCalls_ast; 
    59  
    6049  struct bitAndExpression_ast; 
    61  
    6250  struct bitOrExpression_ast; 
    63  
    6451  struct bitXorExpression_ast; 
    65  
    6652  struct booleanAndExpression_ast; 
    67  
    6853  struct booleanOrExpression_ast; 
    69  
    7054  struct caseList_ast; 
    71  
    7255  struct case_item_ast; 
    73  
    7456  struct catch_item_ast; 
    75  
    7657  struct classConstantDeclaration_ast; 
    77  
    7858  struct classDeclarationStatement_ast; 
    79  
    8059  struct classNameReference_ast; 
    81  
    8260  struct classStatement_ast; 
    83  
    8461  struct classVariable_ast; 
    85  
    8662  struct classVariableDeclaration_ast; 
    87  
    8863  struct commonScalar_ast; 
    89  
    9064  struct compoundVariable_ast; 
    91  
    9265  struct compoundVariableWithSimpleIndirectReference_ast; 
    93  
    9466  struct conditionalExpression_ast; 
    95  
    9667  struct ctorArguments_ast; 
    97  
    9868  struct declareItem_ast; 
    99  
    10069  struct declareStatement_ast; 
    101  
    10270  struct dimListItem_ast; 
    103  
    10471  struct dimOffset_ast; 
    105  
    10672  struct dynamicClassNameReference_ast; 
    107  
    10873  struct dynamicClassNameVariableProperties_ast; 
    109  
    11074  struct dynamicClassNameVariableProperty_ast; 
    111  
    11275  struct elseSingle_ast; 
    113  
    11476  struct elseifList_ast; 
    115  
    11677  struct elseifListItem_ast; 
    117  
    11878  struct encaps_ast; 
    119  
    12079  struct encapsList_ast; 
    121  
    12280  struct encapsVar_ast; 
    123  
    12481  struct encapsVarOffset_ast; 
    125  
    12682  struct equalityExpression_ast; 
    127  
    12883  struct equalityExpressionRest_ast; 
    129  
    13084  struct expr_ast; 
    131  
    13285  struct forExpr_ast; 
    133  
    13486  struct forStatement_ast; 
    135  
    13687  struct foreachOptionalArg_ast; 
    137  
    13888  struct foreachStatement_ast; 
    139  
    14089  struct foreachVariable_ast; 
    141  
    14290  struct functionCall_ast; 
    143  
    14491  struct functionCallParameterList_ast; 
    145  
    14692  struct functionCallParameterListElement_ast; 
    147  
    14893  struct functionDeclarationStatement_ast; 
    149  
    15094  struct globalVar_ast; 
    151  
    15295  struct innerStatementList_ast; 
    153  
    15496  struct logicalAndExpression_ast; 
    155  
    15697  struct logicalOrExpression_ast; 
    157  
    15898  struct logicalXorExpression_ast; 
    159  
    16099  struct memberModifier_ast; 
    161  
    162100  struct methodBody_ast; 
    163  
    164101  struct multiplicativeExpression_ast; 
    165  
    166102  struct multiplicativeExpression_rest_ast; 
    167  
    168103  struct newElseSingle_ast; 
    169  
    170104  struct newElseifList_ast; 
    171  
    172105  struct newelseifListItem_ast; 
    173  
    174106  struct objectDimList_ast; 
    175  
    176107  struct objectProperty_ast; 
    177  
    178108  struct parameter_ast; 
    179  
    180109  struct parameterList_ast; 
    181  
    182110  struct postprefixOperator_ast; 
    183  
    184111  struct printExpression_ast; 
    185  
    186112  struct relationalExpression_ast; 
    187  
    188113  struct relationalExpressionRest_ast; 
    189  
    190114  struct scalar_ast; 
    191  
    192115  struct semicolonOrCloseTag_ast; 
    193  
    194116  struct shiftExpression_ast; 
    195  
    196117  struct shiftExpressionRest_ast; 
    197  
    198118  struct start_ast; 
    199  
    200119  struct statement_ast; 
    201  
    202120  struct staticArrayPairValue_ast; 
    203  
    204121  struct staticMember_ast; 
    205  
    206122  struct staticScalar_ast; 
    207  
    208123  struct staticVar_ast; 
    209  
    210124  struct switchCaseList_ast; 
    211  
    212125  struct topStatement_ast; 
    213  
    214126  struct unaryExpression_ast; 
    215  
    216127  struct unaryExpression_not_plusminus_ast; 
    217  
    218128  struct varExpression_ast; 
    219  
    220129  struct varExpressionNewObject_ast; 
    221  
    222130  struct varExpressionNormal_ast; 
    223  
    224131  struct variable_ast; 
    225  
    226132  struct variableName_ast; 
    227  
    228133  struct variableProperty_ast; 
    229  
    230134  struct variableWithoutObjects_ast; 
    231  
    232135  struct whileStatement_ast; 
    233136 
  • trunk/rphp/compiler/parser/rphp_default_visitor.cpp

    r555 r616  
    1010  { 
    1111    visit_node(node->expression); 
    12  
    13     if  (node->additionalExpression_sequence) 
    14       { 
    15         const list_node<additiveExpressionRest_ast*> *__it =  node->additionalExpression_sequence->to_front(),  *__end =  __it; 
    16  
    17         do 
    18           { 
    19             visit_node(__it->element); 
    20             __it =  __it->next; 
    21           } 
    22  
    23         while  (__it !=  __end); 
     12    if (node->additionalExpression_sequence) 
     13      { 
     14        const list_node<additiveExpressionRest_ast*> *__it = node->additionalExpression_sequence->to_front(), *__end = __it; 
     15        do 
     16          { 
     17            visit_node(__it->element); 
     18            __it = __it->next; 
     19          } 
     20        while (__it != __end); 
    2421      } 
    2522  } 
     
    5552  void default_visitor::visit_assignmentList(assignmentList_ast *node) 
    5653  { 
    57     if  (node->element_sequence) 
    58       { 
    59         const list_node<assignmentListElement_ast*> *__it =  node->element_sequence->to_front(),  *__end =  __it; 
    60  
    61         do 
    62           { 
    63             visit_node(__it->element); 
    64             __it =  __it->next; 
    65           } 
    66  
    67         while  (__it !=  __end); 
     54    if (node->element_sequence) 
     55      { 
     56        const list_node<assignmentListElement_ast*> *__it = node->element_sequence->to_front(), *__end = __it; 
     57        do 
     58          { 
     59            visit_node(__it->element); 
     60            __it = __it->next; 
     61          } 
     62        while (__it != __end); 
    6863      } 
    6964  } 
     
    7873  { 
    7974    visit_node(node->var); 
    80  
    81     if  (node->offsetItems_sequence) 
    82       { 
    83         const list_node<dimListItem_ast*> *__it =  node->offsetItems_sequence->to_front(),  *__end =  __it; 
    84  
    85         do 
    86           { 
    87             visit_node(__it->element); 
    88             __it =  __it->next; 
    89           } 
    90  
    91         while  (__it !=  __end); 
    92       } 
    93  
     75    if (node->offsetItems_sequence) 
     76      { 
     77        const list_node<dimListItem_ast*> *__it = node->offsetItems_sequence->to_front(), *__end = __it; 
     78        do 
     79          { 
     80            visit_node(__it->element); 
     81            __it = __it->next; 
     82          } 
     83        while (__it != __end); 
     84      } 
    9485    visit_node(node->staticMember); 
    9586  } 
     
    10394  void default_visitor::visit_bitAndExpression(bitAndExpression_ast *node) 
    10495  { 
    105     if  (node->expression_sequence) 
    106       { 
    107         const list_node<equalityExpression_ast*> *__it =  node->expression_sequence->to_front(),  *__end =  __it; 
    108  
    109         do 
    110           { 
    111             visit_node(__it->element); 
    112             __it =  __it->next; 
    113           } 
    114  
    115         while  (__it !=  __end); 
     96    if (node->expression_sequence) 
     97      { 
     98        const list_node<equalityExpression_ast*> *__it = node->expression_sequence->to_front(), *__end = __it; 
     99        do 
     100          { 
     101            visit_node(__it->element); 
     102            __it = __it->next; 
     103          } 
     104        while (__it != __end); 
    116105      } 
    117106  } 
     
    119108  void default_visitor::visit_bitOrExpression(bitOrExpression_ast *node) 
    120109  { 
    121     if  (node->expression_sequence) 
    122       { 
    123         const list_node<bitXorExpression_ast*> *__it =  node->expression_sequence->to_front(),  *__end =  __it; 
    124  
    125         do 
    126           { 
    127             visit_node(__it->element); 
    128             __it =  __it->next; 
    129           } 
    130  
    131         while  (__it !=  __end); 
     110    if (node->expression_sequence) 
     111      { 
     112        const list_node<bitXorExpression_ast*> *__it = node->expression_sequence->to_front(), *__end = __it; 
     113        do 
     114          { 
     115            visit_node(__it->element); 
     116            __it = __it->next; 
     117          } 
     118        while (__it != __end); 
    132119      } 
    133120  } 
     
    135122  void default_visitor::visit_bitXorExpression(bitXorExpression_ast *node) 
    136123  { 
    137     if  (node->expression_sequence) 
    138       { 
    139         const list_node<bitAndExpression_ast*> *__it =  node->expression_sequence->to_front(),  *__end =  __it; 
    140  
    141         do 
    142           { 
    143             visit_node(__it->element); 
    144             __it =  __it->next; 
    145           } 
    146  
    147         while  (__it !=  __end); 
     124    if (node->expression_sequence) 
     125      { 
     126        const list_node<bitAndExpression_ast*> *__it = node->expression_sequence->to_front(), *__end = __it; 
     127        do 
     128          { 
     129            visit_node(__it->element); 
     130            __it = __it->next; 
     131          } 
     132        while (__it != __end); 
    148133      } 
    149134  } 
     
    151136  void default_visitor::visit_booleanAndExpression(booleanAndExpression_ast *node) 
    152137  { 
    153     if  (node->expression_sequence) 
    154       { 
    155         const list_node<bitOrExpression_ast*> *__it =  node->expression_sequence->to_front(),  *__end =  __it; 
    156  
    157         do 
    158           { 
    159             visit_node(__it->element); 
    160             __it =  __it->next; 
    161           } 
    162  
    163         while  (__it !=  __end); 
     138    if (node->expression_sequence) 
     139      { 
     140        const list_node<bitOrExpression_ast*> *__it = node->expression_sequence->to_front(), *__end = __it; 
     141        do 
     142          { 
     143            visit_node(__it->element); 
     144            __it = __it->next; 
     145          } 
     146        while (__it != __end); 
    164147      } 
    165148  } 
     
    167150  void default_visitor::visit_booleanOrExpression(booleanOrExpression_ast *node) 
    168151  { 
    169     if  (node->expression_sequence) 
    170       { 
    171         const list_node<booleanAndExpression_ast*> *__it =  node->expression_sequence->to_front(),  *__end =  __it; 
    172  
    173         do 
    174           { 
    175             visit_node(__it->element); 
    176             __it =  __it->next; 
    177           } 
    178  
    179         while  (__it !=  __end);