+/**
+ * \file texparser.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
#include <config.h>
#include "texparser.h"
-#include "Lsstream.h"
#include <iostream>
+#include <sstream>
using std::cerr;
using std::endl;
using std::fill;
-using std::ios;
using std::istream;
using std::istringstream;
using std::ostream;
-using std::vector;
+using std::string;
namespace {
fill(theCatcode + 'a', theCatcode + 'z' + 1, catLetter);
fill(theCatcode + 'A', theCatcode + 'Z' + 1, catLetter);
- theCatcode['\\'] = catEscape;
- theCatcode['{'] = catBegin;
- theCatcode['}'] = catEnd;
- theCatcode['$'] = catMath;
- theCatcode['&'] = catAlign;
+ theCatcode[int('\\')] = catEscape;
+ theCatcode[int('{')] = catBegin;
+ theCatcode[int('}')] = catEnd;
+ theCatcode[int('$')] = catMath;
+ theCatcode[int('&')] = catAlign;
theCatcode[10] = catNewline;
- theCatcode['#'] = catParameter;
- theCatcode['^'] = catSuper;
- theCatcode['_'] = catSub;
- theCatcode['\7f'] = catIgnore;
- theCatcode[' '] = catSpace;
- theCatcode['\t'] = catSpace;
+ theCatcode[int('#')] = catParameter;
+ theCatcode[int('^')] = catSuper;
+ theCatcode[int('_')] = catSub;
+ theCatcode[0x7f] = catIgnore;
+ theCatcode[int(' ')] = catSpace;
+ theCatcode[int('\t')] = catSpace;
theCatcode[13] = catIgnore;
- theCatcode['~'] = catActive;
- theCatcode['%'] = catComment;
+ theCatcode[int('~')] = catActive;
+ theCatcode[int('%')] = catComment;
// This is wrong!
- theCatcode['@'] = catLetter;
+ theCatcode[int('@')] = catLetter;
}
}
-//
+//
// catcodes
//
Parser::Parser(string const & s)
: lineno_(0), pos_(0)
{
- istringstream is(STRCONV(s));
+ istringstream is(s);
tokenize(is);
}
while (1) {
if (next_token().cat() == catSpace || next_token().cat() == catNewline)
get_token();
- else if (next_token().cat() == catComment)
+ else if (next_token().cat() == catComment)
while (next_token().cat() != catNewline)
get_token();
else
void Parser::setCatCode(char c, CatCode cat)
{
- theCatcode[c] = cat;
+ theCatcode[(unsigned char)c] = cat;
}
CatCode Parser::getCatCode(char c) const
{
- return theCatcode[c];
+ return theCatcode[(unsigned char)c];
}