Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
5217149e
Commit
5217149e
authored
Sep 06, 2009
by
Jesse Beder
Browse files
Fixed bug with complex keys (and simplified the parsing for flow maps)
parent
e7ac6b3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
16 deletions
+10
-16
src/map.cpp
src/map.cpp
+8
-11
src/scantoken.cpp
src/scantoken.cpp
+0
-3
yaml-reader/spectests.cpp
yaml-reader/spectests.cpp
+2
-2
No files found.
src/map.cpp
View file @
5217149e
...
@@ -122,24 +122,21 @@ namespace YAML
...
@@ -122,24 +122,21 @@ namespace YAML
pScanner
->
pop
();
pScanner
->
pop
();
break
;
break
;
}
}
// now it better be a key
if
(
token
.
type
!=
Token
::
KEY
)
throw
ParserException
(
token
.
mark
,
ErrorMsg
::
END_OF_MAP_FLOW
);
pScanner
->
pop
();
std
::
auto_ptr
<
Node
>
pKey
(
new
Node
),
pValue
(
new
Node
);
std
::
auto_ptr
<
Node
>
pKey
(
new
Node
),
pValue
(
new
Node
);
// grab key
// grab key (if non-null)
pKey
->
Parse
(
pScanner
,
state
);
if
(
token
.
type
==
Token
::
KEY
)
{
pScanner
->
pop
();
pKey
->
Parse
(
pScanner
,
state
);
}
// now grab value (optional)
// now grab value (optional)
if
(
!
pScanner
->
empty
()
&&
pScanner
->
peek
().
type
==
Token
::
VALUE
)
{
if
(
!
pScanner
->
empty
()
&&
pScanner
->
peek
().
type
==
Token
::
VALUE
)
{
pScanner
->
pop
();
pScanner
->
pop
();
pValue
->
Parse
(
pScanner
,
state
);
pValue
->
Parse
(
pScanner
,
state
);
}
}
// now eat the separator (or could be a map end, which we ignore - but if it's neither, then it's a bad node)
// now eat the separator (or could be a map end, which we ignore - but if it's neither, then it's a bad node)
Token
&
nextToken
=
pScanner
->
peek
();
Token
&
nextToken
=
pScanner
->
peek
();
if
(
nextToken
.
type
==
Token
::
FLOW_ENTRY
)
if
(
nextToken
.
type
==
Token
::
FLOW_ENTRY
)
...
...
src/scantoken.cpp
View file @
5217149e
...
@@ -182,9 +182,6 @@ namespace YAML
...
@@ -182,9 +182,6 @@ namespace YAML
// Value
// Value
void
Scanner
::
ScanValue
()
void
Scanner
::
ScanValue
()
{
{
// just in case we have an empty key
InsertPotentialSimpleKey
();
// and check that simple key
// and check that simple key
bool
isSimpleKey
=
VerifySimpleKey
();
bool
isSimpleKey
=
VerifySimpleKey
();
...
...
yaml-reader/spectests.cpp
View file @
5217149e
...
@@ -325,8 +325,8 @@ namespace Test {
...
@@ -325,8 +325,8 @@ namespace Test {
parser
.
GetNextDocument
(
doc
);
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
.
size
()
==
2
);
YAML_ASSERT
(
doc
.
size
()
==
2
);
YAML_ASSERT
(
doc
[
Pair
(
"Detroit Tigers"
,
"Chicago
C
ubs"
)].
size
()
==
1
);
YAML_ASSERT
(
doc
[
Pair
(
"Detroit Tigers"
,
"Chicago
c
ubs"
)].
size
()
==
1
);
YAML_ASSERT
(
doc
[
Pair
(
"Detroit Tigers"
,
"Chicago
C
ubs"
)][
0
]
==
"2001-07-23"
);
YAML_ASSERT
(
doc
[
Pair
(
"Detroit Tigers"
,
"Chicago
c
ubs"
)][
0
]
==
"2001-07-23"
);
YAML_ASSERT
(
doc
[
Pair
(
"New York Yankees"
,
"Atlanta Braves"
)].
size
()
==
3
);
YAML_ASSERT
(
doc
[
Pair
(
"New York Yankees"
,
"Atlanta Braves"
)].
size
()
==
3
);
YAML_ASSERT
(
doc
[
Pair
(
"New York Yankees"
,
"Atlanta Braves"
)][
0
]
==
"2001-07-02"
);
YAML_ASSERT
(
doc
[
Pair
(
"New York Yankees"
,
"Atlanta Braves"
)][
0
]
==
"2001-07-02"
);
YAML_ASSERT
(
doc
[
Pair
(
"New York Yankees"
,
"Atlanta Braves"
)][
1
]
==
"2001-08-12"
);
YAML_ASSERT
(
doc
[
Pair
(
"New York Yankees"
,
"Atlanta Braves"
)][
1
]
==
"2001-08-12"
);
...
...
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