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
03e6b5b9
Commit
03e6b5b9
authored
Jul 08, 2008
by
Jesse Beder
Browse files
Centralized the error messages to one location.
parent
c0c55fe5
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
46 deletions
+71
-46
exceptions.h
exceptions.h
+35
-0
exp.cpp
exp.cpp
+3
-4
map.cpp
map.cpp
+5
-5
node.cpp
node.cpp
+4
-4
parser.cpp
parser.cpp
+4
-4
scanner.cpp
scanner.cpp
+1
-1
scanscalar.cpp
scanscalar.cpp
+3
-3
scantoken.cpp
scantoken.cpp
+12
-21
sequence.cpp
sequence.cpp
+4
-4
No files found.
exceptions.h
View file @
03e6b5b9
...
@@ -18,4 +18,39 @@ namespace YAML
...
@@ -18,4 +18,39 @@ namespace YAML
// representation exceptions
// representation exceptions
class
InvalidScalar
:
public
RepresentationException
{};
class
InvalidScalar
:
public
RepresentationException
{};
class
BadDereference
:
public
RepresentationException
{};
class
BadDereference
:
public
RepresentationException
{};
// error messages
namespace
ErrorMsg
{
const
std
::
string
YAML_DIRECTIVE_ARGS
=
"YAML directives must have exactly one argument"
;
const
std
::
string
YAML_VERSION
=
"bad YAML version: "
;
const
std
::
string
YAML_MAJOR_VERSION
=
"YAML major version too large"
;
const
std
::
string
TAG_DIRECTIVE_ARGS
=
"TAG directives must have exactly two arguments"
;
const
std
::
string
END_OF_MAP
=
"end of map not found"
;
const
std
::
string
END_OF_MAP_FLOW
=
"end of map flow not found"
;
const
std
::
string
END_OF_SEQ
=
"end of sequence not found"
;
const
std
::
string
END_OF_SEQ_FLOW
=
"end of sequence flow not found"
;
const
std
::
string
MULTIPLE_TAGS
=
"cannot assign multiple tags to the same node"
;
const
std
::
string
MULTIPLE_ANCHORS
=
"cannot assign multiple anchors to the same node"
;
const
std
::
string
MULTIPLE_ALIASES
=
"cannot assign multiple aliases to the same node"
;
const
std
::
string
ALIAS_CONTENT
=
"aliases can't have any content, *including* tags"
;
const
std
::
string
INVALID_HEX
=
"bad character found while scanning hex number"
;
const
std
::
string
INVALID_UNICODE
=
"invalid unicode: "
;
const
std
::
string
INVALID_ESCAPE
=
"unknown escape character: "
;
const
std
::
string
UNKNOWN_TOKEN
=
"unknown token"
;
const
std
::
string
DOC_IN_SCALAR
=
"illegal document indicator in scalar"
;
const
std
::
string
EOF_IN_SCALAR
=
"illegal EOF in scalar"
;
const
std
::
string
CHAR_IN_SCALAR
=
"illegal character in scalar"
;
const
std
::
string
TAB_IN_INDENTATION
=
"illegal tab when looking for indentation"
;
const
std
::
string
FLOW_END
=
"illegal flow end"
;
const
std
::
string
BLOCK_ENTRY
=
"illegal block entry"
;
const
std
::
string
MAP_KEY
=
"illegal map key"
;
const
std
::
string
MAP_VALUE
=
"illegal map value"
;
const
std
::
string
ALIAS_NOT_FOUND
=
"alias not found after *"
;
const
std
::
string
ANCHOR_NOT_FOUND
=
"anchor not found after &"
;
const
std
::
string
CHAR_IN_ALIAS
=
"illegal character found while scanning alias"
;
const
std
::
string
CHAR_IN_ANCHOR
=
"illegal character found while scanning anchor"
;
const
std
::
string
ZERO_INDENT_IN_BLOCK
=
"cannot set zero indentation for a block scalar"
;
const
std
::
string
CHAR_IN_BLOCK
=
"unexpected character in block scalar"
;
}
}
}
exp.cpp
View file @
03e6b5b9
...
@@ -19,7 +19,7 @@ namespace YAML
...
@@ -19,7 +19,7 @@ namespace YAML
else
if
(
'0'
<=
ch
&&
ch
<=
'9'
)
else
if
(
'0'
<=
ch
&&
ch
<=
'9'
)
digit
=
ch
-
'0'
;
digit
=
ch
-
'0'
;
else
else
throw
ParserException
(
line
,
column
,
"bad character found while scanning hex number"
);
throw
ParserException
(
line
,
column
,
ErrorMsg
::
INVALID_HEX
);
value
=
(
value
<<
4
)
+
digit
;
value
=
(
value
<<
4
)
+
digit
;
}
}
...
@@ -48,7 +48,7 @@ namespace YAML
...
@@ -48,7 +48,7 @@ namespace YAML
// legal unicode?
// legal unicode?
if
((
value
>=
0xD800
&&
value
<=
0xDFFF
)
||
value
>
0x10FFFF
)
{
if
((
value
>=
0xD800
&&
value
<=
0xDFFF
)
||
value
>
0x10FFFF
)
{
std
::
stringstream
msg
;
std
::
stringstream
msg
;
msg
<<
"invalid unicode: "
<<
value
;
msg
<<
ErrorMsg
::
INVALID_UNICODE
<<
value
;
throw
ParserException
(
in
.
line
,
in
.
column
,
msg
.
str
());
throw
ParserException
(
in
.
line
,
in
.
column
,
msg
.
str
());
}
}
...
@@ -106,8 +106,7 @@ namespace YAML
...
@@ -106,8 +106,7 @@ namespace YAML
}
}
std
::
stringstream
msg
;
std
::
stringstream
msg
;
msg
<<
"unknown escape character: "
<<
ch
;
throw
ParserException
(
in
.
line
,
in
.
column
,
ErrorMsg
::
INVALID_ESCAPE
+
ch
);
throw
ParserException
(
in
.
line
,
in
.
column
,
msg
.
str
());
}
}
}
}
}
}
map.cpp
View file @
03e6b5b9
...
@@ -57,10 +57,10 @@ namespace YAML
...
@@ -57,10 +57,10 @@ namespace YAML
while
(
1
)
{
while
(
1
)
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
!
pToken
)
if
(
!
pToken
)
throw
ParserException
(
-
1
,
-
1
,
"end of map not found"
);
throw
ParserException
(
-
1
,
-
1
,
ErrorMsg
::
END_OF_MAP
);
if
(
pToken
->
type
!=
TT_KEY
&&
pToken
->
type
!=
TT_BLOCK_END
)
if
(
pToken
->
type
!=
TT_KEY
&&
pToken
->
type
!=
TT_BLOCK_END
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"end of map not found"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
END_OF_MAP
);
pScanner
->
PopNextToken
();
pScanner
->
PopNextToken
();
if
(
pToken
->
type
==
TT_BLOCK_END
)
if
(
pToken
->
type
==
TT_BLOCK_END
)
...
@@ -96,7 +96,7 @@ namespace YAML
...
@@ -96,7 +96,7 @@ namespace YAML
while
(
1
)
{
while
(
1
)
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
!
pToken
)
if
(
!
pToken
)
throw
ParserException
(
-
1
,
-
1
,
"end of map flow not found"
);
throw
ParserException
(
-
1
,
-
1
,
ErrorMsg
::
END_OF_MAP_FLOW
);
// first check for end
// first check for end
if
(
pToken
->
type
==
TT_FLOW_MAP_END
)
{
if
(
pToken
->
type
==
TT_FLOW_MAP_END
)
{
...
@@ -106,7 +106,7 @@ namespace YAML
...
@@ -106,7 +106,7 @@ namespace YAML
// now it better be a key
// now it better be a key
if
(
pToken
->
type
!=
TT_KEY
)
if
(
pToken
->
type
!=
TT_KEY
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"end of map flow not found"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
END_OF_MAP_FLOW
);
pScanner
->
PopNextToken
();
pScanner
->
PopNextToken
();
...
@@ -128,7 +128,7 @@ namespace YAML
...
@@ -128,7 +128,7 @@ namespace YAML
if
(
pToken
->
type
==
TT_FLOW_ENTRY
)
if
(
pToken
->
type
==
TT_FLOW_ENTRY
)
pScanner
->
EatNextToken
();
pScanner
->
EatNextToken
();
else
if
(
pToken
->
type
!=
TT_FLOW_MAP_END
)
else
if
(
pToken
->
type
!=
TT_FLOW_MAP_END
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"end of map flow not found"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
END_OF_MAP_FLOW
);
m_data
[
pKey
]
=
pValue
;
m_data
[
pKey
]
=
pValue
;
}
catch
(
Exception
&
e
)
{
}
catch
(
Exception
&
e
)
{
...
...
node.cpp
View file @
03e6b5b9
...
@@ -85,7 +85,7 @@ namespace YAML
...
@@ -85,7 +85,7 @@ namespace YAML
{
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
m_tag
!=
""
)
if
(
m_tag
!=
""
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"cannot assign multiple tags to the same node"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
MULTIPLE_TAGS
);
m_tag
=
state
.
TranslateTag
(
pToken
->
value
);
m_tag
=
state
.
TranslateTag
(
pToken
->
value
);
...
@@ -98,7 +98,7 @@ namespace YAML
...
@@ -98,7 +98,7 @@ namespace YAML
{
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
m_anchor
!=
""
)
if
(
m_anchor
!=
""
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"cannot assign multiple anchors to the same node"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
MULTIPLE_ANCHORS
);
m_anchor
=
pToken
->
value
;
m_anchor
=
pToken
->
value
;
m_alias
=
false
;
m_alias
=
false
;
...
@@ -109,9 +109,9 @@ namespace YAML
...
@@ -109,9 +109,9 @@ namespace YAML
{
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
m_anchor
!=
""
)
if
(
m_anchor
!=
""
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"cannot assign multiple aliases to the same node"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
MULTIPLE_ALIASES
);
if
(
m_tag
!=
""
)
if
(
m_tag
!=
""
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"aliases can't have any content, *including* tags"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
ALIAS_CONTENT
);
m_anchor
=
pToken
->
value
;
m_anchor
=
pToken
->
value
;
m_alias
=
true
;
m_alias
=
true
;
...
...
parser.cpp
View file @
03e6b5b9
...
@@ -90,17 +90,17 @@ namespace YAML
...
@@ -90,17 +90,17 @@ namespace YAML
void
Parser
::
HandleYamlDirective
(
Token
*
pToken
)
void
Parser
::
HandleYamlDirective
(
Token
*
pToken
)
{
{
if
(
pToken
->
params
.
size
()
!=
1
)
if
(
pToken
->
params
.
size
()
!=
1
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"YAML directives must have exactly one argument"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
YAML_DIRECTIVE_ARGS
);
std
::
stringstream
str
(
pToken
->
params
[
0
]);
std
::
stringstream
str
(
pToken
->
params
[
0
]);
str
>>
m_state
.
version
.
major
;
str
>>
m_state
.
version
.
major
;
str
.
get
();
str
.
get
();
str
>>
m_state
.
version
.
minor
;
str
>>
m_state
.
version
.
minor
;
if
(
!
str
||
str
.
peek
()
!=
EOF
)
if
(
!
str
||
str
.
peek
()
!=
EOF
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"bad YAML version: "
+
pToken
->
params
[
0
]);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
YAML_VERSION
+
pToken
->
params
[
0
]);
if
(
m_state
.
version
.
major
>
1
)
if
(
m_state
.
version
.
major
>
1
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"YAML major version > 1"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
YAML_MAJOR_VERSION
);
// TODO: warning on major == 1, minor > 2?
// TODO: warning on major == 1, minor > 2?
}
}
...
@@ -110,7 +110,7 @@ namespace YAML
...
@@ -110,7 +110,7 @@ namespace YAML
void
Parser
::
HandleTagDirective
(
Token
*
pToken
)
void
Parser
::
HandleTagDirective
(
Token
*
pToken
)
{
{
if
(
pToken
->
params
.
size
()
!=
2
)
if
(
pToken
->
params
.
size
()
!=
2
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"TAG directives must have exactly two arguments"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
TAG_DIRECTIVE_ARGS
);
std
::
string
handle
=
pToken
->
params
[
0
],
prefix
=
pToken
->
params
[
1
];
std
::
string
handle
=
pToken
->
params
[
0
],
prefix
=
pToken
->
params
[
1
];
m_state
.
tags
[
handle
]
=
prefix
;
m_state
.
tags
[
handle
]
=
prefix
;
...
...
scanner.cpp
View file @
03e6b5b9
...
@@ -157,7 +157,7 @@ namespace YAML
...
@@ -157,7 +157,7 @@ namespace YAML
return
ScanPlainScalar
();
return
ScanPlainScalar
();
// don't know what it is!
// don't know what it is!
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"unknown token"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
UNKNOWN_TOKEN
);
}
}
// ScanToNextToken
// ScanToNextToken
...
...
scanscalar.cpp
View file @
03e6b5b9
...
@@ -35,7 +35,7 @@ namespace YAML
...
@@ -35,7 +35,7 @@ namespace YAML
if
(
params
.
onDocIndicator
==
BREAK
)
if
(
params
.
onDocIndicator
==
BREAK
)
break
;
break
;
else
if
(
params
.
onDocIndicator
==
THROW
)
else
if
(
params
.
onDocIndicator
==
THROW
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal document indicator in scalar"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
DOC_IN_SCALAR
);
}
}
foundNonEmptyLine
=
true
;
foundNonEmptyLine
=
true
;
...
@@ -61,7 +61,7 @@ namespace YAML
...
@@ -61,7 +61,7 @@ namespace YAML
// eof? if we're looking to eat something, then we throw
// eof? if we're looking to eat something, then we throw
if
(
INPUT
.
peek
()
==
EOF
)
{
if
(
INPUT
.
peek
()
==
EOF
)
{
if
(
params
.
eatEnd
)
if
(
params
.
eatEnd
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal EOF in scalar"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
EOF_IN_SCALAR
);
break
;
break
;
}
}
...
@@ -97,7 +97,7 @@ namespace YAML
...
@@ -97,7 +97,7 @@ namespace YAML
while
(
Exp
::
Blank
.
Matches
(
INPUT
))
{
while
(
Exp
::
Blank
.
Matches
(
INPUT
))
{
// we check for tabs that masquerade as indentation
// we check for tabs that masquerade as indentation
if
(
INPUT
.
peek
()
==
'\t'
&&
INPUT
.
column
<
params
.
indent
&&
params
.
onTabInIndentation
==
THROW
)
if
(
INPUT
.
peek
()
==
'\t'
&&
INPUT
.
column
<
params
.
indent
&&
params
.
onTabInIndentation
==
THROW
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal tab when looking for indentation"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
TAB_IN_INDENTATION
);
if
(
!
params
.
eatLeadingWhitespace
)
if
(
!
params
.
eatLeadingWhitespace
)
break
;
break
;
...
...
scantoken.cpp
View file @
03e6b5b9
...
@@ -100,7 +100,7 @@ namespace YAML
...
@@ -100,7 +100,7 @@ namespace YAML
void
Scanner
::
ScanFlowEnd
()
void
Scanner
::
ScanFlowEnd
()
{
{
if
(
m_flowLevel
==
0
)
if
(
m_flowLevel
==
0
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal flow end"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
FLOW_END
);
m_flowLevel
--
;
m_flowLevel
--
;
m_simpleKeyAllowed
=
false
;
m_simpleKeyAllowed
=
false
;
...
@@ -128,11 +128,11 @@ namespace YAML
...
@@ -128,11 +128,11 @@ namespace YAML
{
{
// we better be in the block context!
// we better be in the block context!
if
(
m_flowLevel
>
0
)
if
(
m_flowLevel
>
0
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal block entry"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
BLOCK_ENTRY
);
// can we put it here?
// can we put it here?
if
(
!
m_simpleKeyAllowed
)
if
(
!
m_simpleKeyAllowed
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal block entry"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
BLOCK_ENTRY
);
PushIndentTo
(
INPUT
.
column
,
true
);
PushIndentTo
(
INPUT
.
column
,
true
);
m_simpleKeyAllowed
=
true
;
m_simpleKeyAllowed
=
true
;
...
@@ -149,7 +149,7 @@ namespace YAML
...
@@ -149,7 +149,7 @@ namespace YAML
// handle keys diffently in the block context (and manage indents)
// handle keys diffently in the block context (and manage indents)
if
(
m_flowLevel
==
0
)
{
if
(
m_flowLevel
==
0
)
{
if
(
!
m_simpleKeyAllowed
)
if
(
!
m_simpleKeyAllowed
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal map key"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
MAP_KEY
);
PushIndentTo
(
INPUT
.
column
,
false
);
PushIndentTo
(
INPUT
.
column
,
false
);
}
}
...
@@ -177,7 +177,7 @@ namespace YAML
...
@@ -177,7 +177,7 @@ namespace YAML
// handle values diffently in the block context (and manage indents)
// handle values diffently in the block context (and manage indents)
if
(
m_flowLevel
==
0
)
{
if
(
m_flowLevel
==
0
)
{
if
(
!
m_simpleKeyAllowed
)
if
(
!
m_simpleKeyAllowed
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal map value"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
MAP_VALUE
);
PushIndentTo
(
INPUT
.
column
,
false
);
PushIndentTo
(
INPUT
.
column
,
false
);
}
}
...
@@ -216,21 +216,12 @@ namespace YAML
...
@@ -216,21 +216,12 @@ namespace YAML
name
+=
INPUT
.
get
();
name
+=
INPUT
.
get
();
// we need to have read SOMETHING!
// we need to have read SOMETHING!
if
(
name
.
empty
())
{
if
(
name
.
empty
())
std
::
stringstream
msg
;
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
alias
?
ErrorMsg
::
ALIAS_NOT_FOUND
:
ErrorMsg
::
ANCHOR_NOT_FOUND
);
msg
<<
(
alias
?
"alias"
:
"anchor"
);
msg
<<
" not found after "
;
msg
<<
(
alias
?
"*"
:
"&"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
msg
.
str
());
}
// and needs to end correctly
// and needs to end correctly
if
(
INPUT
.
peek
()
!=
EOF
&&
!
Exp
::
AnchorEnd
.
Matches
(
INPUT
))
{
if
(
INPUT
.
peek
()
!=
EOF
&&
!
Exp
::
AnchorEnd
.
Matches
(
INPUT
))
std
::
stringstream
msg
;
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
alias
?
ErrorMsg
::
CHAR_IN_ALIAS
:
ErrorMsg
::
CHAR_IN_ANCHOR
);
msg
<<
"illegal character found while scanning "
;
msg
<<
(
alias
?
"alias"
:
"anchor"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
msg
.
str
());
}
// and we're done
// and we're done
Token
*
pToken
=
new
Token
(
alias
?
TT_ALIAS
:
TT_ANCHOR
,
line
,
column
);
Token
*
pToken
=
new
Token
(
alias
?
TT_ALIAS
:
TT_ANCHOR
,
line
,
column
);
...
@@ -306,7 +297,7 @@ namespace YAML
...
@@ -306,7 +297,7 @@ namespace YAML
// finally, we can't have any colons in a scalar, so if we ended on a colon, there
// finally, we can't have any colons in a scalar, so if we ended on a colon, there
// had better be a break after it
// had better be a break after it
if
(
Exp
::
IllegalColonInScalar
.
Matches
(
INPUT
))
if
(
Exp
::
IllegalColonInScalar
.
Matches
(
INPUT
))
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"illegal character in scalar"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
CHAR_IN_SCALAR
);
Token
*
pToken
=
new
Token
(
TT_SCALAR
,
line
,
column
);
Token
*
pToken
=
new
Token
(
TT_SCALAR
,
line
,
column
);
pToken
->
value
=
scalar
;
pToken
->
value
=
scalar
;
...
@@ -374,7 +365,7 @@ namespace YAML
...
@@ -374,7 +365,7 @@ namespace YAML
params
.
chomp
=
STRIP
;
params
.
chomp
=
STRIP
;
else
if
(
Exp
::
Digit
.
Matches
(
ch
))
{
else
if
(
Exp
::
Digit
.
Matches
(
ch
))
{
if
(
ch
==
'0'
)
if
(
ch
==
'0'
)
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"cannot set zero indentation for a block scalar"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
ZERO_INDENT_IN_BLOCK
);
params
.
indent
=
ch
-
'0'
;
params
.
indent
=
ch
-
'0'
;
params
.
detectIndent
=
false
;
params
.
detectIndent
=
false
;
...
@@ -392,7 +383,7 @@ namespace YAML
...
@@ -392,7 +383,7 @@ namespace YAML
// if it's not a line break, then we ran into a bad character inline
// if it's not a line break, then we ran into a bad character inline
if
(
INPUT
&&
!
Exp
::
Break
.
Matches
(
INPUT
))
if
(
INPUT
&&
!
Exp
::
Break
.
Matches
(
INPUT
))
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
"unexpected character in block scalar"
);
throw
ParserException
(
INPUT
.
line
,
INPUT
.
column
,
ErrorMsg
::
CHAR_IN_BLOCK
);
// set the initial indentation
// set the initial indentation
if
(
m_indents
.
top
()
>=
0
)
if
(
m_indents
.
top
()
>=
0
)
...
...
sequence.cpp
View file @
03e6b5b9
...
@@ -68,10 +68,10 @@ namespace YAML
...
@@ -68,10 +68,10 @@ namespace YAML
while
(
1
)
{
while
(
1
)
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
!
pToken
)
if
(
!
pToken
)
throw
ParserException
(
-
1
,
-
1
,
"end of sequence not found"
);
throw
ParserException
(
-
1
,
-
1
,
ErrorMsg
::
END_OF_SEQ
);
if
(
pToken
->
type
!=
TT_BLOCK_ENTRY
&&
pToken
->
type
!=
TT_BLOCK_END
)
if
(
pToken
->
type
!=
TT_BLOCK_ENTRY
&&
pToken
->
type
!=
TT_BLOCK_END
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"end of sequence not found"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
END_OF_SEQ
);
pScanner
->
PopNextToken
();
pScanner
->
PopNextToken
();
if
(
pToken
->
type
==
TT_BLOCK_END
)
if
(
pToken
->
type
==
TT_BLOCK_END
)
...
@@ -111,7 +111,7 @@ namespace YAML
...
@@ -111,7 +111,7 @@ namespace YAML
while
(
1
)
{
while
(
1
)
{
Token
*
pToken
=
pScanner
->
PeekNextToken
();
Token
*
pToken
=
pScanner
->
PeekNextToken
();
if
(
!
pToken
)
if
(
!
pToken
)
throw
ParserException
(
-
1
,
-
1
,
"end of sequence flow not found"
);
throw
ParserException
(
-
1
,
-
1
,
ErrorMsg
::
END_OF_SEQ_FLOW
);
// first check for end
// first check for end
if
(
pToken
->
type
==
TT_FLOW_SEQ_END
)
{
if
(
pToken
->
type
==
TT_FLOW_SEQ_END
)
{
...
@@ -129,7 +129,7 @@ namespace YAML
...
@@ -129,7 +129,7 @@ namespace YAML
if
(
pToken
->
type
==
TT_FLOW_ENTRY
)
if
(
pToken
->
type
==
TT_FLOW_ENTRY
)
pScanner
->
EatNextToken
();
pScanner
->
EatNextToken
();
else
if
(
pToken
->
type
!=
TT_FLOW_SEQ_END
)
else
if
(
pToken
->
type
!=
TT_FLOW_SEQ_END
)
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
"end of sequence flow not found"
);
throw
ParserException
(
pToken
->
line
,
pToken
->
column
,
ErrorMsg
::
END_OF_SEQ_FLOW
);
}
}
}
}
...
...
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