File: command.t

package info (click to toggle)
libmakefile-dom-perl 0.004-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 616 kB
  • ctags: 535
  • sloc: perl: 6,552; makefile: 2
file content (361 lines) | stat: -rw-r--r-- 8,239 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
use t::GmakeDOM;

plan tests => blocks() * 2;

run_tests;

__DATA__

=== TEST 1: blank lines and comment lines as comments
blank lines and lines of just comments may appear among
the command lines; they are ignored.
--- src
foo:
	first

 
# This is ignored
	second

--- dom
M::D::G
  M::R::S
    M::T::B         'foo'
    M::T::S         ':'
    M::T::W         '\n'
  M::C
    M::T::S         '\t'
    M::T::B         'first'
    M::T::W         '\n'
  M::T::W           '\n'
  M::T::W           ' \n'
  M::T::C           '# This is ignored'
  M::T::W           '\n'
  M::C
    M::T::S         '\t'
    M::T::B         'second'
    M::T::W         '\n'



=== TEST 2: empty commands
a blank line that begins with a tab is not blank; it's an empty
command
--- src

foo:
	
	echo

--- dom
M::D::G
  M::R::S
    M::T::B         'foo'
    M::T::S         ':'
    M::T::W         '\n'
  M::C
    M::T::S         '\t'
    M::T::W         '\n'
  M::C
    M::T::S         '\t'
    M::T::B         'echo'
    M::T::W         '\n'



=== TEST 3: comments as commands
a comment in a command line is not a make comment;
it will be passed to the shell as-is.
--- src

foo:
	# This is a command, not a comment

--- dom
M::D::G
  M::R::S
    M::T::B             'foo'
    M::T::S             ':'
    M::T::W             '\n'
  M::C
    M::T::S             '\t'
    M::T::B             '# This is a command, not a comment'
    M::T::W             '\n'



=== TEST 4: var def as commands
a variable definition in a "rule context" which is indented by a tab
as the first character on the line, will be considered a command line.
--- src

foo:
	var = value
	var := value
	var += value
	var ?= value

--- dom
M::D::G
  M::R::S
    M::T::B                 'foo'
    M::T::S                 ':'
    M::T::W                 '\n'
  M::C
    M::T::S                 '\t'
    M::T::B                 'var = value'
    M::T::W                 '\n'
  M::C
    M::T::S                 '\t'
    M::T::B                 'var := value'
    M::T::W                 '\n'
  M::C
    M::T::S                 '\t'
    M::T::B                 'var += value'
    M::T::W                 '\n'
  M::C
    M::T::S                 '\t'
    M::T::B                 'var ?= value'
    M::T::W                 '\n'



=== TEST 5: conditional directives as commands
a conditional expression (ifdef, ifeq, etc) in a "rule context"
which is indented by a tab as the first character on the line,
will be considered a command line
--- src

foo:
	ifdef $(foo)
	echo
	endif

--- dom
M::D::G
  M::R::S
    M::T::B             'foo'
    M::T::S             ':'
    M::T::W             '\n'
  M::C
    M::T::S             '\t'
    M::T::B             'ifdef '
    M::T::I             '$(foo)'
    M::T::W             '\n'
  M::C
    M::T::S             '\t'
    M::T::B             'echo'
    M::T::W             '\n'
  M::C
    M::T::S             '\t'
    M::T::B             'endif'
    M::T::W             '\n'



=== TEST 6: line continuations in commands
--- src
a :
	- mv \#\
	+ e \
  \\
	@

--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare           'a'
    MDOM::Token::Whitespace     ' '
    MDOM::Token::Separator      ':'
    MDOM::Token::Whitespace     '\n'
  MDOM::Command
    MDOM::Token::Separator      '\t'
    MDOM::Token::Modifier       '-'
    MDOM::Token::Bare           ' mv \#\\n\t+ e \\n  \\'
    MDOM::Token::Whitespace     '\n'
  MDOM::Command
    MDOM::Token::Separator      '\t'
    MDOM::Token::Modifier       '@'
    MDOM::Token::Whitespace     '\n'



=== TEST 7: line continuations in prereqs and "inline" commands
--- src

a: \
	b;\
    c \
    d

--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare           'a'
    MDOM::Token::Separator      ':'
    MDOM::Token::Whitespace     ' '
    MDOM::Token::Continuation   '\\n'
    MDOM::Token::Whitespace     '\t'
    MDOM::Token::Bare           'b'
    MDOM::Command
      MDOM::Token::Separator    ';'
      MDOM::Token::Bare         '\\n    c \\n    d'
      MDOM::Token::Whitespace   '\n'



