Package: opentoken
Version: 4.0b
The Column function is off by 1 for all lines other than the first.
The following small program tests the output of the Ada_Lexer package:
with Ada.Text_IO; use Ada.Text_IO;
with Ada_Lexer; use Ada_Lexer;
with Ada.Command_Line; use Ada.Command_Line;
procedure Parse is
F : File_Type;
begin
Ada.Text_IO.Open (F, In_File, Ada.Command_Line.Argument (1));
Set_Input_Feeder(F);
Set_Comments_Reportable(True);
loop
Find_Next;
exit when Token_ID = End_Of_File_T;
Put_Line ("Found token: " & Ada_Token'Image(Token_ID) &
" line=" & integer'image(Line) &
" column=" & integer'image(Column) &
" lexeme=" & Lexeme);
end loop;
end Parse;
When run on a file containing this text:
with Ada.Text_IO;
use Ada.Text_IO;
procedure Hello is
begin
Put_Line ("Hello");
end Hello;
the first part of the output looks like:
Found token: WITH_T line= 1 column= 1 lexeme=with
Found token: IDENTIFIER_T line= 1 column= 6 lexeme=Ada
Found token: DOT_T line= 1 column= 9 lexeme=.
Found token: IDENTIFIER_T line= 1 column= 10 lexeme=Text_IO
Found token: SEMICOLON_T line= 1 column= 17 lexeme=;
Found token: USE_T line= 2 column= 2 lexeme=use
Found token: IDENTIFIER_T line= 2 column= 6 lexeme=Ada
Found token: DOT_T line= 2 column= 9 lexeme=.
Found token: IDENTIFIER_T line= 2 column= 10 lexeme=Text_IO
Found token: SEMICOLON_T line= 2 column= 17 lexeme=;
Found token: PROCEDURE_T line= 3 column= 2 lexeme=procedure
Note that on line 2 (of the "hello" program), Ada_Lexer says the
column number of "use" is 2 (should be 1), of "Ada" is 6 (should be
5), and so on.
The problem is that Opentoken.Token.Enumerated.Analyzer.-
Characters_After_Last_EOL does not compute its result correctly if
Slice_Tail >= Analyzer.Buffer_Head.
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]