[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 394f7ae 017/405: Fixed issue with empty strin
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 394f7ae 017/405: Fixed issue with empty strings before non-empty strings |
Date: |
Sat, 13 Jul 2019 09:59:31 -0400 (EDT) |
branch: externals/phps-mode
commit 394f7aed8ac2c47acfdaaed21aae1b31e4e5ab61
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Fixed issue with empty strings before non-empty strings
---
phps-lexer.el | 106 ++++++++++++++++++++++-----------------------
sample-php-files/class.php | 1 +
2 files changed, 53 insertions(+), 54 deletions(-)
diff --git a/phps-lexer.el b/phps-lexer.el
index 3e84f52..1e5ce6f 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -447,15 +447,15 @@
((looking-at "return")
(phps-mode/RETURN_TOKEN 'T_RETURN (match-beginning 0) (match-end 0)))
((looking-at (concat "yield" phps-mode/WHITESPACE "from"
"[^a-zA-Z0-9_\x80-\xff]"))
- (phps-mode/RETURN_TOKEN 'T_YIELD_FROM (match-beginning 0) (match-end 0)))
+ (phps-mode/RETURN_TOKEN 'T_YIELD_FROM (match-beginning 0) (match-end 0)))
((looking-at "yield")
- (phps-mode/RETURN_TOKEN 'T_YIELD (match-beginning 0) (match-end 0)))
+ (phps-mode/RETURN_TOKEN 'T_YIELD (match-beginning 0) (match-end 0)))
((looking-at "try")
(phps-mode/RETURN_TOKEN 'T_TRY (match-beginning 0) (match-end 0)))
((looking-at "catch")
- (phps-mode/RETURN_TOKEN 'T_CATCH (match-beginning 0) (match-end 0)))
+ (phps-mode/RETURN_TOKEN 'T_CATCH (match-beginning 0) (match-end 0)))
((looking-at "finally")
- (phps-mode/RETURN_TOKEN 'T_FINALLY (match-beginning 0) (match-end 0)))
+ (phps-mode/RETURN_TOKEN 'T_FINALLY (match-beginning 0) (match-end 0)))
((looking-at "throw")
(phps-mode/RETURN_TOKEN 'T_THROW (match-beginning 0) (match-end 0)))
((looking-at "if")
@@ -471,7 +471,7 @@
((looking-at "endwhile")
(phps-mode/RETURN_TOKEN 'T_ENDWHILE (match-beginning 0) (match-end 0)))
((looking-at "do")
- (phps-mode/RETURN_TOKEN 'T_DO (match-beginning 0) (match-end 0)))
+ (phps-mode/RETURN_TOKEN 'T_DO (match-beginning 0) (match-end 0)))
((looking-at "foreach")
(phps-mode/RETURN_TOKEN 'T_FOREACH (match-beginning 0) (match-end 0)))
((looking-at "endforeach")
@@ -557,7 +557,7 @@
(phps-mode/RETURN_TOKEN 'T_START_HEREDOC start end)))
((looking-at "::")
- (phps-mode/RETURN_TOKEN 'T_PAAMAYIM_NEKUDOTAYIM (match-beginning 0)
(match-end 0)))
+ (phps-mode/RETURN_TOKEN 'T_PAAMAYIM_NEKUDOTAYIM (match-beginning 0)
(match-end 0)))
((looking-at "\\\\")
(phps-mode/RETURN_TOKEN 'T_NS_SEPARATOR (match-beginning 0) (match-end 0)))
((looking-at "\\.\\.\\.")
@@ -827,24 +827,23 @@
(data (buffer-substring-no-properties start end))
(found nil))
(forward-char)
- (let ((string-start (search-forward-regexp "[^\\\\]'" nil t)))
- (if string-start
- (progn
- ;; (message "Single quoted string %s"
(buffer-substring-no-properties start string-start))
- (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start
string-start))
+ ;; Handle the '' case
+ (if (looking-at-p "'")
(progn
- ;; Handle the '' case
- (if (looking-at-p "'")
- (progn
- ;; (message "Empty single quoted string from %s to %s" start
(+ start 2))
- (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+
start 2))
- (forward-char))
+ ;; (message "Empty single quoted string from %s to %s" start (+
start 2))
+ (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ start
2))
+ (forward-char))
+ (let ((string-start (search-forward-regexp "[^\\\\]'" nil t)))
+ (if string-start
(progn
- ;; Unclosed single quotes
- ;; (message "Single quoted string never ends..")
- (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start
(point-max))
- (phps-mode/MOVE_FORWARD (point-max))
- )))))))
+ ;; (message "Single quoted string %s"
(buffer-substring-no-properties start string-start))
+ (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start
string-start))
+ (progn
+ ;; Unclosed single quotes
+ ;; (message "Single quoted string never ends..")
+ (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start
(point-max))
+ (phps-mode/MOVE_FORWARD (point-max))
+ ))))))
;; Double quoted string
((looking-at "\"")
@@ -852,39 +851,38 @@
(end (match-end 0))
(data (buffer-substring-no-properties start end)))
(forward-char)
- (let ((string-start (search-forward-regexp (concat
- "\\([^\\\\]\""
- "\\|\\$" phps-mode/LABEL
- "\\|\\${" phps-mode/LABEL
- "\\|{\\$" phps-mode/LABEL
"\\)")
- nil t)))
- ;; Do we find a ending double quote or starting variable?
- (if string-start
- (let ((string-start (match-beginning 0)))
- ;; (message "Double quoted string %s" double-quoted-string)
- ;; Do we find variable inside quote?
- (goto-char string-start)
- (if (looking-at "[^\\\\]\"")
- (progn
- (let ((double-quoted-string
(buffer-substring-no-properties start (+ string-start 2))))
- ;; (message "Double quoted string: %s"
double-quoted-string)
- (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING
start (+ string-start 2))))
- (progn
- ;; (message "Found variable after '%s'"
(buffer-substring-no-properties start (point)))
- (phps-mode/BEGIN phps-mode/ST_DOUBLE_QUOTES)
- (phps-mode/RETURN_TOKEN "\"" start (+ start 1))
- (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE (+ start
1) string-start))))
+ ;; Handle the "" case
+ (if (looking-at-p "\"")
(progn
- ;; Handle the "" case
- (if (looking-at-p "\"")
- (progn
- ;; (message "Empty double quoted string from %s to %s" start
(+ start 2))
- (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+
start 2))
- (forward-char))
- (progn
- ;; (message "Found no ending quote, skipping to end")
- (phps-mode/RETURN_TOKEN 'T_ERROR start (point-max))
- (phps-mode/MOVE_FORWARD (point-max)))))))))
+ ;; (message "Empty double quoted string from %s to %s" start (+
start 2))
+ (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ start
2))
+ (forward-char))
+ (let ((string-start (search-forward-regexp (concat
+ "\\([^\\\\]\""
+ "\\|\\$" phps-mode/LABEL
+ "\\|\\${" phps-mode/LABEL
+ "\\|{\\$" phps-mode/LABEL
"\\)")
+ nil t)))
+ ;; Do we find a ending double quote or starting variable?
+ (if string-start
+ (let ((string-start (match-beginning 0)))
+ ;; (message "Double quoted string %s" double-quoted-string)
+ ;; Do we find variable inside quote?
+ (goto-char string-start)
+ (if (looking-at "[^\\\\]\"")
+ (progn
+ (let ((double-quoted-string
(buffer-substring-no-properties start (+ string-start 2))))
+ ;; (message "Double quoted string: %s"
double-quoted-string)
+ (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING
start (+ string-start 2))))
+ (progn
+ ;; (message "Found variable after '%s'"
(buffer-substring-no-properties start (point)))
+ (phps-mode/BEGIN phps-mode/ST_DOUBLE_QUOTES)
+ (phps-mode/RETURN_TOKEN "\"" start (+ start 1))
+ (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE (+
start 1) string-start))))
+ (progn
+ ;; (message "Found no ending quote, skipping to end")
+ (phps-mode/RETURN_TOKEN 'T_ERROR start (point-max))
+ (phps-mode/MOVE_FORWARD (point-max))))))))
((looking-at "[`]")
;; (message "Begun backquote at %s-%s" (match-beginning 0) (match-end 0))
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index f3c81bf..7862e0b 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -24,6 +24,7 @@ class MyClass {
if (!empty($this->var)) {
$this->var = '';
}
+ $this->var = 'abc';
}
}
- [elpa] externals/phps-mode 7d0cd36 002/405: Updated goals, (continued)
- [elpa] externals/phps-mode 7d0cd36 002/405: Updated goals, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode dd8d800 004/405: Using coloring overlay for comments as well, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c64b3b4 008/405: More work on lexer tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a724438 010/405: Handled lexing with empty single and double quote string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5a6a96b 012/405: Added another test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b3a6308 015/405: Added hook for resetting lexer variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ce656a5 006/405: More general cleaning up, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f3205d5 011/405: Fixed lexing of basic tokens, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 31ca9d5 007/405: More cleaning up, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 79040dc 005/405: Some cleaning up, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 394f7ae 017/405: Fixed issue with empty strings before non-empty strings,
Stefan Monnier <=
- [elpa] externals/phps-mode 41c4fbb 009/405: Lexer unit tests now working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be078dc 020/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c4a8ca5 016/405: Free lexer tokens does not have properties anymore, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8ed0716 022/405: Started with unit tests for getting point lexer data, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode abcfd01 021/405: Started with function to gather current point data, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2475734 018/405: Improved logic for single quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 795053b 013/405: Lexer unit tests using start and ends as well, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 95e749e 028/405: Started with indentation function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3202213 025/405: Added another unit test for lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode bf59f0a 023/405: More unit tests for getting point lex information, Stefan Monnier, 2019/07/13