semantic / make.bnf

Diff from to
 # Simple BNF notation for Makefiles.
 #
-# Copyright (C) 1999, 2000, 2001 Eric M. Ludlam
+# Copyright (C) 1999, 2000, 2001, 2002 Eric M. Ludlam
 #
 # Author: Eric M. Ludlam <zappo@gnu.org>
 # X-RCS: $Id$
 # Boston, MA 02111-1307, USA.
 #
 # $Log$
+# Revision 1.13  2002/05/07 01:31:15  zappo
+# Merged from v1_4 branch.
+#
+# Revision 1.12.2.2  2002/02/19 21:35:09  zappo
+# (setup): Enable whitespace
+# (BACKSLASH): New token
+# (variable rule conditional targets include): Use whitespace where needed.
+# (targets): Enable subtarget groupings w/ mixed variables.
+# (target sub-target): New rules
+# (element-list, element, sub-element): New rules
+# (elements): Enable mixed groupings.
+# (opt-whitespace): New rule.
+#
+# Revision 1.12.2.1  2002/02/10 18:06:04  zappo
+# (semantic-flex-syntax-modifications): Remove tab.
+# (conditional): Return explicit nils.
+#
+# Revision 1.12  2001/12/18 02:19:48  zappo
+# Removed parens and $ from symbol syntax types.
+# Added IFEQ and IFNEQ tokens
+# Added BACKSLASH and DOLLAR tokens
+# Added IFEQ and IFNEQ rule matches
+# Added $(VAR) types to expression.
+# Support backslash terminated lines for variables.
+#
+# Revision 1.11  2001/12/07 01:36:32  zappo
+# Added ifdef, and ifndef tokens.  (Oy)
+#
+# Revision 1.10  2001/12/07 01:32:45  zappo
+# Added ifdef, and ifndef commands.
+#
+# Revision 1.9  2001/11/08 19:40:21  zappo
+# (Makefile): Handle blank lines
+#
+# Revision 1.8  2001/10/03 00:29:01  zappo
+# Disable number matching.
+#
 # Revision 1.7  2001/04/13 02:01:59  zappo
 # Added a keyword table, and several new tokens and summaries.
 # Added support for the include macro.
 %setupfunction semantic-default-make-setup
 %quotemode     backquote
 
-%(setq semantic-flex-enable-newlines t
-       semantic-symbol->name-assoc-list '((variable . "Variables")
+%(setq semantic-symbol->name-assoc-list '((variable . "Variables")
 					  (function . "Rules")
 					  (include . "Dependencies"))
+       semantic-number-expression nil
        semantic-case-fold t
+       semantic-expand-nonterminal 'semantic-expand-make-nonterminal
        semantic-flex-syntax-modifications '((?. "_")
 					    (?= ".")
 					    (?/ "_")
-					    (?\t ".")
-					    (?( "_")
-					    (?) "_")
-					    (?{ "_")
-					    (?} "_")
-					    (?$ "_")
+					    (?$ ".")
 					    )
        semantic-flex-enable-newlines t
+       semantic-flex-enable-whitespace t
        imenu-create-index-function 'semantic-create-imenu-index
        )%
 
 %token IF "if"
+%token IFDEF "ifdef"
+%token IFNDEF "ifndef"
+%token IFEQ "ifeq"
+%token IFNEQ "ifneq"
 %token ELSE "else"
 %token ENDIF "endif"
 %put { IF ELSE ENDIF } summary "Conditional: if (expression) ... else ... endif"
+%put IFDEF  summary "Conditional: ifdef (expression) ... else ... endif"
+%put IFNDEF summary "Conditional: ifndef (expression) ... else ... endif"
+%put IFEQ summary "Conditional: ifeq (expression) ... else ... endif"
+%put IFNEQ summary "Conditional: ifneq (expression) ... else ... endif"
 %token INCLUDE "include"
 %put INCLUDE summary "Macro: include filename1 filename2 ..."
 
 %token COLON punctuation ":"
 %token PLUS punctuation "+"
 %token EQUAL punctuation "="
+%token DOLLAR punctuation "$"
+%token BACKSLASH punctuation "\\"
 
 Makefile : variable
 	 | rule
 	 | conditional
 	 | include
+	 | whitespace ( nil )
+	 | newline ( nil )
 	 ;
 
-variable: symbol equals elements
-	  (,$1 variable nil ,$3 nil nil)
+variable: symbol opt-whitespace equals opt-whitespace element-list
+	  (,$1 variable nil ,$5 nil nil)
 	;
 
-rule: symbol colons elements commands
-      (,$1 function nil ,$3 nil nil)
+rule: targets opt-whitespace colons opt-whitespace element-list commands
+      (,$1 function nil ,$5 nil nil)
     ;
 
-conditional: IF symbol newline
-	     ( )
+targets: target opt-whitespace targets
+	 ( (car ,$1) (car ,@$3) )
+       | target
+	 ( (car ,$1) )
+       ;
+
+target: sub-target target
+	( (concat (car ,$1) (car ,@$3) ) )
+      | sub-target
+	( (car ,$1) )
+      ;
+
+sub-target: symbol
+	  | string
+	  | varref
+	  ;
+
+conditional: IF whitespace symbol newline
+	     ( nil )
+	   | IFDEF whitespace symbol newline
+	     ( nil )
+	   | IFNDEF whitespace symbol newline
+	     ( nil )
+	   | IFEQ whitespace expression newline
+	     ( nil )
+	   | IFNEQ whitespace expression newline
+	     ( nil )
 	   | ELSE newline
-	     ( )
+	     ( nil )
 	   | ENDIF newline
-	     ( )
+	     ( nil )
 	   ;
 
-include: INCLUDE symbol elements
-	 (,$2 include nil)
+expression : semantic-list
+	   ;
+
+include: INCLUDE whitespace element-list
+	 (,$3 include nil nil)
        ;
 
 equals: COLON EQUAL ()
       | COLON ()
       ;
 
-elements: symbol elements
-	  ( ,$1 ,@$2 )
-	| symbol newline
+element-list: elements newline
+	      ( ,@$1 )
+	    ;
+
+elements: element whitespace elements
+	  ( ,$1 ,@$3 )
+	| element
 	  ( ,$1 )
-	| newline
-	  (  )
+	| EMPTY
 	;
   
+element: sub-element element
+	 ( (concat (car ,$1) (car ,$2)) )
+       | EMPTY
+       ;
+
+sub-element: symbol
+	   | string
+	   | punctuation
+	   | semantic-list
+	     ( (buffer-substring-no-properties
+		 (identity start) (identity end)) )
+	   ;
+
+varref: DOLLAR semantic-list
+	( (buffer-substring-no-properties (identity start) (identity end)) )
+      ;
+
 commands: shell-command newline commands
 	  ( ,$1 ,@$2 )
 	| EMPTY
 	  ( )
 	;
 
+opt-whitespace : whitespace ( nil )
+	       | EMPTY
+	       ;
 # End
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.