
#line 24 "../cplusplu/chopper.ch"
/*************************************************************************/
#line 24 "../cplusplu/chopper.ch"
/*                                                                       */
#line 24 "../cplusplu/chopper.ch"
/*        Produced by Metachop version 2.0  -    1989-1995               */
#line 24 "../cplusplu/chopper.ch"
/*     Tree      Meta     Chopper      developped    by                  */
#line 24 "../cplusplu/chopper.ch"
/*                  Eric Lavillonniere                                   */
#line 24 "../cplusplu/chopper.ch"
/*                                                                       */
#line 24 "../cplusplu/chopper.ch"
/*************************************************************************/
#line 24 "../cplusplu/chopper.ch"
#line 24 "../cplusplu/chopper.ch"
#include "token.h"
#line 24 "../cplusplu/chopper.ch"
extern int _retVal[50];
#line 24 "../cplusplu/chopper.ch"
extern PPTREE _storeVal[50],_nextVal;
#line 24 "../cplusplu/chopper.ch"
extern PPTREE stackTree[1024];
#line 24 "../cplusplu/chopper.ch"
extern int ptStackTree;
#line 24 "../cplusplu/chopper.ch"
#define decomp decomp_cplus
#line 24 "../cplusplu/chopper.ch"
#line 24 "../cplusplu/chopper.ch"
#ifndef for_elem
#line 24 "../cplusplu/chopper.ch"
#line 24 "../cplusplu/chopper.ch"
#define for_elem _for_elem
#line 24 "../cplusplu/chopper.ch"
#endif
#ifdef INCONNU
#line 24 "../cplusplu/chopper.ch"
#line 24 "../cplusplu/chopper.ch"
PTREE   for_elem ;
#line 24 "../cplusplu/chopper.ch"
#line 24 "../cplusplu/chopper.ch"
#endif
#include <stdio.h>
#include <stdlib.h>
#include "deccplus.h"
#include <fcntl.h>

DecompCplus *DecompCplus::ptDecomp = 0 ;
int nbOpenComment = 0 ;

