mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
Renamed the stream member functions get() and eat().
This commit is contained in:
parent
852e5b63e5
commit
c1966ba3fc
8 changed files with 143 additions and 73 deletions
6
exp.cpp
6
exp.cpp
|
@ -39,7 +39,7 @@ namespace YAML
|
|||
// grab string
|
||||
std::string str;
|
||||
for(int i=0;i<codeLength;i++)
|
||||
str += in.GetChar();
|
||||
str += in.get();
|
||||
|
||||
// get the value
|
||||
unsigned value = ParseHex(str);
|
||||
|
@ -67,10 +67,10 @@ namespace YAML
|
|||
std::string Escape(Stream& in)
|
||||
{
|
||||
// eat slash
|
||||
char escape = in.GetChar();
|
||||
char escape = in.get();
|
||||
|
||||
// switch on escape character
|
||||
char ch = in.GetChar();
|
||||
char ch = in.get();
|
||||
|
||||
// first do single quote, since it's easier
|
||||
if(escape == '\'' && ch == '\'')
|
||||
|
|
|
@ -153,13 +153,13 @@ namespace YAML
|
|||
while(1) {
|
||||
// first eat whitespace
|
||||
while(IsWhitespaceToBeEaten(INPUT.peek()))
|
||||
INPUT.Eat(1);
|
||||
INPUT.eat(1);
|
||||
|
||||
// then eat a comment
|
||||
if(Exp::Comment.Matches(INPUT)) {
|
||||
// eat until line break
|
||||
while(INPUT && !Exp::Break.Matches(INPUT))
|
||||
INPUT.Eat(1);
|
||||
INPUT.eat(1);
|
||||
}
|
||||
|
||||
// if it's NOT a line break, then we're done!
|
||||
|
@ -168,7 +168,7 @@ namespace YAML
|
|||
|
||||
// otherwise, let's eat the line break and keep going
|
||||
int n = Exp::Break.Match(INPUT);
|
||||
INPUT.Eat(n);
|
||||
INPUT.eat(n);
|
||||
|
||||
// oh yeah, and let's get rid of that simple key
|
||||
VerifySimpleKey();
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <queue>
|
||||
#include <stack>
|
||||
#include <set>
|
||||
#include "regex.h"
|
||||
#include "stream.h"
|
||||
|
||||
namespace YAML
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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<n;i++) {
|
||||
char ch = INPUT.GetChar();
|
||||
char ch = INPUT.get();
|
||||
if(ch == '+')
|
||||
params.chomp = KEEP;
|
||||
else if(ch == '-')
|
||||
|
@ -355,12 +355,12 @@ namespace YAML
|
|||
|
||||
// now eat whitespace
|
||||
while(Exp::Blank.Matches(INPUT))
|
||||
INPUT.Eat(1);
|
||||
INPUT.eat(1);
|
||||
|
||||
// and comments to the end of the line
|
||||
if(Exp::Comment.Matches(INPUT))
|
||||
while(INPUT && !Exp::Break.Matches(INPUT))
|
||||
INPUT.Eat(1);
|
||||
INPUT.eat(1);
|
||||
|
||||
// if it's not a line break, then we ran into a bad character inline
|
||||
if(INPUT && !Exp::Break.Matches(INPUT))
|
||||
|
|
16
stream.cpp
16
stream.cpp
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace YAML
|
||||
{
|
||||
// GetChar
|
||||
// get
|
||||
// . Extracts a character from the stream and updates our position
|
||||
char Stream::GetChar()
|
||||
char Stream::get()
|
||||
{
|
||||
char ch = input.get();
|
||||
column++;
|
||||
|
@ -15,21 +15,21 @@ namespace YAML
|
|||
return ch;
|
||||
}
|
||||
|
||||
// GetChar
|
||||
// get
|
||||
// . Extracts 'n' characters from the stream and updates our position
|
||||
std::string Stream::GetChar(int n)
|
||||
std::string Stream::get(int n)
|
||||
{
|
||||
std::string ret;
|
||||
for(int i=0;i<n;i++)
|
||||
ret += GetChar();
|
||||
ret += get();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Eat
|
||||
// eat
|
||||
// . Eats 'n' characters and updates our position.
|
||||
void Stream::Eat(int n)
|
||||
void Stream::eat(int n)
|
||||
{
|
||||
for(int i=0;i<n;i++)
|
||||
GetChar();
|
||||
get();
|
||||
}
|
||||
}
|
||||
|
|
8
stream.h
8
stream.h
|
@ -9,15 +9,15 @@ namespace YAML
|
|||
{
|
||||
Stream(std::istream& input_): input(input_), line(0), column(0) {}
|
||||
|
||||
char peek() { return input.peek(); }
|
||||
int pos() const { return input.tellg(); }
|
||||
operator std::istream& () { return input; }
|
||||
operator bool() { return input.good(); }
|
||||
bool operator !() { return !input; }
|
||||
|
||||
char GetChar();
|
||||
std::string GetChar(int n);
|
||||
void Eat(int n = 1);
|
||||
char peek() { return input.peek(); }
|
||||
char get();
|
||||
std::string get(int n);
|
||||
void eat(int n = 1);
|
||||
|
||||
std::istream& input;
|
||||
int line, column;
|
||||
|
|
121
test.yaml
121
test.yaml
|
@ -1,26 +1,97 @@
|
|||
---
|
||||
Time: 2001-11-23 15:01:42 -5
|
||||
User: ed
|
||||
Warning:
|
||||
This is an error message
|
||||
for the log file
|
||||
---
|
||||
Time: 2001-11-23 15:02:31 -5
|
||||
User: ed
|
||||
Warning:
|
||||
A slightly different error
|
||||
message.
|
||||
---
|
||||
Date: 2001-11-23 15:03:17 -5
|
||||
User: ed
|
||||
Fatal:
|
||||
Unknown variable "bar"
|
||||
Stack:
|
||||
- file: TopClass.py
|
||||
line: 23
|
||||
code: |
|
||||
x = MoreObject("345\n")
|
||||
- file: MoreClass.py
|
||||
line: 58
|
||||
code: |-
|
||||
foo = bar
|
||||
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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue