Merge from emacs-24; up to 2013-01-03T01:56:56Z!rgm@gnu.org
[bpt/emacs.git] / admin / grammars / srecode-template.wy
index 4ff2d7e..fd3f619 100644 (file)
@@ -1,6 +1,6 @@
 ;;; srecode-template.wy --- Semantic Recoder Template parser
 
-;; Copyright (C) 2005-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2013 Free Software Foundation, Inc.
 
 ;; Author: Eric Ludlam <zappo@gnu.org>
 ;; Keywords: syntax
@@ -28,6 +28,9 @@
 ;; Semantic Recoder templates are based on Google Templates
 ;; and are at the bottom of the Semantic Recoder API.
 
+%package srecode-template-wy
+%provide srecode/srt-wy
+
 %languagemode  srecode-mode
 
 %start template_file
 %put     TEMPLATE  summary "template <name>\\n <template definition>"
 %keyword SECTIONDICTIONARY "sectiondictionary"
 %put     SECTIONDICTIONARY summary "sectiondictionary <name>\\n <dictionary entries>"
+
+%keyword SECTION  "section"
+%put     SECTION  summary
+         "section <name>\\n <dictionary entries>\\n end"
+
+%keyword END      "end"
+%put     END      summary
+         "section ... end"
+
 %keyword PROMPT "prompt"
 %keyword DEFAULT "default"
 %keyword DEFAULTMACRO "defaultmacro"
@@ -62,7 +74,7 @@
 %token <separator> TEMPLATE_BLOCK "^----"
 
 ;;; Bland default types
-%type <property> ":\\(\\w\\|\\s_\\)*"
+%type <property> syntax ":\\(\\w\\|\\s_\\)*"
 %token <property> property
 
 %type  <symbol>
@@ -113,6 +125,10 @@ opt-read-fcn
 variable
   : SET symbol insertable-string-list newline
     (VARIABLE-TAG $2 nil $3)
+  | SET symbol number newline
+    ;; This so a common error w/ priority works.
+    ;; Note that "number" still has a string value in the lexer.
+    (VARIABLE-TAG $2 nil (list $3))
   | SHOW symbol newline
     (VARIABLE-TAG $2 nil t)
   ;
@@ -134,7 +150,7 @@ insertable-string
 template
   : TEMPLATE templatename opt-dynamic-arguments newline
     opt-string
-    opt-section-dictionaries
+    section-dictionary-list
     TEMPLATE_BLOCK newline
     opt-bind
     (FUNCTION-TAG $2 nil $3 :documentation $5 :code $7
@@ -165,29 +181,52 @@ opt-string
   | ()
   ;
 
-opt-section-dictionaries
-  : () ;; EMPTY
-  | section-dictionary-list
-  ;
-
 section-dictionary-list
-  : one-section-dictionary
-    (list $1)
-  | section-dictionary-list one-section-dictionary
+  : ;; empty
+    ()
+  | section-dictionary-list flat-section-dictionary
+    (append $1 (list $2))
+  | section-dictionary-list section-dictionary
     (append $1 (list $2))
   ;
 
-one-section-dictionary
+flat-section-dictionary
   : SECTIONDICTIONARY string newline
-    variable-list
+    flat-dictionary-entry-list
+    (cons (read $2) $4)
+  ;
+
+flat-dictionary-entry-list
+  : ;; empty
+    ()
+  | flat-dictionary-entry-list flat-dictionary-entry
+    (append $1 $2)
+  ;
+
+flat-dictionary-entry
+  : variable
+    (EXPANDTAG $1)
+  ;
+
+section-dictionary
+  : SECTION string newline
+    dictionary-entry-list
+    END newline
     (cons (read $2) $4)
   ;
 
-variable-list
+dictionary-entry-list
+  : ;; empty
+    ()
+  | dictionary-entry-list dictionary-entry
+    (append $1 $2)
+  ;
+
+dictionary-entry
   : variable
     (EXPANDTAG $1)
-  | variable-list variable
-    (append $1 (EXPANDTAG $2))
+  | section-dictionary
+    (list $1)
   ;
 
 opt-bind
@@ -225,11 +264,11 @@ It ignores whitespace, newlines and comments."
   srecode-template-separator-block
   srecode-template-wy--<keyword>-keyword-analyzer
   srecode-template-property-analyzer
-  srecode-template-wy--<symbol>-regexp-analyzer
   srecode-template-wy--<number>-regexp-analyzer
+  srecode-template-wy--<symbol>-regexp-analyzer
   srecode-template-wy--<string>-sexp-analyzer
   srecode-template-wy--<punctuation>-string-analyzer
   semantic-lex-default-action
   )
 
-;;; wisent-dot.wy ends here
+;;; srecode-template.wy ends here