File:  [parser3project] / parser3 / src / main / compile.C
Revision 1.74: download - view: text, annotated - select for diffs - revision graph
Fri Feb 27 13:38:37 2004 UTC (22 years, 3 months ago) by paf
Branches: MAIN
CVS tags: release_3_1_2, HEAD
bugfix: line numbers after ^process{}[$.line(-10]] can be negative, allowed to print they as signed

/** @file
	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)
*/

static const char * const IDENT_COMPILE_C="$Date: 2004/02/27 13:38:37 $";

#include "pa_opcode.h"
#include "pa_request.h"
#include "compile_tools.h"

extern int yydebug;
extern int yyparse (void *);

VStateless_class& 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.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);
	}

	// result
	return *pc.cclass;
}

E-mail: