Files
quickbook/detail/template_stack.cpp
Daniel James 056170abed Merge quickbook 1.5 from trunk.
Merged revisions 55905-55917,56077,56715,56717-56719 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r55905 | danieljames | 2009-08-31 12:36:13 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Update quickbook version number.
........
  r55906 | danieljames | 2009-08-31 12:36:23 +0100 (Mon, 31 Aug 2009) | 4 lines
  
  Create entry for 1.5 in the change log.
  
  Starting it of with some of the changes that have been made to quickbook
  since 1.4 - considering the first 1.4 release as the proper 1.4 release.
........
  r55907 | danieljames | 2009-08-31 12:36:34 +0100 (Mon, 31 Aug 2009) | 3 lines
  
  Wrap the template info in a struct.
  
  So that I can add extra scoping info.
........
  r55908 | danieljames | 2009-08-31 12:36:47 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Implement static/lexical scoping for 1.5. Refs #2034.
........
  r55909 | danieljames | 2009-08-31 12:37:04 +0100 (Mon, 31 Aug 2009) | 1 line
  
  In quickbook 1.5 don't mix '..' and whitespace seperators for template arguments. Refs #1174
........
  r55910 | danieljames | 2009-08-31 12:37:17 +0100 (Mon, 31 Aug 2009) | 2 lines
  
  Put the quickbook version numbers in a single header, along with convenience
  functions for using them in spirit grammars.
........
  r55911 | danieljames | 2009-08-31 12:37:32 +0100 (Mon, 31 Aug 2009) | 3 lines
  
  Ignore spaces after 'section:' for quickbook 1.5+ Refs #2712
  
  And warn when section id is empty after colon.
........
  r55912 | danieljames | 2009-08-31 12:37:48 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Introduce temporary id variable.
........
  r55913 | danieljames | 2009-08-31 12:37:59 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Table ids. Refs #1194.
........
  r55914 | danieljames | 2009-08-31 12:38:11 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Separate out the current version of the template argument parser, as I want to create a new one for 1.5
........
  r55915 | danieljames | 2009-08-31 12:38:20 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Don't use seperators that are in brackets, or are escaped. Refs #2036.
........
  r55916 | danieljames | 2009-08-31 12:38:33 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Add missing table tests.
........
  r55917 | danieljames | 2009-08-31 12:38:47 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Support image attributes. Refs #1157.
........
  r56077 | djowel | 2009-09-07 02:35:24 +0100 (Mon, 07 Sep 2009) | 1 line
  
  fix for msvc
........
  r56715 | danieljames | 2009-10-11 17:18:04 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Use qualified ids in tables, and fix a bug generating ids when there isn't a section.
........
  r56717 | danieljames | 2009-10-11 19:21:11 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Document the simplified quickbook 1.5 argument separators.
........
  r56718 | danieljames | 2009-10-11 19:21:32 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Use quickbook 1.5 in the document block example.
........
  r56719 | danieljames | 2009-10-11 19:21:48 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Add table ids to the documentation.
........


[SVN r56752]
2009-10-12 19:54:36 +00:00

79 lines
2.3 KiB
C++

/*=============================================================================
Copyright (c) 2002 2004 2006 Joel de Guzman
http://spirit.sourceforge.net/
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "./template_stack.hpp"
#ifdef BOOST_MSVC
#pragma warning(disable : 4355)
#endif
namespace quickbook
{
template_stack::template_stack()
: scope(template_stack::parser(*this))
, scopes()
{
scopes.push_front(template_scope());
}
template_symbol* template_stack::find(std::string const& symbol) const
{
for (template_scope const* i = &*scopes.begin(); i; i = i->parent_scope)
{
if (template_symbol* ts = boost::spirit::classic::find(i->symbols, symbol.c_str()))
return ts;
}
return 0;
}
template_symbol* template_stack::find_top_scope(std::string const& symbol) const
{
return boost::spirit::classic::find(scopes.front().symbols, symbol.c_str());
}
template_symbols const& template_stack::top() const
{
BOOST_ASSERT(!scopes.empty());
return scopes.front().symbols;
}
template_scope const& template_stack::top_scope() const
{
BOOST_ASSERT(!scopes.empty());
return scopes.front();
}
// TODO: Should symbols defined by '[import]' use the current scope?
void template_stack::add(std::string const& symbol, template_symbol const& ts)
{
BOOST_ASSERT(!scopes.empty());
boost::spirit::classic::add(scopes.front().symbols, symbol.c_str(),
boost::get<2>(ts) ? ts :
template_symbol(boost::get<0>(ts), boost::get<1>(ts), &top_scope()));
}
void template_stack::push()
{
template_scope const& old_front = scopes.front();
scopes.push_front(template_scope());
set_parent_scope(old_front);
}
void template_stack::pop()
{
scopes.pop_front();
}
void template_stack::set_parent_scope(template_scope const& parent)
{
scopes.front().parent_scope = &parent;
}
}