Fixed complex keys.

This commit is contained in:
Jesse Beder 2008-06-28 17:32:10 +00:00
parent c63ebbd878
commit 01ef70a6f9
3 changed files with 11 additions and 103 deletions

View file

@ -229,14 +229,14 @@ namespace YAML
Eat(1); Eat(1);
// then eat a comment // then eat a comment
if(Exp::Comment.Matches(INPUT.peek())) { if(Exp::Comment.Matches(INPUT)) {
// eat until line break // eat until line break
while(INPUT && !Exp::Break.Matches(INPUT.peek())) while(INPUT && !Exp::Break.Matches(INPUT))
Eat(1); Eat(1);
} }
// if it's NOT a line break, then we're done! // if it's NOT a line break, then we're done!
if(!Exp::Break.Matches(INPUT.peek())) if(!Exp::Break.Matches(INPUT))
break; break;
// otherwise, let's eat the line break and keep going // otherwise, let's eat the line break and keep going

View file

@ -204,7 +204,8 @@ namespace YAML
template <> PlainScalarToken *Scanner::ScanToken(PlainScalarToken *pToken) template <> PlainScalarToken *Scanner::ScanToken(PlainScalarToken *pToken)
{ {
// insert a potential simple key // insert a potential simple key
InsertSimpleKey(); if(m_simpleKeyAllowed)
InsertSimpleKey();
m_simpleKeyAllowed = false; m_simpleKeyAllowed = false;
// now eat and store the scalar // now eat and store the scalar
@ -279,7 +280,8 @@ namespace YAML
template <> QuotedScalarToken *Scanner::ScanToken(QuotedScalarToken *pToken) template <> QuotedScalarToken *Scanner::ScanToken(QuotedScalarToken *pToken)
{ {
// insert a potential simple key // insert a potential simple key
InsertSimpleKey(); if(m_simpleKeyAllowed)
InsertSimpleKey();
m_simpleKeyAllowed = false; m_simpleKeyAllowed = false;
// eat single or double quote // eat single or double quote

102
test.yaml
View file

@ -1,98 +1,4 @@
--- {
model: a simple key: a value,
file: data/models/compound.model ? a complex key: another value,
textures: data/materials/compound }
rooms:
- name: "Room #1"
pos: [0, 0, 0]
size: [1000, 1000, 500]
height: 500
stairtype: none
display: []
pathfinding:
tilesize: 50
size: [24, 24]
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]
...