source: webkit/trunk/JavaScriptCore/kjs/lexer.h@ 38137

Last change on this file since 38137 was 38137, checked in by [email protected], 17 years ago

2008-11-05 Cameron Zwarich <[email protected]>

Rubber-stamped by Sam Weinig.

Move more files to the runtime subdirectory of JavaScriptCore.

JavaScriptCore:

  • API/APICast.h:
  • API/JSBase.cpp:
  • API/JSCallbackObject.cpp:
  • API/JSClassRef.cpp:
  • API/JSClassRef.h:
  • API/JSStringRefCF.cpp:
  • API/JSValueRef.cpp:
  • API/OpaqueJSString.cpp:
  • API/OpaqueJSString.h:
  • AllInOneFile.cpp:
  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • VM/CodeBlock.h:
  • VM/CodeGenerator.cpp:
  • VM/Machine.cpp:
  • VM/RegisterFile.h:
  • debugger/Debugger.h:
  • kjs/SourceProvider.h:
  • kjs/TypeInfo.h: Removed.
  • kjs/collector.cpp: Removed.
  • kjs/collector.h: Removed.
  • kjs/completion.h: Removed.
  • kjs/create_hash_table:
  • kjs/identifier.cpp: Removed.
  • kjs/identifier.h: Removed.
  • kjs/interpreter.cpp: Removed.
  • kjs/interpreter.h: Removed.
  • kjs/lexer.cpp:
  • kjs/lexer.h:
  • kjs/lookup.cpp: Removed.
  • kjs/lookup.h: Removed.
  • kjs/nodes.cpp:
  • kjs/nodes.h:
  • kjs/operations.cpp: Removed.
  • kjs/operations.h: Removed.
  • kjs/protect.h: Removed.
  • kjs/regexp.cpp: Removed.
  • kjs/regexp.h: Removed.
  • kjs/ustring.cpp: Removed.
  • kjs/ustring.h: Removed.
  • pcre/pcre_exec.cpp:
  • profiler/CallIdentifier.h:
  • profiler/Profile.h:
  • runtime/ArrayConstructor.cpp:
  • runtime/ArrayPrototype.cpp:
  • runtime/ArrayPrototype.h:
  • runtime/Collector.cpp: Copied from kjs/collector.cpp.
  • runtime/Collector.h: Copied from kjs/collector.h.
  • runtime/CollectorHeapIterator.h:
  • runtime/Completion.h: Copied from kjs/completion.h.
  • runtime/ErrorPrototype.cpp:
  • runtime/Identifier.cpp: Copied from kjs/identifier.cpp.
  • runtime/Identifier.h: Copied from kjs/identifier.h.
  • runtime/InitializeThreading.cpp:
  • runtime/Interpreter.cpp: Copied from kjs/interpreter.cpp.
  • runtime/Interpreter.h: Copied from kjs/interpreter.h.
  • runtime/JSCell.h:
  • runtime/JSGlobalData.cpp:
  • runtime/JSGlobalData.h:
  • runtime/JSLock.cpp:
  • runtime/JSNumberCell.cpp:
  • runtime/JSNumberCell.h:
  • runtime/JSObject.cpp:
  • runtime/JSValue.h:
  • runtime/Lookup.cpp: Copied from kjs/lookup.cpp.
  • runtime/Lookup.h: Copied from kjs/lookup.h.
  • runtime/MathObject.cpp:
  • runtime/NativeErrorPrototype.cpp:
  • runtime/NumberPrototype.cpp:
  • runtime/Operations.cpp: Copied from kjs/operations.cpp.
  • runtime/Operations.h: Copied from kjs/operations.h.
  • runtime/PropertyMapHashTable.h:
  • runtime/Protect.h: Copied from kjs/protect.h.
  • runtime/RegExp.cpp: Copied from kjs/regexp.cpp.
  • runtime/RegExp.h: Copied from kjs/regexp.h.
  • runtime/RegExpConstructor.cpp:
  • runtime/RegExpObject.h:
  • runtime/RegExpPrototype.cpp:
  • runtime/SmallStrings.h:
  • runtime/StringObjectThatMasqueradesAsUndefined.h:
  • runtime/StructureID.cpp:
  • runtime/StructureID.h:
  • runtime/StructureIDTransitionTable.h:
  • runtime/SymbolTable.h:
  • runtime/TypeInfo.h: Copied from kjs/TypeInfo.h.
  • runtime/UString.cpp: Copied from kjs/ustring.cpp.
  • runtime/UString.h: Copied from kjs/ustring.h.
  • wrec/CharacterClassConstructor.h:
  • wrec/WREC.h:

