1. xemacs
  2. semantic

Source

semantic / c.bnf

Diff from to

File c.bnf

  • Ignore whitespace
 # Boston, MA 02111-1307, USA.
 #
 # $Log$
+# Revision 1.19  2000/09/27 02:08:04  zappo
+# Moved `type' to be before `function' and `variable' in `declaration'.
+#
+# Revision 1.18  2000/09/21 03:35:08  zappo
+# Fixed up struct/union variable declaration section to use new lexical
+# tokens for struct/union.
+#
+# Revision 1.17  2000/09/19 04:22:31  zappo
+# Added %keywordtable
+#
+# Revision 1.16  2000/09/14 19:23:27  zappo
+# Updated to use %token to make new tokens for use in RULES.
+#
+# Revision 1.15  2000/09/11 23:00:32  zappo
+# Use new BNF settings section.
+#
 # Revision 1.14  2000/07/05 14:41:31  zappo
 # Support multiple continuous decl modifiers.
 # Added modifiers into variables.
 # Initial revision
 #
 
-# TABLE: semantic-c.el:semantic-toplevel-c-bovine-table
-# MODE: c-mode
+%start         declaration
+%outputfile    semantic-c.el
+%parsetable    semantic-toplevel-c-bovine-table
+%keywordtable  semantic-c-keyword-table
+%languagemode  c-mode
+%setupfunction semantic-default-c-setup
 
-bovine-toplevel : include
-		| macro
-		| comment
-                | function
-		| variable
-                | prototype
-                | type
-                | define
-                ;
+%(setq semantic-expand-nonterminal 'semantic-expand-c-nonterminal
+       semantic-flex-extensions semantic-flex-c-extensions
+       semantic-dependency-include-path semantic-default-c-path
+       imenu-create-index-function 'semantic-create-imenu-index
+       document-comment-start "/*"
+       document-comment-line-prefix " *"
+       document-comment-end " */"
+       )%
+
+%token HASH punctuation "#"
+%token INCLUDE "include"
+%token DEFINE "define"
+%token PERIOD punctuation "."
+%token COLON punctuation ":"
+%token SEMICOLON punctuation ";"
+%token STAR punctuation "*"
+%token EQUAL punctuation "="
+%token COMA punctuation ","
+%token STRUCT "struct"
+%token UNION "union"
+%token ENUM "enum"
+%token TYPEDEF "typedef"
+
+
+declaration : include
+	    | macro
+	    | type
+	    | function
+	    | variable
+	    | prototype
+	    | define
+	    ;
 		
-include : punctuation "#" symbol "include" punctuation "<"
-	  filename punctuation ">"
+include : HASH INCLUDE punctuation "<" filename punctuation ">"
 	  ( ,$4 include t nil )
-        | punctuation "#" symbol "include" string
+        | HASH INCLUDE string
 	  ( (read $3) include nil nil )
         ;
 
-filename : symbol punctuation "\\." symbol
+filename : symbol PERIOD symbol
 	   ( (concat $1 $2 $3) )
          | symbol punctuation "/" filename
 	   ( (concat $1 $2 (car $3)) )
 	   ( nil )
          ;
 
-typesimple : symbol "struct\\|union" opt-name structparts
+typesimple : STRUCT opt-name structparts
 	     ( ,$2 type $1 $3 nil nil nil )
-	   | symbol "enum" opt-name enumparts
+	   | UNION opt-name structparts
+	     ( ,$2 type $1 $3 nil nil nil )
+	   | ENUM opt-name enumparts
 	     ( ,$2 type $1 $3 nil nil nil )	
-           | symbol "typedef" typeform symbol
+           | TYPEDEF typeform symbol
 	     ( $3 type $1 nil $2 nil nil )
            ;
 
-type : typesimple punctuation ";"
+type : typesimple SEMICOLON
        ( ,$1 )
      ;
 
-opt-stars : punctuation "*" opt-stars
+opt-stars : STAR opt-stars
 	    ( (1+ (car $2)) )
 	  | EMPTY
 	    ( 0 )
 
 typeformbase : typesimple
 	       ( ,$1 )
-	     | symbol "struct\\|union\\|enum" symbol
+	     | STRUCT symbol
+	       ( $2 type $1 )
+	     | UNION symbol
+	       ( $2 type $1 )
+	     | ENUM symbol
 	       ( $2 type $1 )
 	     | symbol
 	       ( $1 )
 	     ;
   
-opt-bits : punctuation ":" symbol
+opt-bits : COLON symbol
 	   ( $2 )
 	 | EMPTY
 	   ( nil )
 	    ( nil )
           ;
 
-opt-assign : punctuation "=" expression
+opt-assign : EQUAL expression
 	     ( $2 )
 	   | EMPTY
 	     ( nil )
 	   ;
 
-macro : punctuation "#" symbol "define" symbol opt-expression
+macro : HASH DEFINE symbol opt-expression
 	( $3 variable nil t $4 nil nil )
       ;
 
-variable : variabledef punctuation ";"
+variable : variabledef SEMICOLON
 	   ( ,$1 )
 	 ;
 
 	      (if (and $1 (string-match "const" (car $1))) (cdr $1) $1) nil )
 	    ;
 
-opt-restrict : symbol "\\(__\\)?restrict"
+opt-restrict : symbol "\\<\\(__\\)?restrict\\>"
 	     | EMPTY
 	     ;
 
 	      nil )
 	    ;
 
-varnamelist : varname  punctuation "," varnamelist
+varnamelist : varname COMA varnamelist
 	      ( ,(cons $1 $3) )
             | varname
 	      ( $1 )
 	    ;
 
-arg-list : symbol "__P" semantic-list
+arg-list : symbol "\\<__?P\\>" semantic-list
 	   (EXPAND $2 arg-list-p)
 	 | semantic-list knr-arguments
 	   ( ,$2 )
 	   (EXPANDFULL $1 arg-sub-list)
 	 ;
 
-knr-arguments : variablearg punctuation ";" knr-arguments
+knr-arguments : variablearg SEMICOLON knr-arguments
 		( ,(cons $1 $3) )
-	      | variablearg punctuation ";"
+	      | variablearg SEMICOLON
 		( $1 )
 	      ;
 
 
 arg-sub-list : variablearg
 	       ( ,$1 )
-	     | punctuation "\\." punctuation "\\." punctuation "\\."
+	     | PERIOD PERIOD PERIOD
 	       close-paren ")"
 	       ( "..." )
 	     ;
 	      ( $3 function $2 $4 $1 nil )
             ;
 
-prototype : functiondef punctuation ";"
+prototype : functiondef SEMICOLON
 	    ( ,$1 )
 	  ;