#ifndef Lexer_h
#define Lexer_h
+#include "SourceCode.h"
#include "ustring.h"
#include <wtf/Vector.h>
class Lexer : Noncopyable {
public:
- void setCode(int startingLineNumber, const UChar *c, unsigned int len);
+ void setCode(const SourceCode&);
int lex();
int lineNo() const { return yylineno; }
bool sawError() const { return error; }
void clear();
+ SourceCode sourceCode(int openBrace, int closeBrace, int firstLine)
+ {
+ // The SourceCode constructor adds 1 to the line number to account for
+ // all of the callers in WebCore that use zero-based line numbers, so
+ // we regrettably subtract 1 here to deal with that.
+ return SourceCode(m_source->provider(), m_source->startOffset() + openBrace + 1, m_source->startOffset() + closeBrace, firstLine - 1);
+ }
private:
friend Lexer& lexer();
bool isLineTerminator();
static bool isOctalDigit(int);
- int matchPunctuator(int c1, int c2, int c3, int c4);
+ int matchPunctuator(int& charPos, int c1, int c2, int c3, int c4);
static unsigned short singleEscape(unsigned short);
static unsigned short convertOctal(int c1, int c2, int c3);
KJS::Identifier* makeIdentifier(const Vector<UChar>& buffer);
UString* makeUString(const Vector<UChar>& buffer);
+ const SourceCode* m_source;
const UChar* code;
unsigned int length;
int yycolumn;
// current and following unicode characters (int to allow for -1 for end-of-file marker)
int current, next1, next2, next3;
+ int m_currentOffset;
+ int m_nextOffset1;
+ int m_nextOffset2;
+ int m_nextOffset3;
+
Vector<UString*> m_strings;
Vector<KJS::Identifier*> m_identifiers;