}
+#ifdef FILEDEBUG
+void debugToken(std::ostream & os, Token const & t, unsigned int flags)
+{
+ char sep = ' ';
+ os << "t: " << t << " flags: " << flags;
+ if (flags & FLAG_BRACE_LAST) { os << sep << "BRACE_LAST"; sep = '|'; }
+ if (flags & FLAG_RIGHT ) { os << sep << "RIGHT" ; sep = '|'; }
+ if (flags & FLAG_END ) { os << sep << "END" ; sep = '|'; }
+ if (flags & FLAG_BRACK_LAST) { os << sep << "BRACK_LAST"; sep = '|'; }
+ if (flags & FLAG_TEXTMODE ) { os << sep << "TEXTMODE" ; sep = '|'; }
+ if (flags & FLAG_ITEM ) { os << sep << "ITEM" ; sep = '|'; }
+ if (flags & FLAG_LEAVE ) { os << sep << "LEAVE" ; sep = '|'; }
+ if (flags & FLAG_SIMPLE ) { os << sep << "SIMPLE" ; sep = '|'; }
+ if (flags & FLAG_EQUATION ) { os << sep << "EQUATION" ; sep = '|'; }
+ if (flags & FLAG_SIMPLE2 ) { os << sep << "SIMPLE2" ; sep = '|'; }
+ if (flags & FLAG_OPTION ) { os << sep << "OPTION" ; sep = '|'; }
+ if (flags & FLAG_BRACED ) { os << sep << "BRACED" ; sep = '|'; }
+ if (flags & FLAG_CELL ) { os << sep << "CELL" ; sep = '|'; }
+ if (flags & FLAG_TABBING ) { os << sep << "TABBING" ; sep = '|'; }
+ os << "\n";
+}
+#endif
+
+
//
// Parser
//
std::string const & cs() const { return cs_; }
/// Returns the catcode of the token
CatCode cat() const { return cat_; }
- ///
+ /** Get the character of tokens that were constructed from a single
+ * character input or a two character input and cat_ == catEscape.
+ * FIXME: The intended usage is not clear. The Token class in
+ * ../mathed/MathParser.cpp (which is the anchestor of this
+ * class) uses a separate char member for this method. I
+ * believe that the intended usage is to not cover tokens with
+ * catEscape, e.g. \code
+ * return (cs_.empty() || cat_ == catEscape) ? 0 : cs_[0];
+ * \endcode
+ * All usages of this method should be checked. gb 2011-01-05
+ */
char character() const { return cs_.empty() ? 0 : cs_[0]; }
/// Returns the token verbatim
std::string asInput() const;
% the following is useful when we have the old nomencl.sty package
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
+\makenomenclature
\usepackage{varioref}
\usepackage{prettyref}
\usepackage{makeidx}
+\makeindex
\usepackage{graphicx}
\usepackage{longtable}
\endlastfoot
\env{longtable} columns are specified& in the \\
same way as in the \env{tabular}& environment.\\
-%\code{@\{*\}r||p\{1in\}@\{*\}}& in this case.\\
+\code{@\{*\}r||p\{1in\}@\{*\}}& in this case.\\
Each row ends with a& \code{\textbackslash\textbackslash} command.\\
The \code{\textbackslash\textbackslash} command has an& optional\\
argument, just as in& the\\
unsigned int optargs = 0;
while (optargs < context.layout->optargs) {
eat_whitespace(p, os, context, false);
- if (p.next_token().character() != '[')
+ if (p.next_token().cat() == catEscape ||
+ p.next_token().character() != '[')
break;
p.get_token(); // eat '['
begin_inset(os, "OptArg\n");
eat_whitespace(p, os, context, false);
++optargs;
}
-#if 0
- // This is the code needed to parse required arguments, but
- // required arguments come into being only much later than the
- // file format tex2lyx is presently outputting.
unsigned int reqargs = 0;
- while (reqargs < context.layout->reqargs) {
+ while (LYX_FORMAT >= 392 && reqargs < context.layout->reqargs) {
eat_whitespace(p, os, context, false);
- if (p.next_token().character() != '{')
+ if (p.next_token().cat() != catBegin)
break;
p.get_token(); // eat '{'
begin_inset(os, "OptArg\n");
eat_whitespace(p, os, context, false);
++reqargs;
}
-#endif
parse_text(p, os, FLAG_ITEM, outer, context);
context.check_end_layout(os);
if (parent_context.deeper_paragraph) {
Token const & t = p.get_token();
#ifdef FILEDEBUG
- cerr << "t: " << t << " flags: " << flags << "\n";
+ debugToken(cerr, t, flags);
#endif
if (flags & FLAG_ITEM) {
flags |= FLAG_LEAVE;
}
- if (t.character() == ']' && (flags & FLAG_BRACK_LAST))
+ if (t.cat() != catEscape && t.character() == ']' &&
+ (flags & FLAG_BRACK_LAST))
return;
- if (t.character() == '}' && (flags & FLAG_BRACE_LAST))
+ if (t.cat() == catEnd && (flags & FLAG_BRACE_LAST))
return;
// If there is anything between \end{env} and \begin{env} we
p.skip_spaces();
string s;
bool optarg = false;
- if (p.next_token().character() == '[') {
+ if (p.next_token().cat() != catEscape &&
+ p.next_token().character() == '[') {
p.get_token(); // eat '['
s = parse_text_snippet(p, FLAG_BRACK_LAST,
outer, context);
os << "\\begin_layout "
<< to_utf8(context.textclass.defaultLayout().name())
<< '\n';
- if (p.next_token().character() == '[') {
+ if (p.next_token().cat() != catEscape &&
+ p.next_token().character() == '[') {
p.get_token(); // eat '['
begin_inset(os, "OptArg\n");
os << "status collapsed\n";