[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 11/46: Support yield*
From: |
Dmitry Gutov |
Subject: |
[elpa] 11/46: Support yield* |
Date: |
Sat, 15 Nov 2014 20:57:58 +0000 |
dgutov pushed a commit to branch master
in repository elpa.
commit d96d8e7ff7ce3c04c7fd409d4f75dbc94e9b9030
Author: Dmitry Gutov <address@hidden>
Date: Wed Jun 4 04:18:31 2014 +0300
Support yield*
#139
---
js2-mode.el | 17 ++++++++++++-----
tests/parser.el | 2 ++
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index f2b9802..2856105 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -3631,8 +3631,9 @@ property `GETTER_SETTER' set to js2-GET or js2-SET. ")
(:constructor nil)
(:constructor make-js2-yield-node (&key (type js2-YIELD)
(pos js2-ts-cursor)
- len value)))
+ len value star-p)))
"AST node for yield statement or expression."
+ star-p ; whether it's yield*
value) ; optional: value to be yielded
(put 'cl-struct-js2-yield-node 'js2-visitor 'js2-visit-yield-node)
@@ -3644,6 +3645,8 @@ property `GETTER_SETTER' set to js2-GET or js2-SET. ")
(defun js2-print-yield-node (n i)
(insert (js2-make-pad i))
(insert "yield")
+ (when (js2-yield-node-star-p n)
+ (insert "*"))
(when (js2-yield-node-value n)
(insert " ")
(js2-print-ast (js2-yield-node-value n) 0)))
@@ -8120,11 +8123,16 @@ but not BEFORE."
(end (js2-current-token-end))
(before js2-end-flags)
(inside-function (js2-inside-function))
- e ret name)
+ e ret name yield-star-p)
(unless inside-function
(js2-report-error (if (eq tt js2-RETURN)
"msg.bad.return"
"msg.bad.yield")))
+ (when (and inside-function
+ (eq (js2-function-node-generator-type js2-current-script-or-fn)
+ 'STAR)
+ (js2-match-token js2-MUL))
+ (setq yield-star-p t))
;; This is ugly, but we don't want to require a semicolon.
(unless (memq (js2-peek-token-or-eol) js2-parse-return-stmt-enders)
(setq e (js2-parse-expr)
@@ -8151,11 +8159,10 @@ but not BEFORE."
(logior js2-end-returns
js2-end-returns-value)))
(js2-add-strict-warning "msg.return.inconsistent" nil pos end)))
(t
- (unless (js2-inside-function)
- (js2-report-error "msg.bad.yield"))
(setq ret (make-js2-yield-node :pos pos
:len (- end pos)
- :value e))
+ :value e
+ :star-p yield-star-p))
(js2-node-add-children ret e)
(unless expr-context
(setq e ret
diff --git a/tests/parser.el b/tests/parser.el
index a4e2e82..a3fa1e0 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -248,6 +248,8 @@ the test."
(js2-deftest-parse harmony-generator "function* bar() {\n yield 2;\n return
3;\n}")
+(js2-deftest-parse harmony-generator-yield-star "(function*(a) { yield*
a;\n});")
+
;;; Scopes
(js2-deftest ast-symbol-table-includes-fn-node "function foo() {}"
- [elpa] 01/46: Add support for React classes in js2-imenu-extras, (continued)
- [elpa] 01/46: Add support for React classes in js2-imenu-extras, Dmitry Gutov, 2014/11/15
- [elpa] 02/46: Merge pull request #133 from johnmastro/imenu-react, Dmitry Gutov, 2014/11/15
- [elpa] 06/46: Merge pull request #138 from martinp/fix-electric-indent, Dmitry Gutov, 2014/11/15
- [elpa] 03/46: Reference #72 in the README, Dmitry Gutov, 2014/11/15
- [elpa] 05/46: Fix electric-indent-mode, Dmitry Gutov, 2014/11/15
- [elpa] 08/46: Fix parsing of function statements in blocks, Dmitry Gutov, 2014/11/15
- [elpa] 04/46: Try to improve formatting, Dmitry Gutov, 2014/11/15
- [elpa] 09/46: Rename mention of espresso-mode to js-mode, Dmitry Gutov, 2014/11/15
- [elpa] 10/46: js2-parse-array-literal: improve trailing comma warning, Dmitry Gutov, 2014/11/15
- [elpa] 07/46: Cut down on reserved words; improve error reporting, Dmitry Gutov, 2014/11/15
- [elpa] 11/46: Support yield*,
Dmitry Gutov <=
- [elpa] 16/46: Support Unicode Identifiers, Dmitry Gutov, 2014/11/15
- [elpa] 17/46: Check if buffer is alive before reparsing., Dmitry Gutov, 2014/11/15
- [elpa] 19/46: Better docstrings, Dmitry Gutov, 2014/11/15
- [elpa] 14/46: Support ES6 generator comprehensions, Dmitry Gutov, 2014/11/15
- [elpa] 13/46: Support ES6 array comprehensions, Dmitry Gutov, 2014/11/15
- [elpa] 12/46: Add `.' to electric-indent-chars for method continuations, Dmitry Gutov, 2014/11/15
- [elpa] 15/46: Add Contributing section, Dmitry Gutov, 2014/11/15
- [elpa] 24/46: Small tweak, Dmitry Gutov, 2014/11/15
- [elpa] 23/46: Add js2-language-version checks, Dmitry Gutov, 2014/11/15
- [elpa] 25/46: Ignore integer overflow, Dmitry Gutov, 2014/11/15