Merge remote-tracking branch 'redux/master' into sh4-pool
[tamarin-stm.git] / esc / src / lex-char.es
blobe4e6dd4f9ec59a45ac3f6860c20fe613631a4f58
1 /* -*- mode: java; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is [Open Source Virtual Machine.].
16  *
17  * The Initial Developer of the Original Code is
18  * Adobe System Incorporated.
19  * Portions created by the Initial Developer are Copyright (C) 2004-2006
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *   Adobe AS3 Team
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
39 use default namespace Char,
40     namespace Char;
42 const EOS = 0;
43 const a = "a".charCodeAt(0);
44 const b = "b".charCodeAt(0);
45 const c = "c".charCodeAt(0);
46 const d = "d".charCodeAt(0);
47 const e = "e".charCodeAt(0);
48 const f = "f".charCodeAt(0);
49 const g = "g".charCodeAt(0);
50 const h = "h".charCodeAt(0);
51 const i = "i".charCodeAt(0);
52 const j = "j".charCodeAt(0);
53 const k = "k".charCodeAt(0);
54 const l = "l".charCodeAt(0);
55 const m = "m".charCodeAt(0);
56 const n = "n".charCodeAt(0);
57 const o = "o".charCodeAt(0);
58 const p = "p".charCodeAt(0);
59 const q = "q".charCodeAt(0);
60 const r = "r".charCodeAt(0);
61 const s = "s".charCodeAt(0);
62 const t = "t".charCodeAt(0);
63 const u = "u".charCodeAt(0);
64 const v = "v".charCodeAt(0);
65 const w = "w".charCodeAt(0);
66 const x = "x".charCodeAt(0);
67 const y = "y".charCodeAt(0);
68 const z = "z".charCodeAt(0);
69 const A = "A".charCodeAt(0);
70 const B = "B".charCodeAt(0);
71 const C = "C".charCodeAt(0);
72 const D = "D".charCodeAt(0);
73 const E = "E".charCodeAt(0);
74 const F = "F".charCodeAt(0);
75 const G = "G".charCodeAt(0);
76 const H = "H".charCodeAt(0);
77 const I = "I".charCodeAt(0);
78 const J = "J".charCodeAt(0);
79 const K = "K".charCodeAt(0);
80 const L = "L".charCodeAt(0);
81 const M = "M".charCodeAt(0);
82 const N = "N".charCodeAt(0);
83 const O = "O".charCodeAt(0);
84 const P = "P".charCodeAt(0);
85 const Q = "Q".charCodeAt(0);
86 const R = "R".charCodeAt(0);
87 const S = "S".charCodeAt(0);
88 const T = "T".charCodeAt(0);
89 const U = "U".charCodeAt(0);
90 const V = "V".charCodeAt(0);
91 const W = "W".charCodeAt(0);
92 const X = "X".charCodeAt(0);
93 const Y = "Y".charCodeAt(0);
94 const Z = "Z".charCodeAt(0);
95 const Zero = "0".charCodeAt(0);
96 const One = "1".charCodeAt(0);
97 const Two = "2".charCodeAt(0);
98 const Three = "3".charCodeAt(0);
99 const Four = "4".charCodeAt(0);
100 const Five = "5".charCodeAt(0);
101 const Six = "6".charCodeAt(0);
102 const Seven = "7".charCodeAt(0);
103 const Eight = "8".charCodeAt(0);
104 const Nine = "9".charCodeAt(0);
105 const Dot = ".".charCodeAt(0);
106 const Bang = "!".charCodeAt(0);
107 const Equal = "=".charCodeAt(0);
108 const Percent = "%".charCodeAt(0);
109 const Ampersand = "&".charCodeAt(0);
110 const Asterisk = "*".charCodeAt(0);
111 const Plus = "+".charCodeAt(0);
112 const Dash = "-".charCodeAt(0);
113 const Slash = "/".charCodeAt(0);
114 const BackSlash = "\\".charCodeAt(0);
115 const Comma = ",".charCodeAt(0);
116 const Colon = ":".charCodeAt(0);
117 const Semicolon = ";".charCodeAt(0);
118 const LeftAngle = "<".charCodeAt(0);
119 const RightAngle = ">".charCodeAt(0);
120 const Caret = "^".charCodeAt(0);
121 const Bar = "|".charCodeAt(0);
122 const QuestionMark = "?".charCodeAt(0);
123 const LeftParen = "(".charCodeAt(0);
124 const RightParen = ")".charCodeAt(0);
125 const LeftBrace = "{".charCodeAt(0);
126 const RightBrace = "}".charCodeAt(0);
127 const LeftBracket = "[".charCodeAt(0);
128 const RightBracket = "]".charCodeAt(0);
129 const Tilde = "~".charCodeAt(0);
130 const At = "@".charCodeAt(0);
131 const SingleQuote = "'".charCodeAt(0);
132 const DoubleQuote = "\"".charCodeAt(0);
133 const UnderScore = "_".charCodeAt(0);
134 const Dollar = "$".charCodeAt(0);
135 const Space = " ".charCodeAt(0);
136 const Tab = "\t".charCodeAt(0);
137 const VerticalTab = "\v".charCodeAt(0);
138 const Newline = "\n".charCodeAt(0);
139 const CarriageReturn = "\r".charCodeAt(0);
140 const Backspace = "\b".charCodeAt(0);
141 const Formfeed = "\f".charCodeAt(0);
142 const UnicodeLS = 0x2028;
143 const UnicodePS = 0x2029;
145 function isUnicodeIdentifierStart(c) {
146     if (c >= Char::A && c <= Char::Z) 
147         return true;
148     if (c >= Char::a && c <= Char::z) 
149         return true;
150     if (c == Char::UnderScore) 
151         return true;
152     if (c == Char::Dollar) 
153         return true;
154     // FIXME: More Unicode here!
155     return false;
158 function isUnicodeIdentifierPart(c) {
159     if (c >= Char::A && c <= Char::Z) 
160         return true;
161     if (c >= Char::a && c <= Char::z) 
162         return true;
163     if (c >= Char::Zero && c <= Char::Nine) 
164         return true;
165     if (c == Char::UnderScore) 
166         return true;
167     if (c == Char::Dollar) 
168         return true;
169     // FIXME: More Unicode here!
170     return false;
173 // Whitespace except BOM
175 function isUnicodeWhitespace(c) {
176     switch (c) {
177     case 0x0009:
178     case 0x000A:
179     case 0x000B:
180     case 0x000D:
181     case 0x0012:
182     case 0x0020:
183     case 0x00A0:
184     case 0x1680:
185     case 0x180e:
186     case 0x2000:
187     case 0x2001:
188     case 0x2002:
189     case 0x2003:
190     case 0x2004:
191     case 0x2005:
192     case 0x2006:
193     case 0x2007:
194     case 0x2008:
195     case 0x2009:
196     case 0x200a:
197     case 0x202f:
198     case 0x205f:
199     case 0x3000:
200         return true;
201     default:
202         return false;
203     }