WebCore:

  • ForwardingHeaders/kjs/collector.h: Removed.
  • ForwardingHeaders/kjs/completion.h: Removed.
  • ForwardingHeaders/kjs/identifier.h: Removed.
  • ForwardingHeaders/kjs/interpreter.h: Removed.
  • ForwardingHeaders/kjs/lookup.h: Removed.
  • ForwardingHeaders/kjs/operations.h: Removed.
  • ForwardingHeaders/kjs/protect.h: Removed.
  • ForwardingHeaders/kjs/ustring.h: Removed.
  • ForwardingHeaders/runtime/Collector.h: Copied from ForwardingHeaders/kjs/collector.h.
  • ForwardingHeaders/runtime/Completion.h: Copied from ForwardingHeaders/kjs/completion.h.
  • ForwardingHeaders/runtime/Identifier.h: Copied from ForwardingHeaders/kjs/identifier.h.
  • ForwardingHeaders/runtime/Interpreter.h: Copied from ForwardingHeaders/kjs/interpreter.h.
  • ForwardingHeaders/runtime/Lookup.h: Copied from ForwardingHeaders/kjs/lookup.h.
  • ForwardingHeaders/runtime/Operations.h: Copied from ForwardingHeaders/kjs/operations.h.
  • ForwardingHeaders/runtime/Protect.h: Copied from ForwardingHeaders/kjs/protect.h.
  • ForwardingHeaders/runtime/UString.h: Copied from ForwardingHeaders/kjs/ustring.h.
  • bindings/js/GCController.cpp:
  • bindings/js/JSCustomPositionCallback.h:
  • bindings/js/JSCustomPositionErrorCallback.h:
  • bindings/js/JSCustomSQLStatementCallback.h:
  • bindings/js/JSCustomSQLStatementErrorCallback.h:
  • bindings/js/JSCustomSQLTransactionErrorCallback.h:
  • bindings/js/JSCustomVoidCallback.h:
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSEventListener.h:
  • bindings/js/ScheduledAction.h:
  • bindings/js/ScriptController.cpp:
  • bindings/js/ScriptController.h:
  • bindings/objc/WebScriptObject.mm:
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/NP_jsobject.cpp:
  • bridge/c/c_class.cpp:
  • bridge/jni/jni_class.cpp:
  • bridge/jni/jni_jsobject.mm:
  • bridge/npruntime.cpp:
  • bridge/runtime_root.h:
  • history/CachedPage.h:
  • html/CanvasRenderingContext2D.cpp:
  • html/HTMLCanvasElement.cpp:
  • inspector/InspectorController.cpp:
  • inspector/JavaScriptCallFrame.cpp:
  • page/Console.cpp:
  • page/Page.cpp:
  • platform/text/AtomicString.cpp:
  • platform/text/PlatformString.h:

WebKit/mac:

  • ForwardingHeaders/kjs/collector.h: Removed.
  • ForwardingHeaders/kjs/identifier.h: Removed.
  • ForwardingHeaders/kjs/interpreter.h: Removed.
  • ForwardingHeaders/kjs/lookup.h: Removed.
  • ForwardingHeaders/kjs/operations.h: Removed.
  • ForwardingHeaders/kjs/protect.h: Removed.
  • ForwardingHeaders/runtime/Interpreter.h: Copied from ForwardingHeaders/kjs/interpreter.h.
  • WebView/WebScriptDebugDelegate.mm:

WebKit/wx:

  • WebFrame.cpp:
  • WebView.cpp:
  • Property svn:eol-style set to native
