emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/phps-mode 7cfa35c 81/96: Improved error-reporting for p


From: Christian Johansson
Subject: [elpa] externals/phps-mode 7cfa35c 81/96: Improved error-reporting for parser errors
Date: Fri, 29 Oct 2021 11:15:01 -0400 (EDT)

branch: externals/phps-mode
commit 7cfa35c8452f5175be475a72ad0f637be35d71e0
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Improved error-reporting for parser errors
---
 phps-mode-lex-analyzer.el    |  6 ++++--
 test/phps-mode-test-lexer.el | 32 +++++++++++++++-----------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index ce6a3b5..4de830c 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -456,13 +456,14 @@
 
              ;; Display parser error (if any)
              (when phps-mode-lex-analyzer--parse-error
+               (setq phps-mode-serial--status 'error)
                (phps-mode-lex-analyzer--set-region-syntax-color
                 (nth 4 phps-mode-lex-analyzer--parse-error)
                 (point-max)
                 (list 'font-lock-face 'font-lock-warning-face))
                (display-warning
                 'phps-mode
-                (nth 2 phps-mode-lex-analyzer--parse-error)
+                (nth 1 phps-mode-lex-analyzer--parse-error)
                 :warning
                 "*PHPs Parser Errors*"))))))
 
@@ -623,13 +624,14 @@
 
              ;; Display parser error (if any)
              (when phps-mode-lex-analyzer--parse-error
+               (setq phps-mode-serial--status 'error)
                (phps-mode-lex-analyzer--set-region-syntax-color
                 (nth 4 phps-mode-lex-analyzer--parse-error)
                 (point-max)
                 (list 'font-lock-face 'font-lock-warning-face))
                (display-warning
                 'phps-mode
-                (nth 2 phps-mode-lex-analyzer--parse-error)
+                (nth 1 phps-mode-lex-analyzer--parse-error)
                 :warning
                 "*PHPs Parser Errors*"))))))
 
diff --git a/test/phps-mode-test-lexer.el b/test/phps-mode-test-lexer.el
index 9a48959..385d44e 100644
--- a/test/phps-mode-test-lexer.el
+++ b/test/phps-mode-test-lexer.el
@@ -72,14 +72,13 @@
      phps-mode-lex-analyzer--tokens
      '((T_INLINE_HTML 1 . 39) (T_OPEN_TAG 39 . 45) (T_EXIT 47 . 51) (";" 51 . 
52) (T_CLOSE_TAG 53 . 55) (T_INLINE_HTML 55 . 80) (T_OPEN_TAG 80 . 86) (T_EXIT 
86 . 90) (";" 90 . 91) (T_CLOSE_TAG 92 . 94)))))
 
-  ;; TODO Make parser handle this
-  ;; (phps-mode-test--with-buffer
-  ;;  "<?php\n\n$k = 'key';\n\necho \"\\$a['{$k}']\";"
-  ;;  "A tricky case where variable inside double quote is escaped"
-  ;;  ;; (message "Tokens: %s" phps-mode-lex-analyzer--tokens)
-  ;;  (should (equal
-  ;;           phps-mode-lex-analyzer--tokens
-  ;;           '((T_OPEN_TAG 1 . 7) (T_VARIABLE 8 . 10) ("=" 11 . 12) 
(T_CONSTANT_ENCAPSED_STRING 13 . 18) (";" 18 . 19) (T_ECHO 21 . 25) ("\"" 26 . 
27) (T_CONSTANT_ENCAPSED_STRING 27 . 32) (T_CURLY_OPEN 32 . 33) (T_VARIABLE 33 
. 35) ("}" 35 . 36) (T_CONSTANT_ENCAPSED_STRING 36 . 38) ("\"" 38 . 39) (";" 39 
. 40)))))
+  (phps-mode-test--with-buffer
+   "<?php\n\n$k = 'key';\n\necho \"\\$a['{$k}']\";"
+   "A tricky case where variable inside double quote is escaped"
+   ;; (message "Tokens: %s" phps-mode-lex-analyzer--tokens)
+   (should (equal
+            phps-mode-lex-analyzer--tokens
+            '((T_OPEN_TAG 1 . 7) (T_VARIABLE 8 . 10) ("=" 11 . 12) 
(T_CONSTANT_ENCAPSED_STRING 13 . 18) (";" 18 . 19) (T_ECHO 21 . 25) ("\"" 26 . 
27) (T_CONSTANT_ENCAPSED_STRING 27 . 32) (T_CURLY_OPEN 32 . 33) (T_VARIABLE 33 
. 35) ("}" 35 . 36) (T_CONSTANT_ENCAPSED_STRING 36 . 38) ("\"" 38 . 39) (";" 39 
. 40)))))
 
   )
 
