[gtksourceview: 1/5] javascript.lang: Support 'export * as ns from "mod"'



commit 97e14db7852b95a4ad6582777a5c474533f9956a
Author: Jeffery To <jeffery to gmail com>
Date:   Fri Jan 17 21:51:08 2020 +0800

    javascript.lang: Support 'export * as ns from "mod"'
    
    This was not considered a "proposal" but is still new syntax for ES2020.
    
    References:
    * https://github.com/tc39/ecma262/pull/1174
    * https://github.com/tc39/proposal-export-ns-from

 data/language-specs/javascript-modules.lang | 126 ++++++++++++----------------
 tests/syntax-highlighting/file.j            |   3 +-
 tests/syntax-highlighting/file.js           |   3 +-
 tests/syntax-highlighting/file.jsx          |   3 +-
 tests/syntax-highlighting/file.ts           |   3 +-
 tests/syntax-highlighting/file.tsx          |   3 +-
 6 files changed, 64 insertions(+), 77 deletions(-)
---
diff --git a/data/language-specs/javascript-modules.lang b/data/language-specs/javascript-modules.lang
index 92748af5..44faf61c 100644
--- a/data/language-specs/javascript-modules.lang
+++ b/data/language-specs/javascript-modules.lang
@@ -67,6 +67,54 @@
       </include>
     </context> <!-- /_ordered-from-module -->
 
+    <!-- ## (Import) all / as namespace
+
+         * from 'module';
+         * as ns from 'module';
+    -->
+
+    <context id="_as-namespace" once-only="true">
+      <start>\%[as\%]</start>
+      <end>\%{js:before-next-token}</end>
+      <include>
+        <context sub-pattern="0" where="start" style-ref="js:keyword"/>
+        <context ref="js:embedded-lang-hooks"/>
+        <context ref="js:comments"/>
+
+        <context id="_as-namespace-content">
+          <include>
+            <context ref="js:identifier"/>
+          </include>
+        </context> <!-- /_as-namespace-content -->
+
+      </include>
+    </context> <!-- /_as-namespace -->
+
+    <context id="_ordered-as-namespace" once-only="true">
+      <start>\%{js:before-next-token}</start>
+      <end>\%{js:before-next-token}</end>
+      <include>
+        <context ref="_as-namespace"/>
+      </include>
+    </context> <!-- /_ordered-as-namespace -->
+
+    <context id="_choice-all-as-namespace" end-parent="true">
+      <start>\*</start>
+      <end>\%{js:statement-end}</end>
+      <include>
+        <context ref="js:embedded-lang-hooks"/>
+        <context ref="js:comments"/>
+
+        <context id="_import-as-namespace-content">
+          <include>
+            <context ref="_ordered-as-namespace"/>
+            <context ref="_ordered-from-module"/>
+          </include>
+        </context> <!-- /_import-as-namespace-content -->
+
+      </include>
+    </context> <!-- /_choice-all-as-namespace -->
+
     <!-- ## Export / import name group
 
          { x, y as b }
@@ -220,33 +268,13 @@
       </include>
     </context> <!-- /_choice-export-default -->
 
-    <!-- ## Export all
-
-         export * from 'module';
-    -->
-
-    <context id="_choice-export-all" end-parent="true">
-      <start>\*</start>
-      <end>\%{js:statement-end}</end>
-      <include>
-        <context ref="js:embedded-lang-hooks"/>
-        <context ref="js:comments"/>
-
-        <context id="_export-all-content">
-          <include>
-            <context ref="_ordered-from-module"/>
-          </include>
-        </context> <!-- /_export-all-content -->
-
-      </include>
-    </context> <!-- /_choice-export-all -->
-
     <!-- ## Export declaration
 
          export { foo, bar as barry };
          export const a = 1;
          export default function () { ... }
          export * from 'module';
+         export * as ns from 'module';
     -->
 
     <!-- <ExportDeclaration> -->
@@ -262,7 +290,7 @@
           <include>
             <context ref="_choice-export-named"/>
             <context ref="_choice-export-default"/>
-            <context ref="_choice-export-all"/>
+            <context ref="_choice-all-as-namespace"/>
             <context ref="js-fn:choice-class-expression-required-name"/>
             <context ref="js-fn:choice-function-expression"/>
             <context ref="js-st:choice-variable-declaration"/>
@@ -297,58 +325,11 @@
       </include>
     </context> <!-- /_choice-import-named -->
 
-    <!-- ## Import as namespace
-
-         import * as nm from 'module';
-    -->
-
-    <context id="_as-namespace" once-only="true">
-      <start>\%[as\%]</start>
-      <end>\%{js:before-next-token}</end>
-      <include>
-        <context sub-pattern="0" where="start" style-ref="js:keyword"/>
-        <context ref="js:embedded-lang-hooks"/>
-        <context ref="js:comments"/>
-
-        <context id="_as-namespace-content">
-          <include>
-            <context ref="js:identifier"/>
-          </include>
-        </context> <!-- /_as-namespace-content -->
-
-      </include>
-    </context> <!-- /_as-namespace -->
-
-    <context id="_ordered-as-namespace" once-only="true">
-      <start>\%{js:before-next-token}</start>
-      <end>\%{js:before-next-token}</end>
-      <include>
-        <context ref="_as-namespace"/>
-      </include>
-    </context> <!-- /_ordered-as-namespace -->
-
-    <context id="_choice-import-as-namespace" end-parent="true">
-      <start>\*</start>
-      <end>\%{js:statement-end}</end>
-      <include>
-        <context ref="js:embedded-lang-hooks"/>
-        <context ref="js:comments"/>
-
-        <context id="_import-as-namespace-content">
-          <include>
-            <context ref="_ordered-as-namespace"/>
-            <context ref="_ordered-from-module"/>
-          </include>
-        </context> <!-- /_import-as-namespace-content -->
-
-      </include>
-    </context> <!-- /_choice-import-as-namespace -->
-
     <!-- ## Import default
 
          import def from 'module';
          import def, { a, b } from 'module';
