|
|
| version 1.3, 2001/02/21 06:21:19 | version 1.76, 2005/07/25 08:53:12 |
|---|---|
| Line 1 | Line 1 |
| /* | /** @file |
| $Id$ | Parser: compiler part of request class. |
| Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) | |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | |
| */ | */ |
| #include "pa_string.h" | static const char * const IDENT_COMPILE_C="$Date$"; |
| #include "pa_array.h" | |
| #include "code.h" | |
| #include "compile_tools.h" | |
| #include "compile.h" | |
| #include <stdio.h> | #include "pa_opcode.h" |
| #include "pa_request.h" | |
| #include "compile_tools.h" | |
| #include "pa_vclass.h" | |
| extern int yydebug; | extern int yydebug; |
| extern int yyparse (void *); | extern int yyparse (void *); |
| Array *real_compile(COMPILE_PARAMS) { | VStateless_class& Request::compile(VStateless_class* aclass, |
| if(!source) | const char* source, const String* main_alias, |
| return 0; | uint file_no, |
| int line_no_offset) { | |
| yydebug=1; | // prepare to parse |
| struct parse_control pc; | Parse_control pc(*this, aclass, source, main_alias, file_no, line_no_offset); |
| /* input */ | |
| pc.pool=pool; | // parse=compile! |
| pc.source=source; | //yydebug=1; |
| #ifndef NO_STRING_ORIGIN | if(yyparse(&pc)) { // error? |
| pc.file=file; | pc.pos_prev_c(); |
| pc.line=1; | if(!pc.explicit_result) |
| #endif | if(pc.pos.col==0) // expecting something after EOL means they've expected it BEFORE |
| /* state to initial */ | pc.pos_prev_c(); |
| pc.pending_state=0; | |
| pc.string=new(*pool) String(*pool); | throw Exception("parser.compile", |
| pc.ls=LS_USER; | 0, |
| pc.sp=0; | "%s(%d:%d): %s", file_list[file_no].cstr(), 1+pc.pos.line, 1+pc.pos.col, pc.error); |
| /* parse! */ | } |
| int parse_error=yyparse(&pc); | |
| /* result */ | // fill properties |
| return parse_error?0:static_cast<Array *>(pc.result); | static_cast<VClass*>(pc.cclass)->fill_properties(); |
| // result | |
| return *pc.cclass; | |
| } | } |