]> git.eshelyaron.com Git - emacs.git/commitdiff
semantic: C grammar optimizations
authorEric Ludlam <eric@siege-engine.com>
Fri, 16 Oct 2015 20:37:48 +0000 (16:37 -0400)
committerDavid Engster <deng@randomsample.de>
Sun, 22 Jan 2017 21:25:16 +0000 (22:25 +0100)
* admin/grammars/c.by (extern-c, c-or-cpp, opt-extern-c-contents):
 Optimize out all the extra EXTERN matches.

admin/grammars/c.by

index 06d58bdfe7ec77fdcb7d5bb8e99d9b7ecbbb39bc..ccdf8087804a05acf93010939eaa81600dd86f92 100644 (file)
@@ -240,20 +240,24 @@ extern-c-contents
   ;
 
 extern-c
-  : EXTERN C semantic-list
+  : EXTERN c-or-cpp opt-extern-c-contents
  ;; Extern C commands which contain a list need to have the
  ;; entries of the list extracted, and spliced into the main
  ;; list of entries.  This must be done via the function
  ;; that expands singular nonterminals, such as int x,y;
-    (TAG "C" 'extern :members (EXPANDFULL $3 extern-c-contents) )
-  | EXTERN CPP semantic-list
-    (TAG "C" 'extern :members (EXPANDFULL $3 extern-c-contents) )
-  | EXTERN C
- ;; A plain extern "C" call should add something to the token,
- ;; but just strip it from the buffer here for now.
-    ( nil )
-  | EXTERN CPP
-    ( nil )
+    (TAG (car $2) 'extern :members $3)
+  ;
+
+c-or-cpp
+  : C
+  | CPP
+  ;
+
+opt-extern-c-contents
+  : semantic-list
+    (EXPANDFULL $1 extern-c-contents)
+  | ;; EMPTY
+    ()
   ;
 
 macro