adayaml_0.3.0_ab19e387/Parser_Tools/src/unicode/implementation/lexer-base-unicode.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
--  part of ParserTools, (c) 2017 Felix Krause
--  released under the terms of the MIT license, see the file "copying.txt"

with Ada.IO_Exceptions;

package body Lexer.Base.Unicode is
   function Next (Object : in out Instance'Class) return Rune is
   begin
      if Object.Buffer (Object.Pos) = Character'Val (4) then
         return End_Of_Input;
      end if;
      return Ret : Rune do
         Strings_Edit.UTF8.Get (Object.Buffer.all, Object.Pos, Ret);
      end return;
   exception
      when Ada.IO_Exceptions.Data_Error =>
         raise Lexer_Error with "Illegal content in UTF-8 source";
   end Next;
end Lexer.Base.Unicode;