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
2e27c5d9
Commit
2e27c5d9
authored
Jun 28, 2008
by
Jesse Beder
Browse files
Small refactoring.
parent
72b44337
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
42 deletions
+20
-42
exceptions.h
exceptions.h
+1
-0
scanner.cpp
scanner.cpp
+0
-16
scanner.h
scanner.h
+0
-2
scantoken.cpp
scantoken.cpp
+19
-24
No files found.
exceptions.h
View file @
2e27c5d9
...
...
@@ -12,6 +12,7 @@ namespace YAML
class
IllegalMapValue
:
public
Exception
{};
class
IllegalScalar
:
public
Exception
{};
class
IllegalTabInScalar
:
public
Exception
{};
class
IllegalFlowEnd
:
public
Exception
{};
class
DocIndicatorInQuote
:
public
Exception
{};
class
EOFInQuote
:
public
Exception
{};
class
RequiredSimpleKeyNotFound
:
public
Exception
{};
...
...
scanner.cpp
View file @
2e27c5d9
...
...
@@ -288,22 +288,6 @@ namespace YAML
}
}
// IncreaseFlowLevel
void
Scanner
::
IncreaseFlowLevel
()
{
// TODO: Push simple key
m_flowLevel
++
;
}
// DecreaseFlowLevel
void
Scanner
::
DecreaseFlowLevel
()
{
if
(
m_flowLevel
>
0
)
{
m_flowLevel
--
;
// TODO: Pop simple key
}
}
// GetNextToken
// . Returns the next token on the queue, and scans if only we need to.
Token
*
Scanner
::
GetNextToken
()
...
...
scanner.h
View file @
2e27c5d9
...
...
@@ -22,8 +22,6 @@ namespace YAML
void
ScanToNextToken
();
Token
*
PushIndentTo
(
int
column
,
bool
sequence
);
void
PopIndentTo
(
int
column
);
void
IncreaseFlowLevel
();
void
DecreaseFlowLevel
();
void
InsertSimpleKey
();
bool
ValidateSimpleKey
();
...
...
scantoken.cpp
View file @
2e27c5d9
...
...
@@ -63,7 +63,7 @@ namespace YAML
{
// flow sequences can be simple keys
InsertSimpleKey
();
IncreaseF
lowLevel
()
;
m_f
lowLevel
++
;
m_simpleKeyAllowed
=
true
;
// eat
...
...
@@ -76,7 +76,7 @@ namespace YAML
{
// flow maps can be simple keys
InsertSimpleKey
();
IncreaseF
lowLevel
()
;
m_f
lowLevel
++
;
m_simpleKeyAllowed
=
true
;
// eat
...
...
@@ -87,8 +87,10 @@ namespace YAML
// FlowSeqEndToken
template
<
>
FlowSeqEndToken
*
Scanner
::
ScanToken
(
FlowSeqEndToken
*
pToken
)
{
// ValidateSimpleKey();
DecreaseFlowLevel
();
if
(
m_flowLevel
==
0
)
throw
IllegalFlowEnd
();
m_flowLevel
--
;
m_simpleKeyAllowed
=
false
;
// eat
...
...
@@ -99,8 +101,10 @@ namespace YAML
// FlowMapEndToken
template
<
>
FlowMapEndToken
*
Scanner
::
ScanToken
(
FlowMapEndToken
*
pToken
)
{
//ValidateSimpleKey();
DecreaseFlowLevel
();
if
(
m_flowLevel
==
0
)
throw
IllegalFlowEnd
();
m_flowLevel
--
;
m_simpleKeyAllowed
=
false
;
// eat
...
...
@@ -111,7 +115,6 @@ namespace YAML
// FlowEntryToken
template
<
>
FlowEntryToken
*
Scanner
::
ScanToken
(
FlowEntryToken
*
pToken
)
{
//ValidateSimpleKey();
m_simpleKeyAllowed
=
true
;
// eat
...
...
@@ -122,19 +125,15 @@ namespace YAML
// BlockEntryToken
template
<
>
BlockEntryToken
*
Scanner
::
ScanToken
(
BlockEntryToken
*
pToken
)
{
//ValidateSimpleKey();
// we better be in the block context!
if
(
m_flowLevel
==
0
)
{
// can we put it here?
if
(
!
m_simpleKeyAllowed
)
throw
IllegalBlockEntry
();
if
(
m_flowLevel
>
0
)
throw
IllegalBlockEntry
();
PushIndentTo
(
m_column
,
true
);
// , -1
}
else
{
// TODO: throw?
}
// can we put it here?
if
(
!
m_simpleKeyAllowed
)
throw
IllegalBlockEntry
();
PushIndentTo
(
m_column
,
true
);
m_simpleKeyAllowed
=
true
;
// eat
...
...
@@ -145,7 +144,7 @@ namespace YAML
// KeyToken
template
<
>
KeyToken
*
Scanner
::
ScanToken
(
KeyToken
*
pToken
)
{
//
are we in block context?
//
handle keys diffently in the block context (and manage indents)
if
(
m_flowLevel
==
0
)
{
if
(
!
m_simpleKeyAllowed
)
throw
IllegalMapKey
();
...
...
@@ -153,8 +152,6 @@ namespace YAML
PushIndentTo
(
m_column
,
false
);
}
// TODO: "remove simple key"
// can only put a simple key here if we're in block context
if
(
m_flowLevel
==
0
)
m_simpleKeyAllowed
=
true
;
...
...
@@ -170,13 +167,11 @@ namespace YAML
template
<
>
ValueToken
*
Scanner
::
ScanToken
(
ValueToken
*
pToken
)
{
// does this follow a simple key?
// bool isValidKey = ValidateSimpleKey();
if
(
m_isLastKeyValid
)
{
// can't follow a simple key with another simple key (dunno why, though - it seems fine)
m_simpleKeyAllowed
=
false
;
}
else
{
//
are we in block context?
//
handle values diffently in the block context (and manage indents)
if
(
m_flowLevel
==
0
)
{
if
(
!
m_simpleKeyAllowed
)
throw
IllegalMapValue
();
...
...
@@ -393,7 +388,7 @@ namespace YAML
// set the initial indentation
int
indent
=
info
.
increment
;
if
(
info
.
increment
&&
m_indents
.
top
()
>=
0
)
if
(
info
.
increment
&&
m_indents
.
top
()
>=
0
)
indent
+=
m_indents
.
top
();
// finally, grab that scalar
...
...
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