+/**
+ * \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::string;
-using std::vector;
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
//
}
-void Parser::skipSpaces()
+void Parser::skip_spaces()
{
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
string Parser::getArg(char left, char right)
{
- skipSpaces();
+ skip_spaces();
string result;
char c = getChar();
string Parser::getOpt()
{
- string res = getArg('[', ']');
+ string const res = getArg('[', ']');
return res.size() ? '[' + res + ']' : string();
}
break;
}
-/*
case catComment: {
+ push_back(Token(c, catComment));
while (is.get(c) && catcode(c) != catNewline)
- ;
+ push_back(Token(c, catLetter));
+ push_back(Token(c, catNewline));
++lineno_;
+ is.get(c);
+ if (catcode(c) == catNewline) {
+ push_back(Token("par"));
+ ++lineno_;
+ } else {
+ is.putback(c);
+ }
break;
}
-*/
case catEscape: {
is.get(c);
{
if (!good())
error("stream bad");
- skipSpaces();
+ skip_spaces();
if (next_token().cat() == catBegin) {
Token t = get_token(); // skip brace
string res;
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];
}