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

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

[elpa] externals/phps-mode f3205d5 011/405: Fixed lexing of basic tokens


From: Stefan Monnier
Subject: [elpa] externals/phps-mode f3205d5 011/405: Fixed lexing of basic tokens
Date: Sat, 13 Jul 2019 09:59:29 -0400 (EDT)

branch: externals/phps-mode
commit f3205d56c5244a8a6bd36a68a6e5f133cd032d8f
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    Fixed lexing of basic tokens
---
 phps-lexer.el      | 8 ++++++--
 phps-test-lexer.el | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index af9db86..c5713b3 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -146,7 +146,7 @@
 (defvar phps-mode/TABS_AND_SPACES "[ \t]*"
   "Tabs and whitespaces.")
 
-(defvar phps-mode/TOKENS "[;\\:,.()^&+-/*=%!~\\$<>?@]"
+(defvar phps-mode/TOKENS "[][;\\:,\.()|^&+-/*=%!~\\$<>?@]"
   "Tokens.")
 
 (defvar phps-mode/ANY_CHAR ".\\|\n"
@@ -838,7 +838,7 @@
                 (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
end 1))
               (progn
                 ;; Unclosed single quotes
-                (message "Single quoted string never ends..")
+                ;; (message "Single quoted string never ends..")
                 (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
                 (phps-mode/MOVE_FORWARD (point-max))
                 )))))))
@@ -896,8 +896,12 @@
    ((looking-at phps-mode/LABEL)
     (phps-mode/RETURN_TOKEN 'T_STRING (match-beginning 0) (match-end 0)))
 
+   ((looking-at phps-mode/TOKENS)
+    (phps-mode/RETURN_TOKEN (match-string 0) (match-beginning 0) (match-end 
0)))
+
    ((looking-at phps-mode/ANY_CHAR)
     ;; Unexpected character
+    ;; (message "Unexpected character '%s'" (buffer-substring (match-beginning 
0) (match-end 0)))
     (phps-mode/RETURN_TOKEN 'T_ERROR (match-beginning 0) (point-max))
     (phps-mode/MOVE_FORWARD (point-max)))
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index efdb9af..78a0674 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -117,12 +117,17 @@
           (string-tokens (phps-mode/token-stream-to-string tokens)))
      (should (equal string-tokens " T_OPEN_TAG T_ECHO T_VARIABLE = T_ARRAY ( 
T_CONSTANT_ENCAPSED_STRING T_DOUBLE_ARROW T_CONSTANT_ENCAPSED_STRING ) ;"))))
 
-  ;; TODO Fix this
+  (phps-mode/with-test-buffer
+   "<?php $var = []; "
+   (let* ((tokens phps-mode/lexer-tokens)
+          (string-tokens (phps-mode/token-stream-to-string tokens)))
+     (should (equal string-tokens " T_OPEN_TAG T_VARIABLE = [ ] ;"))))
+
   (phps-mode/with-test-buffer
    "<?php echo isset($backtrace[1]['file']) ? 'yes' : 'no'; "
    (let* ((tokens phps-mode/lexer-tokens)
           (string-tokens (phps-mode/token-stream-to-string tokens)))
-     (should (equal string-tokens " T_OPEN_TAG T_ECHO T_ISSET ( T_VARIABLE 
TODO HERE"))))
+     (should (equal string-tokens " T_OPEN_TAG T_ECHO T_ISSET ( T_VARIABLE [ 
T_LNUMBER ] [ T_CONSTANT_ENCAPSED_STRING ] ) ? T_CONSTANT_ENCAPSED_STRING : 
T_CONSTANT_ENCAPSED_STRING ;"))))
 
   (phps-mode/with-test-buffer
    "<?php $var EXIT die function return yield from yield try catch finally 
throw if elseif endif else while endwhile do for endfor foreach endforeach 
declare enddeclare instanceof as switch endswitch case default break continue 
goto echo print class interface trait extends implements :: \\ ... ?? new clone 
var (int) (integer) (real) (double) (float) (string) (binary) (array) (object) 
(boolean) (bool) (unset) eval include include_once require require_once 
namespace use insteadof global is [...]



reply via email to

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