Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
a8a0fb41
Commit
a8a0fb41
authored
Jul 08, 2008
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some exceptions for directives.
parent
6c2946bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
13 deletions
+22
-13
node.cpp
+7
-7
parser.cpp
+8
-4
tests.cpp
+1
-2
tests/directives.yaml
+6
-0
No files found.
node.cpp
View file @
a8a0fb41
...
...
@@ -83,10 +83,10 @@ namespace YAML
void
Node
::
ParseTag
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
m_tag
!=
""
)
return
;
// TODO: throw
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"cannot assign multiple tags to the same node"
);
Token
*
pToken
=
pScanner
->
PeekNextToken
();
m_tag
=
state
.
TranslateTag
(
pToken
->
value
);
for
(
unsigned
i
=
0
;
i
<
pToken
->
params
.
size
();
i
++
)
...
...
@@ -96,10 +96,10 @@ namespace YAML
void
Node
::
ParseAnchor
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
m_anchor
!=
""
)
return
;
// TODO: throw
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"cannot assign multiple anchors to the same node"
);
Token
*
pToken
=
pScanner
->
PeekNextToken
();
m_anchor
=
pToken
->
value
;
m_alias
=
false
;
pScanner
->
PopNextToken
();
...
...
@@ -107,12 +107,12 @@ namespace YAML
void
Node
::
ParseAlias
(
Scanner
*
pScanner
,
const
ParserState
&
state
)
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
m_anchor
!=
""
)
return
;
// TODO: throw
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"cannot assign multiple aliases to the same node"
);
if
(
m_tag
!=
""
)
return
;
// TODO: throw (aliases can't have any content, *including* tags)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"aliases can't have any content, *including* tags"
);
Token
*
pToken
=
pScanner
->
PeekNextToken
();
m_anchor
=
pToken
->
value
;
m_alias
=
true
;
pScanner
->
PopNextToken
();
...
...
parser.cpp
View file @
a8a0fb41
...
...
@@ -96,13 +96,17 @@ namespace YAML
str
>>
m_state
.
version
.
major
;
str
.
get
();
str
>>
m_state
.
version
.
minor
;
if
(
!
str
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"bad YAML directive"
);
// TODO: or throw if there are any more characters in the stream?
if
(
!
str
||
str
.
peek
()
!=
EOF
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"bad YAML version: "
+
pToken
->
params
[
0
]);
// TODO: throw on major > 1? warning on major == 1, minor > 2?
if
(
m_state
.
version
.
major
>
1
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"YAML major version > 1"
);
// TODO: warning on major == 1, minor > 2?
}
// HandleTagDirective
// . Should be of the form 'handle prefix', where 'handle' is converted to 'prefix' in the file.
void
Parser
::
HandleTagDirective
(
Token
*
pToken
)
{
if
(
pToken
->
params
.
size
()
!=
2
)
...
...
tests.cpp
View file @
a8a0fb41
...
...
@@ -16,6 +16,7 @@ namespace YAML
files
.
push_back
(
"tests/simple.yaml"
);
files
.
push_back
(
"tests/mixed.yaml"
);
files
.
push_back
(
"tests/scalars.yaml"
);
files
.
push_back
(
"tests/directives.yaml"
);
bool
passed
=
true
;
for
(
unsigned
i
=
0
;
i
<
files
.
size
();
i
++
)
{
...
...
@@ -69,8 +70,6 @@ namespace YAML
fout
<<
firstTry
<<
std
::
endl
;
fout
<<
"---
\n
"
;
fout
<<
secondTry
<<
std
::
endl
;
return
false
;
}
catch
(
ParserException
&
e
)
{
std
::
cout
<<
file
<<
" (line "
<<
e
.
line
+
1
<<
", col "
<<
e
.
column
+
1
<<
"): "
<<
e
.
msg
<<
std
::
endl
;
return
false
;
...
...
tests/directives.yaml
0 → 100644
View file @
a8a0fb41
%YAML
1.2
%TAG
!
!
howdy
---
-
basic node
-
!
yeah baby
\ No newline at end of file
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