thirdparty/jsdoctoolkit/app/lib/JSDOC/TokenReader.js
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 25 Oct 2009 18:45:58 -0700
changeset 3052 6907a33ca0a2
parent 3041 c8f47f0b6697
permissions -rw-r--r--
Removed now unused method from Role Logic.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3041
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     1
if (typeof JSDOC == "undefined") JSDOC = {};
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     2
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     3
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     4
	@class Search a {@link JSDOC.TextStream} for language tokens.
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     5
*/
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     6
JSDOC.TokenReader = function() {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     7
	this.keepDocs = true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     8
	this.keepWhite = false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
     9
	this.keepComments = false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    10
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    11
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    12
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    13
	@type {JSDOC.Token[]}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    14
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    15
JSDOC.TokenReader.prototype.tokenize = function(/**JSDOC.TextStream*/stream) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    16
	var tokens = [];
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    17
	/**@ignore*/ tokens.last    = function() { return tokens[tokens.length-1]; }
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    18
	/**@ignore*/ tokens.lastSym = function() {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    19
		for (var i = tokens.length-1; i >= 0; i--) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    20
			if (!(tokens[i].is("WHIT") || tokens[i].is("COMM"))) return tokens[i];
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    21
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    22
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    23
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    24
	while (!stream.look().eof) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    25
		if (this.read_mlcomment(stream, tokens)) continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    26
		if (this.read_slcomment(stream, tokens)) continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    27
		if (this.read_dbquote(stream, tokens))   continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    28
		if (this.read_snquote(stream, tokens))   continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    29
		if (this.read_regx(stream, tokens))      continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    30
		if (this.read_numb(stream, tokens))      continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    31
		if (this.read_punc(stream, tokens))      continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    32
		if (this.read_newline(stream, tokens))   continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    33
		if (this.read_space(stream, tokens))     continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    34
		if (this.read_word(stream, tokens))      continue;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    35
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    36
		// if execution reaches here then an error has happened
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    37
		tokens.push(new JSDOC.Token(stream.next(), "TOKN", "UNKNOWN_TOKEN"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    38
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    39
	return tokens;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    40
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    41
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    42
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    43
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    44
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    45
JSDOC.TokenReader.prototype.read_word = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    46
	var found = "";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    47
	while (!stream.look().eof && JSDOC.Lang.isWordChar(stream.look())) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    48
		found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    49
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    50
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    51
	if (found === "") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    52
		return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    53
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    54
	else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    55
		var name;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    56
		if ((name = JSDOC.Lang.keyword(found))) tokens.push(new JSDOC.Token(found, "KEYW", name));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    57
		else tokens.push(new JSDOC.Token(found, "NAME", "NAME"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    58
		return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    59
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    60
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    61
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    62
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    63
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    64
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    65
JSDOC.TokenReader.prototype.read_punc = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    66
	var found = "";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    67
	var name;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    68
	while (!stream.look().eof && JSDOC.Lang.punc(found+stream.look())) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    69
		found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    70
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    71
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    72
	if (found === "") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    73
		return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    74
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    75
	else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    76
		tokens.push(new JSDOC.Token(found, "PUNC", JSDOC.Lang.punc(found)));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    77
		return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    78
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    79
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    80
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    81
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    82
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    83
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    84
JSDOC.TokenReader.prototype.read_space = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    85
	var found = "";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    86
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    87
	while (!stream.look().eof && JSDOC.Lang.isSpace(stream.look())) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    88
		found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    89
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    90
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    91
	if (found === "") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    92
		return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    93
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    94
	else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    95
		if (this.collapseWhite) found = " ";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    96
		if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "SPACE"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    97
		return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    98
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
    99
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   100
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   101
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   102
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   103
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   104
JSDOC.TokenReader.prototype.read_newline = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   105
	var found = "";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   106
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   107
	while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look())) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   108
		found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   109
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   110
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   111
	if (found === "") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   112
		return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   113
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   114
	else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   115
		if (this.collapseWhite) found = "\n";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   116
		if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "NEWLINE"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   117
		return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   118
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   119
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   120
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   121
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   122
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   123
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   124
JSDOC.TokenReader.prototype.read_mlcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   125
	if (stream.look() == "/" && stream.look(1) == "*") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   126
		var found = stream.next(2);
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   127
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   128
		while (!stream.look().eof && !(stream.look(-1) == "/" && stream.look(-2) == "*")) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   129
			found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   130
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   131
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   132
		// to start doclet we allow /** or /*** but not /**/ or /****
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   133
		if (/^\/\*\*([^\/]|\*[^*])/.test(found) && this.keepDocs) tokens.push(new JSDOC.Token(found, "COMM", "JSDOC"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   134
		else if (this.keepComments) tokens.push(new JSDOC.Token(found, "COMM", "MULTI_LINE_COMM"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   135
		return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   136
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   137
	return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   138
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   139
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   140
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   141
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   142
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   143
JSDOC.TokenReader.prototype.read_slcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   144
	var found;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   145
	if (
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   146
		(stream.look() == "/" && stream.look(1) == "/" && (found=stream.next(2)))
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   147
		|| 
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   148
		(stream.look() == "<" && stream.look(1) == "!" && stream.look(2) == "-" && stream.look(3) == "-" && (found=stream.next(4)))
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   149
	) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   150
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   151
		while (!stream.look().eof && !JSDOC.Lang.isNewline(stream.look())) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   152
			found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   153
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   154
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   155
		if (this.keepComments) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   156
			tokens.push(new JSDOC.Token(found, "COMM", "SINGLE_LINE_COMM"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   157
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   158
		return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   159
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   160
	return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   161
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   162
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   163
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   164
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   165
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   166
JSDOC.TokenReader.prototype.read_dbquote = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   167
	if (stream.look() == "\"") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   168
		// find terminator
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   169
		var string = stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   170
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   171
		while (!stream.look().eof) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   172
			if (stream.look() == "\\") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   173
				if (JSDOC.Lang.isNewline(stream.look(1))) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   174
					do {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   175
						stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   176
					} while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look()));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   177
					string += "\\\n";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   178
				}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   179
				else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   180
					string += stream.next(2);
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   181
				}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   182
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   183
			else if (stream.look() == "\"") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   184
				string += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   185
				tokens.push(new JSDOC.Token(string, "STRN", "DOUBLE_QUOTE"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   186
				return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   187
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   188
			else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   189
				string += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   190
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   191
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   192
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   193
	return false; // error! unterminated string
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   194
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   195
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   196
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   197
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   198
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   199
JSDOC.TokenReader.prototype.read_snquote = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   200
	if (stream.look() == "'") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   201
		// find terminator
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   202
		var string = stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   203
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   204
		while (!stream.look().eof) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   205
			if (stream.look() == "\\") { // escape sequence
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   206
				string += stream.next(2);
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   207
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   208
			else if (stream.look() == "'") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   209
				string += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   210
				tokens.push(new JSDOC.Token(string, "STRN", "SINGLE_QUOTE"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   211
				return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   212
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   213
			else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   214
				string += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   215
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   216
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   217
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   218
	return false; // error! unterminated string
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   219
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   220
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   221
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   222
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   223
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   224
JSDOC.TokenReader.prototype.read_numb = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   225
	if (stream.look() === "0" && stream.look(1) == "x") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   226
		return this.read_hex(stream, tokens);
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   227
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   228
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   229
	var found = "";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   230
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   231
	while (!stream.look().eof && JSDOC.Lang.isNumber(found+stream.look())){
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   232
		found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   233
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   234
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   235
	if (found === "") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   236
		return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   237
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   238
	else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   239
		if (/^0[0-7]/.test(found)) tokens.push(new JSDOC.Token(found, "NUMB", "OCTAL"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   240
		else tokens.push(new JSDOC.Token(found, "NUMB", "DECIMAL"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   241
		return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   242
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   243
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   244
/*t:
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   245
	requires("../lib/JSDOC/TextStream.js");
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   246
	requires("../lib/JSDOC/Token.js");
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   247
	requires("../lib/JSDOC/Lang.js");
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   248
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   249
	plan(3, "testing JSDOC.TokenReader.prototype.read_numb");
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   250
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   251
	//// setup
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   252
	var src = "function foo(num){while (num+8.0 >= 0x20 && num < 0777){}}";
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   253
	var tr = new JSDOC.TokenReader();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   254
	var tokens = tr.tokenize(new JSDOC.TextStream(src));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   255
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   256
	var hexToken, octToken, decToken;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   257
	for (var i = 0; i < tokens.length; i++) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   258
		if (tokens[i].name == "HEX_DEC") hexToken = tokens[i];
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   259
		if (tokens[i].name == "OCTAL") octToken = tokens[i];
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   260
		if (tokens[i].name == "DECIMAL") decToken = tokens[i];
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   261
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   262
	////
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   263
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   264
	is(decToken.data, "8.0", "decimal number is found in source.");
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   265
	is(hexToken.data, "0x20", "hexdec number is found in source (issue #99).");
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   266
	is(octToken.data, "0777", "octal number is found in source.");
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   267
*/
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   268
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   269
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   270
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   271
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   272
JSDOC.TokenReader.prototype.read_hex = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   273
	var found = stream.next(2);
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   274
	
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   275
	while (!stream.look().eof) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   276
		if (JSDOC.Lang.isHexDec(found) && !JSDOC.Lang.isHexDec(found+stream.look())) { // done
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   277
			tokens.push(new JSDOC.Token(found, "NUMB", "HEX_DEC"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   278
			return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   279
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   280
		else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   281
			found += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   282
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   283
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   284
	return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   285
}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   286
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   287
/**
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   288
	@returns {Boolean} Was the token found?
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   289
 */
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   290
JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/stream, tokens) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   291
	var last;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   292
	if (
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   293
		stream.look() == "/"
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   294
		&& 
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   295
		(
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   296
			
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   297
			(
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   298
				!(last = tokens.lastSym()) // there is no last, the regex is the first symbol
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   299
				|| 
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   300
				(
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   301
					   !last.is("NUMB")
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   302
					&& !last.is("NAME")
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   303
					&& !last.is("RIGHT_PAREN")
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   304
					&& !last.is("RIGHT_BRACKET")
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   305
				)
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   306
			)
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   307
		)
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   308
	) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   309
		var regex = stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   310
		
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   311
		while (!stream.look().eof) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   312
			if (stream.look() == "\\") { // escape sequence
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   313
				regex += stream.next(2);
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   314
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   315
			else if (stream.look() == "/") {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   316
				regex += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   317
				
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   318
				while (/[gmi]/.test(stream.look())) {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   319
					regex += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   320
				}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   321
				
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   322
				tokens.push(new JSDOC.Token(regex, "REGX", "REGX"));
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   323
				return true;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   324
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   325
			else {
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   326
				regex += stream.next();
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   327
			}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   328
		}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   329
		// error: unterminated regex
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   330
	}
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   331
	return false;
c8f47f0b6697 JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff changeset
   332
}