• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • kjs
lexer.h
1/*
2 * This file is part of the KDE libraries
3 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22#ifndef _KJSLEXER_H_
23#define _KJSLEXER_H_
24
25#include "ustring.h"
26
27
28namespace KJS {
29
30 class Identifier;
31
32 class RegExp;
33
34 class Lexer {
35 public:
36 Lexer();
37 ~Lexer();
38 static Lexer *curr();
39
40 void setCode(const UChar *c, unsigned int len);
41 int lex();
42
43 int lineNo() const { return yylineno + 1; }
44
45 bool prevTerminator() const { return terminator; }
46
47 enum State { Start,
48 IdentifierOrKeyword,
49 Identifier,
50 InIdentifierOrKeyword,
51 InIdentifier,
52 InIdentifierUnicodeEscapeStart,
53 InIdentifierUnicodeEscape,
54 InSingleLineComment,
55 InMultiLineComment,
56 InNum,
57 InNum0,
58 InHex,
59 InOctal,
60 InDecimal,
61 InExponentIndicator,
62 InExponent,
63 Hex,
64 Octal,
65 Number,
66 String,
67 Eof,
68 InString,
69 InEscapeSequence,
70 InHexEscape,
71 InUnicodeEscape,
72 Other,
73 Bad };
74
75 bool scanRegExp();
76 UString pattern, flags;
77 bool hadError() const { return foundBad; }
78
79 static bool isWhiteSpace(unsigned short c);
80 static bool isIdentLetter(unsigned short c);
81 static bool isDecimalDigit(unsigned short c);
82 static bool isHexDigit(unsigned short c);
83 static bool isOctalDigit(unsigned short c);
84
85 private:
86 int yylineno;
87 bool done;
88 char *buffer8;
89 UChar *buffer16;
90 unsigned int size8, size16;
91 unsigned int pos8, pos16;
92 bool terminator;
93 bool restrKeyword;
94 // encountered delimiter like "'" and "}" on last run
95 bool delimited;
96 bool skipLF;
97 bool skipCR;
98 bool convertNextIdentifier;
99 int stackToken;
100 int lastToken;
101 bool foundBad;
102
103 State state;
104 void setDone(State s);
105 unsigned int pos;
106 void shift(unsigned int p);
107 void nextLine();
108 int lookupKeyword(const char *);
109
110 int matchPunctuator(unsigned short c1, unsigned short c2,
111 unsigned short c3, unsigned short c4);
112 unsigned short singleEscape(unsigned short c) const;
113 unsigned short convertOctal(unsigned short c1, unsigned short c2,
114 unsigned short c3) const;
115 public:
116 static unsigned char convertHex(unsigned short c1);
117 static unsigned char convertHex(unsigned short c1, unsigned short c2);
118 static UChar convertUnicode(unsigned short c1, unsigned short c2,
119 unsigned short c3, unsigned short c4);
120
121#ifdef KJS_DEBUG_MEM
125 static void globalClear();
126#endif
127
128 void doneParsing();
129
130 private:
131
132 void record8(unsigned short c);
133 void record16(int c);
134 void record16(UChar c);
135
136 KJS::Identifier *makeIdentifier(UChar *buffer, unsigned int pos);
137 UString *makeUString(UChar *buffer, unsigned int pos);
138
139 const UChar *code;
140 unsigned int length;
141 int yycolumn;
142#ifndef KJS_PURE_ECMA
143 int bol; // begin of line
144#endif
145
146 // current and following unicode characters (int to allow for -1 for end-of-file marker)
147 int current, next1, next2, next3;
148
149 UString **strings;
150 unsigned int numStrings;
151 unsigned int stringsCapacity;
152
153 KJS::Identifier **identifiers;
154 unsigned int numIdentifiers;
155 unsigned int identifiersCapacity;
156
157 // for future extensions
158 class LexerPrivate;
159 LexerPrivate *priv;
160 };
161
162} // namespace
163
164#endif
KJS::Identifier
Represents an Identifier for a Javascript object.
Definition: identifier.h:32

kjs

Skip menu "kjs"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kjs

Skip menu "kjs"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.9.4
This website is maintained by Timothy Pearson.