@@ -209,15 +208,14 @@
      phps-mode-lex-analyzer--tokens
      '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 16) ("=" 17 . 18) (T_VARIABLE 19 . 
24) ("[" 24 . 25) (T_CONSTANT_ENCAPSED_STRING 25 . 31) ("]" 31 . 32) 
(T_COALESCE 33 . 35) (T_CONSTANT_ENCAPSED_STRING 36 . 44) (";" 44 . 45) 
(T_VARIABLE 46 . 51) (T_OBJECT_OPERATOR 51 . 53) (T_STRING 53 . 60) 
(T_OBJECT_OPERATOR 60 . 62) (T_STRING 62 . 66) ("[" 66 . 67) 
(T_CONSTANT_ENCAPSED_STRING 67 . 77) ("]" 77 . 78) ("[" 78 . 79) 
(T_CONSTANT_ENCAPSED_STRING 79 . 88) ("]" 88 . 89) (T_COALESCE_EQUAL 90 . 93) 
(T [...]
 
-  ;; TODO Uncomment when parser handles this
-  ;; (phps-mode-test--with-buffer
-  ;;  "<?php\necho $array['abc'];\necho \"My $array[12] random statement\";\n"
-  ;;  "Long inside array offset"
-  ;;  ;; (message "Tokens: %s" phps-mode-lex-analyzer--tokens)
-  ;;  (should
-  ;;   (equal
-  ;;    phps-mode-lex-analyzer--tokens
-  ;;    '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_VARIABLE 12 . 18) ("[" 18 . 
19) (T_CONSTANT_ENCAPSED_STRING 19 . 24) ("]" 24 . 25) (";" 25 . 26) (T_ECHO 27 
. 31) ("\"" 32 . 33) (T_CONSTANT_ENCAPSED_STRING 33 . 36) (T_VARIABLE 36 . 42) 
("[" 42 . 43) (T_NUM_STRING 43 . 45) ("]" 45 . 46) (T_CONSTANT_ENCAPSED_STRING 
46 . 63) ("\"" 63 . 64) (";" 64 . 65)))))
+  (phps-mode-test--with-buffer
+   "<?php\necho $array['abc'];\necho \"My $array[12] random statement\";\n"
+   "Long inside array offset"
+   ;; (message "Tokens: %s" phps-mode-lex-analyzer--tokens)
+   (should
+    (equal
+     phps-mode-lex-analyzer--tokens
+     '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_VARIABLE 12 . 18) ("[" 18 . 19) 
(T_CONSTANT_ENCAPSED_STRING 19 . 24) ("]" 24 . 25) (";" 25 . 26) (T_ECHO 27 . 
31) ("\"" 32 . 33) (T_CONSTANT_ENCAPSED_STRING 33 . 36) (T_VARIABLE 36 . 42) 
("[" 42 . 43) (T_NUM_STRING 43 . 45) ("]" 45 . 46) (T_CONSTANT_ENCAPSED_STRING 
46 . 63) ("\"" 63 . 64) (";" 64 . 65)))))
 
   (phps-mode-test--with-buffer
    "<?php\n/*my comment */\n/** my doc comment */"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]