[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 3fa1b13 41/96: Translation of productions now
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 3fa1b13 41/96: Translation of productions now working |
Date: |
Fri, 29 Oct 2021 11:14:43 -0400 (EDT) |
branch: externals/phps-mode
commit 3fa1b1316f211eae72eabd184f87976dc461ac73
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Translation of productions now working
---
admin/phps-mode-grammar-parser-generator.el | 151 +++++++++++++++++-----------
1 file changed, 94 insertions(+), 57 deletions(-)
diff --git a/admin/phps-mode-grammar-parser-generator.el
b/admin/phps-mode-grammar-parser-generator.el
index a5b9d78..b78a6af 100644
--- a/admin/phps-mode-grammar-parser-generator.el
+++ b/admin/phps-mode-grammar-parser-generator.el
@@ -31,7 +31,6 @@
(parser-generator-set-look-ahead-number
1)
- (message "set here")
(setq
parser-generator--e-identifier
'%empty)
@@ -52,18 +51,57 @@
(Start Productions-Block Productions-Delimiter Productions Productions
Production LHS RHSS RHS RHS-Symbol Comment Logic Symbol)
(productions-delimiter ":" "|" ";" comment logic symbol literal)
(
- (Start Productions-Block)
- (Productions-Block (Productions-Delimiter Productions
Productions-Delimiter))
- (Productions-Delimiter (productions-delimiter (lambda(args) "")))
- (Productions Production (Productions Production (lambda(args) (format
"%s\n\n%s" (nth 0 args) (nth 1 args)))))
- (Production (Comment Production) (LHS ":" RHSS ";" (lambda(args) (format
"(%s\n %s\n)" (nth 0 args) (nth 2 args)))))
- (LHS Symbol)
- (RHSS RHS (RHSS "|" RHS (lambda(args) (format "%s\n %s" (nth 0 args)
(nth 2 args)))))
- (RHS RHS-Symbol (RHS RHS-Symbol))
+ (Start
+ Productions-Block)
+ (Productions-Block
+ (Productions-Delimiter Productions Productions-Delimiter
+ (lambda(args) (format "'(\n%s\n)" (nth 1 args))))
+ )
+ (Productions-Delimiter
+ (productions-delimiter
+ (lambda(args) ""))
+ )
+ (Productions
+ (Production
+ (lambda(args) (format "%s" args)))
+ (Productions Production
+ (lambda(args) (format "%s\n\n%s" (nth 0 args) (nth 1
args))))
+ )
+ (Production
+ (Comment Production
+ (lambda(args) (format "%s" (nth 1 args))))
+ (LHS ":" RHSS ";"
+ (lambda(args) (format " (%s\n %s\n )" (nth 0 args) (nth 2 args))))
+ )
+ (LHS
+ (Symbol
+ (lambda(args) (format "%s" args)))
+ )
+ (RHSS
+ (RHS
+ (lambda(args) (format "%s" args)))
+ (RHSS "|" RHS
+ (lambda(args) (format "%s\n %s" (nth 0 args) (nth 2 args))))
+ )
+ (RHS
+ (RHS-Symbol
+ (lambda(args) (format "%s" args)))
+ (RHS
+ RHS-Symbol
+ (lambda (args) (format "%s %s" (nth 0 args) (nth 1 args))))
+ )
(RHS-Symbol Comment Logic Symbol)
(Comment (comment (lambda(args) "")))
- (Logic (logic (lambda(args) "")))
- (Symbol symbol (literal (lambda(args) (format "%S" (substring args 1
2)))))
+ (Logic
+ (logic
+ (lambda(args) ""))
+ )
+ (Symbol
+ (symbol
+ (lambda(args) (format "%s" args)))
+ (literal
+ (lambda(args) (format "%S" (substring args 1 2))))
+ )
)
Start))
@@ -108,55 +146,55 @@
(logic-end)
(continue t))
(forward-char 1)
- (while (and
- continue
- (> nesting-stack 0)
- (< (point) (point-max)))
- (let ((next-stop (search-forward-regexp "\\({\\|}\\|/\\*\\)"
nil t)))
- (let ((match (buffer-substring-no-properties (match-beginning
0) (match-end 0))))
- (cond
-
- ((not next-stop)
- (setq
+ (while (and
continue
- nil))
-
- ((string= match "{")
- (setq
- nesting-stack
- (1+ nesting-stack)))
-
- ((string= match "}")
- (setq
- nesting-stack
- (1- nesting-stack))
- (when
- (= nesting-stack 0)
- (when (looking-at ";")
- (forward-char 1))
+ (> nesting-stack 0)
+ (< (point) (point-max)))
+ (let ((next-stop (search-forward-regexp "\\({\\|}\\|/\\*\\)"
nil t)))
+ (let ((match (buffer-substring-no-properties
(match-beginning 0) (match-end 0))))
+ (cond
+
+ ((not next-stop)
+ (setq
+ continue
+ nil))
+
+ ((string= match "{")
+ (setq
+ nesting-stack
+ (1+ nesting-stack)))
+
+ ((string= match "}")
(setq
- logic-end
- (point))))
-
- ((string= match "/*")
- (let (
- (comment-start (match-beginning 0))
- (comment-end
- (search-forward-regexp "\\*/" nil t)))
- (unless comment-end
- (error
- "Failed to find end of comment started at %S (2))"
- comment-start))))
-
-
- ))))
+ nesting-stack
+ (1- nesting-stack))
+ (when
+ (= nesting-stack 0)
+ (when (looking-at ";")
+ (forward-char 1))
+ (setq
+ logic-end
+ (point))))
+
+ ((string= match "/*")
+ (let (
+ (comment-start (match-beginning 0))
+ (comment-end
+ (search-forward-regexp "\\*/" nil t)))
+ (unless comment-end
+ (error
+ "Failed to find end of comment started at %S (2))"
+ comment-start))))
+
+
+ ))))
(unless logic-end
(error
"Failed to find end of logic started at %S"
logic-start))
- (setq
- token
- `(logic ,logic-start . ,logic-end))))
+ (setq
+ token
+ `(logic ,logic-start . ,logic-end))))
((looking-at "\\(:\\|;\\||\\)")
(setq
@@ -189,8 +227,7 @@
(let ((token-data
(buffer-substring-no-properties
(car (cdr token))
- (cdr (cdr token)))))
- (message "Token: %S = %S" token token-data)))
+ (cdr (cdr token)))))))
token))))
(setq
@@ -225,7 +262,7 @@
(kill-region delimiter-start (point-max)))
(goto-char (point-min))
(let ((translation (parser-generator-lr-translate)))
- (message "translation:\n%S" translation))))
+ (message "translation:\n%s" translation))))
(provide 'phps-mode-grammar-parser-generator)
;;; phps-mode-grammar-parser-generator.el ends here
- [elpa] externals/phps-mode 50a014a 18/96: Using same lexer buffer for parser as the lex-analyzer is using, (continued)
- [elpa] externals/phps-mode 50a014a 18/96: Using same lexer buffer for parser as the lex-analyzer is using, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode fb9905f 19/96: Added basic translation test, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode ec18c1e 22/96: Using parser to be able to implement incremental parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 1ee3094 28/96: More refactoring of the parsers lex-analyzer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 2ceb6e5 23/96: Added potential support for incremental parsing, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode e59d30e 26/96: Improvements in lex-analyzer for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode c62ec64 27/96: Started refactor of parsers lex-analyzer, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 9acda54 33/96: Added more passing tests for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode c470e37 38/96: More work on grammar parser generator, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 6b9c1a4 40/96: More pasing of grammar, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 3fa1b13 41/96: Translation of productions now working,
Christian Johansson <=
- [elpa] externals/phps-mode b0ad204 44/96: Improved YACC grammar parser for productions, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 3824d7d 46/96: More work on automatically parsing YACC grammar, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 42c4e0e 48/96: Work on automatically generating terminals, non-terminals and start from YACC grammar, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode f56ba64 49/96: Terminals, non-terminals and start is automatically generated from YACC, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 7323416 31/96: Added failing test for parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 7c66145 30/96: Refactor of parsers lex-analyzer complete, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 0e89b6e 35/96: Fixed bug in automation grammar, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode 65152f4 36/96: Added TODO item, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode add17a7 24/96: T_COMMENT and T_DOC_COMMENT are excluded from parser, Christian Johansson, 2021/10/29
- [elpa] externals/phps-mode f46b98f 25/96: More work on integrating parser, Christian Johansson, 2021/10/29