diff options
Diffstat (limited to 'bitbake/lib/bb/parse/parse_c/bitbakeparser.y')
-rw-r--r-- | bitbake/lib/bb/parse/parse_c/bitbakeparser.y | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/bitbake/lib/bb/parse/parse_c/bitbakeparser.y b/bitbake/lib/bb/parse/parse_c/bitbakeparser.y new file mode 100644 index 0000000000..4bc81a913a --- /dev/null +++ b/bitbake/lib/bb/parse/parse_c/bitbakeparser.y | |||
@@ -0,0 +1,161 @@ | |||
1 | /* bbp.lemon | ||
2 | |||
3 | written by Marc Singer | ||
4 | 6 January 2005 | ||
5 | |||
6 | This program is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU General Public License as | ||
8 | published by the Free Software Foundation; either version 2 of the | ||
9 | License, or (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
19 | USA. | ||
20 | |||
21 | DESCRIPTION | ||
22 | ----------- | ||
23 | |||
24 | lemon parser specification file for a BitBake input file parser. | ||
25 | |||
26 | Most of the interesting shenanigans are done in the lexer. The | ||
27 | BitBake grammar is not regular. In order to emit tokens that | ||
28 | the parser can properly interpret in LALR fashion, the lexer | ||
29 | manages the interpretation state. This is why there are ISYMBOLs, | ||
30 | SYMBOLS, and TSYMBOLS. | ||
31 | |||
32 | This parser was developed by reading the limited available | ||
33 | documentation for BitBake and by analyzing the available BB files. | ||
34 | There is no assertion of correctness to be made about this parser. | ||
35 | |||
36 | */ | ||
37 | |||
38 | %token_type {token_t} | ||
39 | %name bbparse | ||
40 | %token_prefix T_ | ||
41 | %extra_argument {lex_t* lex} | ||
42 | |||
43 | %include { | ||
44 | #include "token.h" | ||
45 | } | ||
46 | |||
47 | |||
48 | %token_destructor { $$.release_this (); } | ||
49 | |||
50 | %syntax_error { printf ("%s:%d: syntax error\n", | ||
51 | lex->filename (), lex->line ()); } | ||
52 | |||
53 | program ::= statements. | ||
54 | |||
55 | statements ::= statements statement. | ||
56 | statements ::= . | ||
57 | |||
58 | variable(r) ::= SYMBOL(s). | ||
59 | { r.assignString( s.string() ); | ||
60 | s.assignString( 0 ); | ||
61 | s.release_this(); } | ||
62 | variable(r) ::= VARIABLE(v). | ||
63 | { | ||
64 | r.assignString( v.string() ); | ||
65 | v.assignString( 0 ); | ||
66 | v.release_this(); } | ||
67 | |||
68 | statement ::= EXPORT variable(s) OP_ASSIGN STRING(v). | ||
69 | { e_assign( s.string(), v.string() ); | ||
70 | e_export( s.string() ); | ||
71 | s.release_this(); v.release_this(); } | ||
72 | statement ::= EXPORT variable(s) OP_IMMEDIATE STRING(v). | ||
73 | { e_immediate (s.string(), v.string() ); | ||
74 | e_export( s.string() ); | ||
75 | s.release_this(); v.release_this(); } | ||
76 | statement ::= EXPORT variable(s) OP_COND STRING(v). | ||
77 | { e_cond( s.string(), v.string() ); | ||
78 | s.release_this(); v.release_this(); } | ||
79 | |||
80 | statement ::= variable(s) OP_ASSIGN STRING(v). | ||
81 | { e_assign( s.string(), v.string() ); | ||
82 | s.release_this(); v.release_this(); } | ||
83 | statement ::= variable(s) OP_PREPEND STRING(v). | ||
84 | { e_prepend( s.string(), v.string() ); | ||
85 | s.release_this(); v.release_this(); } | ||
86 | statement ::= variable(s) OP_APPEND STRING(v). | ||
87 | { e_append( s.string() , v.string() ); | ||
88 | s.release_this(); v.release_this(); } | ||
89 | statement ::= variable(s) OP_IMMEDIATE STRING(v). | ||
90 | { e_immediate( s.string(), v.string() ); | ||
91 | s.release_this(); v.release_this(); } | ||
92 | statement ::= variable(s) OP_COND STRING(v). | ||
93 | { e_cond( s.string(), v.string() ); | ||
94 | s.release_this(); v.release_this(); } | ||
95 | |||
96 | task ::= TSYMBOL(t) BEFORE TSYMBOL(b) AFTER TSYMBOL(a). | ||
97 | { e_addtask( t.string(), b.string(), a.string() ); | ||
98 | t.release_this(); b.release_this(); a.release_this(); } | ||
99 | task ::= TSYMBOL(t) AFTER TSYMBOL(a) BEFORE TSYMBOL(b). | ||
100 | { e_addtask( t.string(), b.string(), a.string()); | ||
101 | t.release_this(); a.release_this(); b.release_this(); } | ||
102 | task ::= TSYMBOL(t). | ||
103 | { e_addtask( t.string(), NULL, NULL); | ||
104 | t.release_this();} | ||
105 | task ::= TSYMBOL(t) BEFORE TSYMBOL(b). | ||
106 | { e_addtask( t.string(), b.string(), NULL); | ||
107 | t.release_this(); b.release_this(); } | ||
108 | task ::= TSYMBOL(t) AFTER TSYMBOL(a). | ||
109 | { e_addtask( t.string(), NULL, a.string()); | ||
110 | t.release_this(); a.release_this(); } | ||
111 | tasks ::= tasks task. | ||
112 | tasks ::= task. | ||
113 | statement ::= ADDTASK tasks. | ||
114 | |||
115 | statement ::= ADDHANDLER SYMBOL(s). | ||
116 | { e_addhandler( s.string()); s.release_this (); } | ||
117 | |||
118 | func ::= FSYMBOL(f). { e_export_func(f.string()); f.release_this(); } | ||
119 | funcs ::= funcs func. | ||
120 | funcs ::= func. | ||
121 | statement ::= EXPORT_FUNC funcs. | ||
122 | |||
123 | inherit ::= ISYMBOL(i). { e_inherit(i.string() ); i.release_this (); } | ||
124 | inherits ::= inherits inherit. | ||
125 | inherits ::= inherit. | ||
126 | statement ::= INHERIT inherits. | ||
127 | |||
128 | statement ::= INCLUDE ISYMBOL(i). | ||
129 | { e_include(i.string() ); i.release_this(); } | ||
130 | |||
131 | proc_body(r) ::= proc_body(l) PROC_BODY(b). | ||
132 | { /* concatenate body lines */ | ||
133 | r.assignString( token_t::concatString(l.string(), b.string()) ); | ||
134 | l.release_this (); | ||
135 | b.release_this (); | ||
136 | } | ||
137 | proc_body(b) ::= . { b.assignString(0); } | ||
138 | statement ::= variable(p) PROC_OPEN proc_body(b) PROC_CLOSE. | ||
139 | { e_proc( p.string(), b.string() ); | ||
140 | p.release_this(); b.release_this(); } | ||
141 | statement ::= PYTHON SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE. | ||
142 | { e_proc_python (p.string(), b.string() ); | ||
143 | p.release_this(); b.release_this(); } | ||
144 | statement ::= PYTHON PROC_OPEN proc_body(b) PROC_CLOSE. | ||
145 | { e_proc_python( NULL, b.string()); | ||
146 | b.release_this (); } | ||
147 | |||
148 | statement ::= FAKEROOT SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE. | ||
149 | { e_proc_fakeroot(p.string(), b.string() ); | ||
150 | p.release_this (); b.release_this (); } | ||
151 | |||
152 | def_body(r) ::= def_body(l) DEF_BODY(b). | ||
153 | { /* concatenate body lines */ | ||
154 | r.assignString( token_t::concatString(l.string(), b.string()); | ||
155 | l.release_this (); b.release_this (); | ||
156 | } | ||
157 | def_body(b) ::= . { b.sz = 0; } | ||
158 | statement ::= SYMBOL(p) DEF_ARGS(a) def_body(b). | ||
159 | { e_def( p.string(), a.string(), b.string()); | ||
160 | p.release_this(); a.release_this(); b.release_this(); } | ||
161 | |||