1 //<script type="text/javscript">
4 * Language related methods (eg. what's a token...)
13 isBuiltin : function(name) {
14 return (this.coreObjects.indexOf(name) > -1);
16 coreObjects : ['_global_', 'Array', 'Boolean', 'Date', 'Error',
17 'Function', 'Math', 'Number', 'Object', 'RegExp', 'String'],
20 whitespace : function(ch) {
21 return this.whitespaceNames[ch];
28 "\u0009": "UNICODE_TAB",
29 "\u000A": "UNICODE_NBR",
30 "\u0008": "VERTICAL_TAB"
33 newline : function(ch) {
34 return this.newlineNames[ch];
39 "\u000A": "UNICODE_LF",
40 "\u000D": "UNICODE_CR",
41 "\u2029": "UNICODE_PS",
42 "\u2028": "UNICODE_LS"
45 keyword : function(word) {
46 return this.keywordNames["="+word];
48 isKeyword: function(word) {
49 return typeof(this.keywordNames["="+word]) == 'undefined' ? false : true;
57 "=continue": "CONTINUE",
58 "=default": "DEFAULT",
64 "=finally": "FINALLY",
66 "=function": "FUNCTION",
69 "=instanceof": "INSTANCEOF",
86 return this.puncNames[ch];
128 matching : function(name) {
129 name = typeof(this.puncNames[name]) == 'undefined' ? name : this.puncNames[name];
131 return this.matchingNames[name];
134 "LEFT_PAREN": "RIGHT_PAREN",
135 "RIGHT_PAREN": "LEFT_PAREN",
136 "LEFT_CURLY": "RIGHT_CURLY",
137 "RIGHT_CURLY": "LEFT_CURLY",
138 "LEFT_BRACE": "RIGHT_BRACE",
139 "RIGHT_BRACE": "LEFT_BRACE"
142 isNumber : function(str) {
143 return /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i.test(str);
146 isHexDec : function(str) {
147 return /^0x[0-9A-F]+$/i.test(str);
150 isWordChar : function(str) {
151 return /^[a-zA-Z0-9$_.]+$/.test(str);
154 isSpace : function(str) {
155 return (typeof this.whitespace(str) != "undefined");
158 isNewline : function(str) {
159 return (typeof this.newline(str) != "undefined");