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

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

[elpa] externals/phps-mode c1ab121 25/62: Work on making integration-tes


From: Christian Johansson
Subject: [elpa] externals/phps-mode c1ab121 25/62: Work on making integration-tests pass
Date: Tue, 20 Apr 2021 10:56:17 -0400 (EDT)

branch: externals/phps-mode
commit c1ab1210961993dba3caff1fdf2aefa9dfac1111
Author: Christian Johansson <christian@mediastrategi.se>
Commit: Christian Johansson <christian@mediastrategi.se>

    Work on making integration-tests pass
---
 phps-mode-lex-analyzer.el          | 107 +++++++++++++++++++++++++------------
 phps-mode-lexer.el                 |  36 ++++++-------
 test/phps-mode-test-integration.el |   2 +-
 3 files changed, 90 insertions(+), 55 deletions(-)

diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 8b57c4e..99b8574 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -89,6 +89,9 @@
 (defvar-local phps-mode-lex-analyzer--heredoc-label-stack nil
   "Latest Heredoc label-stack.")
 
+(defvar-local phps-mode-lex-analyzer--nest-location-stack nil
+  "Nest location stack.")
+
 
 ;; FUNCTIONS
 
@@ -106,7 +109,8 @@
   (setq phps-mode-lex-analyzer--state nil)
   (setq phps-mode-lex-analyzer--state-stack nil)
   (setq phps-mode-lex-analyzer--states nil)
-  (setq phps-mode-lex-analyzer--tokens nil))
+  (setq phps-mode-lex-analyzer--tokens nil)
+  (setq phps-mode-lex-analyzer--nest-location-stack nil))
 
 (defun phps-mode-lex-analyzer--set-region-syntax-color (start end properties)
   "Do syntax coloring for region START to END with PROPERTIES."
@@ -397,6 +401,7 @@
              (setq phps-mode-lex-analyzer--state-stack (nth 3 lex-result))
              (setq phps-mode-lex-analyzer--heredoc-label (nth 4 lex-result))
              (setq phps-mode-lex-analyzer--heredoc-label-stack (nth 5 
lex-result))
+             (setq phps-mode-lex-analyzer--nest-location-stack (nth 6 
lex-result))
 
              ;; Save processed result
              (setq phps-mode-lex-analyzer--processed-buffer-p t)
@@ -437,8 +442,15 @@
                           error-start
                           (point-max)
                           (list 'font-lock-face 'font-lock-warning-face))))
-                     (display-warning 'phps-mode error-message :warning "*PHPs 
Lexer Errors*"))
-                 (display-warning error-type error-message :warning)))))))
+                     (display-warning
+                      'phps-mode
+                      error-message
+                      :warning
+                      "*PHPs Lexer Errors*"))
+                 (display-warning
+                  error-type
+                  error-message
+                  :warning)))))))
 
      nil
 
@@ -447,7 +459,7 @@
 
 (defun phps-mode-lex-analyzer--incremental-lex-string
     (buffer-name buffer-contents incremental-start-new-buffer point-max
-                 head-states incremental-state incremental-state-stack 
incremental-heredoc-label incremental-heredoc-label-stack head-tokens &optional 
force-synchronous)
+                 head-states incremental-state incremental-state-stack 
incremental-heredoc-label incremental-heredoc-label-stack 
incremental-nest-location-stack head-tokens &optional force-synchronous)
   "Incremental lex region."
   (let ((async (and (boundp 'phps-mode-async-process)
                     phps-mode-async-process))
@@ -460,16 +472,18 @@
      buffer-name
 
      (lambda()
-       (let* ((lex-result (phps-mode-lex-analyzer--lex-string
-                           buffer-contents
-                           incremental-start-new-buffer
-                           point-max
-                           head-states
-                           incremental-state
-                           incremental-state-stack
-                           incremental-heredoc-label
-                           incremental-heredoc-label-stack
-                           head-tokens))
+       (let* ((lex-result
+               (phps-mode-lex-analyzer--lex-string
+                buffer-contents
+                incremental-start-new-buffer
+                point-max
+                head-states
+                incremental-state
+                incremental-state-stack
+                incremental-heredoc-label
+                incremental-heredoc-label-stack
+                incremental-nest-location-stack
+                head-tokens))
               (processed-result
                (phps-mode-lex-analyzer--process-tokens-in-string
                 (nth 0 lex-result)
@@ -491,6 +505,7 @@
              (setq phps-mode-lex-analyzer--state-stack (nth 3 lex-result))
              (setq phps-mode-lex-analyzer--heredoc-label (nth 4 lex-result))
              (setq phps-mode-lex-analyzer--heredoc-label-stack (nth 5 
lex-result))
+             (setq phps-mode-lex-analyzer--nest-location-stack (nth 6 
lex-result))
 
              ;; Save processed result
              (setq phps-mode-lex-analyzer--processed-buffer-p t)
@@ -536,8 +551,15 @@
                           error-start
                           (point-max)
                           (list 'font-lock-face 'font-lock-warning-face))))
-                     (display-warning 'phps-mode error-message :warning "*PHPs 
Lexer Errors*"))
-                 (display-warning error-type error-message :warning)))))))
+                     (display-warning
+                      'phps-mode
+                      error-message
+                      :warning
+                      "*PHPs Lexer Errors*"))
+                 (display-warning
+                  error-type
+                  error-message
+                  :warning)))))))
 
      nil
      async
