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
45dfc719
"examples/community/stable_diffusion_ipex.py" did not exist on "57f7d2593427bd2cbf7d15d32844cfc5f7717d3f"
Commit
45dfc719
authored
Jun 29, 2008
by
beder
Browse files
No commit message
No commit message
parent
ab27b978
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
104 deletions
+74
-104
exceptions.h
exceptions.h
+2
-0
exp.h
exp.h
+3
-0
scanner.cpp
scanner.cpp
+20
-7
scantoken.cpp
scantoken.cpp
+30
-0
test.yaml
test.yaml
+13
-97
token.h
token.h
+6
-0
No files found.
exceptions.h
View file @
45dfc719
...
@@ -18,6 +18,8 @@ namespace YAML
...
@@ -18,6 +18,8 @@ namespace YAML
class
RequiredSimpleKeyNotFound
:
public
Exception
{};
class
RequiredSimpleKeyNotFound
:
public
Exception
{};
class
ZeroIndentationInBlockScalar
:
public
Exception
{};
class
ZeroIndentationInBlockScalar
:
public
Exception
{};
class
UnexpectedCharacterInBlockScalar
:
public
Exception
{};
class
UnexpectedCharacterInBlockScalar
:
public
Exception
{};
class
AnchorNotFound
:
public
Exception
{};
class
IllegalCharacterInAnchor
:
public
Exception
{};
class
UnknownEscapeSequence
:
public
Exception
{
class
UnknownEscapeSequence
:
public
Exception
{
public:
public:
...
...
exp.h
View file @
45dfc719
...
@@ -16,6 +16,8 @@ namespace YAML
...
@@ -16,6 +16,8 @@ namespace YAML
const
RegEx
Break
=
RegEx
(
'\n'
);
const
RegEx
Break
=
RegEx
(
'\n'
);
const
RegEx
BlankOrBreak
=
Blank
||
Break
;
const
RegEx
BlankOrBreak
=
Blank
||
Break
;
const
RegEx
Digit
=
RegEx
(
'0'
,
'9'
);
const
RegEx
Digit
=
RegEx
(
'0'
,
'9'
);
const
RegEx
Alpha
=
RegEx
(
'a'
,
'z'
)
||
RegEx
(
'A'
,
'Z'
);
const
RegEx
AlphaNumeric
=
Alpha
||
Digit
;
const
RegEx
Hex
=
Digit
||
RegEx
(
'A'
,
'F'
)
||
RegEx
(
'a'
,
'f'
);
const
RegEx
Hex
=
Digit
||
RegEx
(
'A'
,
'F'
)
||
RegEx
(
'a'
,
'f'
);
// actual tags
// actual tags
...
@@ -28,6 +30,7 @@ namespace YAML
...
@@ -28,6 +30,7 @@ namespace YAML
const
RegEx
Value
=
RegEx
(
':'
),
const
RegEx
Value
=
RegEx
(
':'
),
ValueInFlow
=
RegEx
(
':'
)
+
BlankOrBreak
;
ValueInFlow
=
RegEx
(
':'
)
+
BlankOrBreak
;
const
RegEx
Comment
=
RegEx
(
'#'
);
const
RegEx
Comment
=
RegEx
(
'#'
);
const
RegEx
AnchorEnd
=
RegEx
(
"?:,]}%@`"
,
REGEX_OR
)
||
BlankOrBreak
;
// Plain scalar rules:
// Plain scalar rules:
// . Cannot start with a blank.
// . Cannot start with a blank.
...
...
scanner.cpp
View file @
45dfc719
...
@@ -148,9 +148,9 @@ namespace YAML
...
@@ -148,9 +148,9 @@ namespace YAML
m_limboTokens
.
erase
(
pToken
);
m_limboTokens
.
erase
(
pToken
);
}
}
//
/////////////////////////////////////////////////////////////////////
//
ScanNextToken
// The main scanning function
//
.
The main scanning function
; here we branch out and
// scan whatever the next token should be.
void
Scanner
::
ScanNextToken
()
void
Scanner
::
ScanNextToken
()
{
{
if
(
m_endedStream
)
if
(
m_endedStream
)
...
@@ -159,21 +159,31 @@ namespace YAML
...
@@ -159,21 +159,31 @@ namespace YAML
if
(
!
m_startedStream
)
if
(
!
m_startedStream
)
return
ScanAndEnqueue
(
new
StreamStartToken
);
return
ScanAndEnqueue
(
new
StreamStartToken
);
// get rid of whitespace, etc. (in between tokens it should be irrelevent)
ScanToNextToken
();
ScanToNextToken
();
// check the latest simple key
ValidateSimpleKey
();
ValidateSimpleKey
();
// maybe need to end some blocks
PopIndentTo
(
m_column
);
PopIndentTo
(
m_column
);
// *****
// And now branch based on the next few characters!
// *****
// end of stream
if
(
INPUT
.
peek
()
==
EOF
)
if
(
INPUT
.
peek
()
==
EOF
)
return
ScanAndEnqueue
(
new
StreamEndToken
);
return
ScanAndEnqueue
(
new
StreamEndToken
);
//
are we at a
document token
?
// document token
if
(
IsDocumentStart
())
if
(
IsDocumentStart
())
return
ScanAndEnqueue
(
new
DocumentStartToken
);
return
ScanAndEnqueue
(
new
DocumentStartToken
);
if
(
IsDocumentEnd
())
if
(
IsDocumentEnd
())
return
ScanAndEnqueue
(
new
DocumentEndToken
);
return
ScanAndEnqueue
(
new
DocumentEndToken
);
//
are we at a
flow start/end/entry
?
// flow start/end/entry
if
(
INPUT
.
peek
()
==
Keys
::
FlowSeqStart
)
if
(
INPUT
.
peek
()
==
Keys
::
FlowSeqStart
)
return
ScanAndEnqueue
(
new
FlowSeqStartToken
);
return
ScanAndEnqueue
(
new
FlowSeqStartToken
);
...
@@ -189,7 +199,7 @@ namespace YAML
...
@@ -189,7 +199,7 @@ namespace YAML
if
(
INPUT
.
peek
()
==
Keys
::
FlowEntry
)
if
(
INPUT
.
peek
()
==
Keys
::
FlowEntry
)
return
ScanAndEnqueue
(
new
FlowEntryToken
);
return
ScanAndEnqueue
(
new
FlowEntryToken
);
// block/map stuff
?
// block/map stuff
if
(
IsBlockEntry
())
if
(
IsBlockEntry
())
return
ScanAndEnqueue
(
new
BlockEntryToken
);
return
ScanAndEnqueue
(
new
BlockEntryToken
);
...
@@ -199,7 +209,10 @@ namespace YAML
...
@@ -199,7 +209,10 @@ namespace YAML
if
(
IsValue
())
if
(
IsValue
())
return
ScanAndEnqueue
(
new
ValueToken
);
return
ScanAndEnqueue
(
new
ValueToken
);
// TODO: alias/anchor/tag
if
(
INPUT
.
peek
()
==
Keys
::
Alias
||
INPUT
.
peek
()
==
Keys
::
Anchor
)
return
ScanAndEnqueue
(
new
AnchorToken
);
// TODO: tag
// special scalars
// special scalars
if
(
m_flowLevel
==
0
&&
(
INPUT
.
peek
()
==
Keys
::
LiteralScalar
||
INPUT
.
peek
()
==
Keys
::
FoldedScalar
))
if
(
m_flowLevel
==
0
&&
(
INPUT
.
peek
()
==
Keys
::
LiteralScalar
||
INPUT
.
peek
()
==
Keys
::
FoldedScalar
))
...
...
scantoken.cpp
View file @
45dfc719
...
@@ -191,6 +191,36 @@ namespace YAML
...
@@ -191,6 +191,36 @@ namespace YAML
return
pToken
;
return
pToken
;
}
}
// AnchorToken
template
<
>
AnchorToken
*
Scanner
::
ScanToken
(
AnchorToken
*
pToken
)
{
// insert a potential simple key
if
(
m_simpleKeyAllowed
)
InsertSimpleKey
();
m_simpleKeyAllowed
=
false
;
// eat the indicator
char
indicator
=
GetChar
();
pToken
->
alias
=
(
indicator
==
Keys
::
Alias
);
// now eat the content
std
::
string
tag
;
while
(
Exp
::
AlphaNumeric
.
Matches
(
INPUT
))
tag
+=
GetChar
();
// we need to have read SOMETHING!
if
(
tag
.
empty
())
throw
AnchorNotFound
();
// and needs to end correctly
if
(
INPUT
.
peek
()
!=
EOF
&&
!
Exp
::
AnchorEnd
.
Matches
(
INPUT
))
throw
IllegalCharacterInAnchor
();
// and we're done
pToken
->
value
=
tag
;
return
pToken
;
}
// PlainScalarToken
// PlainScalarToken
// . We scan these in passes of two steps each: First, grab all non-whitespace
// . We scan these in passes of two steps each: First, grab all non-whitespace
// characters we can, and then grab all whitespace characters we can.
// characters we can, and then grab all whitespace characters we can.
...
...
test.yaml
View file @
45dfc719
---
people
:
model
:
-
&jsb
file
:
data/models/compound.model
name
:
Jesse
textures
:
data/materials/compound
age
:
23
rooms
:
-
&dab
-
name
:
"
Room
#1"
name
:
Daniel
pos
:
[
0
,
0
,
0
]
age
:
25
size
:
[
1000
,
1000
,
500
]
-
&ncb
height
:
500
name
:
Naftali
stairtype
:
none
age
:
21
display
:
[]
students
:
pathfinding
:
-
*jsb
tilesize
:
50
-
*ncb
size
:
[
24
,
24
]
\ No newline at end of file
map
:
|
-----------------------
-+++++++++++++++++++++-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+---------------------
-+---------------------
-+---------------------
-+---------------------
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+++++++++++++++++++++-
-----------------------
-
name
:
Doorway
pos
:
[
1000
,
400
,
0
]
size
:
[
50
,
200
,
500
]
height
:
500
stairtype
:
none
display
:
[]
pathfinding
:
tilesize
:
50
size
:
[
5
,
9
]
map
:
|
-----
-+++-
-----
-----
-----
-----
-----
-+++-
-----
-
name
:
"
Room
#2"
pos
:
[
1050
,
0
,
0
]
size
:
[
1000
,
1000
,
500
]
height
:
500
stairtype
:
none
display
:
[]
pathfinding
:
tilesize
:
50
size
:
[
24
,
24
]
map
:
|
-----------------------
-+++++++++++++++++++++-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
---------------------+-
---------------------+-
---------------------+-
---------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+-------------------+-
-+++++++++++++++++++++-
-----------------------
exits
:
-
room1
:
"
Room
#1"
room2
:
"
Room
#2"
dir
:
e
pos
:
[
400
,
600
]
token.h
View file @
45dfc719
...
@@ -31,6 +31,12 @@ namespace YAML
...
@@ -31,6 +31,12 @@ namespace YAML
struct
KeyToken
:
public
Token
{};
struct
KeyToken
:
public
Token
{};
struct
ValueToken
:
public
Token
{};
struct
ValueToken
:
public
Token
{};
struct
AnchorToken
:
public
Token
{
bool
alias
;
std
::
string
value
;
virtual
void
Write
(
std
::
ostream
&
out
)
const
{
out
<<
(
alias
?
'*'
:
'&'
)
<<
value
;
}
};
struct
ScalarToken
:
public
Token
{
struct
ScalarToken
:
public
Token
{
std
::
string
value
;
std
::
string
value
;
...
...
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