|
|
| version 1.2, 2001/02/20 19:21:13 | version 1.83, 2015/09/27 20:12:42 |
|---|---|
| Line 1 | Line 1 |
| /* | /** @file |
| $Id$ | Parser: compiler part of request class. |
| Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) | |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | |
| */ | */ |
| #include "pa_array.h" | volatile const char * IDENT_COMPILE_C="$Id$"; |
| #include "code.h" | |
| #include "compile_tools.h" | |
| #include "compile.h" | |
| #include <stdio.h> | #include "pa_request.h" |
| #include "compile_tools.h" | |
| extern int yydebug; | extern int yydebug; |
| extern int yyparse (void *); | extern int yyparse (Parse_control *); |
| ArrayClass& Request::compile(VStateless_class* aclass, | |
| const char* source, const String* main_alias, | |
| uint file_no, | |
| int line_no_offset) { | |
| // prepare to parse | |
| Parse_control pc(*this, aclass, source, main_alias, file_no, line_no_offset); | |
| // parse=compile! | |
| //yydebug=1; | |
| if(yyparse(&pc)) { // error? | |
| pc.pos_prev_c(); | |
| if(!pc.explicit_result) | |
| if(pc.pos.col==0) // expecting something after EOL means they've expected it BEFORE | |
| pc.pos_prev_c(); | |
| throw Exception("parser.compile", | |
| 0, | |
| "%s(%d:%d): %s", file_list[file_no].cstr(), 1+pc.pos.line, 1+pc.pos.col, pc.error); | |
| } | |
| Array *real_compile(COMPILE_PARAMS) { | // result |
| if(!source) | return *pc.cclasses; |
| return 0; | |
| yydebug=1; | |
| struct parse_control pc; | |
| /* input */ | |
| pc.pool=pool; | |
| pc.source=source; | |
| #ifndef NO_STRING_ORIGIN | |
| pc.file=file; | |
| pc.line=1; | |
| #endif | |
| /* state to initial */ | |
| pc.pending_state=0; | |
| pc.string=string_create(pool); | |
| pc.ls=LS_USER; | |
| pc.sp=0; | |
| /* parse! */ | |
| int parse_error=yyparse(&pc); | |
| /* result */ | |
| return parse_error?0:static_cast<Array *>(pc.result); | |
| } | } |