Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
328b0d8a
Commit
328b0d8a
authored
May 25, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactor regex
parent
994b0dfe
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
regex.h
include/rapidjson/internal/regex.h
+10
-14
No files found.
include/rapidjson/internal/regex.h
View file @
328b0d8a
...
...
@@ -152,8 +152,7 @@ private:
}
void
Patch
(
SizeType
l
,
SizeType
s
)
{
SizeType
next
;
for
(;
l
!=
kRegexInvalidState
;
l
=
next
)
{
for
(
SizeType
next
;
l
!=
kRegexInvalidState
;
l
=
next
)
{
next
=
GetState
(
l
).
out
;
GetState
(
l
).
out
=
s
;
}
...
...
@@ -173,7 +172,7 @@ private:
switch
(
codepoint
)
{
case
'|'
:
while
(
!
operatorStack
.
Empty
()
&&
*
operatorStack
.
template
Top
<
Operator
>
()
<
kAlternation
)
if
(
!
Eval
(
operandStack
,
operatorStack
))
if
(
!
Eval
(
operandStack
,
*
operatorStack
.
template
Pop
<
Operator
>
(
1
)
))
return
;
*
operatorStack
.
template
Push
<
Operator
>
()
=
kAlternation
;
*
atomCountStack
.
template
Top
<
unsigned
>
()
=
0
;
...
...
@@ -186,7 +185,7 @@ private:
case
')'
:
while
(
!
operatorStack
.
Empty
()
&&
*
operatorStack
.
template
Top
<
Operator
>
()
!=
kLeftParenthesis
)
if
(
!
Eval
(
operandStack
,
operatorStack
))
if
(
!
Eval
(
operandStack
,
*
operatorStack
.
template
Pop
<
Operator
>
(
1
)
))
return
;
if
(
operatorStack
.
Empty
())
return
;
...
...
@@ -196,20 +195,17 @@ private:
break
;
case
'?'
:
*
operatorStack
.
template
Push
<
Operator
>
()
=
kZeroOrOne
;
if
(
!
Eval
(
operandStack
,
operatorStack
))
if
(
!
Eval
(
operandStack
,
kZeroOrOne
))
return
;
break
;
case
'*'
:
*
operatorStack
.
template
Push
<
Operator
>
()
=
kZeroOrMore
;
if
(
!
Eval
(
operandStack
,
operatorStack
))
if
(
!
Eval
(
operandStack
,
kZeroOrMore
))
return
;
break
;
case
'+'
:
*
operatorStack
.
template
Push
<
Operator
>
()
=
kOneOrMore
;
if
(
!
Eval
(
operandStack
,
operatorStack
))
if
(
!
Eval
(
operandStack
,
kOneOrMore
))
return
;
break
;
...
...
@@ -221,7 +217,7 @@ private:
}
while
(
!
operatorStack
.
Empty
())
if
(
!
Eval
(
operandStack
,
operatorStack
))
if
(
!
Eval
(
operandStack
,
*
operatorStack
.
template
Pop
<
Operator
>
(
1
)
))
return
;
// Link the operand to matching state.
...
...
@@ -229,6 +225,7 @@ private:
Frag
*
e
=
operandStack
.
template
Pop
<
Frag
>
(
1
);
Patch
(
e
->
out
,
NewState
(
kRegexInvalidState
,
kRegexInvalidState
,
0
));
root_
=
e
->
start
;
#if RAPIDJSON_REGEX_VERBOSE
printf
(
"root: %d
\n
"
,
root_
);
for
(
SizeType
i
=
0
;
i
<
stateCount_
;
i
++
)
{
...
...
@@ -240,9 +237,8 @@ private:
}
}
bool
Eval
(
Stack
<
Allocator
>&
operandStack
,
Stack
<
Allocator
>&
operatorStack
)
{
// printf("Eval %c\n", "?*+.|("[*operatorStack.template Top<Operator>()]);
switch
(
*
operatorStack
.
template
Pop
<
Operator
>
(
1
))
{
bool
Eval
(
Stack
<
Allocator
>&
operandStack
,
Operator
op
)
{
switch
(
op
)
{
case
kConcatenation
:
if
(
operandStack
.
GetSize
()
>=
sizeof
(
Frag
)
*
2
)
{
Frag
e2
=
*
operandStack
.
template
Pop
<
Frag
>
(
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment