aboutsummaryrefslogtreecommitdiff
path: root/src/build.y
blob: 600b923f7a31dd7c7db9f8785b6e34a0b1bce4d7 (plain)
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
%skeleton "lalr1.cc"
%define "parser_class_name" "BuildParser"
%defines
%{
# include <string>
# include "builder.h"
# include "build.tab.h"
%}

%parse-param { Builder &bld }
%lex-param { Builder &bld }

%locations
%initial-action
{
	@$.begin.filename = @$.end.filename = &bld.file;
}

%debug
%error-verbose
%union {
	char *strval;
}

%token <strval>		STRING		"string literal"

%token TOK_ADDSET				"+="
%token TOK_DEFAULT				"keyword 'default'"
%token TOK_ACTION				"keyword 'action'"
%token TOK_CREATE				"keyword 'create'"
%token TOK_FILE					"keyword 'file'"
%token TOK_FROM					"keyword 'from'"
%token TOK_FILES				"keyword 'files'"
%token TOK_IN					"keyword 'in'"
%token TOK_USING				"keyword 'using'"
%token TOK_RULE					"keyword 'rule'"
%token TOK_REQUIRES				"keyword 'requires'"
%token TOK_FOR					"keyword 'for'"
%token TOK_SET					"keyword 'set'"
%token TOK_MATCHES				"keyword 'matches'"
%token TOK_ALL					"keyword 'all'"
%token TOK_ONE					"keyword 'one'"
%token TOK_PERFORM				"keyword 'perform'"
%token TOK_PRODUCES				"keyword 'produces'"
%token TOK_COMMAND				"keyword 'command'"
%token TOK_EOL					"end of line"

%destructor { delete[] $$; } STRING

%%

input:
	 | input line
	 ;

line: stuff TOK_EOL				{ printf("\n"); }
	;

stuff:
	 | stuff token
	 ;

token: TOK_ADDSET				{ printf("+= "); }
	 | TOK_DEFAULT				{ printf("default "); }
	 | TOK_ACTION				{ printf("action "); }
	 | TOK_CREATE				{ printf("create "); }
	 | TOK_FILE					{ printf("file "); }
	 | TOK_FROM					{ printf("from "); }
	 | TOK_FILES				{ printf("files "); }
	 | TOK_IN					{ printf("in "); }
	 | TOK_USING				{ printf("using "); }
	 | TOK_RULE					{ printf("rule "); }
	 | TOK_REQUIRES				{ printf("requires "); }
	 | TOK_FOR					{ printf("for "); }
	 | TOK_SET					{ printf("set "); }
	 | TOK_MATCHES				{ printf("matches "); }
	 | TOK_ALL					{ printf("all "); }
	 | TOK_ONE					{ printf("one "); }
	 | TOK_PERFORM				{ printf("perform "); }
	 | TOK_PRODUCES				{ printf("produces "); }
	 | TOK_COMMAND				{ printf("command "); }
	 ;

%%

void yy::BuildParser::error( const yy::BuildParser::location_type &l,
						   const std::string &m )
{
	bld.error( l, m );
}