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

1.32      paf         1: /** @file
1.33      paf         2:        Parser: compiler part of request class.
                      3: 
1.69.2.4  paf         4:        Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
1.58      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.64      paf         6: */
1.33      paf         7: 
1.69.2.5! paf         8: static const char* IDENT_COMPILE_C="$Date: 2003/01/31 12:34:34 $";
1.1       paf         9: 
1.36      paf        10: #include "pa_opcode.h"
1.10      paf        11: #include "pa_request.h"
1.1       paf        12: #include "compile_tools.h"
                     13: 
                     14: extern int yydebug;
                     15: extern int yyparse (void *);
                     16: 
1.29      paf        17: VStateless_class& Request::real_compile(COMPILE_PARAMS) {
1.7       paf        18:        // prepare to parse
1.1       paf        19:        struct parse_control pc;
1.10      paf        20: 
1.7       paf        21:        // input 
1.10      paf        22:        pc.pool=&pool();
1.18      paf        23:        pc.request=this;
1.67      paf        24:        // we were told the class to compile to?
1.69.2.3  paf        25:        pc.cclass=aclass; // until changed with @CLASS would consider operators loading
1.9       paf        26: 
1.1       paf        27:        pc.source=source;
                     28: #ifndef NO_STRING_ORIGIN
                     29:        pc.file=file;
                     30: #endif
1.59      paf        31:        pc.line=pc.col=0; // off the check, 'col' used in compile
                     32: 
1.7       paf        33:        // initialise state
1.44      parser     34:        pc.trim_bof=true;
1.1       paf        35:        pc.pending_state=0;
1.69.2.1  paf        36:        pc.string=StringPtr(new String);
1.1       paf        37:        pc.ls=LS_USER;
1.54      paf        38:        pc.ls_sp=0;
1.56      paf        39:        pc.in_call_value=false;
1.7       paf        40:        
1.12      paf        41:        // parse=compile! 
1.69.2.5! paf        42:        yydebug=1;
1.10      paf        43:        if(yyparse(&pc)) { // error?
1.15      paf        44:                if(pc.col==0) { // expecting something after EOL means they've expected it BEFORE
                     45:                        // step back.  -1 col means EOL
1.8       paf        46:                        pc.line--;
1.16      paf        47:                        pc.col=-1;
                     48:                } 
1.63      paf        49:                throw Exception("parser.compile",
1.69.2.1  paf        50:                        Exception::undefined_source,
1.62      paf        51:                        "%s(%d:%d): %s",  file, 1+pc.line, pc.col,  pc.error);
1.8       paf        52:        }
1.7       paf        53: 
                     54:        // result
1.27      paf        55:        return *pc.cclass;
1.1       paf        56: }

E-mail: