JSDOC/BuildDocs.js
[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         "=eval":       "EVAL",
59         "=false":      "FALSE",
60         "=finally":    "FINALLY",
61         "=for":        "FOR",
62         "=function":   "FUNCTION",
63         "=if":         "IF",
64         "=in":         "IN",
65         "=instanceof": "INSTANCEOF",
66         "=new":        "NEW",
67         "=null":       "NULL",
68         "=return":     "RETURN",
69         "=switch":     "SWITCH",
70         "=this":       "THIS",
71         "=throw":      "THROW",
72         "=true":       "TRUE",
73         "=try":        "TRY",
74         "=typeof":     "TYPEOF",
75         "=void":       "VOID",
76         "=while":      "WHILE",
77         "=with":       "WITH",
78         "=var":        "VAR"
79     },
80
81     punc : function(ch) {
82         return this.puncNames[ch];
83     },
84     puncNames : {
85         ";":   "SEMICOLON",
86         ",":   "COMMA",
87         "?":   "HOOK",
88         ":":   "COLON",
89         "||":  "OR", 
90         "&&":  "AND",
91         "|":   "BITWISE_OR",
92         "^":   "BITWISE_XOR",
93         "&":   "BITWISE_AND",
94         "===": "STRICT_EQ", 
95         "==":  "EQ",
96         "=":   "ASSIGN",
97         "!==": "STRICT_NE",
98         "!=":  "NE",
99         "<<":  "LSH",
100         "<=":  "LE", 
101         "<":   "LT",
102         ">>>": "URSH",
103         ">>":  "RSH",
104         ">=":  "GE",
105         ">":   "GT", 
106         "++":  "INCREMENT",
107         "--":  "DECREMENT",
108         "+":   "PLUS",
109         "-":   "MINUS",
110         "*":   "MUL",
111         "/":   "DIV", 
112         "%":   "MOD",
113         "!":   "NOT",
114         "~":   "BITWISE_NOT",
115         ".":   "DOT",
116         "[":   "LEFT_BRACE",
117         "]":   "RIGHT_BRACE",
118         "{":   "LEFT_CURLY",
119         "}":   "RIGHT_CURLY",
120         "(":   "LEFT_PAREN",
121         ")":   "RIGHT_PAREN"
122     },
123
124     matching : function(name) {
125         name = typeof(this.puncNames[name]) == 'undefined' ? name : this.puncNames[name];
126         
127         return this.matchingNames[name];
128     },
129     matchingNames : {
130         "LEFT_PAREN": "RIGHT_PAREN",
131         "RIGHT_PAREN": "LEFT_PAREN",
132         "LEFT_CURLY": "RIGHT_CURLY",
133         "RIGHT_CURLY": "LEFT_CURLY",
134         "LEFT_BRACE": "RIGHT_BRACE",
135         "RIGHT_BRACE": "LEFT_BRACE"
136     },
137
138     isNumber : function(str) {
139         return /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i.test(str);
140     },
141
142     isHexDec : function(str) {
143         return /^0x[0-9A-F]+$/i.test(str);
144     },
145
146     isWordChar : function(str) {
147         return /^[a-zA-Z0-9$_.]+$/.test(str);
148     },
149
150     isSpace : function(str) {
151         return (typeof this.whitespace(str) != "undefined");
152     },
153
154     isNewline : function(str) {
155         return (typeof this.newline(str) != "undefined");
156     }
157     
158 };