Package: yui-compressor / 2.4.8-2

parser.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
YUI patch for the Rhino library's Parser.java
===================================================================
--- a/src/org/mozilla/javascript/Parser.java
+++ b/src/org/mozilla/javascript/Parser.java
@@ -169,11 +169,30 @@
     {
         int tt = currentFlaggedToken;
         if (tt == Token.EOF) {
-            tt = ts.getToken();
+
+            while ((tt = ts.getToken()) == Token.CONDCOMMENT || tt == Token.KEEPCOMMENT) {
+                if (tt == Token.CONDCOMMENT) {
+                    /* Support for JScript conditional comments */
+                    decompiler.addJScriptConditionalComment(ts.getString());
+                } else {
+                    /* Support for preserved comments */
+                    decompiler.addPreservedComment(ts.getString());
+                }
+            }
+
             if (tt == Token.EOL) {
                 do {
                     tt = ts.getToken();
-                } while (tt == Token.EOL);
+
+                    if (tt == Token.CONDCOMMENT) {
+                        /* Support for JScript conditional comments */
+                        decompiler.addJScriptConditionalComment(ts.getString());
+                    } else if (tt == Token.KEEPCOMMENT) {
+                        /* Support for preserved comments */
+                        decompiler.addPreservedComment(ts.getString());
+                    }
+
+                } while (tt == Token.EOL || tt == Token.CONDCOMMENT || tt == Token.KEEPCOMMENT);
                 tt |= TI_AFTER_EOL;
             }
             currentFlaggedToken = tt;