=== TEST 8: whitespace before command modifiers (@)
--- src

all:
	  @ echo $@

--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare         'all'
    MDOM::Token::Separator            ':'
    MDOM::Token::Whitespace           '\n'
  MDOM::Command
    MDOM::Token::Separator            '\t'
    MDOM::Token::Whitespace           '  '
    MDOM::Token::Modifier             '@'
    MDOM::Token::Bare         ' echo '
    MDOM::Token::Interpolation                '$@'
    MDOM::Token::Whitespace           '\n'



=== TEST 9: whitespace before command modifiers (+/-)
--- src

all:
	  + echo $@
		-blah!

--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare         'all'
    MDOM::Token::Separator            ':'
    MDOM::Token::Whitespace           '\n'
  MDOM::Command
    MDOM::Token::Separator            '\t'
    MDOM::Token::Whitespace           '  '
    MDOM::Token::Modifier             '+'
    MDOM::Token::Bare         ' echo '
    MDOM::Token::Interpolation                '$@'
    MDOM::Token::Whitespace           '\n'
  MDOM::Command
    MDOM::Token::Separator            '\t'
    MDOM::Token::Whitespace           '\t'
    MDOM::Token::Modifier             '-'
    MDOM::Token::Bare                 'blah!'
    MDOM::Token::Whitespace           '\n'



=== TEST 10: multi-line commands
--- src

compile_all:
	for d in $(source_dirs); \
	do                       \
		$(JAVAC) $$d/*.java; \
	done

--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare         'compile_all'
    MDOM::Token::Separator            ':'
    MDOM::Token::Whitespace           '\n'
  MDOM::Command
    MDOM::Token::Separator            '\t'
    MDOM::Token::Bare         'for d in '
    MDOM::Token::Interpolation        '$(source_dirs)'
    MDOM::Token::Bare	'; \\n\tdo                       \\n\t\t'
    MDOM::Token::Interpolation          '$(JAVAC)'
    MDOM::Token::Bare         ' '
    MDOM::Token::Interpolation      '$$'
    MDOM::Token::Bare           'd/*.java; \\n\tdone'
    MDOM::Token::Whitespace		'\n'



=== TEST 11: multi-modifiers
--- src
all:
	@ - exit
        -@ exit 1
        @-exit 1
--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare         'all'
    MDOM::Token::Separator            ':'
    MDOM::Token::Whitespace           '\n'
  MDOM::Command
    MDOM::Token::Separator            '\t'
    MDOM::Token::Modifier             '@'
    MDOM::Token::Whitespace           ' '
    MDOM::Token::Modifier             '-'
    MDOM::Token::Bare         ' exit'
    MDOM::Token::Whitespace           '\n'
  MDOM::Unknown
    MDOM::Token::Whitespace           '        '
    MDOM::Token::Modifier             '-'
    MDOM::Token::Modifier             '@'
    MDOM::Token::Bare         ' exit 1'
    MDOM::Token::Whitespace           '\n'
  MDOM::Unknown
    MDOM::Token::Whitespace           '        '
    MDOM::Token::Modifier             '@'
    MDOM::Token::Modifier             '-'
    MDOM::Token::Bare         'exit 1'
    MDOM::Token::Whitespace           '\n'



=== TEST 12: line continuations in commands
--- src
all:
	\
	echo $@
--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare         'all'
    MDOM::Token::Separator            ':'
    MDOM::Token::Whitespace           '\n'
  MDOM::Command
    MDOM::Token::Separator            '\t'
    MDOM::Token::Bare               '\\n\techo '
    MDOM::Token::Interpolation        '$@'
    MDOM::Token::Whitespace           '\n'



=== TEST 13: ditto (with interpolations)
--- src
all:
	@echo $(FOO) \
   $(BAR) \
	$(BIT)
--- dom
MDOM::Document::Gmake
  MDOM::Rule::Simple
    MDOM::Token::Bare         'all'
    MDOM::Token::Separator            ':'
    MDOM::Token::Whitespace           '\n'
  MDOM::Command
    MDOM::Token::Separator            '\t'
    MDOM::Token::Modifier             '@'
    MDOM::Token::Bare         'echo '
    MDOM::Token::Interpolation                '$(FOO)'
    MDOM::Token::Bare         ' \\n   '
    MDOM::Token::Interpolation  '$(BAR)'
    MDOM::Token::Bare           ' \\n\t'
    MDOM::Token::Interpolation                '$(BIT)'
    MDOM::Token::Whitespace           '\n'