xref: /haiku/src/kits/debugger/source_language/c_family/CLanguageFamilySyntaxHighlighter.cpp (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1 /*
2  * Copyright 2014, Rene Gollent, rene@gollent.com.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "CLanguageFamilySyntaxHighlighter.h"
8 
9 #include <new>
10 
11 #include <AutoDeleter.h>
12 
13 #include "CLanguageFamilySyntaxHighlightInfo.h"
14 #include "CLanguageTokenizer.h"
15 
16 
17 using CLanguage::Tokenizer;
18 
19 
CLanguageFamilySyntaxHighlighter()20 CLanguageFamilySyntaxHighlighter::CLanguageFamilySyntaxHighlighter()
21 	:
22 	SyntaxHighlighter()
23 {
24 }
25 
26 
~CLanguageFamilySyntaxHighlighter()27 CLanguageFamilySyntaxHighlighter::~CLanguageFamilySyntaxHighlighter()
28 {
29 }
30 
31 
32 status_t
ParseText(LineDataSource * source,TeamTypeInformation * typeInfo,SyntaxHighlightInfo * & _info)33 CLanguageFamilySyntaxHighlighter::ParseText(LineDataSource* source,
34 	TeamTypeInformation* typeInfo, SyntaxHighlightInfo*& _info)
35 {
36 	Tokenizer* tokenizer = new(std::nothrow) Tokenizer();
37 	if (tokenizer == NULL)
38 		return B_NO_MEMORY;
39 	ObjectDeleter<Tokenizer> deleter(tokenizer);
40 
41 	_info = new(std::nothrow) CLanguageFamilySyntaxHighlightInfo(source,
42 		tokenizer, typeInfo);
43 	if (_info == NULL)
44 		return B_NO_MEMORY;
45 
46 	deleter.Detach();
47 	return B_OK;
48 }
49