-         import def, * as nm from 'module';
+         import def, * as ns from 'module';
     -->
 
     <context id="_choice-import-default-additional" end-parent="true">
@@ -361,7 +342,7 @@
         <context id="_import-default-additional-content">
           <include>
             <context ref="_choice-import-named"/>
-            <context ref="_choice-import-as-namespace"/>
+            <context ref="_choice-all-as-namespace"/>
           </include>
         </context> <!-- /_import-default-additional-content -->
 
@@ -406,6 +387,7 @@
 
          import { foo as food, bar } from 'module';
          import defaultFn, * as Mod from 'module';
+         import * as ns from 'module';
          import 'module';
     -->
 
@@ -423,7 +405,7 @@
         <context id="_import-declaration-content">
           <include>
             <context ref="_choice-import-named"/>
-            <context ref="_choice-import-as-namespace"/>
+            <context ref="_choice-all-as-namespace"/>
             <context ref="_choice-import-default"/>
             <context ref="js-lit:choice-string-path"/>
           </include>
diff --git a/tests/syntax-highlighting/file.j b/tests/syntax-highlighting/file.j
index 5779534e..62f01920 100644
--- a/tests/syntax-highlighting/file.j
+++ b/tests/syntax-highlighting/file.j
@@ -915,6 +915,7 @@ export default class {}
 export { a as default, b };
 
 export * from 'module';
+export * as ns from 'module';
 export { a, b } from 'module';
 export { x as a, y as b, } from 'module';
 export { default } from 'module';
@@ -927,7 +928,7 @@ import { x as a } from "module";
 import { x as a, y as b } from "module";
 import { default as a } from "module";
 import a, { b } from "module";
-import a, * as nm from "module";
+import a, * as ns from "module";
 import "module";
 
 
diff --git a/tests/syntax-highlighting/file.js b/tests/syntax-highlighting/file.js
index cd123b95..ac0e1f3b 100644
--- a/tests/syntax-highlighting/file.js
+++ b/tests/syntax-highlighting/file.js
@@ -614,6 +614,7 @@ export default class {}
 export { a as default, b };
 
 export * from 'module';
+export * as ns from 'module';
 export { a, b } from 'module';
 export { x as a, y as b, } from 'module';
 export { default } from 'module';
@@ -626,7 +627,7 @@ import { x as a } from "module";
 import { x as a, y as b } from "module";
 import { default as a } from "module";
 import a, { b } from "module";
-import a, * as nm from "module";
+import a, * as ns from "module";
 import "module";
 
 
diff --git a/tests/syntax-highlighting/file.jsx b/tests/syntax-highlighting/file.jsx
index 2a6ca4a8..d7f18777 100644
--- a/tests/syntax-highlighting/file.jsx
+++ b/tests/syntax-highlighting/file.jsx
@@ -671,6 +671,7 @@ export default class {}
 export { a as default, b };
 
 export * from 'module';
+export * as ns from 'module';
 export { a, b } from 'module';
 export { x as a, y as b, } from 'module';
 export { default } from 'module';
@@ -683,7 +684,7 @@ import { x as a } from "module";
 import { x as a, y as b } from "module";
 import { default as a } from "module";
 import a, { b } from "module";
-import a, * as nm from "module";
+import a, * as ns from "module";
 import "module";
 
 
diff --git a/tests/syntax-highlighting/file.ts b/tests/syntax-highlighting/file.ts
index ff22762d..f51d1190 100644
--- a/tests/syntax-highlighting/file.ts
+++ b/tests/syntax-highlighting/file.ts
@@ -1218,6 +1218,7 @@ export default class {}
 export { a as default, b };
 
 export * from 'module';
+export * as ns from 'module';
 export { a, b } from 'module';
 export { x as a, y as b, } from 'module';
 export { default } from 'module';
@@ -1230,7 +1231,7 @@ import { x as a } from "module";
 import { x as a, y as b } from "module";
 import { default as a } from "module";
 import a, { b } from "module";
-import a, * as nm from "module";
+import a, * as ns from "module";
 import "module";
 
 
diff --git a/tests/syntax-highlighting/file.tsx b/tests/syntax-highlighting/file.tsx
index 63351b7f..c713e5cd 100644
--- a/tests/syntax-highlighting/file.tsx
+++ b/tests/syntax-highlighting/file.tsx
@@ -1326,6 +1326,7 @@ export default class {}
 export { a as default, b };
 
 export * from 'module';
+export * as ns from 'module';
 export { a, b } from 'module';
 export { x as a, y as b, } from 'module';
 export { default } from 'module';
@@ -1338,7 +1339,7 @@ import { x as a } from "module";
 import { x as a, y as b } from "module";
 import { default as a } from "module";
 import a, { b } from "module";
-import a, * as nm from "module";
+import a, * as ns from "module";
 import "module";
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]