Annotation of parser3/src/main/compile.C, revision 1.53
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.53 ! paf 7: $Id: compile.C,v 1.52 2001/10/31 16:19:58 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;
53: pc.sp=0;
1.46 parser 54: pc.object_constructor_allowed=false;
1.7 paf 55:
1.12 paf 56: // parse=compile!
1.48 parser 57: //yydebug=1;
1.10 paf 58: if(yyparse(&pc)) { // error?
1.15 paf 59: if(pc.col==0) { // expecting something after EOL means they've expected it BEFORE
60: // step back. -1 col means EOL
1.8 paf 61: pc.line--;
1.16 paf 62: pc.col=-1;
63: }
1.51 parser 64: throw Exception(0,0,
1.6 paf 65: 0,
1.47 parser 66: #ifndef NO_STRING_ORIGIN
67: "%s(%d:%d): "
68: #endif
69: "%s",
70: #ifndef NO_STRING_ORIGIN
71: file, 1+pc.line, pc.col,
72: #endif
73: pc.error);
1.8 paf 74: }
1.7 paf 75:
76: // result
1.27 paf 77: return *pc.cclass;
1.1 paf 78: }
E-mail: