[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 70f2d46 242/405: Fixed lexer issue with multi
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 70f2d46 242/405: Fixed lexer issue with multiple expressions inside double-quoted string |
Date: |
Sat, 13 Jul 2019 10:00:24 -0400 (EDT) |
branch: externals/phps-mode
commit 70f2d4694a59aa487886aa0dd4ce4048391c0c83
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Fixed lexer issue with multiple expressions inside double-quoted string
---
phps-mode-lexer.el | 27 +++++++++++----------------
phps-mode-test-lexer.el | 4 ++--
2 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index b894087..9733cc5 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -148,10 +148,10 @@
"Characters not starting a label.")
(defvar phps-mode-lexer-WHITESPACE "[ \n\r\t]+"
- "Whitespace.")
+ "White-space.")
(defvar phps-mode-lexer-TABS_AND_SPACES "[ \t]*"
- "Tabs and whitespaces.")
+ "Tabs and white-spaces.")
(defvar phps-mode-lexer-TOKENS "[][;\\:,\.()|^&+-/*=%!~\\$<>?@]"
"Tokens.")
@@ -176,14 +176,13 @@
(defun phps-mode-lexer-yy_push_state (new-state)
"Add NEW-STATE to stack and then begin state."
(push phps-mode-lexer-STATE phps-mode-lexer-state_stack)
- ;; (message "Added state %s to stack" old-state)
+ ;; (message "Added state %s to stack begun state %s" phps-mode-lexer-STATE
new-state)
(phps-mode-lexer-BEGIN new-state))
(defun phps-mode-lexer-yy_pop_state ()
"Pop current state from stack."
(let ((old-state (pop phps-mode-lexer-state_stack)))
;; (message "Going back to poppped state %s" old-state)
- ;; (message "Ended state %s, going back to %s" old-state new-state)
(if old-state
(phps-mode-lexer-BEGIN old-state)
(display-warning "phps-mode" "PHPs Lexer Error - Going back to nil?"))
@@ -721,10 +720,11 @@
((looking-at "}")
(when phps-mode-lexer-state_stack
- (message "State stack %s" phps-mode-lexer-state_stack)
- (message "popping state from } %s at %s-%s" (length
phps-mode-lexer-state_stack) (match-beginning 0) (match-end 0))
+ ;; (message "State stack %s" phps-mode-lexer-state_stack)
+ ;; (message "popping state from } %s at %s-%s" (length
phps-mode-lexer-state_stack) (match-beginning 0) (match-end 0))
(phps-mode-lexer-yy_pop_state)
- (message "New state: %s" phps-mode-lexer-STATE))
+ ;; (message "New state: %s" phps-mode-lexer-STATE)
+ )
(phps-mode-lexer-RETURN_TOKEN "}" (match-beginning 0) (match-end 0)))
((looking-at phps-mode-lexer-BNUM)
@@ -997,12 +997,12 @@
((looking-at "{\\$")
(phps-mode-lexer-yy_push_state phps-mode-lexer-ST_IN_SCRIPTING)
- (message "Starting ST_IN_SCRIPTING from double-quoted string at %s-%s"
(match-beginning 0) (- (match-end 0) 1))
+ ;; (message "Starting ST_IN_SCRIPTING from double-quoted string at %s-%s"
(match-beginning 0) (- (match-end 0) 1))
(phps-mode-lexer-RETURN_TOKEN 'T_CURLY_OPEN (match-beginning 0) (-
(match-end 0) 1)))
((looking-at "[\"]")
(phps-mode-lexer-BEGIN phps-mode-lexer-ST_IN_SCRIPTING)
- (message "Ended double-quote at %s" (match-beginning 0))
+ ;; (message "Ended double-quote at %s" (match-beginning 0))
(phps-mode-lexer-RETURN_TOKEN "\"" (match-beginning 0) (match-end 0)))
((looking-at phps-mode-lexer-ANY_CHAR)
@@ -1018,17 +1018,12 @@
(progn
(let ((variable-start (+ start (match-beginning 0))))
- (when (or (string-match (concat "\\${"
phps-mode-lexer-LABEL) double-quoted-string)
- (string-match (concat "{\\$"
phps-mode-lexer-LABEL) double-quoted-string))
- (setq variable-start (1- variable-start))
- (message "Decreased index with one"))
-
- (message "Found starting expression inside double-quoted
string at: %s %s" start variable-start)
+ ;; (message "Found starting expression inside
double-quoted string at: %s %s" start variable-start)
(phps-mode-lexer-RETURN_TOKEN
'T_CONSTANT_ENCAPSED_STRING start variable-start)
))
(progn
(phps-mode-lexer-RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING
start end)
- (message "Found end of quote at %s-%s, moving ahead after
'%s'" start end (buffer-substring-no-properties start end))
+ ;; (message "Found end of quote at %s-%s, moving ahead after
'%s'" start end (buffer-substring-no-properties start end))
)))
(progn
;; "Found no end of double-quoted region
diff --git a/phps-mode-test-lexer.el b/phps-mode-test-lexer.el
index 3292197..685c954 100644
--- a/phps-mode-test-lexer.el
+++ b/phps-mode-test-lexer.el
@@ -271,9 +271,9 @@
(phps-mode-test-with-buffer
"<?php $this->add($option['style']['selectors'], array('background' =>
\"{$value['color']} url('{$value['image']}')\"));"
"Complex tokens with tokens inside double-quoted string"
- ;; (message "Tokens 2: %s" phps-mode-lexer-tokens)
+ (message "Tokens 2: %s" phps-mode-lexer-tokens)
(should (equal phps-mode-lexer-tokens
- '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR
12 . 14) (T_STRING 14 . 21) ("(" 21 . 22) ("\"" 22 . 23)
(T_ENCAPSED_AND_WHITESPACE 23 . 47) (T_VARIABLE 47 . 52) (T_OBJECT_OPERATOR 52
. 54) (T_STRING 54 . 59) (T_CONSTANT_ENCAPSED_STRING 59 . 72) ("\"" 72 . 73)
("." 73 . 74) (T_VARIABLE 74 . 77) ("." 77 . 78) (T_CONSTANT_ENCAPSED_STRING 78
. 81) (")" 81 . 82) (";" 82 . 83) (";" 84 . 86) (T_CLOSE_TAG 84 . 86)))))
+ '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR
12 . 14) (T_STRING 14 . 17) ("(" 17 . 18) (T_VARIABLE 18 . 25) ("[" 25 . 26)
(T_CONSTANT_ENCAPSED_STRING 26 . 33) ("]" 33 . 34) ("[" 34 . 35)
(T_CONSTANT_ENCAPSED_STRING 35 . 46) ("]" 46 . 47) ("," 47 . 48) (T_ARRAY 49 .
54) ("(" 54 . 55) (T_CONSTANT_ENCAPSED_STRING 55 . 67) (T_DOUBLE_ARROW 68 . 70)
("\"" 71 . 72) (T_ENCAPSED_AND_WHITESPACE 72 . 72) (T_CURLY_OPEN 72 . 73)
(T_VARIABLE 73 . 79) ("[" 79 . 80) (T_C [...]
;; TODO Test object properties inside heredoc, nowdocs strings
- [elpa] externals/phps-mode eb0ee5e 236/405: Updated README with imenu-support, (continued)
- [elpa] externals/phps-mode eb0ee5e 236/405: Updated README with imenu-support, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 811c499 220/405: New algorithm now works for switch, case syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d2e5a03 228/405: Updated indentation algorithm document and README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1aa0f90 238/405: Typo in README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode da1cfd5 231/405: Adding failing lexer test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e6a8944 241/405: Started work on a lexer bug with expressions inside double quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0c49d6d 243/405: Removed debugging output, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 95ac15a 245/405: Imenu index now handles class extends and implements, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 67233ef 213/405: Fixed indent algorithm for multi-line strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 36a4b64 222/405: Added lost test for token-less lines again, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 70f2d46 242/405: Fixed lexer issue with multiple expressions inside double-quoted string,
Stefan Monnier <=
- [elpa] externals/phps-mode 0286660 224/405: Indentation passes new tests for concatenated strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f05d40a 230/405: Tests for lexer passes again after close_tag modification, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1bc5713 227/405: New tests for concatenation passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c71a97d 178/405: Started on refactored indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8bb3918 249/405: Clean-up of unit test logging, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9201d1c 246/405: Imenu index now handles functions with optional arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2c3239a 187/405: Adding new failing tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d9a0119 183/405: Optimized indentation code by removing unused variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a0cbcd1 186/405: More work on indentation of multi-line IF-expressions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d7c5f67 190/405: More work on nesting-stack, Stefan Monnier, 2019/07/13