From c1966ba3fcc478058244e06628aced957eb78a7c Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Mon, 30 Jun 2008 22:34:10 +0000 Subject: [PATCH] Renamed the stream member functions get() and eat(). --- exp.cpp | 6 +-- scanner.cpp | 6 +-- scanner.h | 1 - scanscalar.cpp | 12 ++--- scantoken.cpp | 46 +++++++++---------- stream.cpp | 16 +++---- stream.h | 8 ++-- test.yaml | 121 +++++++++++++++++++++++++++++++++++++++---------- 8 files changed, 143 insertions(+), 73 deletions(-) diff --git a/exp.cpp b/exp.cpp index f2b89d5b84..493654c551 100644 --- a/exp.cpp +++ b/exp.cpp @@ -39,7 +39,7 @@ namespace YAML // grab string std::string str; for(int i=0;i #include #include -#include "regex.h" #include "stream.h" namespace YAML diff --git a/scanscalar.cpp b/scanscalar.cpp index 9026d919b1..17f9d7c721 100644 --- a/scanscalar.cpp +++ b/scanscalar.cpp @@ -43,7 +43,7 @@ namespace YAML // escaped newline? (only if we're escaping on slash) if(params.escape == '\\' && Exp::EscBreak.Matches(INPUT)) { int n = Exp::EscBreak.Match(INPUT); - INPUT.Eat(n); + INPUT.eat(n); continue; } @@ -54,7 +54,7 @@ namespace YAML } // otherwise, just add the damn character - scalar += INPUT.GetChar(); + scalar += INPUT.get(); } // eof? if we're looking to eat something, then we throw @@ -72,21 +72,21 @@ namespace YAML int n = params.end.Match(INPUT); if(n >= 0) { if(params.eatEnd) - INPUT.Eat(n); + INPUT.eat(n); break; } // ******************************** // Phase #2: eat line ending n = Exp::Break.Match(INPUT); - INPUT.Eat(n); + INPUT.eat(n); // ******************************** // Phase #3: scan initial spaces // first the required indentation while(INPUT.peek() == ' ' && (INPUT.column < params.indent || (params.detectIndent && !foundNonEmptyLine))) - INPUT.Eat(1); + INPUT.eat(1); // update indent if we're auto-detecting if(params.detectIndent && !foundNonEmptyLine) @@ -101,7 +101,7 @@ namespace YAML if(!params.eatLeadingWhitespace) break; - INPUT.Eat(1); + INPUT.eat(1); } // was this an empty line? diff --git a/scantoken.cpp b/scantoken.cpp index 6e22a8816a..fca7ae6106 100644 --- a/scantoken.cpp +++ b/scantoken.cpp @@ -23,17 +23,17 @@ namespace YAML m_simpleKeyAllowed = false; // eat indicator - INPUT.Eat(1); + INPUT.eat(1); // read name while(INPUT.peek() != EOF && !Exp::BlankOrBreak.Matches(INPUT)) - name += INPUT.GetChar(); + name += INPUT.get(); // read parameters while(1) { // first get rid of whitespace while(Exp::Blank.Matches(INPUT)) - INPUT.Eat(1); + INPUT.eat(1); // break on newline or comment if(INPUT.peek() == EOF || Exp::Break.Matches(INPUT) || Exp::Comment.Matches(INPUT)) @@ -42,7 +42,7 @@ namespace YAML // now read parameter std::string param; while(INPUT.peek() != EOF && !Exp::BlankOrBreak.Matches(INPUT)) - param += INPUT.GetChar(); + param += INPUT.get(); params.push_back(param); } @@ -61,7 +61,7 @@ namespace YAML m_simpleKeyAllowed = false; // eat - INPUT.Eat(3); + INPUT.eat(3); m_tokens.push(new Token(TT_DOC_START)); } @@ -73,7 +73,7 @@ namespace YAML m_simpleKeyAllowed = false; // eat - INPUT.Eat(3); + INPUT.eat(3); m_tokens.push(new Token(TT_DOC_END)); } @@ -86,7 +86,7 @@ namespace YAML m_simpleKeyAllowed = true; // eat - char ch = INPUT.GetChar(); + char ch = INPUT.get(); TOKEN_TYPE type = (ch == Keys::FlowSeqStart ? TT_FLOW_SEQ_START : TT_FLOW_MAP_START); m_tokens.push(new Token(type)); } @@ -101,7 +101,7 @@ namespace YAML m_simpleKeyAllowed = false; // eat - char ch = INPUT.GetChar(); + char ch = INPUT.get(); TOKEN_TYPE type = (ch == Keys::FlowSeqEnd ? TT_FLOW_SEQ_END : TT_FLOW_MAP_END); m_tokens.push(new Token(type)); } @@ -112,7 +112,7 @@ namespace YAML m_simpleKeyAllowed = true; // eat - INPUT.Eat(1); + INPUT.eat(1); m_tokens.push(new Token(TT_FLOW_ENTRY)); } @@ -131,7 +131,7 @@ namespace YAML m_simpleKeyAllowed = true; // eat - INPUT.Eat(1); + INPUT.eat(1); m_tokens.push(new Token(TT_BLOCK_ENTRY)); } @@ -153,7 +153,7 @@ namespace YAML m_simpleKeyAllowed = false; // eat - INPUT.Eat(1); + INPUT.eat(1); m_tokens.push(new Token(TT_KEY)); } @@ -181,7 +181,7 @@ namespace YAML } // eat - INPUT.Eat(1); + INPUT.eat(1); m_tokens.push(new Token(TT_VALUE)); } @@ -197,12 +197,12 @@ namespace YAML m_simpleKeyAllowed = false; // eat the indicator - char indicator = INPUT.GetChar(); + char indicator = INPUT.get(); alias = (indicator == Keys::Alias); // now eat the content while(Exp::AlphaNumeric.Matches(INPUT)) - tag += INPUT.GetChar(); + tag += INPUT.get(); // we need to have read SOMETHING! if(tag.empty()) @@ -229,20 +229,20 @@ namespace YAML m_simpleKeyAllowed = false; // eat the indicator - INPUT.Eat(1); + INPUT.eat(1); // read the handle while(INPUT.peek() != EOF && INPUT.peek() != Keys::Tag && !Exp::BlankOrBreak.Matches(INPUT)) - handle += INPUT.GetChar(); + handle += INPUT.get(); // is there a suffix? if(INPUT.peek() == Keys::Tag) { // eat the indicator - INPUT.Eat(1); + INPUT.eat(1); // then read it while(INPUT.peek() != EOF && !Exp::BlankOrBreak.Matches(INPUT)) - suffix += INPUT.GetChar(); + suffix += INPUT.get(); } Token *pToken = new Token(TT_TAG); @@ -293,7 +293,7 @@ namespace YAML std::string scalar; // eat single or double quote - char quote = INPUT.GetChar(); + char quote = INPUT.get(); bool single = (quote == '\''); // setup the scanning parameters @@ -333,13 +333,13 @@ namespace YAML params.detectIndent = true; // eat block indicator ('|' or '>') - char indicator = INPUT.GetChar(); + char indicator = INPUT.get(); params.fold = (indicator == Keys::FoldedScalar); // eat chomping/indentation indicators int n = Exp::Chomp.Match(INPUT); for(int i=0;i