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

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

[elpa] externals/phps-mode 054ee03 1/4: Fixed bug in lexer not recognizi


From: Christian Johansson
Subject: [elpa] externals/phps-mode 054ee03 1/4: Fixed bug in lexer not recognizing T_MATCH token
Date: Mon, 1 Nov 2021 12:28:44 -0400 (EDT)

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

    Fixed bug in lexer not recognizing T_MATCH token
---
 phps-mode-lex-analyzer.el     |  1 +
 phps-mode-lexer.el            |  4 ++++
 test/phps-mode-test-lexer.el  |  2 +-
 test/phps-mode-test-parser.el | 30 +++++++++++++++++-------------
 4 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 7c68a4d..1a6b793 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -213,6 +213,7 @@
        (equal token-name 'T_INSTANCEOF)
        (equal token-name 'T_AS)
        (equal token-name 'T_SWITCH)
+       (equal token-name 'T_MATCH)
        (equal token-name 'T_ENDSWITCH)
        (equal token-name 'T_CASE)
        (equal token-name 'T_DEFAULT)
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 7b8953b..ba1d661 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -637,6 +637,10 @@
        (phps-mode-lexer--return-token-with-indent 'T_SWITCH))
 
       (phps-mode-lexer--match-macro
+       (and ST_IN_SCRIPTING (looking-at "match"))
+       (phps-mode-lexer--return-token-with-indent 'T_MATCH))
+
+      (phps-mode-lexer--match-macro
        (and ST_IN_SCRIPTING (looking-at "endswitch"))
        (phps-mode-lexer--return-token-with-indent 'T_ENDSWITCH))
 
diff --git a/test/phps-mode-test-lexer.el b/test/phps-mode-test-lexer.el
index 4c6ec87..7322716 100644
--- a/test/phps-mode-test-lexer.el
+++ b/test/phps-mode-test-lexer.el
@@ -265,7 +265,7 @@
    (should
     (equal
      phps-mode-lex-analyzer--tokens
-     '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_STRING 12 . 17) ("(" 18 . 19) 
(T_DNUMBER 19 . 22) (")" 22 . 23) ("{" 24 . 25) (T_CONSTANT_ENCAPSED_STRING 28 
. 33) (T_DOUBLE_ARROW 34 . 36) (T_CONSTANT_ENCAPSED_STRING 37 . 45) ("," 45 . 
46) (T_DNUMBER 49 . 52) (T_DOUBLE_ARROW 53 . 55) (T_CONSTANT_ENCAPSED_STRING 56 
. 81) ("," 81 . 82) ("}" 83 . 84) (";" 84 . 85) (T_COMMENT 86 . 113)))))
+     '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_MATCH 12 . 17) ("(" 18 . 19) 
(T_DNUMBER 19 . 22) (")" 22 . 23) ("{" 24 . 25) (T_CONSTANT_ENCAPSED_STRING 28 
. 33) (T_DOUBLE_ARROW 34 . 36) (T_CONSTANT_ENCAPSED_STRING 37 . 45) ("," 45 . 
46) (T_DNUMBER 49 . 52) (T_DOUBLE_ARROW 53 . 55) (T_CONSTANT_ENCAPSED_STRING 56 
. 81) ("," 81 . 82) ("}" 83 . 84) (";" 84 . 85) (T_COMMENT 86 . 113)))))
 
   (phps-mode-test--with-buffer
    "<?php\n\n$country = $session?->user?->getAddress()?->country;\n"
diff --git a/test/phps-mode-test-parser.el b/test/phps-mode-test-parser.el
index f016154..9ed0948 100644
--- a/test/phps-mode-test-parser.el
+++ b/test/phps-mode-test-parser.el
@@ -286,19 +286,23 @@
    (lambda()
      (phps-mode-parser-parse)))
 
-  ;; TODO Make this work
-  ;; (phps-mode-test-parser--buffer-contents
-  ;;  "<?php\n$food = 'cake';\n\n$return_value = match ($food) {\n    default 
=> 'This food is an apple',\n};\n\nvar_dump($return_value);\n?>"
-  ;;  "Basic match usage 1"
-  ;;  (lambda()
-  ;;    (phps-mode-parser-parse)))
-
-  ;; TODO Make this work
-  ;; (phps-mode-test-parser--buffer-contents
-  ;;  "<?php\n$food = 'cake';\n\n$return_value = match ($food) {\n    'apple' 
=> 'This food is an apple',\n    'bar' => 'This food is a bar',\n    'cake' => 
'This food is a cake',\n};\n\nvar_dump($return_value);\n?>"
-  ;;  "Basic match usage 2"
-  ;;  (lambda()
-  ;;    (phps-mode-parser-parse)))
+  (phps-mode-test-parser--buffer-contents
+   "<?php match (55) {\n    22,33 => 22,\n    25 => 20,\n    default => 33\n};"
+   "Simple match expression"
+   (lambda()
+     (phps-mode-parser-parse)))
+
+  (phps-mode-test-parser--buffer-contents
+   "<?php\n$food = 'cake';\n\n$return_value = match ($food) {\n    default => 
'This food is an apple',\n};\n\nvar_dump($return_value);\n?>"
+   "Basic match usage 1"
+   (lambda()
+     (phps-mode-parser-parse)))
+
+  (phps-mode-test-parser--buffer-contents
+   "<?php\n$food = 'cake';\n\n$return_value = match ($food) {\n    'apple' => 
'This food is an apple',\n    'bar' => 'This food is a bar',\n    'cake' => 
'This food is a cake',\n};\n\nvar_dump($return_value);\n?>"
+   "Basic match usage 2"
+   (lambda()
+     (phps-mode-parser-parse)))
 
   (message "\n-- Ran tests for parser boundaries. --"))
 



reply via email to

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