1 /* Generated by re2c 0.13.5 on Tue Jan 26 01:16:33 2010 */
3 * Copyright (C) 2009 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 WebInspector.SourceTokenizer = function()
36 WebInspector.SourceTokenizer.prototype = {
41 set condition(condition)
43 this._condition = condition;
48 return this._condition;
51 getLexCondition: function()
53 return this.condition.lexCondition;
56 setLexCondition: function(lexCondition)
58 this.condition.lexCondition = lexCondition;
61 _charAt: function(cursor)
63 return cursor < this._line.length ? this._line.charAt(cursor) : "\n";
68 WebInspector.SourceTokenizer.Registry = function() {
69 this._tokenizers = {};
70 this._tokenizerConstructors = {
71 "text/css": "SourceCSSTokenizer",
72 "text/html": "SourceHTMLTokenizer",
73 "text/javascript": "SourceJavaScriptTokenizer"
77 WebInspector.SourceTokenizer.Registry.getInstance = function()
79 if (!WebInspector.SourceTokenizer.Registry._instance)
80 WebInspector.SourceTokenizer.Registry._instance = new WebInspector.SourceTokenizer.Registry();
81 return WebInspector.SourceTokenizer.Registry._instance;
84 WebInspector.SourceTokenizer.Registry.prototype = {
85 getTokenizer: function(mimeType)
87 if (!this._tokenizerConstructors[mimeType])
89 var tokenizerClass = this._tokenizerConstructors[mimeType];
90 var tokenizer = this._tokenizers[tokenizerClass];
92 tokenizer = new WebInspector[tokenizerClass]();
93 this._tokenizers[tokenizerClass] = tokenizer;