Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
capnproto
Commits
2e71ad16
Commit
2e71ad16
authored
Jul 02, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move parser-combinator framework to subdirectory.
parent
feb5c1ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
24 deletions
+24
-24
common-test.c++
c++/src/kj/parse/common-test.c++
+16
-16
common.h
c++/src/kj/parse/common.h
+8
-8
No files found.
c++/src/kj/parse-test.c++
→
c++/src/kj/parse
/common
-test.c++
View file @
2e71ad16
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "
parse
.h"
#include "
common
.h"
#include "string.h"
#include "
../
string.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
namespace
kj
{
namespace
kj
{
...
@@ -32,7 +32,7 @@ namespace {
...
@@ -32,7 +32,7 @@ namespace {
typedef
IteratorInput
<
char
,
const
char
*>
Input
;
typedef
IteratorInput
<
char
,
const
char
*>
Input
;
typedef
Span
<
const
char
*>
TestLocation
;
typedef
Span
<
const
char
*>
TestLocation
;
TEST
(
Parsers
,
ExactElementParser
)
{
TEST
(
Common
Parsers
,
ExactElementParser
)
{
StringPtr
text
=
"foo"
;
StringPtr
text
=
"foo"
;
Input
input
(
text
.
begin
(),
text
.
end
());
Input
input
(
text
.
begin
(),
text
.
end
());
...
@@ -55,7 +55,7 @@ TEST(Parsers, ExactElementParser) {
...
@@ -55,7 +55,7 @@ TEST(Parsers, ExactElementParser) {
EXPECT_TRUE
(
input
.
atEnd
());
EXPECT_TRUE
(
input
.
atEnd
());
}
}
TEST
(
Parsers
,
ExactlyConstParser
)
{
TEST
(
Common
Parsers
,
ExactlyConstParser
)
{
StringPtr
text
=
"foo"
;
StringPtr
text
=
"foo"
;
Input
input
(
text
.
begin
(),
text
.
end
());
Input
input
(
text
.
begin
(),
text
.
end
());
...
@@ -78,7 +78,7 @@ TEST(Parsers, ExactlyConstParser) {
...
@@ -78,7 +78,7 @@ TEST(Parsers, ExactlyConstParser) {
EXPECT_TRUE
(
input
.
atEnd
());
EXPECT_TRUE
(
input
.
atEnd
());
}
}
TEST
(
Parsers
,
ExactChar
)
{
TEST
(
Common
Parsers
,
ExactChar
)
{
constexpr
auto
parser
=
exactChar
<
'a'
>
();
constexpr
auto
parser
=
exactChar
<
'a'
>
();
{
{
...
@@ -96,7 +96,7 @@ TEST(Parsers, ExactChar) {
...
@@ -96,7 +96,7 @@ TEST(Parsers, ExactChar) {
}
}
}
}
TEST
(
Parsers
,
ConstResultParser
)
{
TEST
(
Common
Parsers
,
ConstResultParser
)
{
auto
parser
=
constResult
(
exactly
(
'o'
),
123
);
auto
parser
=
constResult
(
exactly
(
'o'
),
123
);
StringPtr
text
=
"o"
;
StringPtr
text
=
"o"
;
...
@@ -110,7 +110,7 @@ TEST(Parsers, ConstResultParser) {
...
@@ -110,7 +110,7 @@ TEST(Parsers, ConstResultParser) {
EXPECT_TRUE
(
input
.
atEnd
());
EXPECT_TRUE
(
input
.
atEnd
());
}
}
TEST
(
Parsers
,
SequenceParser
)
{
TEST
(
Common
Parsers
,
SequenceParser
)
{
StringPtr
text
=
"foo"
;
StringPtr
text
=
"foo"
;
{
{
...
@@ -163,7 +163,7 @@ TEST(Parsers, SequenceParser) {
...
@@ -163,7 +163,7 @@ TEST(Parsers, SequenceParser) {
}
}
}
}
TEST
(
Parsers
,
ManyParser
)
{
TEST
(
Common
Parsers
,
ManyParser
)
{
StringPtr
text
=
"foooob"
;
StringPtr
text
=
"foooob"
;
auto
parser
=
transform
(
auto
parser
=
transform
(
...
@@ -204,7 +204,7 @@ TEST(Parsers, ManyParser) {
...
@@ -204,7 +204,7 @@ TEST(Parsers, ManyParser) {
}
}
}
}
TEST
(
Parsers
,
OptionalParser
)
{
TEST
(
Common
Parsers
,
OptionalParser
)
{
auto
parser
=
sequence
(
auto
parser
=
sequence
(
transform
(
exactly
(
'b'
),
[](
TestLocation
)
->
uint
{
return
123
;
}),
transform
(
exactly
(
'b'
),
[](
TestLocation
)
->
uint
{
return
123
;
}),
optional
(
transform
(
exactly
(
'a'
),
[](
TestLocation
)
->
uint
{
return
456
;
})),
optional
(
transform
(
exactly
(
'a'
),
[](
TestLocation
)
->
uint
{
return
456
;
})),
...
@@ -250,7 +250,7 @@ TEST(Parsers, OptionalParser) {
...
@@ -250,7 +250,7 @@ TEST(Parsers, OptionalParser) {
}
}
}
}
TEST
(
Parsers
,
OneOfParser
)
{
TEST
(
Common
Parsers
,
OneOfParser
)
{
auto
parser
=
oneOf
(
auto
parser
=
oneOf
(
transform
(
sequence
(
exactly
(
'f'
),
exactly
(
'o'
),
exactly
(
'o'
)),
transform
(
sequence
(
exactly
(
'f'
),
exactly
(
'o'
),
exactly
(
'o'
)),
[](
TestLocation
)
->
StringPtr
{
return
"foo"
;
}),
[](
TestLocation
)
->
StringPtr
{
return
"foo"
;
}),
...
@@ -282,7 +282,7 @@ TEST(Parsers, OneOfParser) {
...
@@ -282,7 +282,7 @@ TEST(Parsers, OneOfParser) {
}
}
}
}
TEST
(
Parsers
,
TransformParser
)
{
TEST
(
Common
Parsers
,
TransformParser
)
{
StringPtr
text
=
"foo"
;
StringPtr
text
=
"foo"
;
auto
parser
=
transform
(
auto
parser
=
transform
(
...
@@ -304,7 +304,7 @@ TEST(Parsers, TransformParser) {
...
@@ -304,7 +304,7 @@ TEST(Parsers, TransformParser) {
}
}
}
}
TEST
(
Parsers
,
References
)
{
TEST
(
Common
Parsers
,
References
)
{
struct
TransformFunc
{
struct
TransformFunc
{
int
value
;
int
value
;
...
@@ -344,7 +344,7 @@ TEST(Parsers, References) {
...
@@ -344,7 +344,7 @@ TEST(Parsers, References) {
}
}
}
}
TEST
(
Parsers
,
AcceptIfParser
)
{
TEST
(
Common
Parsers
,
AcceptIfParser
)
{
auto
parser
=
acceptIf
(
auto
parser
=
acceptIf
(
oneOf
(
transform
(
exactly
(
'a'
),
[](
TestLocation
)
->
uint
{
return
123
;
}),
oneOf
(
transform
(
exactly
(
'a'
),
[](
TestLocation
)
->
uint
{
return
123
;
}),
transform
(
exactly
(
'b'
),
[](
TestLocation
)
->
uint
{
return
456
;
}),
transform
(
exactly
(
'b'
),
[](
TestLocation
)
->
uint
{
return
456
;
}),
...
@@ -383,7 +383,7 @@ TEST(Parsers, AcceptIfParser) {
...
@@ -383,7 +383,7 @@ TEST(Parsers, AcceptIfParser) {
}
}
}
}
TEST
(
Parsers
,
CharRange
)
{
TEST
(
Common
Parsers
,
CharRange
)
{
constexpr
auto
parser
=
charRange
(
'a'
,
'z'
);
constexpr
auto
parser
=
charRange
(
'a'
,
'z'
);
{
{
...
@@ -447,7 +447,7 @@ TEST(Parsers, CharRange) {
...
@@ -447,7 +447,7 @@ TEST(Parsers, CharRange) {
}
}
}
}
TEST
(
Parsers
,
AnyChar
)
{
TEST
(
Common
Parsers
,
AnyChar
)
{
constexpr
auto
parser
=
anyChar
(
"axn2B"
);
constexpr
auto
parser
=
anyChar
(
"axn2B"
);
{
{
...
@@ -511,7 +511,7 @@ TEST(Parsers, AnyChar) {
...
@@ -511,7 +511,7 @@ TEST(Parsers, AnyChar) {
}
}
}
}
TEST
(
Parsers
,
CharGroupCombo
)
{
TEST
(
Common
Parsers
,
CharGroupCombo
)
{
constexpr
auto
parser
=
constexpr
auto
parser
=
many
(
charRange
(
'0'
,
'9'
).
orRange
(
'a'
,
'z'
).
orRange
(
'A'
,
'Z'
).
orAny
(
"-_"
));
many
(
charRange
(
'0'
,
'9'
).
orRange
(
'a'
,
'z'
).
orRange
(
'A'
,
'Z'
).
orAny
(
"-_"
));
...
...
c++/src/kj/parse.h
→
c++/src/kj/parse
/common
.h
View file @
2e71ad16
...
@@ -35,14 +35,14 @@
...
@@ -35,14 +35,14 @@
// will have updated the input cursor to point to the position just past the end of what was parsed.
// will have updated the input cursor to point to the position just past the end of what was parsed.
// On failure, the cursor position is unspecified.
// On failure, the cursor position is unspecified.
#ifndef KJ_PARSE
R
_H_
#ifndef KJ_PARSE
_COMMON
_H_
#define KJ_PARSE
R
_H_
#define KJ_PARSE
_COMMON
_H_
#include "common.h"
#include "
../
common.h"
#include "memory.h"
#include "
../
memory.h"
#include "array.h"
#include "
../
array.h"
#include "tuple.h"
#include "
../
tuple.h"
#include "vector.h"
#include "
../
vector.h"
namespace
kj
{
namespace
kj
{
namespace
parse
{
namespace
parse
{
...
@@ -632,4 +632,4 @@ constexpr CharGroup_ anyChar(const char* chars) {
...
@@ -632,4 +632,4 @@ constexpr CharGroup_ anyChar(const char* chars) {
}
// namespace parse
}
// namespace parse
}
// namespace kj
}
// namespace kj
#endif // KJ_PARSE
R
_H_
#endif // KJ_PARSE
_COMMON
_H_
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