[go: up one dir, main page]

File: bison

package info (click to toggle)
cook 2.19-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,316 kB
  • ctags: 3,969
  • sloc: ansic: 50,331; sh: 13,190; makefile: 4,542; yacc: 3,174; perl: 224; awk: 154
file content (81 lines) | stat: -rw-r--r-- 2,040 bytes parent folder | download | duplicates (3)
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
/*
 * NAME
 *	bison - how to use bison
 *
 * DESCRIPTION
 *	This cookbook describes how to use bison.
 *
 *	You will have to add "-d" to the [bison_flags] variable
 *	if you want %.h files generated.
 *
 *	If a y.output file is constructed, it will be moved to %.list
 *
 * RECIPES
 *	%.c %.h: %.y	applied if -d in [bison_flags]
 *	%.c: %.y	applied if -d not in [bison_flags]
 *
 * VARIABLES
 *	bison_src	bison source files in the current directory.
 *	dot_src		Source files constructable in the current directory
 *			(unioned with existing setting, if necessary).
 *	dot_obj		Object files constructable in the current directory
 *			(unioned with existing setting, if necessary).
 *	dot_clean	Files which may be removed from the current directory
 *			in a clean target.
 *	dot_lint_obj	Lint object files constructable in the current directory
 *			(unioned with existing setting, if necessary).
 *
 * MANIFEST: cookbook for using bison
 */

#pragma once

#include "c"

if [not [defined bison]] then
	bison = bison;
if [not [defined bison_flags]] then
	bison_flags = ;
bison_src = [glob *.y];
cc_src = [stringset [cc_src] - [fromto %.y %.c [bison_src]]];
dot_src =
	[stringset
		[dot_src] [bison_src]
	-
		[fromto %.y %.c [bison_src]] [fromto %.y %.s [bison_src]]
	];
dot_obj = [stringset [dot_obj] [fromto %.y %.o [bison_src]]];
dot_clean =
	[stringset
		[dot_clean]
		[fromto %.y %.c [bison_src]]
		[fromto %.y %.output [bison_src]]
		[fromto %.y %.tab.c [bison_src]]
		[fromto %.y %.tab.h [bison_src]]
		[fromto %.y %.ln [bison_src]]
		[fromto %.y %.s [bison_src]]
	];
dot_lint_obj = [stringset [dot_lint_obj] [fromto %.y %.ln [bison_src]]];

%.c %.h: %.y
	if [in -d [bison_flags]]
	single-thread %.tab.c %.tab.h %.output
{
	if [exists %.output] then
		rm -f %.output
			set clearstat;
	[bison] [bison_flags] %.y;
	mv %.tab.c %.c;
	mv %.tab.h %.h;
}

%.c: %.y
	if [not [in -d [bison_flags]]]
	single-thread %.tab.c %.output
{
	if [exists %.output] then
		rm -f %.output
			set clearstat;
	[bison] [bison_flags] %.y;
	mv %.tab.c %.c;
}