Intial import
[gnome.introspection-doc-generator] / JSDOC / Lang.js
1 //<script type="text/javscript">
2
3 /**
4         @namespace
5 */
6 Lang = {
7     
8     
9     isBuiltin : function(name) {
10         return (this.coreObjects.indexOf(name) > -1);
11     }, 
12     coreObjects : ['_global_', 'Array', 'Boolean', 'Date', 'Error', 
13         'Function', 'Math', 'Number', 'Object', 'RegExp', 'String'],
14         
15
16     whitespace : function(ch) {
17         return this.whitespaceNames[ch];
18     },
19     
20     whitespaceNames : {
21         " ":      "SPACE",
22         "\f":     "FORMFEED",
23         "\t":     "TAB",
24         "\u0009": "UNICODE_TAB",
25         "\u000A": "UNICODE_NBR",
26         "\u0008": "VERTICAL_TAB"
27     },
28
29     newline : function(ch) {
30         return this.newlineNames[ch];
31     },
32     newlineNames : {
33         "\n":     "NEWLINE",
34         "\r":     "RETURN",
35         "\u000A": "UNICODE_LF",
36         "\u000D": "UNICODE_CR",
37         "\u2029": "UNICODE_PS",
38         "\u2028": "UNICODE_LS"
39     },
40
41     keyword : function(word) {
42         return this.keywordNames["="+word];
43     },
44     isKeyword: function(word) {
45         return typeof(this.keywordNames["="+word]) == 'undefined' ? false : true;
46     },
47
48     keywordNames : {
49         "=break":      "BREAK",
50         "=case":       "CASE",
51         "=catch":      "CATCH",
52         "=const":      "VAR",
53         "=continue":   "CONTINUE",
54         "=default":    "DEFAULT",
55         "=delete":     "DELETE",
56         "=do":         "DO",
57         "=else":       "ELSE",
58         "=false":      "FALSE",
59         "=finally":    "FINALLY",
60         "=for":        "FOR",
61         "=function":   "FUNCTION",
62         "=if":         "IF",
63         "=in":         "IN",
64         "=instanceof": "INSTANCEOF",
65         "=new":        "NEW",
66         "=null":       "NULL",
67         "=return":     "RETURN",
68         "=switch":     "SWITCH",
69         "=this":       "THIS",
70         "=throw":      "THROW",
71         "=true":       "TRUE",
72         "=try":        "TRY",
73         "=typeof":     "TYPEOF",
74         "=void":       "VOID",
75         "=while":      "WHILE",
76         "=with":       "WITH",
77         "=var":        "VAR"
78     },
79
80     punc : function(ch) {
81         return this.puncNames[ch];
82     },
83     puncNames : {
84         ";":   "SEMICOLON",
85         ",":   "COMMA",
86         "?":   "HOOK",
87         ":":   "COLON",
88         "||":  "OR", 
89         "&&":  "AND",
90         "|":   "BITWISE_OR",
91         "^":   "BITWISE_XOR",
92         "&":   "BITWISE_AND",
93         "===": "STRICT_EQ", 
94         "==":  "EQ",
95         "=":   "ASSIGN",
96         "!==": "STRICT_NE",
97         "!=":  "NE",
98         "<<":  "LSH",
99         "<=":  "LE", 
100         "<":   "LT",
101         ">>>": "URSH",
102         ">>":  "RSH",
103         ">=":  "GE",
104         ">":   "GT", 
105         "++":  "INCREMENT",
106         "--":  "DECREMENT",
107         "+":   "PLUS",
108         "-":   "MINUS",
109         "*":   "MUL",
110         "/":   "DIV", 
111         "%":   "MOD",
112         "!":   "NOT",
113         "~":   "BITWISE_NOT",
114         ".":   "DOT",
115         "[":   "LEFT_BRACE",
116         "]":   "RIGHT_BRACE",
117         "{":   "LEFT_CURLY",
118         "}":   "RIGHT_CURLY",
119         "(":   "LEFT_PAREN",
120         ")":   "RIGHT_PAREN"
121     },
122
123     matching : function(name) {
124         return this.matchingNames[name];
125     },
126     matchingNames : {
127         "LEFT_PAREN": "RIGHT_PAREN",
128         "RIGHT_PAREN": "LEFT_PAREN",
129         "LEFT_CURLY": "RIGHT_CURLY",
130         "RIGHT_CURLY": "LEFT_CURLY",
131         "LEFT_BRACE": "RIGHT_BRACE",
132         "RIGHT_BRACE": "LEFT_BRACE"
133     },
134
135     isNumber : function(str) {
136         return /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i.test(str);
137     },
138
139     isHexDec : function(str) {
140         return /^0x[0-9A-F]+$/i.test(str);
141     },
142
143     isWordChar : function(str) {
144         return /^[a-zA-Z0-9$_.]+$/.test(str);
145     },
146
147     isSpace : function(str) {
148         return (typeof this.whitespace(str) != "undefined");
149     },
150
151     isNewline : function(str) {
152         return (typeof this.newline(str) != "undefined");
153     }
154     
155 };