#include "GuiLanguageOperations.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
parsing
;
using
namespace
parsing
::
tabling
;
using
namespace
regex_internal
;
bool
::
(
&
,
parsing
::
*
,
*
)
{
*
=
dynamic_cast
<
*>(
);
if
(!
foundToken
)
return
false
;
*
=
dynamic_cast
<
*>(
->
());
if
(!
tokenParent
)
return
false
;
=
tokenParent
->
().
().
(
);
if
(
index
==-
1
)
return
false
;
=
tokenParent
->
();
=
tokenParent
->
().
().
(
index
);
const
::
&
=
->
(
type
,
field
);
.
=
foundToken
;
.
=
tokenParent
;
.
type
;
.
field
;
.
md
.
;
return
true
;
}
bool
::
(
&
,
parsing
::
,
parsing
::
*
,
*
)
{
*
=
->
(
);
if
(!
foundNode
)
return
false
;
return
(
,
foundNode
,
);
}
bool
::(
& ,
parsing
::
,
* ,
* )
{
* =
->
(
);
if
(!
foundNode
)
return
false
;
return
(
,
foundNode
,
);
}
parsing
::
*
::
::
(
parsing
::
*
,
const
RepeatingPartialParsingOutput
*
)
{
if
(!
|| !
->
)
return
;
return
==
->
.
()
?
->
.
()
:
;
}
parsing
::
*
::
::
(
parsing
::
*
,
const
RepeatingPartialParsingOutput
*
)
{
if
(!
|| !
->
)
return
;
return
==
->
.
()
?
->
.
()
:
;
}
<
parsing
::
>
::
::
(
<
parsing
::
>
,
const
RepeatingPartialParsingOutput
*
)
{
if
(!
)
return
;
return
->
?
->
.
<
>()
:
;
}
parsing
::
*
::
::
(
parsing
::
*
,
const
RepeatingPartialParsingOutput
*
)
{
return
(
,
)->
();
}
<
parsing
::
>
::
::
(
parsing
::
*
,
const
&
,
const
RepeatingPartialParsingOutput
*
)
{
return
(
(
,
)->
(
),
);
}
<
parsing
::
>
::
::
(
parsing
::
*
,
,
const
RepeatingPartialParsingOutput
*
)
{
return
(
->
(
),
);
}
::
::
(
<
>
)
:parsingExecutor(
)
,callbackAutoPushing(
false
)
,callbackElement(
0
)
,callbackElementModifyLock(
0
)
{
}
::
::
()
{
}
void
::
::
(
bool
)
{
=
;
}
void
::
::
(
elements
::
*
,
&
,
compositions
::
*
,
)
{
if
(
)
{
SPIN_LOCK(_elementModifyLock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
=
;
callbackElementModifyLock
=&
;
}
}
(
this
);
if
(
&&
callbackElementModifyLock
&&
)
{
SPIN_LOCK(*callbackElementModifyLock)
if
(
bool
=
true
)
for
(
const
::
&
= *
callbackElementModifyLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
;
input
.
=
;
input
.
->
().
();
(
input
);
}
}
}
void
::
::
()
{
if
(
&&
callbackElementModifyLock
)
{
SPIN_LOCK(*callbackElementModifyLock)
if
(
bool
=
true
)
for
(
const
::
&
= *
callbackElementModifyLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
=
0
;
callbackElementModifyLock
=
0
;
}
}
(
this
);
}
void
::
::
(
&
)
{
}
void
::
::
(
const
&
)
{
}
void
::
::
(
const
&
)
{
}
void
::
::
(
)
{
if
(
&&
callbackElementModifyLock
&&
)
{
SPIN_LOCK(*callbackElementModifyLock)
if
(
bool
=
true
)
for
(
const
::
&
= *
callbackElementModifyLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
;
input
.
=
;
input
.
->
().
();
(
input
);
}
}
}
void
::
(
const
&
)
{
<
<
>>
;
<
>
=
(
.
,
,
errors
).
<
>();
if
(
node
)
{
node
();
}
;
result
.
node
;
result
.
=
.
;
result
.
.
;
if
(
node
)
{
(
result
);
FOREACH(ICallback*, callback, callbacks)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
callback
);)
{
callback
->
(
result
);
}
}
}
void
::
()
{
<
>
=
();
.
();
.
();
.
();
.
();
<
,
<
::
>>
,
,
,
;
<
,
<
::
>>
,
;
{
=
table
();
for
(
=
::
;
token
<
tokenCount
;
token
++)
{
const
::
&
=
table
(
token
);
=
token
-
::
;
.
(
tokenInfo
.
,
tokenIndex
);
if
(
<
::
>
=
(
tokenInfo
.
))
{
tokenColorAtts
.
(
tokenIndex
,
att
);
}
if
(
<
::
>
=
(
tokenInfo
.
))
{
tokenContextColorAtts
.
(
tokenIndex
,
att
);
}
if
(
<
::
>
=
(
tokenInfo
.
))
{
tokenCandidateAtts
.
(
tokenIndex
,
att
);
}
if
(
<
::
>
=
(
tokenInfo
.
))
{
tokenAutoCompleteAtts
.
(
tokenIndex
,
att
);
}
}
}
{
=
table
();
for
(
=
0
;
field
<
fieldCount
;
field
++)
{
const
::
&
=
table
(
field
);
(
fieldInfo
.
,
fieldInfo
.
);
if
(
<
::
>
=
(
fieldInfo
.
))
{
fieldColorAtts
.
(
fieldDesc
,
att
);
}
if
(
<
::
>
=
(
fieldInfo
.
))
{
fieldSemanticAtts
.
(
fieldDesc
,
att
);
}
}
}
FOREACH(Ptr<ParsingTable::AttributeInfo>, att,
From(tokenColorAtts.Values())
.Concat(tokenContextColorAtts.Values())
.Concat(fieldColorAtts.Values())
.Concat(fieldSemanticAtts.Values())
)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
::
>>&
= ::
vl
::
collections
::
(
(
tokenColorAtts
.
()) .
(
tokenContextColorAtts
.
()) .
(
fieldColorAtts
.
()) .
(
fieldSemanticAtts
.
()));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
::
>
;
__foreach_iterator__
.
(
att
);)
{
FOREACH(WString, argument, att->arguments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
att
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
argument
);)
{
if
(!
.
(
argument
))
{
.
(
argument
);
}
}
}
=
0
;
FOREACH(vint, tokenIndex, tokenIndexMap.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
tokenIndex
);)
{
;
md
.
=
tokenIndex
+
::
;
md
.
=
tokenIndex
;
md
.
=-
1
;
md
.
=
false
;
md
.
=
false
;
md
.
=
false
;
if
((
index
=
tokenColorAtts
.
().
(
tokenIndex
))!=-
1
)
{
md
.
=
.
(
tokenColorAtts
.
()
index
]
0
]);
}
md
.
=
tokenContextColorAtts
.
().
(
tokenIndex
);
md
.
=
tokenAutoCompleteAtts
.
().
(
tokenIndex
);
if
((
md
.
=
tokenCandidateAtts
.
().
(
tokenIndex
)))
{
const
::
&
=
table
(
md
.
);
if
(
IsRegexEscapedLiteralString
(
tokenInfo
.
regex
))
{
md
.
(
tokenInfo
.
regex
);
}
else
{
md
.
=
false
;
}
}
.
(
tokenIndex
,
md
);
}
{
=
table
();
for
(
=
0
;
field
<
fieldCount
;
field
++)
{
const
::
&
=
table
(
field
);
(
fieldInfo
.
,
fieldInfo
.
);
;
md
.
=-
1
;
if
((
index
=
fieldColorAtts
.
().
(
fieldDesc
))!=-
1
)
{
md
.
=
.
(
fieldColorAtts
.
()
index
]
0
]);
}
if
((
index
=
fieldSemanticAtts
.
().
(
fieldDesc
))!=-
1
)
{
md
.
new
<
>;
FOREACH(WString, argument, fieldSemanticAtts.Values()[index]->arguments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
fieldSemanticAtts
.
()
index
]
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
argument
);)
{
md
.
(
.
(
argument
));
}
}
.
(
fieldDesc
,
md
);
}
}
}
void
::
(
&
)
{
if
(
)
{
.
(
);
}
}
::
(
<
parsing
::
tabling
::
>
,
const
&
,
<
>
)
:grammarParser(
)
,grammarRule(
)
,analyzer(
)
,autoPushingCallback(
0
)
{
();
if
(
)
{
(
this
);
}
}
::
~
RepeatingParsingExecutor
()
{
();
if
(
)
{
(
this
);
}
}
<
parsing
::
tabling
::
>
::
()
{
return
;
}
bool
::
(
*
)
{
if
(!
)
return
false
;
if
(
.
(
))
return
false
;
.
(
);
return
true
;
}
bool
::
(
*
)
{
if
(!
)
return
false
;
if
(!
.
(
))
return
false
;
(
);
.
(
);
return
true
;
}
bool
::
(
*
)
{
if
(!
)
return
false
;
if
(!
.
(
))
return
false
;
if
(
.
(
))
return
false
;
.
(
);
if
(!
)
{
=
;
->
(
true
);
}
return
true
;
}
bool
::
(
*
)
{
if
(!
)
return
false
;
if
(!
.
(
))
return
false
;
if
(!
.
(
))
return
false
;
if
(
==
)
{
->
(
false
);
=
0
;
}
.
(
);
if
(!
&&
.
()>
0
)
{
=
0
];
->
(
true
);
}
return
true
;
}
<
::
>
::
()
{
return
;
}
::
(
const
&
)
{
=
.
().
(
);
return
index
==-
1
?-
1
:
.
()
index
];
}
::
(
const
&
)
{
return
.
(
);
}
::
(
)
{
return
0
<=
&&
<
.
()?
]:
L""
;
}
const
::
&
::
(
)
{
return
];
}
const
::
&
::
(
const
&
,
const
&
)
{
return
(
,
)];
}
<
parsing
::
tabling
::
::
>
::
(
,
const
&
,
)
{
if
(
!=-
1
)
{
<
::
>
=
()
(
)
(
);
if
(
att
&& (
==-
1
||
att
.
()==
))
{
return
att
;
}
}
return
0
;
}
<
parsing
::
tabling
::
::
>
::
(
)
{
return
(
,
L"Color"
,
1
);
}
<
parsing
::
tabling
::
::
>
::
(
)
{
return
(
,
L"ContextColor"
,
0
);
}
<
parsing
::
tabling
::
::
>
::
(
)
{
return
(
,
L"Semantic"
, -
1
);
}
<
parsing
::
tabling
::
::
>
::
(
)
{
return
(
,
L"Candidate"
,
0
);
}
<
parsing
::
tabling
::
::
>
::
(
)
{
return
(
,
L"AutoComplete"
,
0
);
}
}
}
}