* lisp/progmodes/elisp-mode.el (eval-sexp-add-defvars): Don't macroexpand.
[emacs.git] / admin / grammars / make.by
blobda1320dbf0b323b990bcc5ae3d6dfb136aa26fcb
1 ;;; make.by -- BY notation for Makefiles.
3 ;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
4 ;;
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;;         David Ponce <david@dponce.com>
7 ;;         Klaus Berndl <klaus.berndl@sdm.de>
8 ;;
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
24 %package semantic-make-by
25 %provide semantic/bovine/make-by
27 %languagemode  makefile-mode
28 %start         Makefile
30 ;; This was always a test case.
31 %quotemode     backquote
33 %token IF      "if"
34 %token IFDEF   "ifdef"
35 %token IFNDEF  "ifndef"
36 %token IFEQ    "ifeq"
37 %token IFNEQ   "ifneq"
38 %token ELSE    "else"
39 %token ENDIF   "endif"
40 %token INCLUDE "include"
42 %put { IF ELSE ENDIF } summary "Conditional: if (expression) ... else ... endif"
43 %put IFDEF   summary "Conditional: ifdef (expression) ... else ... endif"
44 %put IFNDEF  summary "Conditional: ifndef (expression) ... else ... endif"
45 %put IFEQ    summary "Conditional: ifeq (expression) ... else ... endif"
46 %put IFNEQ   summary "Conditional: ifneq (expression) ... else ... endif"
47 %put INCLUDE summary "Macro: include filename1 filename2 ..."
49 %token <punctuation> COLON     "\\`[:]\\'"
50 %token <punctuation> PLUS      "\\`[+]\\'"
51 %token <punctuation> EQUAL     "\\`[=]\\'"
52 %token <punctuation> DOLLAR    "\\`[$]\\'"
53 %token <punctuation> BACKSLASH "\\`[\\]\\'"
57 ;; Escape the ,@ below because the reader doesn't correctly detect
58 ;; old-style backquotes for this case.  The backslashes can be removed
59 ;; once old-style backquotes are completely gone (probably in
60 ;; Emacs 28).
62 Makefile : bol newline (nil)
63          | bol variable
64            ( \,@$2 )
65          | bol rule
66            ( \,@$2 )
67          | bol conditional
68            ( \,@$2 )
69          | bol include
70            ( \,@$2 )
71          | whitespace ( nil )
72          | newline ( nil )
73          ;
75 variable: symbol opt-whitespace equals opt-whitespace element-list
76           (VARIABLE-TAG ,$1 nil ,$5)
77         ;
79 rule: targets opt-whitespace colons opt-whitespace element-list commands
80       (FUNCTION-TAG ,$1 nil ,$5)
81     ;
83 targets: target opt-whitespace targets
84          ( (car ,$1) (car ,@$3) )
85        | target
86          ( (car ,$1) )
87        ;
89 target: sub-target target
90         ( (concat (car ,$1) (car ,@$3) ) )
91       | sub-target
92         ( (car ,$1) )
93       ;
95 sub-target: symbol
96           | string
97           | varref
98           ;
100 conditional: IF some-whitespace symbol newline
101              ( nil )
102            | IFDEF some-whitespace symbol newline
103              ( nil )
104            | IFNDEF some-whitespace symbol newline
105              ( nil )
106            | IFEQ some-whitespace expression newline
107              ( nil )
108            | IFNEQ some-whitespace expression newline
109              ( nil )
110            | ELSE newline
111              ( nil )
112            | ENDIF newline
113              ( nil )
114            ;
116 expression : semantic-list
117            ;
119 include: INCLUDE some-whitespace element-list
120          (INCLUDE-TAG ,$3 nil)
121        ;
123 equals: COLON EQUAL ()
124       | PLUS EQUAL ()
125       | EQUAL ()
126       ;
128 colons: COLON COLON ()
129       | COLON ()
130       ;
132 element-list: elements newline
133               ( \,@$1 )
134             ;
136 elements: element some-whitespace elements
137           ( \,@$1 ,@$3 )
138         | element
139           ( \,@$1 )
140         | ;;EMPTY
141         ;
143 element: sub-element element
144          ( (concat (car ,$1) (car ,$2)) )
145        | ;;EMPTY
146        ;
148 sub-element: symbol
149            | string
150            | punctuation
151            | semantic-list
152              ( (buffer-substring-no-properties
153                  (identity start) (identity end)) )
154            ;
156 varref: DOLLAR semantic-list
157         ( (buffer-substring-no-properties (identity start) (identity end)) )
158       ;
160 commands: bol shell-command newline commands
161           ( ,$1 ,@$2 )
162         | ;;EMPTY
163           ( )
164         ;
166 opt-whitespace : some-whitespace ( nil )
167                | ;;EMPTY
168                ;
170 some-whitespace : whitespace some-whitespace (nil)
171                 | whitespace (nil)
172                 ;
174 ;;; make.by ends here