[go: up one dir, main page]

File: yacc

package info (click to toggle)
cook 2.10-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,856 kB
  • ctags: 3,842
  • sloc: ansic: 47,714; sh: 12,150; makefile: 4,317; yacc: 3,104; awk: 154
file content (93 lines) | stat: -rw-r--r-- 2,245 bytes parent folder | download | duplicates (2)
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
/*
 * NAME
 *	yacc - how to use yacc
 *
 * DESCRIPTION
 *	This cookbook describes how to use yacc.
 *
 *	You will have to add "-d" to the [yacc_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 [yacc_flags]
 *	%.c: %.y	applied if -d not in [yacc_flags]
 *
 * VARIABLES
 *	yacc_src	Yacc 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 yacc
 */

#pragma once

#include "c"

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

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

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