From 01ef70a6f9d3bbd9edebc373d8c482a9bf0f71ef Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Sat, 28 Jun 2008 17:32:10 +0000 Subject: [PATCH] Fixed complex keys. --- scanner.cpp | 6 +-- scantoken.cpp | 6 ++- test.yaml | 102 ++------------------------------------------------ 3 files changed, 11 insertions(+), 103 deletions(-) diff --git a/scanner.cpp b/scanner.cpp index f6c844b836..d785706573 100644 --- a/scanner.cpp +++ b/scanner.cpp @@ -229,14 +229,14 @@ namespace YAML Eat(1); // then eat a comment - if(Exp::Comment.Matches(INPUT.peek())) { + if(Exp::Comment.Matches(INPUT)) { // eat until line break - while(INPUT && !Exp::Break.Matches(INPUT.peek())) + while(INPUT && !Exp::Break.Matches(INPUT)) Eat(1); } // if it's NOT a line break, then we're done! - if(!Exp::Break.Matches(INPUT.peek())) + if(!Exp::Break.Matches(INPUT)) break; // otherwise, let's eat the line break and keep going diff --git a/scantoken.cpp b/scantoken.cpp index 6b071c0ea6..0cc741ee97 100644 --- a/scantoken.cpp +++ b/scantoken.cpp @@ -204,7 +204,8 @@ namespace YAML template <> PlainScalarToken *Scanner::ScanToken(PlainScalarToken *pToken) { // insert a potential simple key - InsertSimpleKey(); + if(m_simpleKeyAllowed) + InsertSimpleKey(); m_simpleKeyAllowed = false; // now eat and store the scalar @@ -279,7 +280,8 @@ namespace YAML template <> QuotedScalarToken *Scanner::ScanToken(QuotedScalarToken *pToken) { // insert a potential simple key - InsertSimpleKey(); + if(m_simpleKeyAllowed) + InsertSimpleKey(); m_simpleKeyAllowed = false; // eat single or double quote diff --git a/test.yaml b/test.yaml index f58841bb22..3cb65c2a51 100644 --- a/test.yaml +++ b/test.yaml @@ -1,98 +1,4 @@ ---- -model: - file: data/models/compound.model - 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] -... +{ + a simple key: a value, + ? a complex key: another value, +} \ No newline at end of file