//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
//
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include <sstream>
#include "parser.hpp"
#include "sanity.hpp"
#include "text.hpp"
// ------------------------------------------------------------------------
// The "parse_error" class.
// ------------------------------------------------------------------------
{
}
throw()
{
}
const char*
const throw()
{
try {
} catch (...) {
return "Could not format message for parsing error.";
}
}
const
{
}
// ------------------------------------------------------------------------
// The "parse_errors" class.
// ------------------------------------------------------------------------
{
}
throw()
{
}
const char*
const throw()
{
try {
} catch (...) {
return "Could not format messages for parsing errors.";
}
}
// ------------------------------------------------------------------------
// The "format_error" class.
// ------------------------------------------------------------------------
{
}
// ------------------------------------------------------------------------
// The "token" class.
// ------------------------------------------------------------------------
m_inited(false)
{
}
const token_type& p_type,
m_inited(true),
{
}
const
{
return m_line;
}
const impl::token_type&
const
{
return m_type;
}
const
{
return m_text;
}
const
{
return m_inited;
}
bool
const
{
return !m_inited;
}
// ------------------------------------------------------------------------
// The "header_entry" class.
// ------------------------------------------------------------------------
{
}
m_name(n),
m_value(v),
{
}
{
return m_name;
}
{
return m_value;
}
{
return m_attrs;
}
bool
{
}
{
}
// ------------------------------------------------------------------------
// The header tokenizer.
// ------------------------------------------------------------------------
namespace header {
public:
{
}
};
static
{
using namespace header;
return p;
}
for (;;) {
"eof, `;' or new line");
break;
}
return p;
}
static
{
iter++) {
}
return os;
}
} // namespace header
// ------------------------------------------------------------------------
// Free functions.
// ------------------------------------------------------------------------
{
using impl::format_error;
//
// Grammar
//
// header = entry+ nl
// entry = line nl
// line = text colon text
// (semicolon (text equal (text | dblquote string dblquote)))*
// string = quoted_string
//
bool first = true;
for (;;) {
try {
break;
throw format_error("Could not determine content type");
else
first = false;
}
}
throw format_error("Unexpected end of stream");
}
void
{
iter++) {
}
os << "\n";
}
void
int version)
{
using impl::format_error;
throw format_error("Could not determine content type");
throw format_error("Could not determine version");
throw format_error("Mismatched version: expected `" +
vstr + "' but got `" +
}