Subversion Repositories spk

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
#include "bod_parser.h"
2
#include "bod_text_parser.h"
3
#include "token_stream.h"
4
#include "bod_cut_parser.h"
5
//---------------------------------------------------------------------------------
6
bob_dom_document * bod_parser::parseBuffer(char *pszBuffer, size_t size, fileType type)
7
{
8
	bod_text_parser parser;
9
	token_stream is;
10
	bob_dom_document *doc=NULL;
11
	bob_dom_cut *cut=NULL;
12
	bob_dom_bob *bob=NULL;
13
	bod_parser_base *errorObj;
14
	bool bRes=false;
15
 
16
	is.rdbuffer(pszBuffer, size);
17
 
18
	if(type==bobFile){
19
		bod_bob_parser *bp=new bod_bob_parser(m_settings);
20
		errorObj=bp;
21
		bob=bp->loadBOB(is, false);
22
		bRes=bob!=NULL;
23
	}
24
	else if(type==cutFile){
25
		bod_cut_parser *cp=new bod_cut_parser(m_settings);
26
		cut=cp->loadCUT(is);
27
		errorObj=cp;
28
		bRes=cut!=NULL;
29
	}
30
 
31
	for(iterator &it=errorObj->errors.begin(); it!=errorObj->errors.end(); ++it){
32
		error(it);
33
	}
34
 
35
	if(bRes){
36
		doc=new bob_dom_document(m_settings);
37
		doc->bob=bob;
38
		doc->cut=cut;
39
	}
40
	return doc;
41
}
42
//---------------------------------------------------------------------------------
43
bool bod_parser::compile(char *pszBuffer, size_t size, fileType type, bob_dom_obinaryfilestream& os)
44
{
45
	bod_text_parser parser;
46
	token_stream is;
47
	bod_parser_base *errorObj;
48
	bool bRes=false;
49
 
50
	is.rdbuffer(pszBuffer, size);
51
 
52
	if(type==bobFile){
53
		bod_bob_parser *bp=new bod_bob_parser(m_settings);
54
		errorObj=bp;
55
		bRes=bp->compile(is, os, false);
56
	}
57
	else if(type==cutFile){
58
		bod_cut_parser *cp=new bod_cut_parser(m_settings);
59
		bRes=cp->compile(is, os);
60
		errorObj=cp;
61
	}
62
 
63
	for(iterator &it=errorObj->errors.begin(); it!=errorObj->errors.end(); ++it){
64
		error(it);
65
	}
66
	return bRes;
67
}
68
//---------------------------------------------------------------------------------
69
void bod_parser::error(iterator& it)
70
{
71
	Error *e=new Error();
72
 
73
	e->code=it->code;
74
	e->col=it->col;
75
	e->line=it->line;
76
	memcpy(e->text, it->text, sizeof(e->text));
77
	errors.push_back(e);
78
}
79
//---------------------------------------------------------------------------------