Intial import
[gnome.introspection-doc-generator] / JSDOC / Token.js
1 //<Script type="text/javascript">
2 JSDOC   = imports['JSDOC.js'].JSDOC;
3 Roo     = imports['Roo.js'].Roo;
4 console = imports['console.js'].console;
5 /**
6         @constructor
7 */
8 Token = function(data, type, name) {
9         this.data = data;
10         this.type = type;
11         this.name = name;
12     this.prefix = '';
13 }
14
15 //JSDOC.Token.prototype.toString = function() { 
16 //      return "<"+this.type+" name=\""+this.name+"\">"+this.data+"</"+this.type+">";
17 //}
18 Roo.apply( Token.prototype, {
19     
20     toRaw : function(lvl)
21     {
22         lvl = lvl || 0;
23         
24         var ret =  this.data ;
25         if (this.items) {
26             var ar = [];
27             Roo.each(this.items, function(ai) {
28                 
29                 var str = '';
30                 Roo.each(ai, function(it) {
31                     str += it.toRaw(lvl + 1);
32                 })
33                 ar.push(str);
34                 
35             })
36             ret +=   ar.join('');
37             
38         }
39         if (this.props) {
40             for (var i in this.props) {
41                 ret += this.props[i].key.toRaw(lvl+1) + ' : ';
42                 Roo.each(this.props[i].val, function(e) {
43                     ret+=e.toRaw(lvl+1);
44                 })
45                 
46             }
47         }
48         
49         
50         
51         return this.prefix +   ret;
52          
53     },
54
55     toJS : function() {
56         
57         try {
58             var _tmp = '';
59             eval( "_tmp = " + this.data);
60             return _tmp;
61         } catch( e) {
62             return "ERROR unparsable" + this.data;
63         }
64     },
65      
66                     
67
68     is : function(what) {
69         return this.name === what || this.type === what;
70     }
71 });
72