53 lines
956 B
Plaintext
53 lines
956 B
Plaintext
%{
|
|
|
|
#include <fxos/errors.h>
|
|
#include <fxos/util.h>
|
|
#include <fxos/load.h>
|
|
#include <fxos/target.h>
|
|
|
|
/* The target description to be filled */
|
|
FxOS::TargetDescription t;
|
|
|
|
using BindingDescription = std::pair<FxOS::MemoryRegion,std::string>;
|
|
|
|
struct ValueType
|
|
{
|
|
BindingDescription binding;
|
|
FxOS::MemoryRegion region;
|
|
};
|
|
|
|
%}
|
|
|
|
/* Tokens */
|
|
%token <char *> NAME
|
|
%token <uint32_t> ADDRESS
|
|
%token <uint32_t> SIZE
|
|
%token <char *> PATH
|
|
|
|
%define api.value.type {ValueType}
|
|
|
|
%type<binding> binding
|
|
%type<region> 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); }
|
|
|
|
%%
|