[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 16/46: Support Unicode Identifiers
From: |
Dmitry Gutov |
Subject: |
[elpa] 16/46: Support Unicode Identifiers |
Date: |
Sat, 15 Nov 2014 20:58:01 +0000 |
dgutov pushed a commit to branch master
in repository elpa.
commit d8d84920a5bafa40e6c985b1d298a027cf0954eb
Author: Gerard Paapu <address@hidden>
Date: Wed Jul 9 16:09:25 2014 +0300
Support Unicode Identifiers
(tiny change)
Closes #148
---
js2-mode.el | 43 +++++++++++++++++++++----------------------
1 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index e7b37a5..2b37a7f 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -2104,16 +2104,6 @@ Returns nil if element is not found in the list."
,@body)
(modify-syntax-entry ?_ ,old-syntax js2-mode-syntax-table)))))
-(defsubst js2-char-uppercase-p (c)
- "Return t if C is an uppercase character.
-Handles unicode and latin chars properly."
- (/= c (downcase c)))
-
-(defsubst js2-char-lowercase-p (c)
- "Return t if C is an uppercase character.
-Handles unicode and latin chars properly."
- (/= c (upcase c)))
-
;;; AST struct and function definitions
;; flags for ast node property 'member-type (used for e4x operators)
@@ -5171,20 +5161,29 @@ Returns nil and consumes nothing if TEST is not the
next character."
(js2-get-char)
(js2-unget-char)))
-(defun js2-java-identifier-start-p (c)
+(defun js2-identifier-start-p (c)
+ "Is C a valid start to an ES5 Identifier
+ http://es5.github.io/#x7.6"
(or
(memq c '(?$ ?_))
- (js2-char-uppercase-p c)
- (js2-char-lowercase-p c)))
+ (memq (get-char-code-property c 'general-category)
+ ;; Letters
+ '(Lu Ll Lt Lm Lo Nl))))
-(defun js2-java-identifier-part-p (c)
- "Implementation of java.lang.Character.isJavaIdentifierPart()."
- ;; TODO: make me Unicode-friendly. See comments above.
+(defun js2-identifier-part-p (c)
+ "Is C a valid part of an ES5 Identifier
+ http://es5.github.io/#x7.6"
(or
- (memq c '(?$ ?_))
- (js2-char-uppercase-p c)
- (js2-char-lowercase-p c)
- (and (>= c ?0) (<= c ?9))))
+ (memq c '(?$ ?_ ?\u200c ?\u200d))
+ (memq (get-char-code-property c 'general-category)
+ '(;; Letters
+ Lu Ll Lt Lm Lo Nl
+ ;; Combining Marks
+ Mn Mc
+ ;; Digits
+ Nd
+ ;; Connector Punctuation
+ Pc))))
(defun js2-alpha-p (c)
(cond ((and (<= ?A c) (<= c ?Z)) t)
@@ -5474,7 +5473,7 @@ its relevant fields and puts it into `js2-ti-tokens'."
(js2-unget-char)
(setq c ?\\)))
(t
- (when (setq identifier-start (js2-java-identifier-start-p c))
+ (when (setq identifier-start (js2-identifier-start-p c))
(setq js2-ts-string-buffer nil)
(js2-add-to-string c))))
(when identifier-start
@@ -5510,7 +5509,7 @@ its relevant fields and puts it into `js2-ti-tokens'."
(js2-report-scan-error "msg.illegal.character" t)))
(t
(if (or (eq c js2-EOF_CHAR)
- (not (js2-java-identifier-part-p c)))
+ (not (js2-identifier-part-p c)))
(throw 'break nil))
(js2-add-to-string c))))))
(js2-unget-char)
- [elpa] 02/46: Merge pull request #133 from johnmastro/imenu-react, (continued)
- [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, 2014/11/15
- [elpa] 16/46: Support Unicode Identifiers,
Dmitry Gutov <=
- [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
- [elpa] 26/46: Allow 'in' operator inside 'for' init when unambiguous, Dmitry Gutov, 2014/11/15