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
148da471
Commit
148da471
authored
May 12, 2016
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update documentation for Scanner and AnchorDict, and fix formatting.
parent
a45a6174
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
89 deletions
+146
-89
include/yaml-cpp/contrib/anchordict.h
+7
-5
src/scanner.cpp
+82
-82
src/scanner.h
+57
-2
No files found.
include/yaml-cpp/contrib/anchordict.h
View file @
148da471
...
@@ -12,11 +12,13 @@
...
@@ -12,11 +12,13 @@
#include "../anchor.h"
#include "../anchor.h"
namespace
YAML
{
namespace
YAML
{
/// AnchorDict
/**
/// . An object that stores and retrieves values correlating to anchor_t
* An object that stores and retrieves values correlating to {@link anchor_t}
/// values.
* values.
/// . Efficient implementation that can make assumptions about how anchor_t
*
/// values are assigned by the Parser class.
* <p>Efficient implementation that can make assumptions about how
* {@code anchor_t} values are assigned by the {@link Parser} class.
*/
template
<
class
T
>
template
<
class
T
>
class
AnchorDict
{
class
AnchorDict
{
public
:
public
:
...
...
src/scanner.cpp
View file @
148da471
This diff is collapsed.
Click to expand it.
src/scanner.h
View file @
148da471
...
@@ -24,15 +24,24 @@ namespace YAML {
...
@@ -24,15 +24,24 @@ namespace YAML {
class
Node
;
class
Node
;
class
RegEx
;
class
RegEx
;
/**
* A scanner transforms a stream of characters into a stream of tokens.
*/
class
Scanner
{
class
Scanner
{
public
:
public
:
Scanner
(
std
::
istream
&
in
);
explicit
Scanner
(
std
::
istream
&
in
);
~
Scanner
();
~
Scanner
();
/
/ token queue management (hopefully this looks kinda stl-ish)
/
** Returns true if there are no more tokens to be read. */
bool
empty
();
bool
empty
();
/** Removes the next token in the queue. */
void
pop
();
void
pop
();
/** Returns, but does not remove, the next token in the queue. */
Token
&
peek
();
Token
&
peek
();
/** Returns the current mark in the input stream. */
Mark
mark
()
const
;
Mark
mark
()
const
;
private
:
private
:
...
@@ -52,11 +61,29 @@ class Scanner {
...
@@ -52,11 +61,29 @@ class Scanner {
private
:
private
:
// scanning
// scanning
/**
* Scans until there's a valid token at the front of the queue, or the queue
* is empty. The state can be checked by {@link #empty}, and the next token
* retrieved by {@link #peek}.
*/
void
EnsureTokensInQueue
();
void
EnsureTokensInQueue
();
/**
* The main scanning function; this method branches out to scan whatever the
* next token should be.
*/
void
ScanNextToken
();
void
ScanNextToken
();
/** Eats the input stream until it reaches the next token-like thing. */
void
ScanToNextToken
();
void
ScanToNextToken
();
/** Sets the initial conditions for starting a stream. */
void
StartStream
();
void
StartStream
();
/** Closes out the stream, finish up, etc. */
void
EndStream
();
void
EndStream
();
Token
*
PushToken
(
Token
::
TYPE
type
);
Token
*
PushToken
(
Token
::
TYPE
type
);
bool
InFlowContext
()
const
{
return
!
m_flows
.
empty
();
}
bool
InFlowContext
()
const
{
return
!
m_flows
.
empty
();
}
...
@@ -64,9 +91,29 @@ class Scanner {
...
@@ -64,9 +91,29 @@ class Scanner {
std
::
size_t
GetFlowLevel
()
const
{
return
m_flows
.
size
();
}
std
::
size_t
GetFlowLevel
()
const
{
return
m_flows
.
size
();
}
Token
::
TYPE
GetStartTokenFor
(
IndentMarker
::
INDENT_TYPE
type
)
const
;
Token
::
TYPE
GetStartTokenFor
(
IndentMarker
::
INDENT_TYPE
type
)
const
;
/**
* Pushes an indentation onto the stack, and enqueues the proper token
* (sequence start or mapping start).
*
* @return the indent marker it generates (if any).
*/
IndentMarker
*
PushIndentTo
(
int
column
,
IndentMarker
::
INDENT_TYPE
type
);
IndentMarker
*
PushIndentTo
(
int
column
,
IndentMarker
::
INDENT_TYPE
type
);
/**
* Pops indentations off the stack until it reaches the current indentation
* level, and enqueues the proper token each time. Then pops all invalid
* indentations off.
*/
void
PopIndentToHere
();
void
PopIndentToHere
();
/**
* Pops all indentations (except for the base empty one) off the stack, and
* enqueues the proper token each time.
*/
void
PopAllIndents
();
void
PopAllIndents
();
/** Pops a single indent, pushing the proper token. */
void
PopIndent
();
void
PopIndent
();
int
GetTopIndent
()
const
;
int
GetTopIndent
()
const
;
...
@@ -78,9 +125,17 @@ class Scanner {
...
@@ -78,9 +125,17 @@ class Scanner {
bool
VerifySimpleKey
();
bool
VerifySimpleKey
();
void
PopAllSimpleKeys
();
void
PopAllSimpleKeys
();
/**
* Throws a ParserException with the current token location (if available),
* and does not parse any more tokens.
*/
void
ThrowParserException
(
const
std
::
string
&
msg
)
const
;
void
ThrowParserException
(
const
std
::
string
&
msg
)
const
;
bool
IsWhitespaceToBeEaten
(
char
ch
);
bool
IsWhitespaceToBeEaten
(
char
ch
);
/**
* Returns the appropriate regex to check if the next token is a value token.
*/
const
RegEx
&
GetValueRegex
()
const
;
const
RegEx
&
GetValueRegex
()
const
;
struct
SimpleKey
{
struct
SimpleKey
{
...
...
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