| LLOOP Index | GSP Language | GSP Library | Framework Classes | Component Classes |
This is the verbatim text of the file "bool.gsp" part of the LLOOP package. The copyright remains with Michel MEHL. All rights reserved.
/**
* This defines the following boolean types:
* - 2-states boolean: reads 'yes' or 'no'
*
* - 3-states boolean (phi-boolean): 'yes', 'no', 'unknown'
*/
/* ---------------------------------------------------------------------- */
/**
* Token BooleanToken
*/
token BooleanToken
alias 'bool', 'boolean'
declare
{{
private:
bool m_bValue;
public:
bool value() { return m_bValue; }
}}
parse
{{
register char c = 0;
std::streampos pos = is.tellg();
if (Symbol::strincmpread("yes", 3))
{
m_bValue = true;
}
else
{
is.seekg(pos, std::ios::beg);
if (Symbol::strincmpread("no", 2))
{
m_bValue = false;
}
else
{
abort("Invalid boolean value");
}
}
}}
expand
{{
if (m_bValue)
os << "yes" ;
else
os << "no" ;
}}
/* ---------------------------------------------------------------------- */
/**
* Token PhibooleanToken
*/
token PhibooleanToken
alias 'phibool', 'phiboolean'
declare
{{
private:
short m_isValue;
public:
short value() { return m_isValue; }
}}
parse
{{
register char c = 0;
std::streampos pos = is.tellg();
if (Symbol::strincmpread("yes", 3))
{
m_isValue = 1;
}
else
{
is.seekg(pos, std::ios::beg);
if (Symbol::strincmpread("no", 2))
{
m_isValue = 0;
}
else
{
is.seekg(pos, std::ios::beg);
if (Symbol::strincmpread("unknown", 7))
{
m_isValue = -1;
}
else
{
abort("Invalid phiboolean value");
}
}
}
}}
expand
{{
switch (m_isValue)
{
case 0: os << "no" ; break;
case 1: os << "yes" ; break;
default:os << "unknown" ; break;
}
}}
This file is part of the LLOOP Reversible Object-Oriented Parser Generator. Copyright (c) 2005-2006 Michel MEHL, France. All rights reserved. LLOOP is distributed by the company ERSA SaRL.
| Copyright (c) 2005-2006 Michel MEHL, Haguenau, France |
| LLOOP version 1.1 |