#include "ParsingTree.h"
#if defined(VCZH_GCC) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnull-dereference"
#endif
namespace
{
using
namespace
collections
;
namespace
{
(
<
> ,
<
> )
{
return
::
(
().
,
().
);
}
::
::
(
)
:direction(
)
{
}
void
::
::
(
*
)
{
}
void
::
::
(
*
)
{
}
void
::
::
(
*
)
{
}
void
::
::
(
*
)
{
}
void
::
::
(
*
)
{
}
void
::
::
(
*
)
{
}
void
::
::
(
*
)
{
(
);
(
);
}
void
::
::
(
*
)
{
(
);
switch
(
)
{
case
::
:
{
FOREACH(Ptr<ParsingTreeNode>, node, node->GetSubNodes())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
node
);)
{
node
(
this
);
}
}
break
;
case
::
:
{
FOREACH(Ptr<ParsingTreeNode>, node, node->GetMembers().Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
().
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
node
);)
{
node
(
this
);
}
}
break
;
}
(
);
}
void
::
::
(
*
)
{
(
);
switch
(
)
{
case
::
:
{
FOREACH(Ptr<ParsingTreeNode>, node, node->GetSubNodes())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
node
);)
{
node
(
this
);
}
}
break
;
case
::
:
{
FOREACH(Ptr<ParsingTreeNode>, node, node->GetItems())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
node
);)
{
node
(
this
);
}
}
break
;
}
(
);
}
bool
::
(
<
>
)
{
return
==
0
;
}
void
::
(
<
>
)
{
=
this
;
();
}
bool
::
(
<
>
)
{
return
!=
0
;
}
void
::
(
<
>
)
{
=
0
;
();
}
::(
const
& )
:codeRange(
)
,parent(
0
)
{
}
::
()
{
}
::()
{
return
;
}
void
::(
const
& )
{
;
}
void
::
()
{
const
&
=
();
();
auto
= &
subNodes
;
if
(
subNodesExists
)
{
FOREACH(Ptr<ParsingTreeNode>, node, subNodes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
subNodes
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
node
);)
{
node
();
}
{
FOREACH(Ptr<ParsingTreeNode>, subNode, subNodes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
subNodes
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
subNode
);)
{
const
auto
&
=
subNode
;
const
auto
&
= !
subRange
.
.
() ?
subRange
.
:
subRange
.
;
const
auto
&
= !
subRange
.
.
() ?
subRange
.
:
subRange
.
;
if
(
.
.
() || (!
min
.
() &&
.
>
min
))
{
.
min
;
}
if
(
.
.
() || (!
max
.
() &&
.
<
max
))
{
.
max
;
}
}
}
(
,
(
subNodes
)
.
([=](
<
>
)
{
const
auto
&
=
node
();
return
!
range
.
.
() && !
range
.
.
();
})
.
(&
)
);
}
}
void
::
()
{
.
();
}
*
::
()
{
return
;
}
const
::
&
::
()
{
return
;
}
*
::
(
const
&
)
{
return
(
(
,
));
}
*
::(
const
& )
{
if
(
.
.
&&
.
<=
.
)
{
=
0
;
=
.
() -
1
;
while
(
start
<=
end
)
{
= (
start
+
end
) /
2
;
* =
selected
].
();
const
& =
selectedNode
->
;
if
(
.
selectedRange
.
)
{
end
=
selected
-
1
;
}
else
if
(
.
selectedRange
.
)
{
start
=
selected
+
1
;
}
else
if
(
selectedRange
.
.
&&
.
<=
selectedRange
.
)
{
return
selectedNode
;
}
else
{
return
this
;
}
}
}
return
this
;
}
*
::
(
const
&
)
{
return
(
(
,
));
}
*
::(
const
& )
{
* =
0
;
* =
this
;
do
{
result
=
node
;
node
=
node
->
(
);
}
while
(
result
!=
node
);
return
result
;
}
const
::
&
::
()
{
return
*(
*)
0
;
}
::(
const
& ,
,
const
& )
:
(
)
,value(
)
,tokenIndex(
)
{
}
::
()
{
}
void
::
(
*
)
{
->
(
this
);
}
<
>
::
()
{
<
>
=
new
(
,
,
);
return
clone
;
}
::
()
{
return
;
}
void
::
(
)
{
=
;
}
const
&
::
()
{
return
;
}
void
::
(
const
&
)
{
;
}
const
::
&
::
()
{
return
.
();
}
::(
const
& ,
const
& )
:
(
)
,type(
)
{
}
::
()
{
}
void
::
(
*
)
{
->
(
this
);
}
<
>
::
()
{
<
>
=
new
(
,
);
(
clone
,
);
for
(
=
0
;
i
<
.
();
i
++)
{
=
.
().
(
i
);
<
>
=
.
().
(
i
)
();
clone
(
name
,
node
);
}
return
clone
;
}
const
&
::
()
{
return
;
}
void
::
(
const
&
)
{
;
}
::
&
::
()
{
return
;
}
<
>
::
(
const
&
)
{
=
.
().
(
);
if
(
index
==-
1
)
return
0
;
return
.
().
(
index
);
}
bool
::
(
const
&
,
<
>
)
{
=
.
().
(
);
if
(
index
!=-
1
)
{
<
>
=
.
().
(
index
);
if
(
previous
)
return
true
;
if
(!
(
previous
) || !
(
))
return
false
;
.
(
);
(
previous
);
}
.
(
,
);
(
);
return
true
;
}
bool
::
(
const
&
)
{
=
.
().
(
);
if
(
index
!=-
1
)
{
<
>
=
.
().
(
index
);
if
(
(
previous
))
{
.
(
);
(
previous
);
return
true
;
}
}
return
false
;
}
const
::
&
::
()
{
return
.
();
}
::
&
::
()
{
return
;
}
const
::
&
::
()
{
return
;
}
::(
const
& ,
const
& )
:
(
)
,elementType(
)
{
}
::
()
{
}
void
::
(
*
)
{
->
(
this
);
}
<
>
::
()
{
<
>
=
new
(
,
);
for
(
=
0
;
i
<
.
();
i
++)
{
<
>
=
.
(
i
)
();
clone
(
node
);
}
return
clone
;
}
const
&
::
()
{
return
;
}
void
::
(
const
&
)
{
;
}
::
&
::
()
{
return
;
}
<
>
::
(
)
{
if
(
0
<=
&&
<
.
())
{
return
];
}
else
{
return
0
;
}
}
bool
::
(
,
<
>
)
{
if
(
0
<=
&&
<
.
())
{
]
;
return
true
;
}
else
{
return
false
;
}
}
bool
::
(
<
>
)
{
return
(
.
(),
);
}
bool
::
(
,
<
>
)
{
if
(
0
<=
&&
<=
.
())
{
if
(
(
))
{
.
(
,
);
(
);
return
true
;
}
}
return
false
;
}
bool
::
(
)
{
if
(
0
<=
&&
<
.
())
{
<
>
=
];
if
(
(
previous
))
{
.
(
);
(
previous
);
return
true
;
}
}
return
false
;
}
bool
::
(
*
)
{
return
(
.
(
));
}
::
(
*
)
{
return
.
(
);
}
bool
::
(
*
)
{
return
.
(
);
}
::
()
{
return
.
();
}
bool
::
()
{
FOREACH(Ptr<ParsingTreeNode>, node, items)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
node
);)
{
if
(!
(
node
))
return
false
;
}
FOREACH(Ptr<ParsingTreeNode>, node, items)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
node
);)
{
(
node
);
}
.
();
return
true
;
}
::
()
:token(
0
)
,parsingTree(
0
)
{
}
::
(
const
&
)
:token(
0
)
,parsingTree(
0
)
,errorMessage(
)
{
}
::
(
const
regex
::
*
,
const
&
)
:token(
)
,parsingTree(
0
)
,errorMessage(
)
{
if
(
)
{
.
.
=
->
;
.
.
=
->
;
.
.
=
->
;
.
.
=
->
;
.
.
=
->
;
.
.
=
->
+
->
-
1
;
.
=
->
;
}
}
::
(
*
,
const
&
)
:codeRange(
->
)
,token(
0
)
,parsingTree(
)
,errorMessage(
)
{
}
::
()
{
}
ParsingEmptyPrintNodeRecorder
::
ParsingEmptyPrintNodeRecorder
()
{
}
ParsingEmptyPrintNodeRecorder
::
~
ParsingEmptyPrintNodeRecorder
()
{
}
void
ParsingEmptyPrintNodeRecorder
::(
* ,
const
& )
{
}
ParsingMultiplePrintNodeRecorder
::
ParsingMultiplePrintNodeRecorder
()
{
}
ParsingMultiplePrintNodeRecorder
::
~
ParsingMultiplePrintNodeRecorder
()
{
}
void
ParsingMultiplePrintNodeRecorder
::
(
<
IParsingPrintNodeRecorder
>
)
{
.
(
);
}
void
ParsingMultiplePrintNodeRecorder
::(
* ,
const
& )
{
FOREACH(Ptr<IParsingPrintNodeRecorder>, recorder, recorders)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
IParsingPrintNodeRecorder
>>& = ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
IParsingPrintNodeRecorder
> ;
__foreach_iterator__
.
(
recorder
);)
{
recorder
(
,
);
}
}
ParsingOriginalLocationRecorder
::
ParsingOriginalLocationRecorder
(
<
IParsingPrintNodeRecorder
>
)
:recorder(
)
{
}
ParsingOriginalLocationRecorder
::
~
ParsingOriginalLocationRecorder
()
{
}
void
ParsingOriginalLocationRecorder
::(
* ,
const
& )
{
auto
=
->
;
codeRange
.
=
.
;
(
,
codeRange
);
}
ParsingGeneratedLocationRecorder
::
ParsingGeneratedLocationRecorder
(
&
)
:rangeMap(
)
{
}
ParsingGeneratedLocationRecorder
::
~
ParsingGeneratedLocationRecorder
()
{
}
void
ParsingGeneratedLocationRecorder
::(
* ,
const
& )
{
.
(
,
);
}
ParsingUpdateLocationRecorder
::
ParsingUpdateLocationRecorder
()
{
}
ParsingUpdateLocationRecorder
::
~
ParsingUpdateLocationRecorder
()
{
}
void
ParsingUpdateLocationRecorder
::(
* ,
const
& )
{
->
;
}
void
::
(
wchar_t
)
{
;
switch
(
)
{
case
L'\n'
:
.
++;
.
++;
.
=
0
;
break
;
default
:
.
++;
.
++;
}
}
::
(
stream
::
&
,
<
IParsingPrintNodeRecorder
>
,
)
:writer(
)
, recorder(
)
, codeIndex(
)
, lastPos(-
1
,
0
, -
1
)
, currentPos(
0
,
0
,
0
)
{
}
::
()
{
}
void
::
(
wchar_t
)
{
.
(
);
if
(!
)
return
;
(
);
}
void
::
(
const
wchar_t
*
,
)
{
.
(
,
);
if
(!
)
return
;
for
(
=
0
;
i
<
;
i
++)
{
(
[
i
]);
}
}
void
::
(
*
)
{
if
(!
)
return
;
.
(
(
,
));
}
void
::
(
*
)
{
if
(!
)
return
;
auto
=
.
() -
1
];
.
(
.
() -
1
);
CHECK_ERROR(pair.key == node, L"vl::parsing::ParsingWriter::AfterPrint(ParsingTreeNode*)#BeforePrint and AfterPrint should be call in pairs.");
do
{
if
(!(
pair
.
==
))
throw
(
L"vl::parsing::ParsingWriter::AfterPrint(ParsingTreeNode*)#BeforePrint and AfterPrint should be call in pairs."
);}
while
(
0
);
(
pair
.
,
,
);
(
,
range
);
}
}
}
#if defined(VCZH_GCC) && defined(__clang__)
#pragma clang diagnostic pop
#endif