branch: externals/phps-mode
commit b0ad20421cfce9e5f688645d4333d7eb8ed04bb0
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Improved YACC grammar parser for productions
---
admin/phps-mode-grammar-parser-generator.el | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/admin/phps-mode-grammar-parser-generator.el
b/admin/phps-mode-grammar-parser-generator.el
index 8c94476..0ae4a1c 100644
--- a/admin/phps-mode-grammar-parser-generator.el
+++ b/admin/phps-mode-grammar-parser-generator.el
@@ -48,7 +48,7 @@
nil)
(parser-generator-set-grammar
'(
- (Start Productions-Block Productions-Delimiter Productions Productions
Production Production-End LHS RHSS RHS RHS-Symbol Comment Logic Symbol)
+ (Start Productions-Block Productions-Delimiter Productions Productions
Production Production-End LHS RHSS RHS RHS-Symbol RHS-Symbols Comment Logic
Symbol)
(productions-delimiter ":" "|" ";" comment logic symbol literal)
(
(Start
@@ -89,9 +89,25 @@
(RHS
(RHS-Symbol
(lambda(args) (format "%s" args)))
+ (RHS-Symbols
+ (lambda(args)
+ (if (string-match-p " " args)
+ (format "(%s)" args)
+ (format "%s" args))))
+ )
+ (RHS-Symbols
+ (RHS-Symbol
+ RHS-Symbols
+ (lambda (args)
+ (if (string= (nth 1 args) "")
+ (format "%s" (nth 0 args))
+ (format "%s %s" (nth 0 args) (nth 1 args)))))
(RHS-Symbol
- RHS
- (lambda (args) (format "%s %s" (nth 0 args) (nth 1 args))))
+ RHS-Symbol
+ (lambda (args)
+ (if (string= (nth 1 args) "")
+ (format "%s" (nth 0 args))
+ (format "%s %s" (nth 0 args) (nth 1 args)))))
)
(RHS-Symbol
Comment