#include "ParsingDefinitions.h"
#include "ParsingAutomaton.h"
namespace
{
using
namespace
stream
;
using
namespace
collections
;
namespace
{
namespace
{
void
(
const
&
,
&
)
{
.
(
L'\"'
);
for
(
int
=
0
;
i
<
.
();
i
++)
{
if
(
i
]==
L'\"'
)
{
.
(
L"\"\""
);
}
else
{
.
(
i
]);
}
}
.
(
L'\"'
);
}
(
const
&
)
{
return
([&](
&
)
{
(
,
writer
);
});
}
void
(
*
,
&
)
{
for
(
=
0
;
i
<
->
.
();
i
++)
{
ParsingDefinitionAttribute
*
=
->
i
].
();
if
(
i
>
0
)
.
(
L','
);
.
(
L" @"
);
.
(
att
->
);
.
(
L'('
);
for
(
=
0
;
j
<
att
->
.
();
j
++)
{
if
(
j
>
0
)
.
(
L", "
);
(
att
->
j
],
);
}
.
(
L')'
);
}
}
class
ParsingDefinitionTypeLogger
:
public
,
public
::
{
public
:
&
;
ParsingDefinitionTypeLogger
(
&
)
:writer(
)
{
}
static
void
(
*
,
&
)
{
ParsingDefinitionTypeLogger
(
);
->
(&
visitor
);
}
void
(
ParsingDefinitionPrimitiveType
*
)
override
{
.
(
->
);
}
void
(
ParsingDefinitionTokenType
*
)
override
{
.
(
L"token"
);
}
void
(
*
)
override
{
(
->
.
(),
);
.
(
L"."
);
.
(
->
);
}
void
(
ParsingDefinitionArrayType
*
)
override
{
(
->
.
(),
);
.
(
L"[]"
);
}
};
void
(
*
,
&
)
{
ParsingDefinitionTypeLogger
::
(
,
);
}
class
ParsingDefinitionTypeDefinitionLogger
:
public
,
public
ParsingDefinitionTypeDefinition
::
{
public
:
;
&
;
static
void
(
ParsingDefinitionTypeDefinition
*
,
const
&
,
&
)
{
ParsingDefinitionTypeDefinitionLogger
(
,
);
->
(&
visitor
);
}
ParsingDefinitionTypeDefinitionLogger
(
const
&
,
&
)
:prefix(
)
,writer(
)
{
}
void
(
ParsingDefinitionClassMemberDefinition
*
)
override
{
.
(
);
(
->
.
(),
);
.
(
L" "
);
.
(
->
);
if
(
->
!=
L""
)
{
.
(
L" ("
);
.
(
->
);
.
(
L")"
);
}
(
,
);
.
(
L";"
);
}
void
(
ParsingDefinitionClassDefinition
*
)
override
{
.
(
);
.
(
L"class "
);
.
(
->
);
if
(
->
)
{
.
(
L" ambiguous("
);
(
->
.
(),
);
.
(
L")"
);
}
if
(
->
)
{
.
(
L" : "
);
(
->
.
(),
);
}
(
,
);
.
(
L""
);
.
(
);
.
(
L"{"
);
for
(
int
=
0
;
i
<
->
.
();
i
++)
{
(
->
i
].
(),
+
L" "
,
);
.
(
L""
);
}
for
(
int
=
0
;
i
<
->
.
();
i
++)
{
(
->
i
].
(),
+
L" "
,
);
}
.
(
);
.
(
L"}"
);
}
void
(
ParsingDefinitionEnumMemberDefinition
*
)
override
{
.
(
);
.
(
->
);
(
,
);
.
(
L","
);
}
void
(
ParsingDefinitionEnumDefinition
*
)
override
{
.
(
);
.
(
L"enum "
);
.
(
->
);
(
,
);
.
(
L""
);
.
(
);
.
(
L"{"
);
for
(
int
=
0
;
i
<
->
.
();
i
++)
{
(
->
i
].
(),
+
L" "
,
);
}
.
(
);
.
(
L"}"
);
}
};
void
(
ParsingDefinitionTypeDefinition
*
,
const
&
,
&
)
{
ParsingDefinitionTypeDefinitionLogger
::
(
,
,
);
}
#define PRIORITY_NONE 0
#define PRIORITY_CREATE 1
#define PRIORITY_SET 1
#define PRIORITY_ALTERNATIVE 2
#define PRIORITY_SEQUENCE 3
#define PRIORITY_USE 4
#define PRIORITY_ASSIGN 4
class
ParsingDefinitionGrammarLogger
:
public
,
public
::
{
public
:
&
;
int
;
*
;
bool
;
ParsingDefinitionGrammarLogger
(
&
,
int
,
*
,
bool
)
:writer(
)
,parentPriority(
)
,stateNode(
)
,beforeNode(
)
{
}
static
void
(
*
,
int
,
*
,
bool
,
&
)
{
if
(
==
&&
)
{
.
(
L"@"
);
}
ParsingDefinitionGrammarLogger
(
,
,
,
);
->
(&
visitor
);
if
(
==
&& !
)
{
.
(
L"@"
);
}
}
void
(
*
,
int
,
&
)
{
(
,
,
,
,
);
}
void
(
ParsingDefinitionPrimitiveGrammar
*
)
override
{
.
(
->
);
}
void
(
ParsingDefinitionTextGrammar
*
)
override
{
(
->
text
,
);
}
void
(
ParsingDefinitionSequenceGrammar
*
)
override
{
int priority=PRIORITY_SEQUENCE;
if
(
>
priority
)
{
.
(
L"( "
);
}
(
->
.
(),
priority
,
);
.
(
L" "
);
(
->
.
(),
priority
,
);
if
(
>
priority
)
{
.
(
L" )"
);
}
}
void
(
ParsingDefinitionAlternativeGrammar
*
)
override
{
int priority=PRIORITY_ALTERNATIVE;
if
(
>
priority
)
{
.
(
L"( "
);
}
(
->
.
(),
priority
,
);
.
(
L" | "
);
(
->
.
(),
priority
,
);
if
(
>
priority
)
{
.
(
L" )"
);
}
}
void
(
ParsingDefinitionLoopGrammar
*
)
override
{
.
(
L"{ "
);
LogInternal(node->grammar.Obj(), PRIORITY_NONE, writer);
.
(
L" }"
);
}
void
(
ParsingDefinitionOptionalGrammar
*
)
override
{
.
(
L"[ "
);
LogInternal(node->grammar.Obj(), PRIORITY_NONE, writer);
.
(
L" ]"
);
}
void
(
ParsingDefinitionCreateGrammar
*
)
override
{
int priority=PRIORITY_CREATE;
if
(
>
priority
)
{
.
(
L"( "
);
}
(
->
.
(),
priority
,
);
.
(
L" as "
);
(
->
.
(),
);
if
(
>
priority
)
{
.
(
L" )"
);
}
}
void
(
ParsingDefinitionAssignGrammar
*
)
override
{
int priority=PRIORITY_ASSIGN;
if
(
>
priority
)
{
.
(
L"( "
);
}
(
->
.
(),
priority
,
);
.
(
L" : "
);
.
(
->
);
if
(
>
priority
)
{
.
(
L" )"
);
}
}
void
(
ParsingDefinitionUseGrammar
*
)
override
{
int priority=PRIORITY_USE;
if
(
>
priority
)
{
.
(
L"( "
);
}
.
(
L"!"
);
(
->
.
(),
priority
,
);
if
(
>
priority
)
{
.
(
L" )"
);
}
}
void
(
ParsingDefinitionSetterGrammar
*
)
override
{
int priority=PRIORITY_SET;
if
(
>
priority
)
{
.
(
L"( "
);
}
(
->
.
(),
priority
,
);
.
(
L" with { "
);
.
(
->
);
.
(
L" = "
);
(
->
,
);
.
(
L" }"
);
if
(
>
priority
)
{
.
(
L" )"
);
}
}
};
void
(
*
,
&
)
{
ParsingDefinitionGrammarLogger::LogInternal(grammar, PRIORITY_NONE, 0, true, writer);
ParsingDefinitionGrammarLogger
::
(
,
0
,
0
,
true
,
);
}
void
(
*
,
*
,
bool
,
&
)
{
ParsingDefinitionGrammarLogger::LogInternal(grammar, PRIORITY_NONE, stateNode, beforeNode, writer);
ParsingDefinitionGrammarLogger
::
(
,
0
,
,
,
);
}
#undef PRIORITY_NONE
#undef PRIORITY_CREATE
#undef PRIORITY_SET
#undef PRIORITY_ALTERNATIVE
#undef PRIORITY_SEQUENCE
#undef PRIORITY_USE
#undef PRIORITY_ASSIGN
class
FindAppropriateGrammarStateVisitor
:
public
,
public
::
{
public
:
*
;
bool
;
*
;
*
;
*
;
FindAppropriateGrammarStateVisitor
(
*
,
bool
,
*
,
*
)
:stateNode(
)
,beforeNode(
)
,beforeReference(
)
,afterReference(
)
,result(
0
)
{
}
static
*
(
*
,
*
,
bool
,
*
,
*
)
{
if
(
==
)
{
return
?(
?
:
)
:(
?
:
)
;
}
else
{
FindAppropriateGrammarStateVisitor
(
,
,
,
);
->
(&
visitor
);
return
visitor
.
;
}
}
void
(
ParsingDefinitionPrimitiveGrammar
*
)
override
{
}
void
(
ParsingDefinitionTextGrammar
*
)
override
{
}
void
(
ParsingDefinitionSequenceGrammar
*
)
override
{
=
(
->
.
(),
,
, (
?
:
),
0
);
if
(!
)
{
=
(
->
.
(),
,
,
0
, (
?
:
));
}
}
void
(
ParsingDefinitionAlternativeGrammar
*
)
override
{
=
(
->
.
(),
,
, (
?
:
), (
?
:
));
if
(!
)
{
=
(
->
.
(),
,
, (
?
:
), (
?
:
));
}
}
void
(
ParsingDefinitionLoopGrammar
*
)
override
{
=
(
->
.
(),
,
, (
?
:
), (
?
:
));
}
void
(
ParsingDefinitionOptionalGrammar
*
)
override
{
=
(
->
.
(),
,
, (
?
:
), (
?
:
));
}
void
(
ParsingDefinitionCreateGrammar
*
)
override
{
=
(
->
.
(),
,
, (
?
:
), (
?
:
));
}
void
(
ParsingDefinitionAssignGrammar
*
)
override
{
=
(
->
.
(),
,
, (
?
:
), (
?
:
));
}
void
(
ParsingDefinitionUseGrammar
*
)
override
{
=
(
->
.
(),
,
, (
?
:
), (
?
:
));
}
void
(
ParsingDefinitionSetterGrammar
*
)
override
{
=
(
->
.
(),
,
,
,
);
}
};
(
*
)
{
return
([&](
&
)
{
(
,
writer
);
},
64
);
}
(
*
)
{
return
(
,
0
,
true
);
}
(
*
,
*
,
bool
)
{
return
([&](
&
)
{
(
,
,
,
writer
);
},
64
);
}
*
FindAppropriateGrammarState
(
*
,
*
,
bool
)
{
return
FindAppropriateGrammarStateVisitor
::
(
,
,
,
0
,
0
);
}
void
(
<
>
,
&
)
{
FOREACH(Ptr<ParsingDefinitionTypeDefinition>, type, definition->types)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
ParsingDefinitionTypeDefinition
>>&
= ::
vl
::
collections
::
(
types
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
ParsingDefinitionTypeDefinition
>
;
__foreach_iterator__
.
(
type
);)
{
(
type
.
(),
L""
,
);
.
(
L""
);
}
FOREACH(Ptr<ParsingDefinitionTokenDefinition>, token, definition->tokens)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
ParsingDefinitionTokenDefinition
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
ParsingDefinitionTokenDefinition
>
;
__foreach_iterator__
.
(
token
);)
{
if
(
token
)
{
.
(
L"discardtoken "
);
}
else
{
.
(
L"token "
);
}
.
(
token
);
.
(
L" = "
);
(
token
regex
,
);
(
token
.
(),
);
.
(
L";"
);
}
.
(
L""
);
FOREACH(Ptr<ParsingDefinitionRuleDefinition>, rule, definition->rules)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
ParsingDefinitionRuleDefinition
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
ParsingDefinitionRuleDefinition
>
;
__foreach_iterator__
.
(
rule
);)
{
.
(
L"rule "
);
(
rule
.
(),
);
.
(
L" "
);
.
(
rule
);
(
rule
.
(),
);
.
(
L""
);
FOREACH(Ptr<ParsingDefinitionGrammar>, grammar, rule->grammars)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
rule
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
grammar
);)
{
.
(
L" = "
);
(
grammar
.
(),
);
.
(
L""
);
}
.
(
L" ;"
);
}
}
}
namespace
{
void
(
*
,
stream
::
&
)
{
if
(
->
()==
::
)
{
.
(
L"["
);
.
(
->
());
=
->
();
if
(
regex_internal
::
IsRegexEscapedLiteralString
(
regex
))
{
.
(
L" "
);
definitions
::
(
regex_internal
::
(
regex
),
);
}
.
(
L"]"
);
}
else
{
.
(
L"<"
);
.
(
->
());
.
(
L">"
);
}
}
void
(
<
>
,
stream
::
&
)
{
FOREACH(Ptr<RuleInfo>, ruleInfo, automaton->ruleInfos)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
ruleInfo
);)
{
.
(
L"Root Rule Start: "
);
.
(
ruleInfo
->
);
.
(
L"Root Rule End: "
);
.
(
ruleInfo
->
);
.
(
L"Rule Start: "
);
.
(
ruleInfo
->
);
FOREACH(State*, endState, ruleInfo->endStates)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
ruleInfo
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
endState
);)
{
.
(
L"Rule End: "
);
.
(
endState
->
);
}
.
(
L""
);
}
<
*>
;
FOREACH(Ptr<RuleInfo>, ruleInfo, automaton->ruleInfos)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
ruleInfo
);)
{
=
states
.
();
states
.
(
ruleInfo
);
while
(
currentState
<
states
.
())
{
*
=
states
currentState
++];
.
(
state
->
);
if
(
state
->
)
{
.
(
L"END STATE "
);
}
else
{
.
(
L"STATE "
);
}
.
(
state
->
);
FOREACH(Transition*, transition, state->transitions)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
state
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
transition
);)
{
if
(!
states
.
(
transition
->
))
{
states
.
(
transition
->
);
}
switch
(
transition
->
)
{
case
::
:
.
(
L" EPSILON"
);
break
;
case
::
:
.
(
L" TOKEN-BEGIN"
);
break
;
case
::
:
.
(
L" TOKEN-FINISH"
);
break
;
case
::
:
.
(
L" NORMAL-REDUCE"
);
break
;
case
::
:
.
(
L" LREC-REDUCE"
);
break
;
case
::
:
{
.
(
L" "
);
if
(
transition
->
)
{
(
transition
->
,
);
}
}
break
;
}
switch
(
transition
->
)
{
case
::
:
.
(
L" => "
);
break
;
case
::
:
.
(
L" [SHIFT-REDUCE-COMPACTED] => "
);
break
;
case
::
:
.
(
L" [LEFT-RECURSIVE] => "
);
break
;
}
.
(
transition
->
->
);
FOREACH(Ptr<Action>, action, transition->actions)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
transition
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
action
);)
{
switch
(
action
)
{
case
::
:
.
(
L" CREATE "
);
break
;
case
::
:
.
(
L" ASSIGN "
);
break
;
case
::
:
.
(
L" USING "
);
break
;
case
::
:
.
(
L" SET "
);
break
;
case
::
:
.
(
L" SHIFT "
);
break
;
case
::
:
.
(
L" REDUCE "
);
break
;
case
::
:
.
(
L" LR-REDUCE "
);
break
;
}
if
(
action
&&
action
)
{
.
(
L"["
);
.
(
action
->
);
.
(
L" => "
);
.
(
action
->
);
.
(
L"] "
);
}
if
(
action
)
{
.
(
action
->
());
}
if
(
action
)
{
.
(
L" => "
);
.
(
action
->
());
}
.
(
L""
);
}
}
.
(
L""
);
}
.
(
L"--------------------------------"
);
}
}
}
namespace
{
void
(
<
>
,
,
const
&
,
stream
::
&
)
{
if
(
!=-
1
)
{
<
::
>
=
(
);
FOREACH(Ptr<ParsingTable::AttributeInfo>, att, atts->attributes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
::
>>&
= ::
vl
::
collections
::
(
atts
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
::
>
;
__foreach_iterator__
.
(
att
);)
{
.
(
);
.
(
L"@"
);
.
(
att
);
.
(
L"("
);
for
(
=
0
;
i
<
att
.
();
i
++)
{
if
(
i
>
0
)
.
(
L", "
);
definitions
::
(
att
i
],
);
}
.
(
L")"
);
}
}
}
void
(
<
>
,
stream
::
&
)
{
=
()+
1
;
=
()+
1
;
<
>
(
rows
*
columns
);
stringTable
0
]=
L"<Parsing Table>"
;
for
(
=
0
;
row
<
();
row
++)
{
stringTable
(
row
+
1
)*
columns
]=
(
row
)+
L": "
+
(
row
).
;
}
for
(
=
0
;
column
<
();
column
++)
{
=
column
==
::
?
L"0: $TokenBegin"
:
column
==
::
?
L"1: $TokenFinish"
:
column
==
::
?
L"2: $NormalReduce"
:
column
==
::
?
L"3: $LeftRecursiveReduce"
:
(
column
)+
L": "
+
(
column
).
+
L"\r\n "
+
(
column
).
regex
;
stringTable
column
+
1
]
content
;
}
for
(
=
0
;
row
<
();
row
++)
{
for
(
=
0
;
column
<
();
column
++)
{
<
::
>
=
(
row
,
column
);
if
(
bag
)
{
;
FOREACH(Ptr<ParsingTable::TransitionItem>, item, bag->transitionItems)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
::
>>&
= ::
vl
::
collections
::
(
bag
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
::
>
;
__foreach_iterator__
.
(
item
);)
{
if
(
content
!=
L""
)
content
+=
L"\r\n"
;
content
(
item
);
FOREACH_INDEXER(vint, state, index, item->stackPattern)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
item
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
state
);
index
++)
{
content
+=(
index
==
0
?
L" : "
:
L", "
);
content
(
state
);
}
content
+=
L"\r\n"
;
FOREACH(Ptr<ParsingTable::LookAheadInfo>, lookAhead, item->lookAheads)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
::
>>&
= ::
vl
::
collections
::
(
item
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
::
>
;
__foreach_iterator__
.
(
lookAhead
);)
{
content
+=
L" "
;
FOREACH_INDEXER(vint, token, index, lookAhead->tokens)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
lookAhead
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
token
);
index
++)
{
content
+=(
index
==
0
?
L"> "
:
L", "
);
content
(
token
);
}
content
+=
L"\r\n"
;
}
content
+=
L" "
;
FOREACH(ParsingTable::Instruction, ins, item->instructions)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
::
>&
= ::
vl
::
collections
::
(
item
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
::
;
__foreach_iterator__
.
(
ins
);)
{
switch
(
ins
.
)
{
case
::
::
:
content
+=
L"C"
;
break
;
case
::
::
:
content
+=
L"U"
;
break
;
case
::
::
:
content
+=
L"A"
;
break
;
case
::
::
:
content
+=
L"I"
;
break
;
case
::
::
:
content
+=
L"S"
;
break
;
case
::
::
:
content
+=
L"[+"
+
(
ins
.
)+
L"]"
;
break
;
case
::
::
:
content
+=
L"[-"
+
(
ins
.
)+
L"]"
;
break
;
case
::
::
:
content
+=
L"[!"
+
(
ins
.
)+
L"]"
;
break
;
}
}
}
stringTable
(
row
+
1
)*
columns
+(
column
+
1
)]
content
;
}
}
}
.
(
L"Target-State : Stack-Pattern ..."
);
.
(
L"> Look-Ahead ..."
);
.
(
L"C: Create"
);
.
(
L"U: Using"
);
.
(
L"A: Assign"
);
.
(
L"I: Item"
);
.
(
L"S: Setter"
);
.
(
L"[+s]: Shift[push s]"
);
.
(
L"[-s]: Reduce[pop s]"
);
.
(
L"[!s]: Left-Recursive-Reduce[fake s]"
);
.
(
L""
);
for
(
=
0
;
i
<
();
i
++)
{
const
::
&
=
(
i
);
.
(
ruleInfo
.
);
.
(
L'<'
);
.
(
ruleInfo
.
);
if
(
ruleInfo
.
L""
)
{
.
(
L", "
);
.
(
ruleInfo
.
);
}
.
(
L">: "
);
.
(
(
ruleInfo
.
));
.
(
L'['
);
.
(
(
ruleInfo
.
).
);
.
(
L']'
);
.
(
L""
);
}
.
WriteMonospacedEnglishTable
(
stringTable
,
rows
,
columns
);
.
(
L""
);
.
(
L"Metadata(Tokens):"
);
for
(
=
0
;
i
<
();
i
++)
{
const
::
&
=
(
i
);
.
(
L" "
);
.
(
info
.
);
.
(
L"="
);
.
(
info
.
regex
);
(
,
info
.
,
L" "
,
);
}
.
(
L""
);
.
(
L"Metadata(Rules):"
);
for
(
=
0
;
i
<
();
i
++)
{
const
::
&
=
(
i
);
.
(
L" "
);
.
(
info
.
);
(
,
info
.
,
L" "
,
);
}
.
(
L""
);
.
(
L"Metadata(Classes):"
);
for
(
=
0
;
i
<
();
i
++)
{
const
::
&
=
(
i
);
.
(
L" "
);
.
(
info
.
);
(
,
info
.
,
L" "
,
);
}
.
(
L""
);
.
(
L"Metadata(Class Members):"
);
for
(
=
0
;
i
<
();
i
++)
{
const
::
&
=
(
i
);
.
(
L" "
);
.
(
info
.
);
.
(
L"."
);
.
(
info
.
);
(
,
info
.
,
L" "
,
);
}
.
(
L""
);
}
}
class
LogParsingTreeNodeVisitor
:
public
,
public
::
{
protected
:
&
;
;
;
public
:
LogParsingTreeNodeVisitor
(
&
,
const
&
,
const
&
)
:writer(
)
,prefix(
)
,originalInput(
)
{
}
void
(
*
)
{
if
(
)
{
->
(
this
);
}
else
{
.
(
L"null"
);
}
}
void
(
*
)
{
if
(
!=
L""
)
{
=
->
();
if
(
range
.
.
!=
::
&&
range
.
.
!=
::
)
{
=
range
.
.
;
=
range
.
.
-
start
+
1
;
if
(
length
>
0
)
{
.
(
L" // ["
);
.
(
.
(
start
,
length
));
.
(
L"]"
);
}
}
}
}
void
(
*
)
{
.
(
L'['
);
.
(
->
());
.
(
L']'
);
(
);
}
void
(
*
)
{
=
;
.
(
->
());
.
(
L" <"
);
for
(
=
0
;
i
<
->
().
();
i
++)
{
if
(
i
!=
0
)
.
(
L", "
);
.
(
->
()
i
]);
}
.
(
L"> {"
);
(
);
.
(
L""
);
+=
L" "
;
for
(
=
0
;
i
<
->
().
();
i
++)
{
.
(
);
.
(
->
().
().
(
i
));
.
(
L" = "
);
(
->
().
().
(
i
).
());
.
(
L""
);
}
oldPrefix
;
.
(
);
.
(
L"}"
);
}
void
(
*
)
{
=
;
.
(
->
());
.
(
L"[] {"
);
(
);
.
(
L""
);
+=
L" "
;
for
(
=
0
;
i
<
->
();
i
++)
{
.
(
);
(
->
(
i
).
());
.
(
L","
);
}
oldPrefix
;
.
(
);
.
(
L"}"
);
}
};
void
(
*
,
const
&
,
stream
::
&
,
const
&
)
{
.
(
);
LogParsingTreeNodeVisitor
(
,
,
);
->
(&
visitor
);
}
}
}