text stringlengths 0 234 |
|---|
procedure Parse_SPM(parser : in out Parser_Type; |
result : out Memory_Pointer) is separate; |
procedure Parse_Stats(parser : in out Parser_Type; |
result : out Memory_Pointer) is separate; |
procedure Parse_Super(parser : in out Parser_Type; |
result : out Memory_Pointer) is separate; |
procedure Parse_Trace(parser : in out Parser_Type; |
result : out Memory_Pointer) is separate; |
type Memory_Parser_Type is record |
name : Unbounded_String; |
parser : access procedure(parser : in out Parser_Type; |
result : out Memory_Pointer); |
end record; |
type Memory_Parser_Array is array(Positive range <>) of Memory_Parser_Type; |
parser_map : constant Memory_Parser_Array := ( |
(To_Unbounded_String("arbiter"), Parse_Arbiter'Access), |
(To_Unbounded_String("cache"), Parse_Cache'Access), |
(To_Unbounded_String("dram"), Parse_DRAM'Access), |
(To_Unbounded_String("dup"), Parse_Dup'Access), |
(To_Unbounded_String("eor"), Parse_EOR'Access), |
(To_Unbounded_String("flash"), Parse_Flash'Access), |
(To_Unbounded_String("flip"), Parse_Flip'Access), |
(To_Unbounded_String("join"), Parse_Join'Access), |
(To_Unbounded_String("offset"), Parse_Offset'Access), |
(To_Unbounded_String("option"), Parse_Option'Access), |
(To_Unbounded_String("perfect_prefetch"), Parse_Perfect_Prefetch'Access), |
(To_Unbounded_String("prefetch"), Parse_Prefetch'Access), |
(To_Unbounded_String("ram"), Parse_RAM'Access), |
(To_Unbounded_String("register"), Parse_Register'Access), |
(To_Unbounded_String("shift"), Parse_Shift'Access), |
(To_Unbounded_String("split"), Parse_Split'Access), |
(To_Unbounded_String("spm"), Parse_SPM'Access), |
(To_Unbounded_String("stats"), Parse_Stats'Access), |
(To_Unbounded_String("super"), Parse_Super'Access), |
(To_Unbounded_String("trace"), Parse_Trace'Access) |
); |
function Parse_Boolean(value : String) return Boolean is |
begin |
if value = "true" then |
return True; |
elsif value = "false" then |
return False; |
else |
raise Data_Error; |
end if; |
end Parse_Boolean; |
procedure Parse_Memory(parser : in out Parser_Type; |
result : out Memory_Pointer) is |
begin |
Match(parser, Open); |
declare |
name : constant String := Get_Value(parser.lexer); |
begin |
Next(parser.lexer); |
for i in parser_map'First .. parser_map'Last loop |
if parser_map(i).name = name then |
parser_map(i).parser(parser, result); |
Match(parser, Close); |
return; |
end if; |
end loop; |
Raise_Error(parser, "invalid memory type: " & name); |
Function Definition: procedure Raise_Error(parser : in Parser_Type; |
Function Body: msg : in String) is |
name : constant String := Get_File_Name(parser.lexer); |
line : constant String := Positive'Image(Get_Line(parser.lexer)); |
begin |
Put_Line(name & "[" & line(2 .. line'Last) & "]: error: " & msg); |
raise Parse_Error; |
end Raise_Error; |
function Get_Type(parser : Parser_Type) return Token_Type is |
begin |
return Get_Type(parser.lexer); |
end Get_Type; |
function Get_Value(parser : Parser_Type) return String is |
begin |
return Get_Value(parser.lexer); |
end Get_Value; |
procedure Match(parser : in out Parser_Type; |
token : in Token_Type) is |
begin |
if Get_Type(parser) /= token then |
Raise_Error(parser, "got '" & Get_Value(parser) & |
"' expected '" & Token_Type'Image(token) & "'"); |
end if; |
Next(parser.lexer); |
end Match; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.