ENH: #codeStream: preserve across preprocessing

- new token: token::VERBATIMSTRING
- writing of this type in primitiveEntry
- disabling of all functionEntries in entry
This commit is contained in:
mattijs
2011-02-22 15:29:57 +00:00
parent 869d6fa460
commit 79939b9e18
12 changed files with 121 additions and 20 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -162,11 +162,16 @@ Foam::Istream& Foam::UIPstream::read(token& t)
// String
case token::STRING :
case token::VERBATIMSTRING :
{
string* pval = new string;
if (read(*pval))
{
t = pval;
if (c == token::VERBATIMSTRING)
{
t.type() = token::VERBATIMSTRING;
}
}
else
{

View File

@ -203,7 +203,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
return *this;
}
// Verbatim string
// Possible verbatim string or dictionary functionEntry
case token::HASH :
{
char nextC;
@ -226,6 +226,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
else
{
t = sPtr;
t.type() = token::VERBATIMSTRING;
}
return *this;

View File

@ -78,6 +78,7 @@ public:
PUNCTUATION,
WORD,
STRING,
VERBATIMSTRING,
LABEL,
FLOAT_SCALAR,
DOUBLE_SCALAR,
@ -318,6 +319,7 @@ public:
// Access
inline tokenType type() const;
inline tokenType& type();
inline bool good() const;
inline bool undefined() const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,7 +39,7 @@ inline void token::clear()
{
delete wordTokenPtr_;
}
else if (type_ == STRING)
else if (type_ == STRING || type_ == VERBATIMSTRING)
{
delete stringTokenPtr_;
}
@ -88,6 +88,7 @@ inline token::token(const token& t)
break;
case STRING:
case VERBATIMSTRING:
stringTokenPtr_ = new string(*t.stringTokenPtr_);
break;
@ -178,6 +179,11 @@ inline token::tokenType token::type() const
return type_;
}
inline token::tokenType& token::type()
{
return type_;
}
inline bool token::good() const
{
return (type_ != ERROR && type_ != UNDEFINED);
@ -231,12 +237,12 @@ inline const word& token::wordToken() const
inline bool token::isString() const
{
return (type_ == STRING);
return (type_ == STRING || type_ == VERBATIMSTRING);
}
inline const string& token::stringToken() const
{
if (type_ == STRING)
if (type_ == STRING || type_ == VERBATIMSTRING)
{
return *stringTokenPtr_;
}
@ -405,6 +411,7 @@ inline void token::operator=(const token& t)
break;
case STRING:
case VERBATIMSTRING:
stringTokenPtr_ = new string(*t.stringTokenPtr_);
break;
@ -511,6 +518,7 @@ inline bool token::operator==(const token& t) const
return *wordTokenPtr_ == *t.wordTokenPtr_;
case STRING:
case VERBATIMSTRING:
return *stringTokenPtr_ == *t.stringTokenPtr_;
case LABEL:
@ -544,7 +552,7 @@ inline bool token::operator==(const word& w) const
inline bool token::operator==(const string& s) const
{
return (type_ == STRING && stringToken() == s);
return ((type_ == STRING || type_ == VERBATIMSTRING) && stringToken() == s);
}
inline bool token::operator==(const label l) const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -70,6 +70,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& t)
break;
case token::STRING:
case token::VERBATIMSTRING:
os << *t.stringTokenPtr_;
break;
@ -156,6 +157,10 @@ ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
os << " the string " << t.stringToken();
break;
case token::VERBATIMSTRING:
os << " the verbatim string " << t.stringToken();
break;
case token::LABEL:
os << " the label " << t.labelToken();
break;
@ -226,6 +231,10 @@ Ostream& operator<<(Ostream& os, const InfoProxy<token>& ip)
os << " the string " << t.stringToken();
break;
case token::VERBATIMSTRING:
os << " the verbatim string " << t.stringToken();
break;
case token::LABEL:
os << " the label " << t.labelToken();
break;