Annotation of parser3/src/main/compile.C, revision 1.54

1.32      paf         1: /** @file
1.33      paf         2:        Parser: compiler part of request class.
                      3: 
1.24      paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.53      paf         5:        Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)
1.33      paf         6: 
1.54    ! paf         7:        $Id: compile.C,v 1.53 2001/11/05 11:46:26 paf Exp $
1.1       paf         8: */
                      9: 
1.36      paf        10: #include "pa_opcode.h"
1.10      paf        11: #include "pa_request.h"
1.3       paf        12: #include "pa_string.h"
1.1       paf        13: #include "pa_array.h"
                     14: #include "compile_tools.h"
1.4       paf        15: #include "pa_exception.h"
1.1       paf        16: 
                     17: extern int yydebug;
                     18: extern int yyparse (void *);
                     19: 
1.29      paf        20: VStateless_class& Request::real_compile(COMPILE_PARAMS) {
1.7       paf        21:        // prepare to parse
1.1       paf        22:        struct parse_control pc;
1.10      paf        23: 
1.7       paf        24:        // input 
1.10      paf        25:        pc.pool=&pool();
1.18      paf        26:        pc.request=this;
1.29      paf        27:        VStateless_class *cclass;
1.27      paf        28:        if(aclass) // we were told the class to compile to?
1.28      paf        29:                cclass=aclass; // yes, remember it [used in ^process]
1.27      paf        30:        else if(name) { // we were told the name of compiled class?
1.20      paf        31:                // yes. create it
1.27      paf        32:                cclass=NEW VClass(pool());
1.20      paf        33:                // defaulting base. may change with @BASE
1.37      parser     34:                // dont use ?: for there would be getting & of temp object
1.34      paf        35:                if(base_class)
                     36:                        cclass->set_base(*base_class);
1.27      paf        37:                classes().put(*name, cclass);
                     38:                cclass->set_name(*name);
1.20      paf        39:        } else
1.35      paf        40:                cclass=&OP; // until changed with @CLASS would consider operators loading
1.27      paf        41:        pc.cclass=cclass;
1.9       paf        42: 
1.1       paf        43:        pc.source=source;
                     44: #ifndef NO_STRING_ORIGIN
                     45:        pc.file=file;
1.7       paf        46:        pc.line=pc.col=0;
1.1       paf        47: #endif
1.7       paf        48:        // initialise state
1.44      parser     49:        pc.trim_bof=true;
1.1       paf        50:        pc.pending_state=0;
1.13      paf        51:        pc.string=NEW String(pool());   
1.1       paf        52:        pc.ls=LS_USER;
1.54    ! paf        53:        pc.ls_sp=0;
1.46      parser     54:        pc.object_constructor_allowed=false;
1.54    ! paf        55:        pc.operator_call_allowed=false;
        !            56:        pc.oca_sp=0;
1.7       paf        57:        
1.12      paf        58:        // parse=compile! 
1.48      parser     59:        //yydebug=1;
1.10      paf        60:        if(yyparse(&pc)) { // error?
1.15      paf        61:                if(pc.col==0) { // expecting something after EOL means they've expected it BEFORE
                     62:                        // step back.  -1 col means EOL
1.8       paf        63:                        pc.line--;
1.16      paf        64:                        pc.col=-1;
                     65:                } 
1.51      parser     66:                throw Exception(0,0,
1.6       paf        67:                        0,
1.47      parser     68: #ifndef NO_STRING_ORIGIN
                     69:                        "%s(%d:%d): "
                     70: #endif
                     71:                        "%s", 
                     72: #ifndef NO_STRING_ORIGIN
                     73:                        file, 1+pc.line, pc.col, 
                     74: #endif
                     75:                        pc.error);
1.8       paf        76:        }
1.7       paf        77: 
                     78:        // result
1.27      paf        79:        return *pc.cclass;
1.1       paf        80: }

E-mail: