|
|
| version 1.5, 2001/02/21 07:19:40 | version 1.90, 2026/04/25 13:38:46 |
|---|---|
| Line 1 | Line 1 |
| /* | /** @file |
| $Id$ | Parser: compiler part of request class. |
| Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) | |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | |
| */ | */ |
| #include "pa_string.h" | volatile const char * IDENT_COMPILE_C="$Id$"; |
| #include "pa_array.h" | |
| #include "code.h" | |
| #include "compile_tools.h" | |
| #include "compile.h" | |
| #include "pa_exception.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(); | |
| exception_trace.push(Trace(0, Operation::Origin::create(file_no, pc.pos.line, pc.pos.col))); | |
| throw Exception("parser.compile", 0, "%s", pc.error); | |
| } | |
| Array *real_compile(COMPILE_PARAMS) { | // result |
| if(!source) | return *pc.cclasses; |
| return 0; | |
| Pool& pool=request.pool(); | |
| yydebug=1; | |
| struct parse_control pc; | |
| /* input */ | |
| pc.pool=&pool; | |
| pc.exception=&request.exception(); | |
| pc.source=source; | |
| #ifndef NO_STRING_ORIGIN | |
| pc.file=file; | |
| pc.line=pc.col=1; | |
| #endif | |
| /* state to initial */ | |
| pc.pending_state=0; | |
| pc.string=new(pool) String(pool); | |
| pc.ls=LS_USER; | |
| pc.sp=0; | |
| /* parse! */ | |
| yyparse(&pc); | |
| /* result */ | |
| return pc.result; | |
| } | } |