extern "C" {
    char    *DecToIdent (PTREE) ;
    int hasGotError = 0 ;
    
#line 39 "../cplusplu/chopper.ch"
#line 39 "../cplusplu/chopper.ch"
    PPTREE bri_parse_entry_cplus ( int error_free )
#line 39 "../cplusplu/chopper.ch"
    {
#line 39 "../cplusplu/chopper.ch"
#line 41 "../cplusplu/chopper.ch"
        cplus   theParser ;
#line 41 "../cplusplu/chopper.ch"
#line 43 "../cplusplu/chopper.ch"
        return theParser.parse_entry(error_free);
#line 43 "../cplusplu/chopper.ch"
#line 44 "../cplusplu/chopper.ch"
    }
#line 44 "../cplusplu/chopper.ch"
    
    extern PPTREE   (*the_parse_entry_pt)(int) ;
    
#line 51 "../cplusplu/chopper.ch"
#line 51 "../cplusplu/chopper.ch"
    PPTREE parse_cplus ( int error_tree )
#line 51 "../cplusplu/chopper.ch"
    {
#line 51 "../cplusplu/chopper.ch"
#line 53 "../cplusplu/chopper.ch"
        cplus   theParser ;
#line 53 "../cplusplu/chopper.ch"
#line 55 "../cplusplu/chopper.ch"
        return theParser.program(error_tree);
#line 55 "../cplusplu/chopper.ch"
#line 56 "../cplusplu/chopper.ch"
    }
#line 56 "../cplusplu/chopper.ch"
    
    typedef struct type_def {
        char    *name ;
        struct type_def *next ;
    }   TYP_DEF,    *PTYP_DEF ;
    
    PTYP_DEF    listTypDef = (PTYP_DEF)0 ;
    
#line 67 "../cplusplu/chopper.ch"
#line 67 "../cplusplu/chopper.ch"
    void AllocTypDef ( char *name )
#line 67 "../cplusplu/chopper.ch"
    {
#line 67 "../cplusplu/chopper.ch"
#line 70 "../cplusplu/chopper.ch"
        PTYP_DEF    point = (PTYP_DEF)malloc(sizeof(TYP_DEF));
#line 70 "../cplusplu/chopper.ch"
#line 72 "../cplusplu/chopper.ch"
        point -> next = listTypDef ;
#line 72 "../cplusplu/chopper.ch"
#line 73 "../cplusplu/chopper.ch"
        point -> name = AllocString(name);
#line 73 "../cplusplu/chopper.ch"
#line 74 "../cplusplu/chopper.ch"
        listTypDef = point ;
#line 74 "../cplusplu/chopper.ch"
#line 75 "../cplusplu/chopper.ch"
    }
#line 75 "../cplusplu/chopper.ch"
    
#line 79 "../cplusplu/chopper.ch"
#line 79 "../cplusplu/chopper.ch"
    int IsTypDef ( char *name )
#line 79 "../cplusplu/chopper.ch"
    {
#line 79 "../cplusplu/chopper.ch"
#line 82 "../cplusplu/chopper.ch"
        register PTYP_DEF   point = listTypDef ;
#line 82 "../cplusplu/chopper.ch"
#line 84 "../cplusplu/chopper.ch"
        while ( point ) {
#line 84 "../cplusplu/chopper.ch"
#line 85 "../cplusplu/chopper.ch"
                            if ( !strcmp(point -> name, name) ) 
#line 85 "../cplusplu/chopper.ch"
#line 86 "../cplusplu/chopper.ch"
                                return 1 ;
#line 86 "../cplusplu/chopper.ch"
#line 87 "../cplusplu/chopper.ch"
                            point = point -> next ;
#line 87 "../cplusplu/chopper.ch"
#line 87 "../cplusplu/chopper.ch"
                         }
#line 87 "../cplusplu/chopper.ch"
#line 89 "../cplusplu/chopper.ch"
        return 0 ;
#line 89 "../cplusplu/chopper.ch"
#line 90 "../cplusplu/chopper.ch"
    }
#line 90 "../cplusplu/chopper.ch"
    
#line 94 "../cplusplu/chopper.ch"
#line 94 "../cplusplu/chopper.ch"
    void TypDef ( PTREE tree )
#line 94 "../cplusplu/chopper.ch"
    {
#line 94 "../cplusplu/chopper.ch"
        register PPTREE _inter ;
#line 94 "../cplusplu/chopper.ch"
#line 94 "../cplusplu/chopper.ch"
#line 97 "../cplusplu/chopper.ch"
        PTREE   list = (PTREE)0 ;
#line 97 "../cplusplu/chopper.ch"
#line 97 "../cplusplu/chopper.ch"
#line 97 "../cplusplu/chopper.ch"
        (list=tree);
#line 97 "../cplusplu/chopper.ch"
#line 97 "../cplusplu/chopper.ch"
#line 99 "../cplusplu/chopper.ch"
        while ( list ) {
#line 99 "../cplusplu/chopper.ch"
#line 100 "../cplusplu/chopper.ch"
                            (tree=SonTree(list, 1));
#line 100 "../cplusplu/chopper.ch"
#line 100 "../cplusplu/chopper.ch"
#line 101 "../cplusplu/chopper.ch"
                            (list=SonTree(list, 2));
#line 101 "../cplusplu/chopper.ch"
#line 101 "../cplusplu/chopper.ch"
#line 102 "../cplusplu/chopper.ch"
                            while ( !(((_inter = (PPTREE)tree,1) && 
#line 102 "../cplusplu/chopper.ch"
                                            (NumberTree(_inter) == TERM_TREE) &&
#line 102 "../cplusplu/chopper.ch"
                                            1)) ) {
#line 102 "../cplusplu/chopper.ch"
#line 103 "../cplusplu/chopper.ch"
                                                    if ( !(((_inter = (PPTREE)tree,1) && 
#line 103 "../cplusplu/chopper.ch"
                                                                (NumberTree(_inter) == cplus::RANGE_MODIFIER) &&
#line 103 "../cplusplu/chopper.ch"
                                                                ((tree=SonTree(_inter,2)),1) &&
#line 103 "../cplusplu/chopper.ch"
                                                                1)) ) 
#line 103 "../cplusplu/chopper.ch"
#line 104 "../cplusplu/chopper.ch"
                                                        ((_inter = (PPTREE)tree,1) && 
#line 104 "../cplusplu/chopper.ch"
                                                            ((tree=SonTree(_inter,1)),1) &&
#line 104 "../cplusplu/chopper.ch"
                                                            1);
#line 104 "../cplusplu/chopper.ch"
                                                        ;
#line 104 "../cplusplu/chopper.ch"
#line 104 "../cplusplu/chopper.ch"
                                                  }
#line 104 "../cplusplu/chopper.ch"
#line 106 "../cplusplu/chopper.ch"
                            AllocTypDef(BrainyValue(tree));
#line 106 "../cplusplu/chopper.ch"
#line 106 "../cplusplu/chopper.ch"
                        }
#line 106 "../cplusplu/chopper.ch"
#line 108 "../cplusplu/chopper.ch"
    }
#line 108 "../cplusplu/chopper.ch"
    
    typedef struct range_modif {
        char    *name ;
        struct range_modif *next ;
    }   RANGE_MODIF,    *PRANGE_MODIF ;
    
    PRANGE_MODIF    listRangeModifier = (PRANGE_MODIF)0 ;
    
#line 119 "../cplusplu/chopper.ch"
#line 119 "../cplusplu/chopper.ch"
    static  void AllocRange ( char *name )
#line 119 "../cplusplu/chopper.ch"
    {
#line 119 "../cplusplu/chopper.ch"
#line 122 "../cplusplu/chopper.ch"
        PRANGE_MODIF    point = (PRANGE_MODIF)malloc(sizeof(RANGE_MODIF));
#line 122 "../cplusplu/chopper.ch"
#line 124 "../cplusplu/chopper.ch"
        point -> next = listRangeModifier ;
#line 124 "../cplusplu/chopper.ch"
#line 125 "../cplusplu/chopper.ch"
        point -> name = AllocString(name);
#line 125 "../cplusplu/chopper.ch"
#line 126 "../cplusplu/chopper.ch"
        listRangeModifier = point ;
#line 126 "../cplusplu/chopper.ch"
#line 127 "../cplusplu/chopper.ch"
    }
#line 127 "../cplusplu/chopper.ch"
    
#line 131 "../cplusplu/chopper.ch"
#line 131 "../cplusplu/chopper.ch"
    int IsRange ( char *name )
#line 131 "../cplusplu/chopper.ch"
    {
#line 131 "../cplusplu/chopper.ch"
#line 134 "../cplusplu/chopper.ch"
        register PRANGE_MODIF   point = listRangeModifier ;
#line 134 "../cplusplu/chopper.ch"
#line 136 "../cplusplu/chopper.ch"
        while ( point ) {
#line 136 "../cplusplu/chopper.ch"
#line 137 "../cplusplu/chopper.ch"
                            if ( !strcmp(point -> name, name) ) 
#line 137 "../cplusplu/chopper.ch"
#line 138 "../cplusplu/chopper.ch"
                                return 1 ;
#line 138 "../cplusplu/chopper.ch"
#line 139 "../cplusplu/chopper.ch"
                            point = point -> next ;
#line 139 "../cplusplu/chopper.ch"
#line 139 "../cplusplu/chopper.ch"
                         }
#line 139 "../cplusplu/chopper.ch"
#line 141 "../cplusplu/chopper.ch"
        return 0 ;
#line 141 "../cplusplu/chopper.ch"
#line 142 "../cplusplu/chopper.ch"
    }
#line 142 "../cplusplu/chopper.ch"
    
#line 146 "../cplusplu/chopper.ch"
#line 146 "../cplusplu/chopper.ch"
    void Range ( PTREE tree )
#line 146 "../cplusplu/chopper.ch"
    {
#line 146 "../cplusplu/chopper.ch"
#line 149 "../cplusplu/chopper.ch"
        AllocRange(BrainyValue(tree));
#line 149 "../cplusplu/chopper.ch"
#line 150 "../cplusplu/chopper.ch"
    }
#line 150 "../cplusplu/chopper.ch"
    
#line 154 "../cplusplu/chopper.ch"
#line 154 "../cplusplu/chopper.ch"
    void AnalyseRange ( char *content )
#line 154 "../cplusplu/chopper.ch"
    {
#line 154 "../cplusplu/chopper.ch"
#line 157 "../cplusplu/chopper.ch"
        AllocRange(content);
#line 157 "../cplusplu/chopper.ch"
#line 158 "../cplusplu/chopper.ch"
    }
#line 158 "../cplusplu/chopper.ch"
    
#line 162 "../cplusplu/chopper.ch"
#line 162 "../cplusplu/chopper.ch"
    void AnalyzeTab ( PPTREE tree )
#line 162 "../cplusplu/chopper.ch"
    {
#line 162 "../cplusplu/chopper.ch"
#line 165 "../cplusplu/chopper.ch"
        int i ;
#line 165 "../cplusplu/chopper.ch"
#line 167 "../cplusplu/chopper.ch"
        sscanf(BrainyValue(tree), "%d", &i);
#line 167 "../cplusplu/chopper.ch"
#line 168 "../cplusplu/chopper.ch"
        tabValue = i ;
#line 168 "../cplusplu/chopper.ch"
#line 169 "../cplusplu/chopper.ch"
    }
#line 169 "../cplusplu/chopper.ch"
    
#line 173 "../cplusplu/chopper.ch"
#line 173 "../cplusplu/chopper.ch"
    void AnalyzeMargin ( PPTREE tree )
#line 173 "../cplusplu/chopper.ch"
    {
#line 173 "../cplusplu/chopper.ch"
#line 176 "../cplusplu/chopper.ch"
        int i ;
#line 176 "../cplusplu/chopper.ch"
#line 178 "../cplusplu/chopper.ch"
        sscanf(BrainyValue(tree), "%d", &i);
#line 178 "../cplusplu/chopper.ch"
#line 179 "../cplusplu/chopper.ch"
        rightMargin = i ;
#line 179 "../cplusplu/chopper.ch"
#line 180 "../cplusplu/chopper.ch"
    }
#line 180 "../cplusplu/chopper.ch"
    
    int ansiMode = 0 ;
    
#line 187 "../cplusplu/chopper.ch"
#line 187 "../cplusplu/chopper.ch"
    void AnalyzeMode ( PPTREE tree )
#line 187 "../cplusplu/chopper.ch"
    {
#line 187 "../cplusplu/chopper.ch"
#line 189 "../cplusplu/chopper.ch"
        ansiMode = !strcmp(BrainyValue(tree), "ansi");
#line 189 "../cplusplu/chopper.ch"
#line 190 "../cplusplu/chopper.ch"
    }
#line 190 "../cplusplu/chopper.ch"
    
    int braceAlign = 0 ;
    
#line 197 "../cplusplu/chopper.ch"
#line 197 "../cplusplu/chopper.ch"
    void AnalyzeBraceAlign ( PPTREE tree )
#line 197 "../cplusplu/chopper.ch"
    {
#line 197 "../cplusplu/chopper.ch"
#line 199 "../cplusplu/chopper.ch"
        braceAlign = !strcmp(BrainyValue(tree), "code");
#line 199 "../cplusplu/chopper.ch"
#line 200 "../cplusplu/chopper.ch"
    }
#line 200 "../cplusplu/chopper.ch"
    
    int indentFunctionType = 0 ;
    
#line 207 "../cplusplu/chopper.ch"
#line 207 "../cplusplu/chopper.ch"
    void AnalyzeIndentFunctionType ( PPTREE tree )
#line 207 "../cplusplu/chopper.ch"
    {
#line 207 "../cplusplu/chopper.ch"
#line 209 "../cplusplu/chopper.ch"
        indentFunctionType = !strcmp(BrainyValue(tree), "On") || !strcmp(BrainyValue(tree), "ON") || !strcmp(BrainyValue(tree), "on");
#line 209 "../cplusplu/chopper.ch"
#line 212 "../cplusplu/chopper.ch"
    }
#line 212 "../cplusplu/chopper.ch"
    
    int assignAlign = 0 ;
    
#line 218 "../cplusplu/chopper.ch"
#line 218 "../cplusplu/chopper.ch"
    void AnalyzeAssignAlign ( PPTREE tree )
#line 218 "../cplusplu/chopper.ch"
    {
#line 218 "../cplusplu/chopper.ch"
#line 220 "../cplusplu/chopper.ch"
        assignAlign = !strcmp(BrainyValue(tree), "On") || !strcmp(BrainyValue(tree), "ON") || !strcmp(BrainyValue(tree), "on");
#line 220 "../cplusplu/chopper.ch"
#line 223 "../cplusplu/chopper.ch"
    }
#line 223 "../cplusplu/chopper.ch"
    
#line 227 "../cplusplu/chopper.ch"
#line 227 "../cplusplu/chopper.ch"
    void AnalyzeSimplify ( PPTREE tree )
#line 227 "../cplusplu/chopper.ch"
    {
#line 227 "../cplusplu/chopper.ch"
#line 230 "../cplusplu/chopper.ch"
        DecompCplus::ptDecomp -> simplifyExpression = !strcmp(BrainyValue(tree), "On") || !strcmp(BrainyValue(tree), "ON") || !strcmp(BrainyValue(tree), "on");
#line 230 "../cplusplu/chopper.ch"
#line 235 "../cplusplu/chopper.ch"
    }
#line 235 "../cplusplu/chopper.ch"
    
    int singleSwitchIndent = 1 ;
    
#line 243 "../cplusplu/chopper.ch"
#line 243 "../cplusplu/chopper.ch"
    void AnalyzeSingleSwitchIndent ( PPTREE tree )
#line 243 "../cplusplu/chopper.ch"
    {
#line 243 "../cplusplu/chopper.ch"
#line 245 "../cplusplu/chopper.ch"
        singleSwitchIndent = !strcmp(BrainyValue(tree), "On") || !strcmp(BrainyValue(tree), "ON") || !strcmp(BrainyValue(tree), "on");
#line 245 "../cplusplu/chopper.ch"
#line 248 "../cplusplu/chopper.ch"
    }
#line 248 "../cplusplu/chopper.ch"
    
#line 254 "../cplusplu/chopper.ch"
#line 254 "../cplusplu/chopper.ch"
    void AnalyzeComment ( PPTREE tree )
#line 254 "../cplusplu/chopper.ch"
    {
#line 254 "../cplusplu/chopper.ch"
#line 258 "../cplusplu/chopper.ch"
        tree = sontree(tree, 1);
#line 258 "../cplusplu/chopper.ch"
#line 259 "../cplusplu/chopper.ch"
        switch ( NumberTree(tree) ) {
#line 259 "../cplusplu/chopper.ch"
#line 260 "../cplusplu/chopper.ch"
            case COMMENT_START_cplus : 
#line 260 "../cplusplu/chopper.ch"
#line 261 "../cplusplu/chopper.ch"
                DecompCplus::ptDecomp -> startComment = AllocString(BrainyValue(tree));
#line 261 "../cplusplu/chopper.ch"
#line 262 "../cplusplu/chopper.ch"
                break ;
#line 262 "../cplusplu/chopper.ch"
#line 263 "../cplusplu/chopper.ch"
            case COMMENT_MIDDLE_cplus : 
#line 263 "../cplusplu/chopper.ch"
#line 264 "../cplusplu/chopper.ch"
                DecompCplus::ptDecomp -> middleComment = AllocString(BrainyValue(tree));
#line 264 "../cplusplu/chopper.ch"
#line 265 "../cplusplu/chopper.ch"
                break ;
#line 265 "../cplusplu/chopper.ch"
#line 266 "../cplusplu/chopper.ch"
            case COMMENT_END_cplus : 
#line 266 "../cplusplu/chopper.ch"
#line 267 "../cplusplu/chopper.ch"
                DecompCplus::ptDecomp -> endComment = AllocString(BrainyValue(tree));
#line 267 "../cplusplu/chopper.ch"
#line 268 "../cplusplu/chopper.ch"
                break ;
#line 268 "../cplusplu/chopper.ch"
#line 269 "../cplusplu/chopper.ch"
            case COMMENT_PLUS_cplus : 
#line 269 "../cplusplu/chopper.ch"
#line 270 "../cplusplu/chopper.ch"
                DecompCplus::ptDecomp -> plusComment = AllocString(BrainyValue(tree));
#line 270 "../cplusplu/chopper.ch"
#line 271 "../cplusplu/chopper.ch"
                break ;
#line 271 "../cplusplu/chopper.ch"
        }
#line 271 "../cplusplu/chopper.ch"
#line 271 "../cplusplu/chopper.ch"
#line 273 "../cplusplu/chopper.ch"
    }
#line 273 "../cplusplu/chopper.ch"
    
#line 277 "../cplusplu/chopper.ch"
#line 277 "../cplusplu/chopper.ch"
    char *DecToIdent ( PTREE tree )
#line 277 "../cplusplu/chopper.ch"
    {
#line 277 "../cplusplu/chopper.ch"
#line 280 "../cplusplu/chopper.ch"
        while ( NumberTree(tree) == RANGE_MODIFIER_cplus ) 
#line 280 "../cplusplu/chopper.ch"
#line 281 "../cplusplu/chopper.ch"
            (tree=SonTree(tree, 2));
#line 281 "../cplusplu/chopper.ch"
#line 281 "../cplusplu/chopper.ch"
#line 282 "../cplusplu/chopper.ch"
        return AllocString(BrainyValue(tree));
#line 282 "../cplusplu/chopper.ch"
#line 283 "../cplusplu/chopper.ch"
    }
#line 283 "../cplusplu/chopper.ch"
    
    extern int  ptOldBuf, line, col, posBufInput, lBufInput, tokenAhead ;
    extern long posFileInput ;
    extern PPTREE   (*the_parse_entry_pt)(int) ;
    
#line 292 "../cplusplu/chopper.ch"
#line 292 "../cplusplu/chopper.ch"
    void ReadInclude ( char *name, int here ) {
#line 292 "../cplusplu/chopper.ch"
    }
#line 292 "../cplusplu/chopper.ch"
    
#line 294 "../cplusplu/chopper.ch"
#line 294 "../cplusplu/chopper.ch"
    PPTREE quick_prog_func ( int error_free )
#line 294 "../cplusplu/chopper.ch"
    {
#line 294 "../cplusplu/chopper.ch"
#line 296 "../cplusplu/chopper.ch"
        cplus   parser ;
#line 296 "../cplusplu/chopper.ch"
#line 298 "../cplusplu/chopper.ch"
        return parser.quick_prog(error_free);
#line 298 "../cplusplu/chopper.ch"
#line 299 "../cplusplu/chopper.ch"
    }
#line 299 "../cplusplu/chopper.ch"
    
#line 301 "../cplusplu/chopper.ch"
#line 301 "../cplusplu/chopper.ch"
    void ReadIncludeS ( char *name, int here )
#line 301 "../cplusplu/chopper.ch"
    {
#line 301 "../cplusplu/chopper.ch"
#line 303 "../cplusplu/chopper.ch"
        PPTREE  (*keep_parse_entry)(int) ;
#line 303 "../cplusplu/chopper.ch"
#line 304 "../cplusplu/chopper.ch"
        char    *theName ;
#line 304 "../cplusplu/chopper.ch"
#line 306 "../cplusplu/chopper.ch"
        keep_parse_entry = the_parse_entry_pt ;
#line 306 "../cplusplu/chopper.ch"
#line 307 "../cplusplu/chopper.ch"
        the_parse_entry_pt = quick_prog_func ;
#line 307 "../cplusplu/chopper.ch"
#line 308 "../cplusplu/chopper.ch"
        theName = FindFile(name, getenv("PATH"), here);
#line 308 "../cplusplu/chopper.ch"
#line 309 "../cplusplu/chopper.ch"
        if ( theName ) 
#line 309 "../cplusplu/chopper.ch"
#line 310 "../cplusplu/chopper.ch"
            FreeTree(ReadFile(theName));
#line 310 "../cplusplu/chopper.ch"
#line 311 "../cplusplu/chopper.ch"
        the_parse_entry_pt = keep_parse_entry ;
#line 311 "../cplusplu/chopper.ch"
#line 312 "../cplusplu/chopper.ch"
    }
}
#line 312 "../cplusplu/chopper.ch"
/*Well done my boy */ 
#line 312 "../cplusplu/chopper.ch"

