%{ #include #include #include #include /* The target description to be filled */ FxOS::TargetDescription t; using BindingDescription = std::pair; struct ValueType { BindingDescription binding; FxOS::MemoryRegion region; }; %} /* Tokens */ %token NAME %token ADDRESS %token SIZE %token PATH %define api.value.type {ValueType} %type binding %type region %% main: init target {} init: %empty { t = FxOS::TargetDescription(); } target: %empty {} | binding target { t.bindings.push_back($1); } binding: region ':' PATH { $$ = std::make_pair($1, std::string($3)); free($3); } region: NAME { $$ = FxOS::MemoryRegion($1); free($1); } | ADDRESS { $$ = FxOS::MemoryRegion("anon", $1, $1, true); } | ADDRESS '(' SIZE ')' { $$ = FxOS::MemoryRegion("anon", $1, $1+$3, true); } %%