Fix regexp for finding code blocks
[bpt/emacs.git] / etc / grammars / make.by
CommitLineData
469d2149
CY
1;;; semantic/bovine/make.by -- BY notation for Makefiles.
2;;
3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2008 Eric M. Ludlam
4;;
5;; Author: Eric M. Ludlam <zappo@gnu.org>
6;;
7;; This program is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation; either version 2, or (at your option)
10;; any later version.
11;;
12;; This software is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16;;
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs; see the file COPYING. If not, write to the
19;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20;; Boston, MA 02110-1301, USA.
21;;
22
23%package make-by
24
25%languagemode makefile-mode
26%start Makefile
27
28;; This was always a test case.
29%quotemode backquote
30
31%token IF "if"
32%token IFDEF "ifdef"
33%token IFNDEF "ifndef"
34%token IFEQ "ifeq"
35%token IFNEQ "ifneq"
36%token ELSE "else"
37%token ENDIF "endif"
38%token INCLUDE "include"
39
40%put { IF ELSE ENDIF } summary "Conditional: if (expression) ... else ... endif"
41%put IFDEF summary "Conditional: ifdef (expression) ... else ... endif"
42%put IFNDEF summary "Conditional: ifndef (expression) ... else ... endif"
43%put IFEQ summary "Conditional: ifeq (expression) ... else ... endif"
44%put IFNEQ summary "Conditional: ifneq (expression) ... else ... endif"
45%put INCLUDE summary "Macro: include filename1 filename2 ..."
46
47%token <punctuation> COLON "\\`[:]\\'"
48%token <punctuation> PLUS "\\`[+]\\'"
49%token <punctuation> EQUAL "\\`[=]\\'"
50%token <punctuation> DOLLAR "\\`[$]\\'"
51%token <punctuation> BACKSLASH "\\`[\\]\\'"
52
53%%
54
55Makefile : bol newline (nil)
56 | bol variable
57 ( ,@$2 )
58 | bol rule
59 ( ,@$2 )
60 | bol conditional
61 ( ,@$2 )
62 | bol include
63 ( ,@$2 )
64 | whitespace ( nil )
65 | newline ( nil )
66 ;
67
68variable: symbol opt-whitespace equals opt-whitespace element-list
69 (VARIABLE-TAG ,$1 nil ,$5)
70 ;
71
72rule: targets opt-whitespace colons opt-whitespace element-list commands
73 (FUNCTION-TAG ,$1 nil ,$5)
74 ;
75
76targets: target opt-whitespace targets
77 ( (car ,$1) (car ,@$3) )
78 | target
79 ( (car ,$1) )
80 ;
81
82target: sub-target target
83 ( (concat (car ,$1) (car ,@$3) ) )
84 | sub-target
85 ( (car ,$1) )
86 ;
87
88sub-target: symbol
89 | string
90 | varref
91 ;
92
93conditional: IF some-whitespace symbol newline
94 ( nil )
95 | IFDEF some-whitespace symbol newline
96 ( nil )
97 | IFNDEF some-whitespace symbol newline
98 ( nil )
99 | IFEQ some-whitespace expression newline
100 ( nil )
101 | IFNEQ some-whitespace expression newline
102 ( nil )
103 | ELSE newline
104 ( nil )
105 | ENDIF newline
106 ( nil )
107 ;
108
109expression : semantic-list
110 ;
111
112include: INCLUDE some-whitespace element-list
113 (INCLUDE-TAG ,$3 nil)
114 ;
115
116equals: COLON EQUAL ()
117 | PLUS EQUAL ()
118 | EQUAL ()
119 ;
120
121colons: COLON COLON ()
122 | COLON ()
123 ;
124
125element-list: elements newline
126 ( ,@$1 )
127 ;
128
129elements: element some-whitespace elements
130 ( ,@$1 ,@$3 )
131 | element
132 ( ,@$1 )
133 | ;;EMPTY
134 ;
135
136element: sub-element element
137 ( (concat (car ,$1) (car ,$2)) )
138 | ;;EMPTY
139 ;
140
141sub-element: symbol
142 | string
143 | punctuation
144 | semantic-list
145 ( (buffer-substring-no-properties
146 (identity start) (identity end)) )
147 ;
148
149varref: DOLLAR semantic-list
150 ( (buffer-substring-no-properties (identity start) (identity end)) )
151 ;
152
153commands: bol shell-command newline commands
154 ( ,$1 ,@$2 )
155 | ;;EMPTY
156 ( )
157 ;
158
159opt-whitespace : some-whitespace ( nil )
160 | ;;EMPTY
161 ;
162
163some-whitespace : whitespace some-whitespace (nil)
164 | whitespace (nil)
165 ;
166
167;;; semantic/bovine/make.by ends here