@@ -631,6 +653,7 @@
                     (incremental-state-stack nil)
                     (incremental-heredoc-label nil)
                     (incremental-heredoc-label-stack nil)
+                    (incremental-nest-location-stack nil)
                     (incremental-tokens nil)
                     (head-states '())
                     (head-tokens '())
@@ -650,6 +673,7 @@
                 (setq phps-mode-lex-analyzer--state-stack nil)
                 (setq phps-mode-lex-analyzer--heredoc-label nil)
                 (setq phps-mode-lex-analyzer--heredoc-label-stack nil)
+                (setq phps-mode-lex-analyzer--nest-location-stack nil)
 
                 ;; NOTE Starts are inclusive while ends are exclusive buffer 
locations
 
@@ -695,6 +719,7 @@
                                   (setq incremental-state-stack (nth 3 
state-object))
                                   (setq incremental-heredoc-label (nth 4 
state-object))
                                   (setq incremental-heredoc-label-stack (nth 5 
state-object))
+                                  (setq incremental-nest-location-stack (nth 6 
state-object))
                                   (push state-object head-states))
                               (throw 'quit "break")))))
 
@@ -703,7 +728,8 @@
                        (message "Incremental state: %s" incremental-state)
                        (message "State stack: %s" incremental-state-stack)
                        (message "Incremental heredoc-label: %s" 
incremental-heredoc-label)
-                       (message "Incremental heredoc-label-stack: %s" 
incremental-heredoc-label-stack))
+                       (message "Incremental heredoc-label-stack: %s" 
incremental-heredoc-label-stack)
+                       (message "Incremental nest-location-stack: %s" 
incremental-nest-location-stack))
 
                       (if (and
                            head-states
@@ -726,6 +752,7 @@
                              incremental-state-stack
                              incremental-heredoc-label
                              incremental-heredoc-label-stack
+                             incremental-nest-location-stack
                              head-tokens
                              force-synchronous)
 
@@ -1235,7 +1262,6 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
                           ;; (message "%s->%s" bookkeeping2-variable-name 
bookkeeping-variable-name)
                           (when (string= bookkeeping2-variable-name "$this")
                             (setq bookkeeping-namespace (concat 
bookkeeping-namespace " id $" bookkeeping-variable-name))
-                            ;; (message "Was here: '%s" bookkeeping-namespace)
                             (setq bookkeeping-named t))))
 
                       (unless bookkeeping-named
@@ -3013,7 +3039,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
   (unless phps-mode-lex-analyzer--state
     (setq phps-mode-lex-analyzer--state 'ST_INITIAL)))
 
-(defun phps-mode-lex-analyzer--lex-string (contents &optional start end states 
state state-stack heredoc-label heredoc-label-stack tokens)
+(defun phps-mode-lex-analyzer--lex-string (contents &optional start end states 
state state-stack heredoc-label heredoc-label-stack nest-location-stack tokens)
   "Run lexer on CONTENTS."
   ;; Create a separate buffer, run lexer inside of it, catch errors and return 
them
   ;; to enable nice presentation
@@ -3026,23 +3052,34 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
         (insert contents)
 
         (if tokens
-            (setq phps-mode-lexer--generated-tokens (nreverse tokens))
-          (setq phps-mode-lexer--generated-tokens nil))
+            (setq
+             phps-mode-lexer--generated-tokens
+             (nreverse tokens))
+          (setq
+           phps-mode-lexer--generated-tokens
+           nil))
         (if state
-            (setq phps-mode-lexer--state state)
-          (setq phps-mode-lexer--state 'ST_INITIAL))
-        (if states
-            (setq phps-mode-lexer--states states)
-          (setq phps-mode-lexer--states nil))
-        (if state-stack
-            (setq phps-mode-lexer--state-stack state-stack)
-          (setq phps-mode-lexer--state-stack nil))
-        (if heredoc-label
-            (setq phps-mode-lexer--heredoc-label heredoc-label)
-          (setq phps-mode-lexer--heredoc-label nil))
-        (if heredoc-label-stack
-            (setq phps-mode-lexer--heredoc-label-stack heredoc-label-stack)
-          (setq phps-mode-lexer--heredoc-label-stack nil))
+            (setq
+             phps-mode-lexer--state state)
+          (setq
+           phps-mode-lexer--state
+           'ST_INITIAL))
+
+        (setq
+         phps-mode-lexer--states
+         states)
+        (setq
+         phps-mode-lexer--state-stack
+         state-stack)
+        (setq
+         phps-mode-lexer--heredoc-label
+         heredoc-label)
+        (setq
+         phps-mode-lexer--heredoc-label-stack
+         heredoc-label-stack)
+        (setq
+         phps-mode-lexer--nest-location-stack
+         nest-location-stack)
 
         ;; Setup lexer settings
         (when (boundp 'phps-mode-syntax-table)
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index af50ba7..899690b 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -226,14 +226,8 @@
   ;; TODO Implement this?
   )
 
-(defun phps-mode-lexer--exit-nesting (&optional closing)
+(defun phps-mode-lexer--exit-nesting (closing)
   "Exit nesting of CLOSING."
-  (unless closing
-    (setq
-     closing
-     (buffer-substring-no-properties
-      (match-beginning 0)
-      (match-end 0))))
   (unless phps-mode-lexer--nest-location-stack
     (signal
      'phps-lexer-error
@@ -243,14 +237,15 @@
   (let ((opening
          (car
           phps-mode-lexer--nest-location-stack)))
-    (when
-        (or
-         (and (string= opening "{")
-              (not (string= closing "}")))
-         (and (string= opening "[")
-              (not (string= closing "]")))
-         (and (string= opening "(")
-              (not (string= closing ")"))))
+    (when (and
+           opening
+           (or
+            (and (string= opening "{")
+                 (not (string= closing "}")))
+            (and (string= opening "[")
+                 (not (string= closing "]")))
+            (and (string= opening "(")
+                 (not (string= closing ")")))))
       (signal
        'phps-lexer-error
        (list
@@ -284,7 +279,8 @@
     phps-mode-lexer--state
     phps-mode-lexer--state-stack
     phps-mode-lexer--heredoc-label
-    phps-mode-lexer--heredoc-label-stack)
+    phps-mode-lexer--heredoc-label-stack
+    phps-mode-lexer--nest-location-stack)
    phps-mode-lexer--states))
 
 (defun phps-mode-lexer--get-next-unescaped (character)
@@ -396,7 +392,10 @@
        (phps-mode-lexer--exit-nesting token)
        (phps-mode-lexer--parser-mode))
       (phps-mode-lexer--return-token 'T_ERROR)
-    (phps-mode-lexer--return-token token start end)))
+    (phps-mode-lexer--return-token
+     token
+     start
+     end)))
 
 (defun phps-mode-lexer--restart ()
   "Restart."
@@ -1215,8 +1214,7 @@
 
           ((equal end (point-max))
            (phps-mode-lexer--begin 'ST_IN_SCRIPTING)
-           (phps-mode-lexer--return-or-skip-token
-            'T_OPEN_TAG))
+           (phps-mode-lexer--return-or-skip-token 'T_OPEN_TAG))
 
           ((phps-mode-parser-grammar-macro-CG 'short-tags)
            (phps-mode-lexer--yyless 2)
diff --git a/test/phps-mode-test-integration.el 
b/test/phps-mode-test-integration.el
index 5891e5d..04b8601 100644
--- a/test/phps-mode-test-integration.el
+++ b/test/phps-mode-test-integration.el
@@ -306,7 +306,7 @@
 
 (defun phps-mode-test-integration ()
   "Run test for integration."
-  ;; (setq debug-on-error t)
+  (setq debug-on-error t)
   ;; (setq phps-mode-analyzer--process-on-indent-and-imenu t)
   (phps-mode-test-integration--incremental-vs-initial-buffers)
   ;; (phps-mode-test-integration--whitespace-modifications)



reply via email to

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