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
0683cbf8
Commit
0683cbf8
authored
Jun 30, 2008
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mostly finished refactoring the scalar scanning.
parent
5f8252ee
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
32 deletions
+31
-32
exceptions.h
+3
-3
exp.h
+1
-0
scanner.h
+4
-3
scanscalar.cpp
+0
-0
scanscalar.h
+11
-17
test.yaml
+12
-9
No files found.
exceptions.h
View file @
0683cbf8
...
@@ -11,10 +11,10 @@ namespace YAML
...
@@ -11,10 +11,10 @@ namespace YAML
class
IllegalMapKey
:
public
Exception
{};
class
IllegalMapKey
:
public
Exception
{};
class
IllegalMapValue
:
public
Exception
{};
class
IllegalMapValue
:
public
Exception
{};
class
IllegalScalar
:
public
Exception
{};
class
IllegalScalar
:
public
Exception
{};
class
IllegalTabIn
Scalar
:
public
Exception
{};
class
IllegalTabIn
Indentation
:
public
Exception
{};
class
IllegalFlowEnd
:
public
Exception
{};
class
IllegalFlowEnd
:
public
Exception
{};
class
DocIndicatorInQuote
:
public
Exception
{};
class
IllegalDocIndicator
:
public
Exception
{};
class
EOFInQuote
:
public
Exception
{};
class
IllegalEOF
:
public
Exception
{};
class
RequiredSimpleKeyNotFound
:
public
Exception
{};
class
RequiredSimpleKeyNotFound
:
public
Exception
{};
class
ZeroIndentationInBlockScalar
:
public
Exception
{};
class
ZeroIndentationInBlockScalar
:
public
Exception
{};
class
UnexpectedCharacterInBlockScalar
:
public
Exception
{};
class
UnexpectedCharacterInBlockScalar
:
public
Exception
{};
...
...
exp.h
View file @
0683cbf8
...
@@ -25,6 +25,7 @@ namespace YAML
...
@@ -25,6 +25,7 @@ namespace YAML
const
RegEx
DocStart
=
RegEx
(
"---"
)
+
(
BlankOrBreak
||
RegEx
(
EOF
)
||
RegEx
());
const
RegEx
DocStart
=
RegEx
(
"---"
)
+
(
BlankOrBreak
||
RegEx
(
EOF
)
||
RegEx
());
const
RegEx
DocEnd
=
RegEx
(
"..."
)
+
(
BlankOrBreak
||
RegEx
(
EOF
)
||
RegEx
());
const
RegEx
DocEnd
=
RegEx
(
"..."
)
+
(
BlankOrBreak
||
RegEx
(
EOF
)
||
RegEx
());
const
RegEx
DocIndicator
=
DocStart
||
DocEnd
;
const
RegEx
BlockEntry
=
RegEx
(
'-'
)
+
(
BlankOrBreak
||
RegEx
(
EOF
));
const
RegEx
BlockEntry
=
RegEx
(
'-'
)
+
(
BlankOrBreak
||
RegEx
(
EOF
));
const
RegEx
Key
=
RegEx
(
'?'
),
const
RegEx
Key
=
RegEx
(
'?'
),
KeyInFlow
=
RegEx
(
'?'
)
+
BlankOrBreak
;
KeyInFlow
=
RegEx
(
'?'
)
+
BlankOrBreak
;
...
...
scanner.h
View file @
0683cbf8
...
@@ -19,19 +19,20 @@ namespace YAML
...
@@ -19,19 +19,20 @@ namespace YAML
~
Scanner
();
~
Scanner
();
Token
*
GetNextToken
();
Token
*
GetNextToken
();
void
Scan
();
private
:
// scanning
void
ScanNextToken
();
void
ScanNextToken
();
void
ScanToNextToken
();
void
ScanToNextToken
();
Token
*
PushIndentTo
(
int
column
,
bool
sequence
);
Token
*
PushIndentTo
(
int
column
,
bool
sequence
);
void
PopIndentTo
(
int
column
);
void
PopIndentTo
(
int
column
);
// checking input
void
InsertSimpleKey
();
void
InsertSimpleKey
();
bool
VerifySimpleKey
();
bool
VerifySimpleKey
();
void
VerifyAllSimpleKeys
();
void
VerifyAllSimpleKeys
();
void
Scan
();
private
:
bool
IsWhitespaceToBeEaten
(
char
ch
);
bool
IsWhitespaceToBeEaten
(
char
ch
);
bool
IsDocumentStart
();
bool
IsDocumentStart
();
bool
IsDocumentEnd
();
bool
IsDocumentEnd
();
...
...
scanscalar.cpp
View file @
0683cbf8
This diff is collapsed.
Click to expand it.
scanscalar.h
View file @
0683cbf8
...
@@ -7,35 +7,29 @@
...
@@ -7,35 +7,29 @@
namespace
YAML
namespace
YAML
{
{
enum
CHOMP
{
STRIP
=
-
1
,
CLIP
,
KEEP
};
enum
CHOMP
{
STRIP
=
-
1
,
CLIP
,
KEEP
};
enum
ACTION
{
NONE
,
BREAK
,
THROW
};
struct
ScanScalarInfo
{
struct
ScanScalarInfo
{
ScanScalarInfo
()
:
eatEnd
(
false
),
indent
(
0
),
eatLeadingWhitespace
(
0
),
escape
(
0
),
fold
(
false
),
trimTrailingSpaces
(
0
),
chomp
(
CLIP
)
{}
ScanScalarInfo
()
:
eatEnd
(
false
),
indent
(
0
),
detectIndent
(
false
),
eatLeadingWhitespace
(
0
),
escape
(
0
),
fold
(
false
),
trimTrailingSpaces
(
0
),
chomp
(
CLIP
),
onDocIndicator
(
NONE
),
onTabInIndentation
(
NONE
),
leadingSpaces
(
false
)
{}
// input:
RegEx
end
;
// what condition ends this scalar?
RegEx
end
;
// what condition ends this scalar?
bool
eatEnd
;
// should we eat that condition when we see it?
bool
eatEnd
;
// should we eat that condition when we see it?
int
indent
;
// what level of indentation should be eaten and ignored?
int
indent
;
// what level of indentation should be eaten and ignored?
bool
detectIndent
;
// should we try to autodetect the indent?
bool
eatLeadingWhitespace
;
// should we continue eating this delicious indentation after 'indent' spaces?
bool
eatLeadingWhitespace
;
// should we continue eating this delicious indentation after 'indent' spaces?
char
escape
;
// what character do we escape on (i.e., slash or single quote) (0 for none)
char
escape
;
// what character do we escape on (i.e., slash or single quote) (0 for none)
bool
fold
;
// do we fold line ends?
bool
fold
;
// do we fold line ends?
bool
trimTrailingSpaces
;
// do we remove all trailing spaces (at the very end)
bool
trimTrailingSpaces
;
// do we remove all trailing spaces (at the very end)
CHOMP
chomp
;
// do we strip, clip, or keep trailing newlines (at the very end)
CHOMP
chomp
;
// do we strip, clip, or keep trailing newlines (at the very end)
// Note: strip means kill all, clip means keep at most one, keep means keep all
// Note: strip means kill all, clip means keep at most one, keep means keep all
};
ACTION
onDocIndicator
;
// what do we do if we see a document indicator?
ACTION
onTabInIndentation
;
// what do we do if we see a tab where we should be seeing indentation spaces
void
GetBlockIndentation
(
Stream
&
INPUT
,
int
&
indent
,
std
::
string
&
breaks
,
int
topIndent
);
std
::
string
ScanScalar
(
Stream
&
INPUT
,
ScanScalarInfo
info
);
struct
WhitespaceInfo
{
WhitespaceInfo
();
void
SetChompers
(
char
ch
);
// output:
void
AddBlank
(
char
ch
);
bool
leadingSpaces
;
void
AddBreak
(
const
std
::
string
&
line
);
std
::
string
Join
(
bool
lastline
=
false
);
bool
leadingBlanks
;
bool
fold
;
std
::
string
whitespace
,
leadingBreaks
,
trailingBreaks
;
int
chomp
,
increment
;
};
};
std
::
string
ScanScalar
(
Stream
&
INPUT
,
ScanScalarInfo
&
info
);
}
}
test.yaml
View file @
0683cbf8
---
---
-
"
quoted
scalar
\t
with
a
tab
\n
and
a
newline"
-
here's a key
:
value
-
'
This
is
Jesse'
'
s
single
quote!'
here's the first block
:
|
-
|
after the block: value
here's a literal:
and here's a block: |-
#include <iostream>
What's going on?
How are you doing?
Here's some code:
#include <iostream>
int main()
int main()
{
{
std::cout << "Hello World!\n";
std::cout << "Hello World!\n";
return 0;
}
}
-
key1
:
value1
key2
:
value2
I'm doing fine!
\ No newline at end of file
and last key: value
\ 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