X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/ba379fdc102753d6be2c4d937058fe40257329fe..f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63:/parser/Lexer.h diff --git a/parser/Lexer.h b/parser/Lexer.h index 0e1b618..c76696c 100644 --- a/parser/Lexer.h +++ b/parser/Lexer.h @@ -23,6 +23,7 @@ #define Lexer_h #include "Lookup.h" +#include "ParserArena.h" #include "SourceCode.h" #include #include @@ -33,7 +34,7 @@ namespace JSC { class RegExp; - class Lexer : Noncopyable { + class Lexer : public Noncopyable { public: // Character manipulation functions. static bool isWhiteSpace(int character); @@ -42,7 +43,7 @@ namespace JSC { static UChar convertUnicode(int c1, int c2, int c3, int c4); // Functions to set up parsing. - void setCode(const SourceCode&); + void setCode(const SourceCode&, ParserArena&); void setIsReparsing() { m_isReparsing = true; } // Functions for the parser itself. @@ -50,9 +51,8 @@ namespace JSC { int lineNumber() const { return m_lineNumber; } bool prevTerminator() const { return m_terminator; } SourceCode sourceCode(int openBrace, int closeBrace, int firstLine); - bool scanRegExp(); - const UString& pattern() const { return m_pattern; } - const UString& flags() const { return m_flags; } + bool scanRegExp(const Identifier*& pattern, const Identifier*& flags, UChar patternPrefix = 0); + bool skipRegExp(); // Functions for use after parsing. bool sawError() const { return m_error; } @@ -79,12 +79,11 @@ namespace JSC { int currentOffset() const; const UChar* currentCharacter() const; - JSC::Identifier* makeIdentifier(const UChar* buffer, size_t length); + const Identifier* makeIdentifier(const UChar* characters, size_t length); bool lastTokenWasRestrKeyword() const; static const size_t initialReadBufferCapacity = 32; - static const size_t initialIdentifierTableCapacity = 64; int m_lineNumber; @@ -108,13 +107,10 @@ namespace JSC { int m_next2; int m_next3; - WTF::SegmentedVector m_identifiers; + IdentifierArena* m_arena; JSGlobalData* m_globalData; - UString m_pattern; - UString m_flags; - const HashTable m_keywordTable; Vector m_codeWithoutBOMs; @@ -140,6 +136,12 @@ namespace JSC { return (convertHex(c1, c2) << 8) | convertHex(c3, c4); } + // A bridge for yacc from the C world to the C++ world. + inline int jscyylex(void* lvalp, void* llocp, void* globalData) + { + return static_cast(globalData)->lexer->lex(lvalp, llocp); + } + } // namespace JSC #endif // Lexer_h