Annotation of parser3/src/main/compile.C, revision 1.8
1.1 paf 1: /*
1.8 ! paf 2: $Id: compile.C,v 1.7 2001/02/21 11:13:16 paf Exp $
1.1 paf 3: */
4:
1.3 paf 5: #include "pa_string.h"
1.1 paf 6: #include "pa_array.h"
7: #include "code.h"
8: #include "compile_tools.h"
9: #include "compile.h"
1.4 paf 10: #include "pa_exception.h"
1.1 paf 11:
12: #include <stdio.h>
13:
14: extern int yydebug;
15: extern int yyparse (void *);
16:
17: Array *real_compile(COMPILE_PARAMS) {
1.2 paf 18: if(!source)
19: return 0;
20:
1.4 paf 21: Pool& pool=request.pool();
22:
1.7 paf 23: // prepare to parse
1.1 paf 24: struct parse_control pc;
1.7 paf 25: // input
1.4 paf 26: pc.pool=&pool;
1.7 paf 27: pc.methods=new(pool) Array(pool);
28: // create new 'name' vclass, add it to request's classes
1.1 paf 29: pc.source=source;
30: #ifndef NO_STRING_ORIGIN
31: pc.file=file;
1.7 paf 32: pc.line=pc.col=0;
1.1 paf 33: #endif
1.7 paf 34: // initialise state
1.1 paf 35: pc.pending_state=0;
1.4 paf 36: pc.string=new(pool) String(pool);
1.1 paf 37: pc.ls=LS_USER;
38: pc.sp=0;
1.7 paf 39:
40: // parse!
41: yydebug=1;
1.8 ! paf 42: if(yyparse(&pc)) {// error?
! 43: if(pc.col==1) {
! 44: // step back from last char. -1 col means EOL
! 45: pc.line--;
! 46: pc.col=-1;
! 47: }
1.6 paf 48: request.exception().raise(0,0,
49: 0,
1.8 ! paf 50: "%s [%s:%d:%d]", pc.error, file, 1+pc.line, pc.col);
! 51: }
1.7 paf 52:
53: // result
54: return pc.methods;
1.1 paf 55: }
E-mail: