PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/jsdoc_toolkit-2.0.1/jsdoc-toolkit/app/lib/JSDOC/Lang.js

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