branch: externals/phps-mode commit e007ea74ef243031abbd184a21a17ddf3b59c989 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Fixed parser-mode issue with parser and lex-analyzer integration --- phps-mode-automation-grammar.el | 10 +++++++++- phps-mode-parser.el | 17 ++++++++++++----- test/phps-mode-test-parser.el | 17 ++++++++--------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/phps-mode-automation-grammar.el b/phps-mode-automation-grammar.el index 5a1cc34..8f40aa4 100644 --- a/phps-mode-automation-grammar.el +++ b/phps-mode-automation-grammar.el @@ -135,6 +135,8 @@ (car (cdr token)) temp-token-list-index) phps-mode-parser-position) + + ;; Compatibility with parser (unless (or (equal token-type 'T_OPEN_TAG) (equal token-type 'T_CLOSE_TAG) @@ -151,17 +153,23 @@ temp-token-list-index (1+ temp-token-list-index)) ))))) - (when token-list-index (let ((token (nth token-list-index phps-mode-parser-tokens))) + + ;; Compatibility with parser (when (equal (car token) 'T_OPEN_TAG_WITH_ECHO) (setf (car token) 'T_ECHO)) + (when (equal (car token) 'T_CLOSE_TAG) + (setf + (car token) + ";")) + token)))) "The custom lex-analyzer.") diff --git a/phps-mode-parser.el b/phps-mode-parser.el index fee65b1..63fe9b9 100644 --- a/phps-mode-parser.el +++ b/phps-mode-parser.el @@ -178,9 +178,10 @@ (car (cdr token)) temp-token-list-index) phps-mode-parser-position) + + ;; Compatibility with parser (unless (or (equal token-type 'T_OPEN_TAG) - (equal token-type 'T_CLOSE_TAG) (equal token-type 'T_DOC_COMMENT) (equal token-type 'T_COMMENT)) (setq-local @@ -194,17 +195,23 @@ temp-token-list-index (1+ temp-token-list-index)) ))))) - (when token-list-index (let ((token (nth token-list-index phps-mode-parser-tokens))) + + ;; Compatibility with parser (when (equal (car token) 'T_OPEN_TAG_WITH_ECHO) - (setf - (car token) - 'T_ECHO)) + (setq + token + `(T_ECHO ,(car (cdr token)) . ,(cdr (cdr token))))) + (when (equal (car token) 'T_CLOSE_TAG) + (setq + token + `(";" ,(car (cdr token)) . ,(cdr (cdr token))))) + token)))) "The lex-analyzer function.") diff --git a/test/phps-mode-test-parser.el b/test/phps-mode-test-parser.el index 301defd..a852a63 100644 --- a/test/phps-mode-test-parser.el +++ b/test/phps-mode-test-parser.el @@ -111,7 +111,7 @@ (lambda() (should (equal - '(80 449 456 403 325 324 152 102 79) + '(80 449 456 403 325 324 152 102 79 159 102 79) (phps-mode-parser-parse))))) (phps-mode-test-parser--buffer-contents @@ -132,7 +132,7 @@ (phps-mode-test-parser--buffer-contents "<?php\necho 'blaha'" - "Basic echo test 5 with invalid code" + "Basic echo test 5 with valid code in parser mode only" (lambda() (should-error (phps-mode-parser-parse)))) @@ -155,7 +155,7 @@ (message "\n") (should (equal - '(80 449 456 403 325 324 152 102 79 153 102 79 449 456 403 325 324 152 102 79 153 102 79) + '(80 449 456 403 325 324 152 102 79 159 102 79 153 102 79 449 456 403 325 324 152 102 79 159 102 79 153 102 79) parse))))) (phps-mode-test-parser--buffer-contents @@ -278,12 +278,11 @@ (lambda() (phps-mode-parser-parse))) - ;; TODO Make this work - ;; (phps-mode-test-parser--buffer-contents - ;; "<?php echo 'here' ?>" - ;; "Expression without trailing semi-colon but with close tag" - ;; (lambda() - ;; (phps-mode-parser-parse))) + (phps-mode-test-parser--buffer-contents + "<?php echo 'here' ?>" + "Expression without trailing semi-colon but with close tag" + (lambda() + (phps-mode-parser-parse))) ;; TODO Make this work ;; (phps-mode-test-parser--buffer-contents