File size: 4.6 KB
Line 
1/*
2 * This file is part of the KDE libraries
3 * Copyright (C) 1999-2000 Harri Porten ([email protected])
4 * Copyright (C) 2007 Apple Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef Lexer_h
24#define Lexer_h
25
26#include "Lookup.h"
27#include "UString.h"
28#include <wtf/Vector.h>
29#include "SourceCode.h"
30
31namespace JSC {
32
33 class Identifier;
34 class RegExp;
35
36 class Lexer : Noncopyable {
37 public:
38 void setCode(const SourceCode&);
39 int lex(void* lvalp, void* llocp);
40
41 int lineNo() const { return yylineno; }
42
43 bool prevTerminator() const { return m_terminator; }
44
45 enum State {
46 Start,
47 IdentifierOrKeyword,
48 Identifier,
49 InIdentifierOrKeyword,
50 InIdentifier,
51 InIdentifierStartUnicodeEscapeStart,
52 InIdentifierStartUnicodeEscape,
53 InIdentifierPartUnicodeEscapeStart,
54 InIdentifierPartUnicodeEscape,
55 InSingleLineComment,
56 InMultiLineComment,
57 InNum,
58 InNum0,
59 InHex,
60 InOctal,
61 InDecimal,
62 InExponentIndicator,
63 InExponent,
64 Hex,
65 Octal,
66 Number,
67 String,
68 Eof,
69 InString,
70 InEscapeSequence,
71 InHexEscape,
72 InUnicodeEscape,
73 Other,
74 Bad
75 };
76
77 bool scanRegExp();
78 const UString& pattern() const { return m_pattern; }
79 const UString& flags() const { return m_flags; }
80
81 static unsigned char convertHex(int);
82 static unsigned char convertHex(int c1, int c2);
83 static UChar convertUnicode(int c1, int c2, int c3, int c4);
84 static bool isIdentStart(int);
85 static bool isIdentPart(int);
86 static bool isHexDigit(int);
87
88 bool sawError() const { return m_error; }
89
90 void clear();
91 SourceCode sourceCode(int openBrace, int closeBrace, int firstLine) { return SourceCode(m_source->provider(), m_source->startOffset() + openBrace + 1, m_source->startOffset() + closeBrace, firstLine); }
92
93 private:
94 friend class JSGlobalData;
95 Lexer(JSGlobalData*);
96 ~Lexer();
97
98 void setDone(State);
99 void shift(unsigned int p);
100 void nextLine();
101 int lookupKeyword(const char *);
102
103 bool isWhiteSpace() const;
104 bool isLineTerminator();
105 static bool isOctalDigit(int);
106
107 int matchPunctuator(int& charPos, int c1, int c2, int c3, int c4);
108 static unsigned short singleEscape(unsigned short);
109 static unsigned short convertOctal(int c1, int c2, int c3);
110
111 void record8(int);
112 void record16(int);
113 void record16(UChar);
114
115 JSC::Identifier* makeIdentifier(const Vector<UChar>& buffer);
116
117 int yylineno;
118 int yycolumn;
119
120 bool m_done;
121 Vector<char> m_buffer8;
122 Vector<UChar> m_buffer16;
123 bool m_terminator;
124 bool m_restrKeyword;
125 bool m_delimited; // encountered delimiter like "'" and "}" on last run
126 bool m_skipLF;
127 bool m_skipCR;
128 bool m_eatNextIdentifier;
129 int m_stackToken;
130 int m_lastToken;
131
132 State m_state;
133 unsigned int m_position;
134 const SourceCode* m_source;
135 const UChar* m_code;
136 unsigned int m_length;
137 int m_atLineStart;
138 bool m_error;
139
140 // current and following unicode characters (int to allow for -1 for end-of-file marker)
141 int m_current;
142 int m_next1;
143 int m_next2;
144 int m_next3;
145
146 int m_currentOffset;
147 int m_nextOffset1;
148 int m_nextOffset2;
149 int m_nextOffset3;
150
151 Vector<UString*> m_strings;
152 Vector<JSC::Identifier*> m_identifiers;
153
154 JSGlobalData* m_globalData;
155
156 UString m_pattern;
157 UString m_flags;
158
159 const HashTable m_mainTable;
160 };
161
162} // namespace JSC
163
164#endif // Lexer_h
Note: See TracBrowser for help on using the repository browser.