mirror of
https://github.com/AdaCore/langkit.git
synced 2026-02-12 12:28:12 -08:00
Remove Analysis_Unit_Interface from the parsers' API
Change-Id: Idf1265c57419bcb0ceb98feb6839a408df07fa2b TN: PC20-015
This commit is contained in:
@@ -103,7 +103,7 @@ loop
|
||||
end;
|
||||
|
||||
## Set token data for result
|
||||
${res}.Unit := Parser.Unit;
|
||||
${res}.Unit := Analysis_Unit_Interface (Parser.Unit);
|
||||
${res}.Token_Start := ${pos_name};
|
||||
${res}.Token_End := (if ${cpos} = ${pos_name}
|
||||
then ${pos_name}
|
||||
@@ -149,7 +149,7 @@ end loop;
|
||||
## If we managed to parse a list, compute and set the sloc range for this AST
|
||||
## node.
|
||||
if ${res} /= null then
|
||||
${res}.Unit := Parser.Unit;
|
||||
${res}.Unit := Analysis_Unit_Interface (Parser.Unit);
|
||||
if Node_Bump_Ptr_Vectors.Length (${res}.Vec) > 0 then
|
||||
${res}.Token_Start := ${pos_name};
|
||||
${res}.Token_End := (if ${cpos} = ${pos_name}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
% if _self.get_type().is_list_type:
|
||||
${res} :=
|
||||
(${_self.get_type().storage_type_name()}_Alloc.Alloc (Parser.Mem_Pool));
|
||||
${res}.Unit := Parser.Unit;
|
||||
${res}.Unit := Analysis_Unit_Interface (Parser.Unit);
|
||||
|
||||
${res}.Token_Start := Token_Index'Max (1, ${pos_name} - 1);
|
||||
${res}.Token_End := No_Token_Index;
|
||||
|
||||
@@ -17,14 +17,15 @@ if ${parser_context.pos_var_name} = No_Token_Index then
|
||||
% else:
|
||||
${bool_res} := ${base.name()}
|
||||
(${alt_false.name()}_Alloc.Alloc (Parser.Mem_Pool));
|
||||
${bool_res}.Unit := Parser.Unit;
|
||||
${bool_res}.Unit := Analysis_Unit_Interface (Parser.Unit);
|
||||
${bool_res}.Token_Start := ${pos_name};
|
||||
${bool_res}.Token_End := No_Token_Index;
|
||||
% endif
|
||||
% elif parser_type.is_list_type:
|
||||
${parser_context.res_var_name} :=
|
||||
(${parser_type.storage_type_name()}_Alloc.Alloc (Parser.Mem_Pool));
|
||||
${parser_context.res_var_name}.Unit := Parser.Unit;
|
||||
${parser_context.res_var_name}.Unit :=
|
||||
Analysis_Unit_Interface (Parser.Unit);
|
||||
${parser_context.res_var_name}.Token_Start := ${pos_name} - 1;
|
||||
${parser_context.res_var_name}.Token_End := No_Token_Index;
|
||||
% else:
|
||||
@@ -53,7 +54,7 @@ else
|
||||
% else:
|
||||
${bool_res} := ${base.name()}
|
||||
(${alt_true.name()}_Alloc.Alloc (Parser.Mem_Pool));
|
||||
${bool_res}.Unit := Parser.Unit;
|
||||
${bool_res}.Unit := Analysis_Unit_Interface (Parser.Unit);
|
||||
${bool_res}.Token_Start := ${pos_name};
|
||||
${bool_res}.Token_End := No_Token_Index;
|
||||
% endif
|
||||
|
||||
@@ -53,14 +53,14 @@ package body ${_self.ada_api_settings.lib_name}.Analysis.Parsers is
|
||||
function Create_From_File
|
||||
(Filename, Charset : String;
|
||||
Read_BOM : Boolean;
|
||||
Unit : Analysis_Unit_Interface;
|
||||
Unit : Analysis_Unit;
|
||||
With_Trivia : Boolean := False)
|
||||
return Parser_type
|
||||
is
|
||||
TDH : Token_Data_Handler renames Unit.Token_Data.all;
|
||||
TDH : Token_Data_Handler_Access renames Token_Data (Unit);
|
||||
begin
|
||||
Lex_From_Filename (Filename, Charset, Read_BOM, TDH, With_Trivia);
|
||||
return (Unit => Unit, TDH => Unit.Token_Data, others => <>);
|
||||
Lex_From_Filename (Filename, Charset, Read_BOM, TDH.all, With_Trivia);
|
||||
return (Unit => Unit, TDH => TDH, others => <>);
|
||||
end Create_From_File;
|
||||
|
||||
------------------------
|
||||
@@ -70,14 +70,14 @@ package body ${_self.ada_api_settings.lib_name}.Analysis.Parsers is
|
||||
function Create_From_Buffer
|
||||
(Buffer, Charset : String;
|
||||
Read_BOM : Boolean;
|
||||
Unit : Analysis_Unit_Interface;
|
||||
Unit : Analysis_Unit;
|
||||
With_Trivia : Boolean := False)
|
||||
return Parser_type
|
||||
is
|
||||
TDH : Token_Data_Handler renames Unit.Token_Data.all;
|
||||
TDH : Token_Data_Handler_Access renames Token_Data (Unit);
|
||||
begin
|
||||
Lex_From_Buffer (Buffer, Charset, Read_BOM, TDH, With_Trivia);
|
||||
return (Unit => Unit, TDH => Unit.Token_Data, others => <>);
|
||||
Lex_From_Buffer (Buffer, Charset, Read_BOM, TDH.all, With_Trivia);
|
||||
return (Unit => Unit, TDH => TDH, others => <>);
|
||||
end Create_From_Buffer;
|
||||
|
||||
---------------------------
|
||||
|
||||
@@ -6,8 +6,6 @@ with Langkit_Support.Diagnostics; use Langkit_Support.Diagnostics;
|
||||
with ${_self.ada_api_settings.lib_name}.Lexer;
|
||||
use ${_self.ada_api_settings.lib_name}.Lexer;
|
||||
use ${_self.ada_api_settings.lib_name}.Lexer.Token_Data_Handlers;
|
||||
with ${_self.ada_api_settings.lib_name}.Analysis_Interfaces;
|
||||
use ${_self.ada_api_settings.lib_name}.Analysis_Interfaces;
|
||||
|
||||
-- This package provides types and primitives to parse buffers and files and
|
||||
-- get AST out of them.
|
||||
@@ -27,7 +25,7 @@ package ${_self.ada_api_settings.lib_name}.Analysis.Parsers is
|
||||
Current_Pos : Token_Index := First_Token_Index;
|
||||
Last_Fail : Fail_Info;
|
||||
Diagnostics : Diagnostics_Vectors.Vector;
|
||||
Unit : Analysis_Unit_Interface;
|
||||
Unit : Analysis_Unit;
|
||||
TDH : Token_Data_Handler_Access;
|
||||
Mem_Pool : Bump_Ptr_Pool;
|
||||
end record;
|
||||
@@ -35,7 +33,7 @@ package ${_self.ada_api_settings.lib_name}.Analysis.Parsers is
|
||||
function Create_From_File
|
||||
(Filename, Charset : String;
|
||||
Read_BOM : Boolean;
|
||||
Unit : Analysis_Unit_Interface;
|
||||
Unit : Analysis_Unit;
|
||||
With_Trivia : Boolean := False) return Parser_type;
|
||||
-- Create a parser to parse the source in Filename, decoding it using
|
||||
-- Charset. The resulting tokens (and trivia if With_Trivia) are stored
|
||||
@@ -47,7 +45,7 @@ package ${_self.ada_api_settings.lib_name}.Analysis.Parsers is
|
||||
function Create_From_Buffer
|
||||
(Buffer, Charset : String;
|
||||
Read_BOM : Boolean;
|
||||
Unit : Analysis_Unit_Interface;
|
||||
Unit : Analysis_Unit;
|
||||
With_Trivia : Boolean := False) return Parser_type;
|
||||
-- Create a parser to parse the source in Buffer, decoding it using
|
||||
-- Charset. The resulting tokens (and trivia if With_Trivia) are stored
|
||||
|
||||
@@ -17,7 +17,7 @@ if ${parser_context.pos_var_name} /= No_Token_Index then
|
||||
## after this parser runs.
|
||||
## If they are equal then we know that this parser consumed no token. As a
|
||||
## result, the result must be a ghost node, i.e. with no token_end.
|
||||
${res}.Unit := Parser.Unit;
|
||||
${res}.Unit := Analysis_Unit_Interface (Parser.Unit);
|
||||
${res}.Token_Start := ${pos_name};
|
||||
${res}.Token_End := (if ${parser_context.pos_var_name} = ${pos_name}
|
||||
then No_Token_Index
|
||||
|
||||
@@ -350,8 +350,8 @@ package body ${_self.ada_api_settings.lib_name}.Analysis is
|
||||
(Unit : Analysis_Unit;
|
||||
Read_BOM : Boolean)
|
||||
return Parser_Type
|
||||
is (Create_From_File (Filename, To_String (Unit.Charset), Read_BOM,
|
||||
Analysis_Unit_Interface (Unit), With_Trivia));
|
||||
is (Create_From_File (Filename, To_String (Unit.Charset), Read_BOM, Unit,
|
||||
With_Trivia));
|
||||
begin
|
||||
return Get_Unit
|
||||
(Context, Filename, Charset, Reparse, Get_Parser'Access, With_Trivia,
|
||||
@@ -376,8 +376,8 @@ package body ${_self.ada_api_settings.lib_name}.Analysis is
|
||||
(Unit : Analysis_Unit;
|
||||
Read_BOM : Boolean)
|
||||
return Parser_Type
|
||||
is (Create_From_Buffer (Buffer, To_String (Unit.Charset), Read_BOM,
|
||||
Analysis_Unit_Interface (Unit), With_Trivia));
|
||||
is (Create_From_Buffer (Buffer, To_String (Unit.Charset), Read_BOM, Unit,
|
||||
With_Trivia));
|
||||
begin
|
||||
return Get_Unit (Context, Filename, Charset, True, Get_Parser'Access,
|
||||
With_Trivia, Rule);
|
||||
@@ -537,7 +537,7 @@ package body ${_self.ada_api_settings.lib_name}.Analysis is
|
||||
is (Create_From_File (To_String (Unit.File_Name),
|
||||
To_String (Unit.Charset),
|
||||
Read_BOM,
|
||||
Analysis_Unit_Interface (Unit)));
|
||||
Unit));
|
||||
begin
|
||||
Update_Charset (Unit, Charset);
|
||||
Do_Parsing (Unit, Charset'Length = 0, Get_Parser'Access);
|
||||
@@ -558,7 +558,7 @@ package body ${_self.ada_api_settings.lib_name}.Analysis is
|
||||
Read_BOM : Boolean)
|
||||
return Parser_Type
|
||||
is (Create_From_Buffer (Buffer, To_String (Unit.Charset), Read_BOM,
|
||||
Analysis_Unit_Interface (Unit)));
|
||||
Unit));
|
||||
begin
|
||||
Update_Charset (Unit, Charset);
|
||||
Do_Parsing (Unit, Charset'Length = 0, Get_Parser'Access);
|
||||
|
||||
Reference in New Issue
Block a user