blob: 67a7b11b11ee5486e3d57188f15a2fa7330e7243 [file] [log] [blame]
Will McVickerd7d18df2019-09-12 13:40:50 -07001/*
2 * Copyright (C) 2016, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Adam Lesinskiffa16862014-01-23 18:17:42 -080017%{
18#include "aidl_language.h"
Dan Willemsen609ba6d2019-12-30 10:44:00 -080019#include "aidl_language_y-module.h"
Steven Moreland46e9da82018-07-27 15:45:29 -070020#include "logging.h"
Steven Morelandf04cd5e2019-11-10 20:35:29 -080021#include <android-base/parseint.h>
Jiyong Park68bc77a2018-07-19 19:00:45 +090022#include <set>
Andrei Onea9445fc62019-06-27 18:11:59 +010023#include <map>
Adam Lesinskiffa16862014-01-23 18:17:42 -080024#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27
Casey Dahline8c0d7a2015-09-11 15:35:07 -070028int yylex(yy::parser::semantic_type *, yy::parser::location_type *, void *);
Adam Lesinskiffa16862014-01-23 18:17:42 -080029
Mathew Inwoodadb74672019-11-29 14:01:53 +000030AidlLocation loc(const yy::parser::location_type& begin, const yy::parser::location_type& end) {
31 CHECK(begin.begin.filename == begin.end.filename);
32 CHECK(begin.end.filename == end.begin.filename);
33 CHECK(end.begin.filename == end.end.filename);
34 AidlLocation::Point begin_point {
35 .line = begin.begin.line,
36 .column = begin.begin.column,
37 };
38 AidlLocation::Point end_point {
39 .line = end.end.line,
40 .column = end.end.column,
41 };
42 return AidlLocation(*begin.begin.filename, begin_point, end_point);
43}
44
Steven Moreland46e9da82018-07-27 15:45:29 -070045AidlLocation loc(const yy::parser::location_type& l) {
Mathew Inwoodadb74672019-11-29 14:01:53 +000046 return loc(l, l);
Steven Moreland46e9da82018-07-27 15:45:29 -070047}
48
Casey Dahlinfd2e08a2015-09-10 18:29:09 -070049#define lex_scanner ps->Scanner()
Casey Dahlindd691812015-09-09 17:59:06 -070050
Adam Lesinskiffa16862014-01-23 18:17:42 -080051%}
52
Steven Moreland46e9da82018-07-27 15:45:29 -070053%initial-action {
54 @$.begin.filename = @$.end.filename =
55 const_cast<std::string *>(&ps->FileName());
56}
57
Casey Dahline2507492015-09-14 17:11:20 -070058%parse-param { Parser* ps }
Casey Dahlinfd2e08a2015-09-10 18:29:09 -070059%lex-param { void *lex_scanner }
Casey Dahlindd691812015-09-09 17:59:06 -070060
Steven Moreland38a41d12018-07-10 11:01:07 -070061%glr-parser
Casey Dahlinfd2e08a2015-09-10 18:29:09 -070062%skeleton "glr.cc"
Casey Dahlindd691812015-09-09 17:59:06 -070063
Steven Moreland38a41d12018-07-10 11:01:07 -070064%expect-rr 0
65
Dan Willemsen609ba6d2019-12-30 10:44:00 -080066%define parse.error verbose
67%locations
Steven Moreland2ca4fcb2018-06-27 16:01:01 -070068
Casey Dahline8c0d7a2015-09-11 15:35:07 -070069%union {
Casey Dahlincdbbc8c2015-10-14 15:31:04 -070070 AidlToken* token;
Steven Moreland25294322018-08-07 18:13:55 -070071 char character;
Casey Dahlin05598752015-10-05 18:18:43 -070072 std::string *str;
Jiyong Park68bc77a2018-07-19 19:00:45 +090073 AidlAnnotation* annotation;
Andrei Onea9445fc62019-06-27 18:11:59 +010074 AidlAnnotationParameter* param;
75 std::map<std::string, std::shared_ptr<AidlConstantValue>>* param_list;
Jiyong Parka6605ab2018-11-11 14:30:21 +090076 std::vector<AidlAnnotation>* annotation_list;
Jiyong Parkd59a10d2018-07-18 11:12:55 +090077 AidlTypeSpecifier* type;
Casey Dahlinbc7a50a2015-09-28 19:20:50 -070078 AidlArgument* arg;
Casey Dahlinfd6fb482015-09-30 14:48:18 -070079 AidlArgument::Direction direction;
Will McVickerd7d18df2019-09-12 13:40:50 -070080 AidlConstantValue* const_expr;
Daniel Norman85aed542019-08-21 12:01:14 -070081 AidlEnumerator* enumerator;
82 std::vector<std::unique_ptr<AidlEnumerator>>* enumerators;
83 AidlEnumDeclaration* enum_decl;
Steven Moreland860b1942018-08-16 14:59:28 -070084 std::vector<std::unique_ptr<AidlConstantValue>>* constant_value_list;
Casey Dahlinbc7a50a2015-09-28 19:20:50 -070085 std::vector<std::unique_ptr<AidlArgument>>* arg_list;
Steven Moreland5557f1c2018-07-02 13:50:23 -070086 AidlVariableDeclaration* variable;
87 std::vector<std::unique_ptr<AidlVariableDeclaration>>* variable_list;
Casey Dahlin5c69deb2015-10-01 14:44:12 -070088 AidlMethod* method;
Christopher Wileyd6bdd8d2016-05-03 11:23:13 -070089 AidlMember* constant;
Steven Morelandc258abc2018-07-10 14:03:38 -070090 std::vector<std::unique_ptr<AidlMember>>* interface_members;
Casey Dahlin2b2879b2015-10-13 16:59:44 -070091 AidlQualifiedName* qname;
Steven Morelandc258abc2018-07-10 14:03:38 -070092 AidlInterface* interface;
Casey Dahlinc1f39b42015-11-24 10:34:34 -080093 AidlParcelable* parcelable;
Steven Morelandc258abc2018-07-10 14:03:38 -070094 AidlDefinedType* declaration;
Jiyong Parkd59a10d2018-07-18 11:12:55 +090095 std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_args;
Jeongik Chadf76dc72019-11-28 00:08:47 +090096 std::vector<std::string>* type_params;
Casey Dahline8c0d7a2015-09-11 15:35:07 -070097}
Adam Lesinskiffa16862014-01-23 18:17:42 -080098
Steven Morelandb49a33d2019-08-21 11:17:32 -070099%destructor { } <character>
100%destructor { } <direction>
101%destructor { delete ($$); } <*>
102
Steven Morelanded906872018-07-10 11:36:37 -0700103%token<token> ANNOTATION "annotation"
Steven Moreland22c78002018-07-17 10:27:33 -0700104%token<token> C_STR "string literal"
Steven Moreland22c78002018-07-17 10:27:33 -0700105%token<token> IDENTIFIER "identifier"
106%token<token> INTERFACE "interface"
Jiyong Parka6605ab2018-11-11 14:30:21 +0900107%token<token> PARCELABLE "parcelable"
Steven Moreland22c78002018-07-17 10:27:33 -0700108%token<token> ONEWAY "oneway"
Steven Morelandb49a33d2019-08-21 11:17:32 -0700109%token<token> ENUM "enum"
Jeongik Cha997281d2020-01-16 15:23:59 +0900110%token<token> CONST "const"
Steven Moreland25294322018-08-07 18:13:55 -0700111
112%token<character> CHARVALUE "char literal"
Steven Moreland1c4ba202018-08-09 10:49:54 -0700113%token<token> FLOATVALUE "float literal"
Steven Moreland25294322018-08-07 18:13:55 -0700114%token<token> HEXVALUE "hex literal"
115%token<token> INTVALUE "int literal"
Casey Dahlin59401da2015-10-09 18:16:45 -0700116
Will McVickerd7d18df2019-09-12 13:40:50 -0700117%token '(' ')' ',' '=' '[' ']' '.' '{' '}' ';'
Steven Moreland2ca4fcb2018-06-27 16:01:01 -0700118%token UNKNOWN "unrecognized character"
Steven Moreland22c78002018-07-17 10:27:33 -0700119%token CPP_HEADER "cpp_header"
120%token IMPORT "import"
121%token IN "in"
122%token INOUT "inout"
Steven Moreland22c78002018-07-17 10:27:33 -0700123%token OUT "out"
124%token PACKAGE "package"
Steven Moreland25294322018-08-07 18:13:55 -0700125%token TRUE_LITERAL "true"
126%token FALSE_LITERAL "false"
Casey Dahline8c0d7a2015-09-11 15:35:07 -0700127
Will McVickerd7d18df2019-09-12 13:40:50 -0700128/* Operator precedence and associativity, as per
129 * http://en.cppreference.com/w/cpp/language/operator_precedence */
130/* Precedence level 13 - 14, LTR, logical operators*/
131%left LOGICAL_OR
132%left LOGICAL_AND
133/* Precedence level 10 - 12, LTR, bitwise operators*/
134%left '|'
135%left '^'
136%left '&'
137/* Precedence level 9, LTR */
138%left EQUALITY NEQ
139/* Precedence level 8, LTR */
140%left '<' '>' LEQ GEQ
141/* Precedence level 7, LTR */
142%left LSHIFT RSHIFT
143/* Precedence level 6, LTR */
144%left '+' '-'
145/* Precedence level 5, LTR */
146%left '*' '/' '%'
147/* Precedence level 3, RTL; but we have to use %left here */
148%right UNARY_PLUS UNARY_MINUS '!' '~'
149
Steven Morelandc258abc2018-07-10 14:03:38 -0700150%type<declaration> decl
Steven Moreland5557f1c2018-07-02 13:50:23 -0700151%type<variable_list> variable_decls
152%type<variable> variable_decl
Steven Morelandc258abc2018-07-10 14:03:38 -0700153%type<interface_members> interface_members
154%type<declaration> unannotated_decl
155%type<interface> interface_decl
156%type<parcelable> parcelable_decl
Casey Dahline8c0d7a2015-09-11 15:35:07 -0700157%type<method> method_decl
Casey Dahlind40e2fe2015-11-24 14:06:52 -0800158%type<constant> constant_decl
Daniel Norman85aed542019-08-21 12:01:14 -0700159%type<enumerator> enumerator
160%type<enumerators> enumerators enum_decl_body
161%type<enum_decl> enum_decl
Andrei Onea9445fc62019-06-27 18:11:59 +0100162%type<param> parameter
163%type<param_list> parameter_list
164%type<param_list> parameter_non_empty_list
Christopher Wileyec31a052016-01-25 07:28:51 -0800165%type<annotation> annotation
166%type<annotation_list>annotation_list
Casey Dahline8c0d7a2015-09-11 15:35:07 -0700167%type<type> type
Steven Moreland3be75772018-08-20 13:27:43 -0700168%type<type> unannotated_type
Steven Morelandf4cd2712019-10-29 14:11:10 -0700169%type<arg_list> arg_list arg_non_empty_list
Casey Dahlinbc7a50a2015-09-28 19:20:50 -0700170%type<arg> arg
Casey Dahlinfd6fb482015-09-30 14:48:18 -0700171%type<direction> direction
Jiyong Parkccf00f82018-07-17 01:39:23 +0900172%type<type_args> type_args
Jeongik Chadf76dc72019-11-28 00:08:47 +0900173%type<type_params> type_params
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700174%type<qname> qualified_name
Will McVickerd7d18df2019-09-12 13:40:50 -0700175%type<const_expr> const_expr
Steven Moreland860b1942018-08-16 14:59:28 -0700176%type<constant_value_list> constant_value_list
177%type<constant_value_list> constant_value_non_empty_list
Casey Dahline8c0d7a2015-09-11 15:35:07 -0700178
Casey Dahlinbed1e872015-10-22 17:03:34 -0700179%type<token> identifier error
Adam Lesinskiffa16862014-01-23 18:17:42 -0800180%%
Casey Dahlin3c6df362015-10-06 15:48:35 -0700181document
Jiyong Parkb034bf02018-07-30 17:44:33 +0900182 : package imports decls {};
Adam Lesinskiffa16862014-01-23 18:17:42 -0800183
Casey Dahlinbed1e872015-10-22 17:03:34 -0700184/* A couple of tokens that are keywords elsewhere are identifiers when
185 * occurring in the identifier position. Therefore identifier is a
186 * non-terminal, which is either an IDENTIFIER token, or one of the
187 * aforementioned keyword tokens.
188 */
189identifier
190 : IDENTIFIER
191 { $$ = $1; }
Casey Dahlincd639212015-12-15 12:51:04 -0800192 | CPP_HEADER
193 { $$ = new AidlToken("cpp_header", ""); }
Christopher Wileyd6bdd8d2016-05-03 11:23:13 -0700194 ;
Casey Dahlinbed1e872015-10-22 17:03:34 -0700195
Casey Dahlin3c6df362015-10-06 15:48:35 -0700196package
197 : {}
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700198 | PACKAGE qualified_name ';'
Jiyong Parkb034bf02018-07-30 17:44:33 +0900199 { ps->SetPackage(unique_ptr<AidlQualifiedName>($2)); };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800200
Casey Dahlin3c6df362015-10-06 15:48:35 -0700201imports
202 : {}
203 | import imports {};
Adam Lesinskiffa16862014-01-23 18:17:42 -0800204
Casey Dahlin3c6df362015-10-06 15:48:35 -0700205import
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700206 : IMPORT qualified_name ';'
Steven Morelandd1039a92020-01-23 09:49:43 -0800207 { ps->AddImport(std::make_unique<AidlImport>(loc(@2), $2->GetDotName()));
Steven Moreland46e9da82018-07-27 15:45:29 -0700208 delete $2;
209 };
Casey Dahlin3c6df362015-10-06 15:48:35 -0700210
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700211qualified_name
Casey Dahlinbed1e872015-10-22 17:03:34 -0700212 : identifier {
Steven Moreland46e9da82018-07-27 15:45:29 -0700213 $$ = new AidlQualifiedName(loc(@1), $1->GetText(), $1->GetComments());
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700214 delete $1;
Casey Dahlin3c6df362015-10-06 15:48:35 -0700215 }
Casey Dahlinbed1e872015-10-22 17:03:34 -0700216 | qualified_name '.' identifier
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700217 { $$ = $1;
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700218 $$->AddTerm($3->GetText());
Andreas Gampe9c25c162017-04-27 13:30:29 -0700219 delete $3;
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700220 };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800221
Steven Morelandc258abc2018-07-10 14:03:38 -0700222decls
Jiyong Parkb034bf02018-07-30 17:44:33 +0900223 : decl {
Steven Moreland7b412722019-10-25 17:46:02 -0700224 if ($1 != nullptr) {
225 ps->AddDefinedType(unique_ptr<AidlDefinedType>($1));
226 }
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700227 }
Jiyong Parkb034bf02018-07-30 17:44:33 +0900228 | decls decl {
Steven Moreland7b412722019-10-25 17:46:02 -0700229 if ($2 != nullptr) {
230 ps->AddDefinedType(unique_ptr<AidlDefinedType>($2));
231 }
Jiyong Parkb034bf02018-07-30 17:44:33 +0900232 };
Steven Morelandc258abc2018-07-10 14:03:38 -0700233
234decl
235 : annotation_list unannotated_decl
236 {
237 $$ = $2;
238
Steven Moreland7b412722019-10-25 17:46:02 -0700239 if ($1->size() > 0 && $$ != nullptr) {
Jiyong Parka6605ab2018-11-11 14:30:21 +0900240 // copy comments from annotation to decl
Steven Moreland7b412722019-10-25 17:46:02 -0700241 $$->SetComments($1->begin()->GetComments());
242 $$->Annotate(std::move(*$1));
Jiyong Parka6605ab2018-11-11 14:30:21 +0900243 }
244
Jiyong Park68bc77a2018-07-19 19:00:45 +0900245 delete $1;
Steven Morelandc258abc2018-07-10 14:03:38 -0700246 }
247 ;
248
249unannotated_decl
250 : parcelable_decl
251 { $$ = $1; }
252 | interface_decl
253 { $$ = $1; }
Daniel Norman85aed542019-08-21 12:01:14 -0700254 | enum_decl
255 { $$ = $1; }
Steven Morelandc258abc2018-07-10 14:03:38 -0700256 ;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800257
Jeongik Chadf76dc72019-11-28 00:08:47 +0900258type_params
259 : identifier {
260 $$ = new std::vector<std::string>();
261 $$->emplace_back($1->GetText());
Steven Morelandd12e3132019-12-17 15:44:37 -0800262 delete $1;
Jeongik Chadf76dc72019-11-28 00:08:47 +0900263 }
264 | type_params ',' identifier {
265 $1->emplace_back($3->GetText());
266 $$ = $1;
Steven Morelandd12e3132019-12-17 15:44:37 -0800267 delete $3;
Jeongik Chadf76dc72019-11-28 00:08:47 +0900268 };
269
270
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700271parcelable_decl
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700272 : PARCELABLE qualified_name ';' {
Jiyong Parka6605ab2018-11-11 14:30:21 +0900273 $$ = new AidlParcelable(loc(@2), $2, ps->Package(), $1->GetComments());
Steven Morelandb49a33d2019-08-21 11:17:32 -0700274 delete $1;
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700275 }
Jeongik Chadf76dc72019-11-28 00:08:47 +0900276 | PARCELABLE qualified_name '<' type_params '>' ';' {
277 $$ = new AidlParcelable(loc(@2), $2, ps->Package(), $1->GetComments(), "", $4);
278 delete $1;
279 }
Casey Dahlincd639212015-12-15 12:51:04 -0800280 | PARCELABLE qualified_name CPP_HEADER C_STR ';' {
Jiyong Parka6605ab2018-11-11 14:30:21 +0900281 $$ = new AidlParcelable(loc(@2), $2, ps->Package(), $1->GetComments(), $4->GetText());
Steven Morelandb49a33d2019-08-21 11:17:32 -0700282 delete $1;
283 delete $4;
Casey Dahlinbed1e872015-10-22 17:03:34 -0700284 }
Steven Moreland5557f1c2018-07-02 13:50:23 -0700285 | PARCELABLE identifier '{' variable_decls '}' {
Steven Moreland46e9da82018-07-27 15:45:29 -0700286 AidlQualifiedName* name = new AidlQualifiedName(loc(@2), $2->GetText(), $2->GetComments());
Jiyong Parka6605ab2018-11-11 14:30:21 +0900287 $$ = new AidlStructuredParcelable(loc(@2), name, ps->Package(), $1->GetComments(), $4);
Steven Morelandb49a33d2019-08-21 11:17:32 -0700288 delete $1;
289 delete $2;
290 delete $4;
Steven Moreland5557f1c2018-07-02 13:50:23 -0700291 }
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700292 | PARCELABLE error ';' {
Steven Moreland2ca4fcb2018-06-27 16:01:01 -0700293 ps->AddError();
Steven Morelandb49a33d2019-08-21 11:17:32 -0700294 $$ = nullptr;
295 delete $1;
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700296 };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800297
Steven Moreland5557f1c2018-07-02 13:50:23 -0700298variable_decls
299 : /* empty */ {
Steven Moreland860b1942018-08-16 14:59:28 -0700300 $$ = new std::vector<std::unique_ptr<AidlVariableDeclaration>>;
301 }
Steven Moreland5557f1c2018-07-02 13:50:23 -0700302 | variable_decls variable_decl {
303 $$ = $1;
304 if ($2 != nullptr) {
305 $$->push_back(std::unique_ptr<AidlVariableDeclaration>($2));
306 }
307 };
308
309variable_decl
310 : type identifier ';' {
Steven Moreland46e9da82018-07-27 15:45:29 -0700311 $$ = new AidlVariableDeclaration(loc(@2), $1, $2->GetText());
Steven Morelandb49a33d2019-08-21 11:17:32 -0700312 delete $2;
Steven Moreland5557f1c2018-07-02 13:50:23 -0700313 }
Will McVickerd7d18df2019-09-12 13:40:50 -0700314 | type identifier '=' const_expr ';' {
Daniel Norman85aed542019-08-21 12:01:14 -0700315 // TODO(b/123321528): Support enum type default assignments (TestEnum foo = TestEnum.FOO).
Steven Moreland46e9da82018-07-27 15:45:29 -0700316 $$ = new AidlVariableDeclaration(loc(@2), $1, $2->GetText(), $4);
Steven Morelandb49a33d2019-08-21 11:17:32 -0700317 delete $2;
Steven Moreland9ea10e32018-07-19 15:26:09 -0700318 }
Steven Moreland5557f1c2018-07-02 13:50:23 -0700319 | error ';' {
320 ps->AddError();
321 $$ = nullptr;
322 }
323
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700324interface_decl
Steven Morelandc258abc2018-07-10 14:03:38 -0700325 : INTERFACE identifier '{' interface_members '}' {
Jiyong Parkb034bf02018-07-30 17:44:33 +0900326 $$ = new AidlInterface(loc(@1), $2->GetText(), $1->GetComments(), false, $4, ps->Package());
Steven Morelandc258abc2018-07-10 14:03:38 -0700327 delete $1;
328 delete $2;
329 }
330 | ONEWAY INTERFACE identifier '{' interface_members '}' {
Steven Moreland46e9da82018-07-27 15:45:29 -0700331 $$ = new AidlInterface(loc(@2), $3->GetText(), $1->GetComments(), true, $5, ps->Package());
Steven Morelandc258abc2018-07-10 14:03:38 -0700332 delete $1;
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700333 delete $2;
334 delete $3;
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700335 }
Steven Morelandc258abc2018-07-10 14:03:38 -0700336 | INTERFACE error '{' interface_members '}' {
Steven Moreland2ca4fcb2018-06-27 16:01:01 -0700337 ps->AddError();
Steven Morelandc258abc2018-07-10 14:03:38 -0700338 $$ = nullptr;
339 delete $1;
Steven Morelandc258abc2018-07-10 14:03:38 -0700340 delete $4;
Casey Dahlin1ae2bc52015-10-07 18:49:10 -0700341 };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800342
Steven Morelandc258abc2018-07-10 14:03:38 -0700343interface_members
Casey Dahlin5c69deb2015-10-01 14:44:12 -0700344 :
Casey Dahlind40e2fe2015-11-24 14:06:52 -0800345 { $$ = new std::vector<std::unique_ptr<AidlMember>>(); }
Steven Morelandc258abc2018-07-10 14:03:38 -0700346 | interface_members method_decl
Steven Morelandb49a33d2019-08-21 11:17:32 -0700347 { $1->push_back(std::unique_ptr<AidlMember>($2)); $$ = $1; }
Steven Morelandc258abc2018-07-10 14:03:38 -0700348 | interface_members constant_decl
Steven Morelandb49a33d2019-08-21 11:17:32 -0700349 { $1->push_back(std::unique_ptr<AidlMember>($2)); $$ = $1; }
Steven Morelandc258abc2018-07-10 14:03:38 -0700350 | interface_members error ';' {
Steven Moreland2ca4fcb2018-06-27 16:01:01 -0700351 ps->AddError();
Casey Dahlin5c69deb2015-10-01 14:44:12 -0700352 $$ = $1;
353 };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800354
Will McVickerd7d18df2019-09-12 13:40:50 -0700355const_expr
Steven Moreland25294322018-08-07 18:13:55 -0700356 : TRUE_LITERAL { $$ = AidlConstantValue::Boolean(loc(@1), true); }
357 | FALSE_LITERAL { $$ = AidlConstantValue::Boolean(loc(@1), false); }
358 | CHARVALUE { $$ = AidlConstantValue::Character(loc(@1), $1); }
359 | INTVALUE {
360 $$ = AidlConstantValue::Integral(loc(@1), $1->GetText());
Will McVickerd7d18df2019-09-12 13:40:50 -0700361 if ($$ == nullptr) {
362 std::cerr << "ERROR: Could not parse integer: "
363 << $1->GetText() << " at " << @1 << ".\n";
364 ps->AddError();
365 $$ = AidlConstantValue::Integral(loc(@1), "0");
366 }
Steven Moreland25294322018-08-07 18:13:55 -0700367 delete $1;
368 }
Steven Moreland1c4ba202018-08-09 10:49:54 -0700369 | FLOATVALUE {
370 $$ = AidlConstantValue::Floating(loc(@1), $1->GetText());
371 delete $1;
372 }
Steven Moreland693640b2018-07-19 13:46:27 -0700373 | HEXVALUE {
Will McVickerd7d18df2019-09-12 13:40:50 -0700374 $$ = AidlConstantValue::Integral(loc(@1), $1->GetText());
375 if ($$ == nullptr) {
376 std::cerr << "ERROR: Could not parse hexvalue: "
377 << $1->GetText() << " at " << @1 << ".\n";
378 ps->AddError();
379 $$ = AidlConstantValue::Integral(loc(@1), "0");
380 }
Steven Moreland693640b2018-07-19 13:46:27 -0700381 delete $1;
382 }
Will McVickerd7d18df2019-09-12 13:40:50 -0700383 | C_STR {
384 $$ = AidlConstantValue::String(loc(@1), $1->GetText());
Steven Moreland693640b2018-07-19 13:46:27 -0700385 delete $1;
386 }
Steven Moreland860b1942018-08-16 14:59:28 -0700387 | '{' constant_value_list '}' {
Will McVickerd7d18df2019-09-12 13:40:50 -0700388 $$ = AidlConstantValue::Array(loc(@1), std::unique_ptr<vector<unique_ptr<AidlConstantValue>>>($2));
Steven Moreland860b1942018-08-16 14:59:28 -0700389 }
Will McVickerd7d18df2019-09-12 13:40:50 -0700390 | const_expr LOGICAL_OR const_expr {
391 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "||", std::unique_ptr<AidlConstantValue>($3));
392 }
393 | const_expr LOGICAL_AND const_expr {
394 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "&&", std::unique_ptr<AidlConstantValue>($3));
395 }
396 | const_expr '|' const_expr {
397 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "|" , std::unique_ptr<AidlConstantValue>($3));
398 }
399 | const_expr '^' const_expr {
400 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "^" , std::unique_ptr<AidlConstantValue>($3));
401 }
402 | const_expr '&' const_expr {
403 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "&" , std::unique_ptr<AidlConstantValue>($3));
404 }
405 | const_expr EQUALITY const_expr {
406 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "==", std::unique_ptr<AidlConstantValue>($3));
407 }
408 | const_expr NEQ const_expr {
409 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "!=", std::unique_ptr<AidlConstantValue>($3));
410 }
411 | const_expr '<' const_expr {
412 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "<" , std::unique_ptr<AidlConstantValue>($3));
413 }
414 | const_expr '>' const_expr {
415 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), ">" , std::unique_ptr<AidlConstantValue>($3));
416 }
417 | const_expr LEQ const_expr {
418 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "<=", std::unique_ptr<AidlConstantValue>($3));
419 }
420 | const_expr GEQ const_expr {
421 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), ">=", std::unique_ptr<AidlConstantValue>($3));
422 }
423 | const_expr LSHIFT const_expr {
424 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "<<", std::unique_ptr<AidlConstantValue>($3));
425 }
426 | const_expr RSHIFT const_expr {
427 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), ">>", std::unique_ptr<AidlConstantValue>($3));
428 }
429 | const_expr '+' const_expr {
430 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "+" , std::unique_ptr<AidlConstantValue>($3));
431 }
432 | const_expr '-' const_expr {
433 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "-" , std::unique_ptr<AidlConstantValue>($3));
434 }
435 | const_expr '*' const_expr {
436 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "*" , std::unique_ptr<AidlConstantValue>($3));
437 }
438 | const_expr '/' const_expr {
439 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "/" , std::unique_ptr<AidlConstantValue>($3));
440 }
441 | const_expr '%' const_expr {
442 $$ = new AidlBinaryConstExpression(loc(@1), std::unique_ptr<AidlConstantValue>($1), "%" , std::unique_ptr<AidlConstantValue>($3));
443 }
444 | '+' const_expr %prec UNARY_PLUS {
445 $$ = new AidlUnaryConstExpression(loc(@1), "+", std::unique_ptr<AidlConstantValue>($2));
446 }
447 | '-' const_expr %prec UNARY_MINUS {
448 $$ = new AidlUnaryConstExpression(loc(@1), "-", std::unique_ptr<AidlConstantValue>($2));
449 }
450 | '!' const_expr {
451 $$ = new AidlUnaryConstExpression(loc(@1), "!", std::unique_ptr<AidlConstantValue>($2));
452 }
453 | '~' const_expr {
454 $$ = new AidlUnaryConstExpression(loc(@1), "~", std::unique_ptr<AidlConstantValue>($2));
455 }
456 | '(' const_expr ')'
457 {
458 $$ = $2;
459 }
460 | '(' error ')'
461 {
Steven Moreland33d56562019-10-28 14:58:01 -0700462 std::cerr << "ERROR: invalid const expression within parenthesis at " << @1 << ".\n";
Will McVickerd7d18df2019-09-12 13:40:50 -0700463 ps->AddError();
Steven Moreland33d56562019-10-28 14:58:01 -0700464 // to avoid segfaults
Will McVickerd7d18df2019-09-12 13:40:50 -0700465 $$ = AidlConstantValue::Integral(loc(@1), "0");
466 }
Steven Moreland860b1942018-08-16 14:59:28 -0700467 ;
468
469constant_value_list
470 : /* empty */ {
471 $$ = new std::vector<std::unique_ptr<AidlConstantValue>>;
472 }
473 | constant_value_non_empty_list {
474 $$ = $1;
475 }
476 ;
477
478constant_value_non_empty_list
Will McVickerd7d18df2019-09-12 13:40:50 -0700479 : const_expr {
Steven Moreland860b1942018-08-16 14:59:28 -0700480 $$ = new std::vector<std::unique_ptr<AidlConstantValue>>;
481 $$->push_back(std::unique_ptr<AidlConstantValue>($1));
482 }
Will McVickerd7d18df2019-09-12 13:40:50 -0700483 | constant_value_non_empty_list ',' const_expr {
Steven Moreland860b1942018-08-16 14:59:28 -0700484 $$ = $1;
485 $$->push_back(std::unique_ptr<AidlConstantValue>($3));
486 }
Steven Moreland693640b2018-07-19 13:46:27 -0700487 ;
488
Casey Dahlind40e2fe2015-11-24 14:06:52 -0800489constant_decl
Will McVickerd7d18df2019-09-12 13:40:50 -0700490 : CONST type identifier '=' const_expr ';' {
Jeongik Cha997281d2020-01-16 15:23:59 +0900491 $2->SetComments($1->GetComments());
Steven Moreland46e9da82018-07-27 15:45:29 -0700492 $$ = new AidlConstantDeclaration(loc(@3), $2, $3->GetText(), $5);
Jooyung Han7953f552020-02-01 00:38:57 +0900493 delete $1;
Christopher Wileyd6bdd8d2016-05-03 11:23:13 -0700494 delete $3;
495 }
Christopher Wileyd6bdd8d2016-05-03 11:23:13 -0700496 ;
Casey Dahlind40e2fe2015-11-24 14:06:52 -0800497
Daniel Norman85aed542019-08-21 12:01:14 -0700498enumerator
Will McVickerd7d18df2019-09-12 13:40:50 -0700499 : identifier '=' const_expr {
Daniel Norman2e4112d2019-10-03 10:22:35 -0700500 $$ = new AidlEnumerator(loc(@1), $1->GetText(), $3, $1->GetComments());
Daniel Norman85aed542019-08-21 12:01:14 -0700501 delete $1;
502 }
Daniel Normanb28684e2019-10-17 15:31:39 -0700503 | identifier {
504 $$ = new AidlEnumerator(loc(@1), $1->GetText(), nullptr, $1->GetComments());
505 delete $1;
506 }
Daniel Norman85aed542019-08-21 12:01:14 -0700507 ;
508
509enumerators
510 : enumerator {
511 $$ = new std::vector<std::unique_ptr<AidlEnumerator>>();
512 $$->push_back(std::unique_ptr<AidlEnumerator>($1));
513 }
514 | enumerators ',' enumerator {
515 $1->push_back(std::unique_ptr<AidlEnumerator>($3));
Steven Morelandb49a33d2019-08-21 11:17:32 -0700516 $$ = $1;
Daniel Norman85aed542019-08-21 12:01:14 -0700517 }
518 ;
519
520enum_decl_body
521 : '{' enumerators '}' { $$ = $2; }
522 | '{' enumerators ',' '}' { $$ = $2; }
523 ;
524
Daniel Norman85aed542019-08-21 12:01:14 -0700525enum_decl
526 : ENUM identifier enum_decl_body {
Daniel Norman2e4112d2019-10-03 10:22:35 -0700527 $$ = new AidlEnumDeclaration(loc(@2), $2->GetText(), $3, ps->Package(), $1->GetComments());
Steven Morelandb49a33d2019-08-21 11:17:32 -0700528 delete $1;
Daniel Norman85aed542019-08-21 12:01:14 -0700529 delete $2;
530 delete $3;
531 }
532 ;
533
Casey Dahlinf4a93112015-10-05 16:58:09 -0700534method_decl
Casey Dahlinbed1e872015-10-22 17:03:34 -0700535 : type identifier '(' arg_list ')' ';' {
Steven Moreland46e9da82018-07-27 15:45:29 -0700536 $$ = new AidlMethod(loc(@2), false, $1, $2->GetText(), $4, $1->GetComments());
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700537 delete $2;
Casey Dahlinf4a93112015-10-05 16:58:09 -0700538 }
Artur Satayev91fe8712019-07-29 13:06:01 +0100539 | annotation_list ONEWAY type identifier '(' arg_list ')' ';' {
540 const std::string& comments = ($1->size() > 0) ? $1->begin()->GetComments() : $2->GetComments();
541 $$ = new AidlMethod(loc(@4), true, $3, $4->GetText(), $6, comments);
542 $3->Annotate(std::move(*$1));
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700543 delete $1;
Artur Satayev91fe8712019-07-29 13:06:01 +0100544 delete $2;
545 delete $4;
Casey Dahlinf4a93112015-10-05 16:58:09 -0700546 }
Casey Dahlind40e2fe2015-11-24 14:06:52 -0800547 | type identifier '(' arg_list ')' '=' INTVALUE ';' {
Steven Morelande7d358a2020-01-16 16:52:34 -0800548 int32_t serial = 0;
Steven Morelandf04cd5e2019-11-10 20:35:29 -0800549 if (!android::base::ParseInt($7->GetText(), &serial)) {
550 AIDL_ERROR(loc(@7)) << "Could not parse int value: " << $7->GetText();
551 ps->AddError();
552 }
553 $$ = new AidlMethod(loc(@2), false, $1, $2->GetText(), $4, $1->GetComments(), serial);
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700554 delete $2;
Steven Morelandb49a33d2019-08-21 11:17:32 -0700555 delete $7;
Casey Dahlinf4a93112015-10-05 16:58:09 -0700556 }
Artur Satayev91fe8712019-07-29 13:06:01 +0100557 | annotation_list ONEWAY type identifier '(' arg_list ')' '=' INTVALUE ';' {
558 const std::string& comments = ($1->size() > 0) ? $1->begin()->GetComments() : $2->GetComments();
Steven Morelande7d358a2020-01-16 16:52:34 -0800559 int32_t serial = 0;
Steven Morelandf04cd5e2019-11-10 20:35:29 -0800560 if (!android::base::ParseInt($9->GetText(), &serial)) {
561 AIDL_ERROR(loc(@9)) << "Could not parse int value: " << $9->GetText();
562 ps->AddError();
563 }
564 $$ = new AidlMethod(loc(@4), true, $3, $4->GetText(), $6, comments, serial);
Artur Satayev91fe8712019-07-29 13:06:01 +0100565 $3->Annotate(std::move(*$1));
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700566 delete $1;
Artur Satayev91fe8712019-07-29 13:06:01 +0100567 delete $2;
568 delete $4;
Steven Morelandb49a33d2019-08-21 11:17:32 -0700569 delete $9;
Casey Dahlinf4a93112015-10-05 16:58:09 -0700570 };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800571
Steven Morelandf4cd2712019-10-29 14:11:10 -0700572arg_non_empty_list
573 : arg {
Casey Dahlinbc7a50a2015-09-28 19:20:50 -0700574 $$ = new std::vector<std::unique_ptr<AidlArgument>>();
575 $$->push_back(std::unique_ptr<AidlArgument>($1));
576 }
Steven Morelandf4cd2712019-10-29 14:11:10 -0700577 | arg_non_empty_list ',' arg {
Casey Dahlinbc7a50a2015-09-28 19:20:50 -0700578 $$ = $1;
579 $$->push_back(std::unique_ptr<AidlArgument>($3));
Casey Dahlinbc7a50a2015-09-28 19:20:50 -0700580 };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800581
Steven Morelandf4cd2712019-10-29 14:11:10 -0700582arg_list
583 : /*empty*/
584 { $$ = new std::vector<std::unique_ptr<AidlArgument>>(); }
585 | arg_non_empty_list { $$ = $1; }
586 ;
587
Casey Dahlin5c69deb2015-10-01 14:44:12 -0700588arg
Casey Dahlinbed1e872015-10-22 17:03:34 -0700589 : direction type identifier {
Steven Moreland46e9da82018-07-27 15:45:29 -0700590 $$ = new AidlArgument(loc(@3), $1, $2, $3->GetText());
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700591 delete $3;
Steven Moreland2ca4fcb2018-06-27 16:01:01 -0700592 }
Casey Dahlinbed1e872015-10-22 17:03:34 -0700593 | type identifier {
Steven Moreland46e9da82018-07-27 15:45:29 -0700594 $$ = new AidlArgument(loc(@2), $1, $2->GetText());
Casey Dahlincdbbc8c2015-10-14 15:31:04 -0700595 delete $2;
Steven Moreland2ca4fcb2018-06-27 16:01:01 -0700596 }
Steven Morelandb49a33d2019-08-21 11:17:32 -0700597 ;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800598
Christopher Wileyec31a052016-01-25 07:28:51 -0800599unannotated_type
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700600 : qualified_name {
Steven Moreland46e9da82018-07-27 15:45:29 -0700601 $$ = new AidlTypeSpecifier(loc(@1), $1->GetDotName(), false, nullptr, $1->GetComments());
Jiyong Park1deecc32018-07-17 01:14:41 +0900602 ps->DeferResolution($$);
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700603 delete $1;
Casey Dahlinf2d23f72015-10-02 16:19:19 -0700604 }
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700605 | qualified_name '[' ']' {
Steven Moreland46e9da82018-07-27 15:45:29 -0700606 $$ = new AidlTypeSpecifier(loc(@1), $1->GetDotName(), true, nullptr, $1->GetComments());
Jiyong Park1deecc32018-07-17 01:14:41 +0900607 ps->DeferResolution($$);
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700608 delete $1;
Casey Dahlinf2d23f72015-10-02 16:19:19 -0700609 }
Jiyong Parkccf00f82018-07-17 01:39:23 +0900610 | qualified_name '<' type_args '>' {
Steven Moreland46e9da82018-07-27 15:45:29 -0700611 $$ = new AidlTypeSpecifier(loc(@1), $1->GetDotName(), false, $3, $1->GetComments());
Jiyong Park1deecc32018-07-17 01:14:41 +0900612 ps->DeferResolution($$);
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700613 delete $1;
Christopher Wileyec31a052016-01-25 07:28:51 -0800614 };
615
616type
617 : annotation_list unannotated_type {
Casey Dahlincb5317d2015-12-03 15:43:33 -0800618 $$ = $2;
Jiyong Parka6605ab2018-11-11 14:30:21 +0900619 if ($1->size() > 0) {
620 // copy comments from annotation to type
621 $2->SetComments($1->begin()->GetComments());
622 }
Jiyong Park68bc77a2018-07-19 19:00:45 +0900623 $2->Annotate(std::move(*$1));
624 delete $1;
Casey Dahlin05598752015-10-05 18:18:43 -0700625 };
626
Jiyong Parkccf00f82018-07-17 01:39:23 +0900627type_args
628 : unannotated_type {
Jiyong Parkd59a10d2018-07-18 11:12:55 +0900629 $$ = new std::vector<std::unique_ptr<AidlTypeSpecifier>>();
Jiyong Parkccf00f82018-07-17 01:39:23 +0900630 $$->emplace_back($1);
Casey Dahlin2b2879b2015-10-13 16:59:44 -0700631 }
Jiyong Parkccf00f82018-07-17 01:39:23 +0900632 | type_args ',' unannotated_type {
633 $1->emplace_back($3);
Steven Morelandb49a33d2019-08-21 11:17:32 -0700634 $$ = $1;
Casey Dahlinf2d23f72015-10-02 16:19:19 -0700635 };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800636
Christopher Wileyec31a052016-01-25 07:28:51 -0800637annotation_list
Casey Dahline7922932016-02-29 17:23:01 -0800638 :
Jiyong Parka6605ab2018-11-11 14:30:21 +0900639 { $$ = new std::vector<AidlAnnotation>(); }
Casey Dahline7922932016-02-29 17:23:01 -0800640 | annotation_list annotation
Jiyong Park68bc77a2018-07-19 19:00:45 +0900641 {
642 if ($2 != nullptr) {
Jiyong Parka6605ab2018-11-11 14:30:21 +0900643 $1->emplace_back(std::move(*$2));
Steven Moreland3be75772018-08-20 13:27:43 -0700644 delete $2;
Jiyong Park68bc77a2018-07-19 19:00:45 +0900645 }
Steven Morelandb49a33d2019-08-21 11:17:32 -0700646 $$ = $1;
Jiyong Park68bc77a2018-07-19 19:00:45 +0900647 };
Christopher Wileyec31a052016-01-25 07:28:51 -0800648
Andrei Onea9445fc62019-06-27 18:11:59 +0100649parameter
Will McVickerd7d18df2019-09-12 13:40:50 -0700650 : identifier '=' const_expr {
Andrei Onea9445fc62019-06-27 18:11:59 +0100651 $$ = new AidlAnnotationParameter{$1->GetText(), std::unique_ptr<AidlConstantValue>($3)};
652 delete $1;
653 };
654
655parameter_list
656 : /*empty*/{
657 $$ = new std::map<std::string, std::shared_ptr<AidlConstantValue>>();
658 }
659 | parameter_non_empty_list {
660 $$ = $1;
661 };
662
663parameter_non_empty_list
664 : parameter {
665 $$ = new std::map<std::string, std::shared_ptr<AidlConstantValue>>();
666 $$->emplace(std::move($1->name), $1->value.release());
667 delete $1;
668 }
669 | parameter_non_empty_list ',' parameter {
670 $$ = $1;
671 if ($$->find($3->name) != $$->end()) {
672 AIDL_ERROR(loc(@3)) << "Trying to redefine parameter " << $3->name << ".";
673 ps->AddError();
674 }
675 $$->emplace(std::move($3->name), std::move($3->value));
676 delete $3;
677 };
678
Christopher Wileyec31a052016-01-25 07:28:51 -0800679annotation
Steven Morelanded906872018-07-10 11:36:37 -0700680 : ANNOTATION
Jiyong Park68bc77a2018-07-19 19:00:45 +0900681 {
Andrei Onea9445fc62019-06-27 18:11:59 +0100682 $$ = AidlAnnotation::Parse(loc(@1), $1->GetText(), nullptr);
Steven Moreland83e78032019-10-25 17:07:20 -0700683 if ($$) {
684 $$->SetComments($1->GetComments());
685 } else {
Steven Morelanded906872018-07-10 11:36:37 -0700686 ps->AddError();
Steven Morelanded906872018-07-10 11:36:37 -0700687 }
Steven Morelandb49a33d2019-08-21 11:17:32 -0700688 delete $1;
Steven Morelanded906872018-07-10 11:36:37 -0700689 };
Andrei Onea9445fc62019-06-27 18:11:59 +0100690 | ANNOTATION '(' parameter_list ')' {
Mathew Inwoodadb74672019-11-29 14:01:53 +0000691 $$ = AidlAnnotation::Parse(loc(@1, @4), $1->GetText(), $3);
Steven Moreland83e78032019-10-25 17:07:20 -0700692 if ($$) {
693 $$->SetComments($1->GetComments());
694 } else {
Andrei Onea9445fc62019-06-27 18:11:59 +0100695 ps->AddError();
696 }
Steven Morelandb49a33d2019-08-21 11:17:32 -0700697 delete $1;
Andrei Onea9445fc62019-06-27 18:11:59 +0100698 delete $3;
699 }
Christopher Wileyec31a052016-01-25 07:28:51 -0800700
Casey Dahlin5c69deb2015-10-01 14:44:12 -0700701direction
702 : IN
Casey Dahlinfd6fb482015-09-30 14:48:18 -0700703 { $$ = AidlArgument::IN_DIR; }
704 | OUT
705 { $$ = AidlArgument::OUT_DIR; }
706 | INOUT
707 { $$ = AidlArgument::INOUT_DIR; };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800708
709%%
710
711#include <ctype.h>
712#include <stdio.h>
713
Steven Moreland46e9da82018-07-27 15:45:29 -0700714void yy::parser::error(const yy::parser::location_type& l, const std::string& errstr) {
Steven Moreland92c55f12018-07-31 14:08:37 -0700715 AIDL_ERROR(loc(l)) << errstr;
Steven Moreland46e9da82018-07-27 15:45:29 -0700716 // parser will return error value
Casey Dahlinfd2e08a2015-09-10 18:29:09 -0700717}