DCL 3.7.4
Loading...
Searching...
No Matches
DocParser Class Reference

#include <DocParser.h>

Inheritance diagram for DocParser:
Object

Public Member Functions

 DocParser (const wchar_t *pchData, size_t nDataSize, const DocSyntax *pSyntax)
bool getNextBlock (DOC_BLOCK &block)
Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Protected Attributes

const DocSyntax__pSyntax
const wchar_t * __pCurrent
const wchar_t * __pEnd

Additional Inherited Members

Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Detailed Description

Definition at line 29 of file DocParser.h.

Constructor & Destructor Documentation

◆ DocParser()

__DCL_BEGIN_NAMESPACE DocParser::DocParser ( const wchar_t * pchData,
size_t nDataSize,
const DocSyntax * pSyntax )

Definition at line 13 of file DocParser.cpp.

14{
15 __pSyntax = pSyntax;
16 __pCurrent = pchData;
17 __pEnd = pchData + nDataSize; // *__pEnd == '\0'
18 __DCL_ASSERT(*__pEnd == '\0');
19}
#define __DCL_ASSERT(expr)
Definition Object.h:394
const wchar_t * __pCurrent
Definition DocParser.h:37
const wchar_t * __pEnd
Definition DocParser.h:38
const DocSyntax * __pSyntax
Definition DocParser.h:36

Member Function Documentation

◆ getNextBlock()

bool DocParser::getNextBlock ( DOC_BLOCK & block)

Definition at line 32 of file DocParser.cpp.

33{
34 if (!(__pCurrent < __pEnd))
35 return false;
36
37 ssize_t nLineCommentLength = __pSyntax->__strLineComment.length();
38
39 block.pData = __pCurrent;
40 block.type = normal;
41
42 CurrentState state = inInitial;
43 wchar_t chQuotation = 0;
44 bool bEscape = false;
45
46 while(__pCurrent < __pEnd) {
47 switch (state) {
48 case inInitial: {
49 if (iswspace((unsigned)*__pCurrent))
50 state = inSpace;
51 else if (__pSyntax->isQuotation(*__pCurrent)) {
52 state = inQuotation;
53 chQuotation = *__pCurrent;
54 }
55 else {
56 state = inNormal;
57 continue;
58 }
59 break;
60 }
61 case inSpace: {
62 if (!iswspace(*__pCurrent))
63 goto __done;
64 break;
65 }
66 case inQuotation: {
67 __DCL_ASSERT(chQuotation != 0);
68 if (!bEscape) {
69 if (chQuotation == *__pCurrent) {
70 __pCurrent++;
71 block.type = quotation;
72 goto __done;
73 }
74 if (__pSyntax->isEscapeChar(*__pCurrent))
75 bEscape = true;
76 }
77 else
78 bEscape = false;
79 break;
80 }
81 case inBlockComment: {
82 if (__pSyntax->isCommentOff(block.pData, DATA_SIZE)) {
83 __pCurrent++;
84 block.type = comment;
85 goto __done;
86 }
87 break;
88 }
89 case inLineComment: {
90 if (*__pCurrent == 10) {
91 __pCurrent++;
92 block.type = comment;
93 goto __done;
94 }
95 break;
96 }
97 case inNormal: {
98 if (iswspace(*__pCurrent) || __pSyntax->isDelimeter(*__pCurrent)) {
99 if ((__pCurrent - block.pData) > 0) {
100 if (__pSyntax->isCommentOn(block.pData, DATA_SIZE)) {
101 state = inBlockComment;
102 block.type = comment;
103 }
104 else if (__pSyntax->isLineComment(block.pData, DATA_SIZE)) {
105 state = inLineComment;
106 block.type = comment;
107 }
108 else if (__pSyntax->isReservedWord(block.pData, DATA_SIZE)) {
109 block.type = keyword;
110 goto __done;
111 }
112 else {
113 if (!__pSyntax->isCommentChar(*__pCurrent))
114 goto __done;
115 }
116 }
117 else {
118 if (__pSyntax->isReservedWord(__pCurrent, 1)) {
119 block.type = keyword;
120 }
121
122 if (!__pSyntax->isCommentChar(*__pCurrent)) {
123 __pCurrent++;
124 goto __done;
125 }
126 }
127
128 }
129 else {
130 if ((DATA_SIZE == nLineCommentLength)
131 && __pSyntax->isLineComment(block.pData, DATA_SIZE)
132 ) {
133 state = inLineComment;
134 block.type = comment;
135 }
136 }
137 break;
138 }
139 default: {
140 __DCL_ASSERT(false);
141 }
142 }
143 __pCurrent++;
144 }
145
146__done:
148
149 block.nDataSize = DATA_SIZE;
150
151 return true;
152}
CurrentState
Definition DocParser.cpp:21
@ inNormal
Definition DocParser.cpp:27
@ inInitial
Definition DocParser.cpp:22
@ inBlockComment
Definition DocParser.cpp:25
@ inLineComment
Definition DocParser.cpp:26
@ inSpace
Definition DocParser.cpp:23
@ inQuotation
Definition DocParser.cpp:24
#define DATA_SIZE
Definition DocParser.cpp:30
@ quotation
Definition DocParser.h:18
@ comment
Definition DocParser.h:17
@ keyword
Definition DocParser.h:19
@ normal
Definition DocParser.h:16
BlockType type
Definition DocParser.h:26
const wchar_t * pData
Definition DocParser.h:24
size_t nDataSize
Definition DocParser.h:25

Member Data Documentation

◆ __pCurrent

const wchar_t* DocParser::__pCurrent
protected

Definition at line 37 of file DocParser.h.

◆ __pEnd

const wchar_t* DocParser::__pEnd
protected

Definition at line 38 of file DocParser.h.

◆ __pSyntax

const DocSyntax* DocParser::__pSyntax
protected

Definition at line 36 of file DocParser.h.


The documentation for this class was generated from the following files: