[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode a1aa0a2 05/62: More work on PHP 8.0 lex analy
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode a1aa0a2 05/62: More work on PHP 8.0 lex analyzer |
Date: |
Tue, 20 Apr 2021 10:56:12 -0400 (EDT) |
branch: externals/phps-mode
commit a1aa0a2cadd403cd8f9c62be7641ef1e5f24c4fc
Author: Christian Johansson <christian@mediastrategi.se>
Commit: Christian Johansson <christian@mediastrategi.se>
More work on PHP 8.0 lex analyzer
---
phps-mode-lexer.el | 49 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 13 deletions(-)
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 699fae6..3419587 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -163,7 +163,8 @@
(defun phps-mode-lexer--yyless (points)
"Move lexer back POINTS."
- (setq semantic-lex-end-point (- semantic-lex-end-point points)))
+ (setq semantic-lex-end-point (- semantic-lex-end-point points))
+ (forward-char (- points)))
(defun phps-mode-lexer--inline-char-handler ()
"Mimic inline_char_handler."
@@ -1060,6 +1061,8 @@
(phps-mode-lexer--return-end-token)
(phps-mode-lexer--inline-char-handler)))
+ ;; Make sure a label character follows "->" or "?->", otherwise there is
no property
+ ;; and "->"/"?->" will be taken literally
(phps-mode-lexer--match-macro
(and (or ST_DOUBLE_QUOTES ST_HEREDOC ST_BACKQUOTE)
(looking-at
@@ -1072,8 +1075,19 @@
(phps-mode-lexer--yy-push-state 'ST_LOOKING_FOR_PROPERTY)
(phps-mode-lexer--return-token-with-str 'T_VARIABLE 1 (match-beginning
0) (- (match-end 0) 3)))
- ;; TODO Was here
+ (phps-mode-lexer--match-macro
+ (and (or ST_DOUBLE_QUOTES ST_HEREDOC ST_BACKQUOTE)
+ (looking-at
+ (concat
+ "\\$"
+ phps-mode-lexer--LABEL
+ "\\?->"
+ "[a-zA-Z_\x80-\xff]")))
+ (phps-mode-lexer--yyless 4)
+ (phps-mode-lexer--yy-push-state 'ST_LOOKING_FOR_PROPERTY)
+ (phps-mode-lexer--return-token-with-str 'T_VARIABLE 1 (match-beginning
0) (- (match-end 0) 4)))
+ ;; A [ always designates a variable offset, regardless of what follows
(phps-mode-lexer--match-macro
(and (or ST_DOUBLE_QUOTES ST_HEREDOC ST_BACKQUOTE)
(looking-at
@@ -1081,9 +1095,10 @@
"\\$"
phps-mode-lexer--LABEL
"\\[")))
+ (phps-mode-lexer--yyless 1)
(phps-mode-lexer--yy-push-state 'ST_VAR_OFFSET)
- (forward-char -1)
- (phps-mode-lexer--return-token 'T_VARIABLE (match-beginning 0) (-
(match-end 0) 1)))
+ (phps-mode-lexer--return-token-with-str
+ 'T_VARIABLE 1 (match-beginning 0) (- (match-end 0) 1)))
(phps-mode-lexer--match-macro
(and (or ST_IN_SCRIPTING ST_DOUBLE_QUOTES ST_HEREDOC ST_BACKQUOTE
ST_VAR_OFFSET)
@@ -1091,27 +1106,35 @@
(concat
"\\$"
phps-mode-lexer--LABEL)))
- (phps-mode-lexer--return-token 'T_VARIABLE (match-beginning 0)
(match-end 0)))
+ (phps-mode-lexer--return-token-with-str 'T_VARIABLE 1))
(phps-mode-lexer--match-macro
(and ST_VAR_OFFSET (looking-at "\\]"))
(phps-mode-lexer--yy-pop-state)
- (phps-mode-lexer--return-token "]" (match-beginning 0) (match-end 0)))
+ (phps-mode-lexer--return-token-with-str "]" 1 (match-beginning 0)
(match-end 0)))
(phps-mode-lexer--match-macro
- (and ST_VAR_OFFSET (looking-at (concat "\\(" phps-mode-lexer--TOKENS
- "\\|[{}\"`]\\)")))
+ (and ST_VAR_OFFSET
+ (looking-at
+ (concat "\\(" phps-mode-lexer--TOKENS
+ "\\|[{}\"`]\\)")))
(let* ((start (match-beginning 0))
(end (match-end 0))
(data (buffer-substring-no-properties start end)))
- (phps-mode-lexer--return-token data start end)))
+ ;; Only '[' or '-' can be valid, but returning other tokens will
allow a more explicit parse error
+ (phps-mode-lexer--return-token data)))
+ ;; TODO New function below
(phps-mode-lexer--match-macro
(and ST_VAR_OFFSET (looking-at (concat "[ \n\r\t'#]")))
- (let* ((start (match-beginning 0))
- (end (- (match-end 0) 1)))
- (phps-mode-lexer--yy-pop-state)
- (phps-mode-lexer--return-token 'T_ENCAPSED_AND_WHITESPACE start end)))
+ ;; Invalid rule to return a more explicit parse error with proper line
number
+ (phps-mode-lexer--yyless 0)
+ (phps-mode-lexer--yy-pop-state)
+ (phps-mode-lexer--return-token-with-val 'T_ENCAPSED_AND_WHITESPACE))
+
+
+ ;; TODO Was here
+
(phps-mode-lexer--match-macro
(and (or ST_IN_SCRIPTING ST_VAR_OFFSET) (looking-at
phps-mode-lexer--LABEL))
- [elpa] externals/phps-mode updated (a8dcba3 -> 209055b), Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 8647f09 01/62: Started on adding support for PHP 8.0 lex analyzer, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 846b3b0 03/62: More work on PHP 8.0 lex analyzer, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 83c7648 04/62: More work on PHP 8 lex analyzer, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode a1aa0a2 05/62: More work on PHP 8.0 lex analyzer,
Christian Johansson <=
- [elpa] externals/phps-mode 60a33b3 06/62: More work on PHP 8.0 lex analyzer, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 111335b 11/62: Added TODO item, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode fbea5d9 07/62: Improved naming in lex analyzer, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 79bbd0c 10/62: Fixed a regex issue, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode de5fea6 12/62: Added new token and lex analyzer functions, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 04d0065 08/62: Added syntax coloring for new tokens, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode c56268f 13/62: Implement new lex-analyzer function, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 11313cc 15/62: Removed unnecessary code, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode cd7ebb7 17/62: Removed unnecessary comment, Christian Johansson, 2021/04/20
- [elpa] externals/phps-mode 09d0bca 18/62: Passing old unit tests for lexer simple tokens, Christian Johansson, 2021/04/20