SourceHTMLTokenizer.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. /* Generated by re2c 0.13.5 on Fri May 6 13:47:06 2011 */
  2. /*
  3. * Copyright (C) 2009 Google Inc. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are
  7. * met:
  8. *
  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
  14. * distribution.
  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.
  18. *
  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.
  30. */
  31. // Generate js file as follows:
  32. //
  33. // re2c -isc WebCore/inspector/front-end/SourceHTMLTokenizer.re2js \
  34. // | sed 's|^yy\([^:]*\)*\:|case \1:|' \
  35. // | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
  36. // | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
  37. // | sed 's|[*]cursor|this._charAt(cursor)|' \
  38. // | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
  39. // | sed 's|{ gotoCase = \([^; continue; };]*\)|{ gotoCase = \1; continue; }|' \
  40. // | sed 's|unsigned\ int|var|' \
  41. // | sed 's|var\ yych|case 1: case 1: var yych|'
  42. /**
  43. * @constructor
  44. * @extends {WebInspector.SourceTokenizer}
  45. */
  46. WebInspector.SourceHTMLTokenizer = function()
  47. {
  48. WebInspector.SourceTokenizer.call(this);
  49. // The order is determined by the generated code.
  50. this._lexConditions = {
  51. INITIAL: 0,
  52. COMMENT: 1,
  53. DOCTYPE: 2,
  54. TAG: 3,
  55. DSTRING: 4,
  56. SSTRING: 5
  57. };
  58. this.case_INITIAL = 1000;
  59. this.case_COMMENT = 1001;
  60. this.case_DOCTYPE = 1002;
  61. this.case_TAG = 1003;
  62. this.case_DSTRING = 1004;
  63. this.case_SSTRING = 1005;
  64. this._parseConditions = {
  65. INITIAL: 0,
  66. ATTRIBUTE: 1,
  67. ATTRIBUTE_VALUE: 2,
  68. LINKIFY: 4,
  69. A_NODE: 8,
  70. SCRIPT: 16,
  71. STYLE: 32
  72. };
  73. this.condition = this.createInitialCondition();
  74. }
  75. WebInspector.SourceHTMLTokenizer.prototype = {
  76. createInitialCondition: function()
  77. {
  78. return { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL };
  79. },
  80. set line(line) {
  81. if (this._condition.internalJavaScriptTokenizerCondition) {
  82. var match = /<\/script/i.exec(line);
  83. if (match) {
  84. this._internalJavaScriptTokenizer.line = line.substring(0, match.index);
  85. } else
  86. this._internalJavaScriptTokenizer.line = line;
  87. } else if (this._condition.internalCSSTokenizerCondition) {
  88. var match = /<\/style/i.exec(line);
  89. if (match) {
  90. this._internalCSSTokenizer.line = line.substring(0, match.index);
  91. } else
  92. this._internalCSSTokenizer.line = line;
  93. }
  94. this._line = line;
  95. },
  96. _isExpectingAttribute: function()
  97. {
  98. return this._condition.parseCondition & this._parseConditions.ATTRIBUTE;
  99. },
  100. _isExpectingAttributeValue: function()
  101. {
  102. return this._condition.parseCondition & this._parseConditions.ATTRIBUTE_VALUE;
  103. },
  104. _setExpectingAttribute: function()
  105. {
  106. if (this._isExpectingAttributeValue())
  107. this._condition.parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE;
  108. this._condition.parseCondition |= this._parseConditions.ATTRIBUTE;
  109. },
  110. _setExpectingAttributeValue: function()
  111. {
  112. if (this._isExpectingAttribute())
  113. this._condition.parseCondition ^= this._parseConditions.ATTRIBUTE;
  114. this._condition.parseCondition |= this._parseConditions.ATTRIBUTE_VALUE;
  115. },
  116. /**
  117. * @param {boolean=} stringEnds
  118. */
  119. _stringToken: function(cursor, stringEnds)
  120. {
  121. if (!this._isExpectingAttributeValue()) {
  122. this.tokenType = null;
  123. return cursor;
  124. }
  125. this.tokenType = this._attrValueTokenType();
  126. if (stringEnds)
  127. this._setExpectingAttribute();
  128. return cursor;
  129. },
  130. _attrValueTokenType: function()
  131. {
  132. if (this._condition.parseCondition & this._parseConditions.LINKIFY) {
  133. if (this._condition.parseCondition & this._parseConditions.A_NODE)
  134. return "html-external-link";
  135. return "html-resource-link";
  136. }
  137. return "html-attribute-value";
  138. },
  139. get _internalJavaScriptTokenizer()
  140. {
  141. return WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/javascript");
  142. },
  143. get _internalCSSTokenizer()
  144. {
  145. return WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/css");
  146. },
  147. scriptStarted: function(cursor)
  148. {
  149. this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.createInitialCondition();
  150. },
  151. scriptEnded: function(cursor)
  152. {
  153. },
  154. styleSheetStarted: function(cursor)
  155. {
  156. this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.createInitialCondition();
  157. },
  158. styleSheetEnded: function(cursor)
  159. {
  160. },
  161. nextToken: function(cursor)
  162. {
  163. if (this._condition.internalJavaScriptTokenizerCondition) {
  164. // Re-set line to force </script> detection first.
  165. this.line = this._line;
  166. if (cursor !== this._internalJavaScriptTokenizer._line.length) {
  167. // Tokenizer is stateless, so restore its condition before tokenizing and save it after.
  168. this._internalJavaScriptTokenizer.condition = this._condition.internalJavaScriptTokenizerCondition;
  169. var result = this._internalJavaScriptTokenizer.nextToken(cursor);
  170. this.tokenType = this._internalJavaScriptTokenizer.tokenType;
  171. this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.condition;
  172. return result;
  173. } else if (cursor !== this._line.length)
  174. delete this._condition.internalJavaScriptTokenizerCondition;
  175. } else if (this._condition.internalCSSTokenizerCondition) {
  176. // Re-set line to force </style> detection first.
  177. this.line = this._line;
  178. if (cursor !== this._internalCSSTokenizer._line.length) {
  179. // Tokenizer is stateless, so restore its condition before tokenizing and save it after.
  180. this._internalCSSTokenizer.condition = this._condition.internalCSSTokenizerCondition;
  181. var result = this._internalCSSTokenizer.nextToken(cursor);
  182. this.tokenType = this._internalCSSTokenizer.tokenType;
  183. this._condition.internalCSSTokenizerCondition = this._internalCSSTokenizer.condition;
  184. return result;
  185. } else if (cursor !== this._line.length)
  186. delete this._condition.internalCSSTokenizerCondition;
  187. }
  188. var cursorOnEnter = cursor;
  189. var gotoCase = 1;
  190. var YYMARKER;
  191. while (1) {
  192. switch (gotoCase)
  193. // Following comment is replaced with generated state machine.
  194. {
  195. case 1: var yych;
  196. var yyaccept = 0;
  197. if (this.getLexCondition() < 3) {
  198. if (this.getLexCondition() < 1) {
  199. { gotoCase = this.case_INITIAL; continue; };
  200. } else {
  201. if (this.getLexCondition() < 2) {
  202. { gotoCase = this.case_COMMENT; continue; };
  203. } else {
  204. { gotoCase = this.case_DOCTYPE; continue; };
  205. }
  206. }
  207. } else {
  208. if (this.getLexCondition() < 4) {
  209. { gotoCase = this.case_TAG; continue; };
  210. } else {
  211. if (this.getLexCondition() < 5) {
  212. { gotoCase = this.case_DSTRING; continue; };
  213. } else {
  214. { gotoCase = this.case_SSTRING; continue; };
  215. }
  216. }
  217. }
  218. /* *********************************** */
  219. case this.case_COMMENT:
  220. yych = this._charAt(cursor);
  221. if (yych <= '\f') {
  222. if (yych == '\n') { gotoCase = 4; continue; };
  223. { gotoCase = 3; continue; };
  224. } else {
  225. if (yych <= '\r') { gotoCase = 4; continue; };
  226. if (yych == '-') { gotoCase = 6; continue; };
  227. { gotoCase = 3; continue; };
  228. }
  229. case 2:
  230. { this.tokenType = "html-comment"; return cursor; }
  231. case 3:
  232. yyaccept = 0;
  233. yych = this._charAt(YYMARKER = ++cursor);
  234. { gotoCase = 9; continue; };
  235. case 4:
  236. ++cursor;
  237. case 5:
  238. { this.tokenType = null; return cursor; }
  239. case 6:
  240. yyaccept = 1;
  241. yych = this._charAt(YYMARKER = ++cursor);
  242. if (yych != '-') { gotoCase = 5; continue; };
  243. case 7:
  244. ++cursor;
  245. yych = this._charAt(cursor);
  246. if (yych == '>') { gotoCase = 10; continue; };
  247. case 8:
  248. yyaccept = 0;
  249. YYMARKER = ++cursor;
  250. yych = this._charAt(cursor);
  251. case 9:
  252. if (yych <= '\f') {
  253. if (yych == '\n') { gotoCase = 2; continue; };
  254. { gotoCase = 8; continue; };
  255. } else {
  256. if (yych <= '\r') { gotoCase = 2; continue; };
  257. if (yych == '-') { gotoCase = 12; continue; };
  258. { gotoCase = 8; continue; };
  259. }
  260. case 10:
  261. ++cursor;
  262. this.setLexCondition(this._lexConditions.INITIAL);
  263. { this.tokenType = "html-comment"; return cursor; }
  264. case 12:
  265. ++cursor;
  266. yych = this._charAt(cursor);
  267. if (yych == '-') { gotoCase = 7; continue; };
  268. cursor = YYMARKER;
  269. if (yyaccept <= 0) {
  270. { gotoCase = 2; continue; };
  271. } else {
  272. { gotoCase = 5; continue; };
  273. }
  274. /* *********************************** */
  275. case this.case_DOCTYPE:
  276. yych = this._charAt(cursor);
  277. if (yych <= '\f') {
  278. if (yych == '\n') { gotoCase = 18; continue; };
  279. { gotoCase = 17; continue; };
  280. } else {
  281. if (yych <= '\r') { gotoCase = 18; continue; };
  282. if (yych == '>') { gotoCase = 20; continue; };
  283. { gotoCase = 17; continue; };
  284. }
  285. case 16:
  286. { this.tokenType = "html-doctype"; return cursor; }
  287. case 17:
  288. yych = this._charAt(++cursor);
  289. { gotoCase = 23; continue; };
  290. case 18:
  291. ++cursor;
  292. { this.tokenType = null; return cursor; }
  293. case 20:
  294. ++cursor;
  295. this.setLexCondition(this._lexConditions.INITIAL);
  296. { this.tokenType = "html-doctype"; return cursor; }
  297. case 22:
  298. ++cursor;
  299. yych = this._charAt(cursor);
  300. case 23:
  301. if (yych <= '\f') {
  302. if (yych == '\n') { gotoCase = 16; continue; };
  303. { gotoCase = 22; continue; };
  304. } else {
  305. if (yych <= '\r') { gotoCase = 16; continue; };
  306. if (yych == '>') { gotoCase = 16; continue; };
  307. { gotoCase = 22; continue; };
  308. }
  309. /* *********************************** */
  310. case this.case_DSTRING:
  311. yych = this._charAt(cursor);
  312. if (yych <= '\f') {
  313. if (yych == '\n') { gotoCase = 28; continue; };
  314. { gotoCase = 27; continue; };
  315. } else {
  316. if (yych <= '\r') { gotoCase = 28; continue; };
  317. if (yych == '"') { gotoCase = 30; continue; };
  318. { gotoCase = 27; continue; };
  319. }
  320. case 26:
  321. { return this._stringToken(cursor); }
  322. case 27:
  323. yych = this._charAt(++cursor);
  324. { gotoCase = 34; continue; };
  325. case 28:
  326. ++cursor;
  327. { this.tokenType = null; return cursor; }
  328. case 30:
  329. ++cursor;
  330. case 31:
  331. this.setLexCondition(this._lexConditions.TAG);
  332. { return this._stringToken(cursor, true); }
  333. case 32:
  334. yych = this._charAt(++cursor);
  335. { gotoCase = 31; continue; };
  336. case 33:
  337. ++cursor;
  338. yych = this._charAt(cursor);
  339. case 34:
  340. if (yych <= '\f') {
  341. if (yych == '\n') { gotoCase = 26; continue; };
  342. { gotoCase = 33; continue; };
  343. } else {
  344. if (yych <= '\r') { gotoCase = 26; continue; };
  345. if (yych == '"') { gotoCase = 32; continue; };
  346. { gotoCase = 33; continue; };
  347. }
  348. /* *********************************** */
  349. case this.case_INITIAL:
  350. yych = this._charAt(cursor);
  351. if (yych == '<') { gotoCase = 39; continue; };
  352. ++cursor;
  353. { this.tokenType = null; return cursor; }
  354. case 39:
  355. yyaccept = 0;
  356. yych = this._charAt(YYMARKER = ++cursor);
  357. if (yych <= '/') {
  358. if (yych == '!') { gotoCase = 44; continue; };
  359. if (yych >= '/') { gotoCase = 41; continue; };
  360. } else {
  361. if (yych <= 'S') {
  362. if (yych >= 'S') { gotoCase = 42; continue; };
  363. } else {
  364. if (yych == 's') { gotoCase = 42; continue; };
  365. }
  366. }
  367. case 40:
  368. this.setLexCondition(this._lexConditions.TAG);
  369. {
  370. if (this._condition.parseCondition & (this._parseConditions.SCRIPT | this._parseConditions.STYLE)) {
  371. // Do not tokenize script and style tag contents, keep lexer state, even though processing "<".
  372. this.setLexCondition(this._lexConditions.INITIAL);
  373. this.tokenType = null;
  374. return cursor;
  375. }
  376. this._condition.parseCondition = this._parseConditions.INITIAL;
  377. this.tokenType = "html-tag";
  378. return cursor;
  379. }
  380. case 41:
  381. yyaccept = 0;
  382. yych = this._charAt(YYMARKER = ++cursor);
  383. if (yych == 'S') { gotoCase = 73; continue; };
  384. if (yych == 's') { gotoCase = 73; continue; };
  385. { gotoCase = 40; continue; };
  386. case 42:
  387. yych = this._charAt(++cursor);
  388. if (yych <= 'T') {
  389. if (yych == 'C') { gotoCase = 62; continue; };
  390. if (yych >= 'T') { gotoCase = 63; continue; };
  391. } else {
  392. if (yych <= 'c') {
  393. if (yych >= 'c') { gotoCase = 62; continue; };
  394. } else {
  395. if (yych == 't') { gotoCase = 63; continue; };
  396. }
  397. }
  398. case 43:
  399. cursor = YYMARKER;
  400. { gotoCase = 40; continue; };
  401. case 44:
  402. yych = this._charAt(++cursor);
  403. if (yych <= 'C') {
  404. if (yych != '-') { gotoCase = 43; continue; };
  405. } else {
  406. if (yych <= 'D') { gotoCase = 46; continue; };
  407. if (yych == 'd') { gotoCase = 46; continue; };
  408. { gotoCase = 43; continue; };
  409. }
  410. yych = this._charAt(++cursor);
  411. if (yych == '-') { gotoCase = 54; continue; };
  412. { gotoCase = 43; continue; };
  413. case 46:
  414. yych = this._charAt(++cursor);
  415. if (yych == 'O') { gotoCase = 47; continue; };
  416. if (yych != 'o') { gotoCase = 43; continue; };
  417. case 47:
  418. yych = this._charAt(++cursor);
  419. if (yych == 'C') { gotoCase = 48; continue; };
  420. if (yych != 'c') { gotoCase = 43; continue; };
  421. case 48:
  422. yych = this._charAt(++cursor);
  423. if (yych == 'T') { gotoCase = 49; continue; };
  424. if (yych != 't') { gotoCase = 43; continue; };
  425. case 49:
  426. yych = this._charAt(++cursor);
  427. if (yych == 'Y') { gotoCase = 50; continue; };
  428. if (yych != 'y') { gotoCase = 43; continue; };
  429. case 50:
  430. yych = this._charAt(++cursor);
  431. if (yych == 'P') { gotoCase = 51; continue; };
  432. if (yych != 'p') { gotoCase = 43; continue; };
  433. case 51:
  434. yych = this._charAt(++cursor);
  435. if (yych == 'E') { gotoCase = 52; continue; };
  436. if (yych != 'e') { gotoCase = 43; continue; };
  437. case 52:
  438. ++cursor;
  439. this.setLexCondition(this._lexConditions.DOCTYPE);
  440. { this.tokenType = "html-doctype"; return cursor; }
  441. case 54:
  442. ++cursor;
  443. yych = this._charAt(cursor);
  444. if (yych <= '\f') {
  445. if (yych == '\n') { gotoCase = 57; continue; };
  446. { gotoCase = 54; continue; };
  447. } else {
  448. if (yych <= '\r') { gotoCase = 57; continue; };
  449. if (yych != '-') { gotoCase = 54; continue; };
  450. }
  451. ++cursor;
  452. yych = this._charAt(cursor);
  453. if (yych == '-') { gotoCase = 59; continue; };
  454. { gotoCase = 43; continue; };
  455. case 57:
  456. ++cursor;
  457. this.setLexCondition(this._lexConditions.COMMENT);
  458. { this.tokenType = "html-comment"; return cursor; }
  459. case 59:
  460. ++cursor;
  461. yych = this._charAt(cursor);
  462. if (yych != '>') { gotoCase = 54; continue; };
  463. ++cursor;
  464. { this.tokenType = "html-comment"; return cursor; }
  465. case 62:
  466. yych = this._charAt(++cursor);
  467. if (yych == 'R') { gotoCase = 68; continue; };
  468. if (yych == 'r') { gotoCase = 68; continue; };
  469. { gotoCase = 43; continue; };
  470. case 63:
  471. yych = this._charAt(++cursor);
  472. if (yych == 'Y') { gotoCase = 64; continue; };
  473. if (yych != 'y') { gotoCase = 43; continue; };
  474. case 64:
  475. yych = this._charAt(++cursor);
  476. if (yych == 'L') { gotoCase = 65; continue; };
  477. if (yych != 'l') { gotoCase = 43; continue; };
  478. case 65:
  479. yych = this._charAt(++cursor);
  480. if (yych == 'E') { gotoCase = 66; continue; };
  481. if (yych != 'e') { gotoCase = 43; continue; };
  482. case 66:
  483. ++cursor;
  484. this.setLexCondition(this._lexConditions.TAG);
  485. {
  486. if (this._condition.parseCondition & this._parseConditions.STYLE) {
  487. // Do not tokenize style tag contents, keep lexer state, even though processing "<".
  488. this.setLexCondition(this._lexConditions.INITIAL);
  489. this.tokenType = null;
  490. return cursor;
  491. }
  492. this.tokenType = "html-tag";
  493. this._condition.parseCondition = this._parseConditions.STYLE;
  494. this._setExpectingAttribute();
  495. return cursor;
  496. }
  497. case 68:
  498. yych = this._charAt(++cursor);
  499. if (yych == 'I') { gotoCase = 69; continue; };
  500. if (yych != 'i') { gotoCase = 43; continue; };
  501. case 69:
  502. yych = this._charAt(++cursor);
  503. if (yych == 'P') { gotoCase = 70; continue; };
  504. if (yych != 'p') { gotoCase = 43; continue; };
  505. case 70:
  506. yych = this._charAt(++cursor);
  507. if (yych == 'T') { gotoCase = 71; continue; };
  508. if (yych != 't') { gotoCase = 43; continue; };
  509. case 71:
  510. ++cursor;
  511. this.setLexCondition(this._lexConditions.TAG);
  512. {
  513. if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
  514. // Do not tokenize script tag contents, keep lexer state, even though processing "<".
  515. this.setLexCondition(this._lexConditions.INITIAL);
  516. this.tokenType = null;
  517. return cursor;
  518. }
  519. this.tokenType = "html-tag";
  520. this._condition.parseCondition = this._parseConditions.SCRIPT;
  521. this._setExpectingAttribute();
  522. return cursor;
  523. }
  524. case 73:
  525. yych = this._charAt(++cursor);
  526. if (yych <= 'T') {
  527. if (yych == 'C') { gotoCase = 75; continue; };
  528. if (yych <= 'S') { gotoCase = 43; continue; };
  529. } else {
  530. if (yych <= 'c') {
  531. if (yych <= 'b') { gotoCase = 43; continue; };
  532. { gotoCase = 75; continue; };
  533. } else {
  534. if (yych != 't') { gotoCase = 43; continue; };
  535. }
  536. }
  537. yych = this._charAt(++cursor);
  538. if (yych == 'Y') { gotoCase = 81; continue; };
  539. if (yych == 'y') { gotoCase = 81; continue; };
  540. { gotoCase = 43; continue; };
  541. case 75:
  542. yych = this._charAt(++cursor);
  543. if (yych == 'R') { gotoCase = 76; continue; };
  544. if (yych != 'r') { gotoCase = 43; continue; };
  545. case 76:
  546. yych = this._charAt(++cursor);
  547. if (yych == 'I') { gotoCase = 77; continue; };
  548. if (yych != 'i') { gotoCase = 43; continue; };
  549. case 77:
  550. yych = this._charAt(++cursor);
  551. if (yych == 'P') { gotoCase = 78; continue; };
  552. if (yych != 'p') { gotoCase = 43; continue; };
  553. case 78:
  554. yych = this._charAt(++cursor);
  555. if (yych == 'T') { gotoCase = 79; continue; };
  556. if (yych != 't') { gotoCase = 43; continue; };
  557. case 79:
  558. ++cursor;
  559. this.setLexCondition(this._lexConditions.TAG);
  560. {
  561. this.tokenType = "html-tag";
  562. this._condition.parseCondition = this._parseConditions.INITIAL;
  563. this.scriptEnded(cursor - 8);
  564. return cursor;
  565. }
  566. case 81:
  567. yych = this._charAt(++cursor);
  568. if (yych == 'L') { gotoCase = 82; continue; };
  569. if (yych != 'l') { gotoCase = 43; continue; };
  570. case 82:
  571. yych = this._charAt(++cursor);
  572. if (yych == 'E') { gotoCase = 83; continue; };
  573. if (yych != 'e') { gotoCase = 43; continue; };
  574. case 83:
  575. ++cursor;
  576. this.setLexCondition(this._lexConditions.TAG);
  577. {
  578. this.tokenType = "html-tag";
  579. this._condition.parseCondition = this._parseConditions.INITIAL;
  580. this.styleSheetEnded(cursor - 7);
  581. return cursor;
  582. }
  583. /* *********************************** */
  584. case this.case_SSTRING:
  585. yych = this._charAt(cursor);
  586. if (yych <= '\f') {
  587. if (yych == '\n') { gotoCase = 89; continue; };
  588. { gotoCase = 88; continue; };
  589. } else {
  590. if (yych <= '\r') { gotoCase = 89; continue; };
  591. if (yych == '\'') { gotoCase = 91; continue; };
  592. { gotoCase = 88; continue; };
  593. }
  594. case 87:
  595. { return this._stringToken(cursor); }
  596. case 88:
  597. yych = this._charAt(++cursor);
  598. { gotoCase = 95; continue; };
  599. case 89:
  600. ++cursor;
  601. { this.tokenType = null; return cursor; }
  602. case 91:
  603. ++cursor;
  604. case 92:
  605. this.setLexCondition(this._lexConditions.TAG);
  606. { return this._stringToken(cursor, true); }
  607. case 93:
  608. yych = this._charAt(++cursor);
  609. { gotoCase = 92; continue; };
  610. case 94:
  611. ++cursor;
  612. yych = this._charAt(cursor);
  613. case 95:
  614. if (yych <= '\f') {
  615. if (yych == '\n') { gotoCase = 87; continue; };
  616. { gotoCase = 94; continue; };
  617. } else {
  618. if (yych <= '\r') { gotoCase = 87; continue; };
  619. if (yych == '\'') { gotoCase = 93; continue; };
  620. { gotoCase = 94; continue; };
  621. }
  622. /* *********************************** */
  623. case this.case_TAG:
  624. yych = this._charAt(cursor);
  625. if (yych <= '&') {
  626. if (yych <= '\r') {
  627. if (yych == '\n') { gotoCase = 100; continue; };
  628. if (yych >= '\r') { gotoCase = 100; continue; };
  629. } else {
  630. if (yych <= ' ') {
  631. if (yych >= ' ') { gotoCase = 100; continue; };
  632. } else {
  633. if (yych == '"') { gotoCase = 102; continue; };
  634. }
  635. }
  636. } else {
  637. if (yych <= '>') {
  638. if (yych <= ';') {
  639. if (yych <= '\'') { gotoCase = 103; continue; };
  640. } else {
  641. if (yych <= '<') { gotoCase = 100; continue; };
  642. if (yych <= '=') { gotoCase = 104; continue; };
  643. { gotoCase = 106; continue; };
  644. }
  645. } else {
  646. if (yych <= '[') {
  647. if (yych >= '[') { gotoCase = 100; continue; };
  648. } else {
  649. if (yych == ']') { gotoCase = 100; continue; };
  650. }
  651. }
  652. }
  653. ++cursor;
  654. yych = this._charAt(cursor);
  655. { gotoCase = 119; continue; };
  656. case 99:
  657. {
  658. if (this._condition.parseCondition === this._parseConditions.SCRIPT || this._condition.parseCondition === this._parseConditions.STYLE) {
  659. // Fall through if expecting attributes.
  660. this.tokenType = null;
  661. return cursor;
  662. }
  663. if (this._condition.parseCondition === this._parseConditions.INITIAL) {
  664. this.tokenType = "html-tag";
  665. this._setExpectingAttribute();
  666. var token = this._line.substring(cursorOnEnter, cursor);
  667. if (token === "a")
  668. this._condition.parseCondition |= this._parseConditions.A_NODE;
  669. else if (this._condition.parseCondition & this._parseConditions.A_NODE)
  670. this._condition.parseCondition ^= this._parseConditions.A_NODE;
  671. } else if (this._isExpectingAttribute()) {
  672. var token = this._line.substring(cursorOnEnter, cursor);
  673. if (token === "href" || token === "src")
  674. this._condition.parseCondition |= this._parseConditions.LINKIFY;
  675. else if (this._condition.parseCondition |= this._parseConditions.LINKIFY)
  676. this._condition.parseCondition ^= this._parseConditions.LINKIFY;
  677. this.tokenType = "html-attribute-name";
  678. } else if (this._isExpectingAttributeValue())
  679. this.tokenType = this._attrValueTokenType();
  680. else
  681. this.tokenType = null;
  682. return cursor;
  683. }
  684. case 100:
  685. ++cursor;
  686. { this.tokenType = null; return cursor; }
  687. case 102:
  688. yyaccept = 0;
  689. yych = this._charAt(YYMARKER = ++cursor);
  690. { gotoCase = 115; continue; };
  691. case 103:
  692. yyaccept = 0;
  693. yych = this._charAt(YYMARKER = ++cursor);
  694. { gotoCase = 109; continue; };
  695. case 104:
  696. ++cursor;
  697. {
  698. if (this._isExpectingAttribute())
  699. this._setExpectingAttributeValue();
  700. this.tokenType = null;
  701. return cursor;
  702. }
  703. case 106:
  704. ++cursor;
  705. this.setLexCondition(this._lexConditions.INITIAL);
  706. {
  707. this.tokenType = "html-tag";
  708. if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
  709. this.scriptStarted(cursor);
  710. // Do not tokenize script tag contents.
  711. return cursor;
  712. }
  713. if (this._condition.parseCondition & this._parseConditions.STYLE) {
  714. this.styleSheetStarted(cursor);
  715. // Do not tokenize style tag contents.
  716. return cursor;
  717. }
  718. this._condition.parseCondition = this._parseConditions.INITIAL;
  719. return cursor;
  720. }
  721. case 108:
  722. ++cursor;
  723. yych = this._charAt(cursor);
  724. case 109:
  725. if (yych <= '\f') {
  726. if (yych != '\n') { gotoCase = 108; continue; };
  727. } else {
  728. if (yych <= '\r') { gotoCase = 110; continue; };
  729. if (yych == '\'') { gotoCase = 112; continue; };
  730. { gotoCase = 108; continue; };
  731. }
  732. case 110:
  733. ++cursor;
  734. this.setLexCondition(this._lexConditions.SSTRING);
  735. { return this._stringToken(cursor); }
  736. case 112:
  737. ++cursor;
  738. { return this._stringToken(cursor, true); }
  739. case 114:
  740. ++cursor;
  741. yych = this._charAt(cursor);
  742. case 115:
  743. if (yych <= '\f') {
  744. if (yych != '\n') { gotoCase = 114; continue; };
  745. } else {
  746. if (yych <= '\r') { gotoCase = 116; continue; };
  747. if (yych == '"') { gotoCase = 112; continue; };
  748. { gotoCase = 114; continue; };
  749. }
  750. case 116:
  751. ++cursor;
  752. this.setLexCondition(this._lexConditions.DSTRING);
  753. { return this._stringToken(cursor); }
  754. case 118:
  755. ++cursor;
  756. yych = this._charAt(cursor);
  757. case 119:
  758. if (yych <= '"') {
  759. if (yych <= '\r') {
  760. if (yych == '\n') { gotoCase = 99; continue; };
  761. if (yych <= '\f') { gotoCase = 118; continue; };
  762. { gotoCase = 99; continue; };
  763. } else {
  764. if (yych == ' ') { gotoCase = 99; continue; };
  765. if (yych <= '!') { gotoCase = 118; continue; };
  766. { gotoCase = 99; continue; };
  767. }
  768. } else {
  769. if (yych <= '>') {
  770. if (yych == '\'') { gotoCase = 99; continue; };
  771. if (yych <= ';') { gotoCase = 118; continue; };
  772. { gotoCase = 99; continue; };
  773. } else {
  774. if (yych <= '[') {
  775. if (yych <= 'Z') { gotoCase = 118; continue; };
  776. { gotoCase = 99; continue; };
  777. } else {
  778. if (yych == ']') { gotoCase = 99; continue; };
  779. { gotoCase = 118; continue; };
  780. }
  781. }
  782. }
  783. }
  784. }
  785. },
  786. __proto__: WebInspector.SourceTokenizer.prototype
  787. }