changed to use the subpackaged rune symbols in the rune classification functions

This commit is contained in:
hyung-hwan 2021-11-02 00:31:30 +00:00
parent db230f8807
commit 84762f7682
3 changed files with 21 additions and 9 deletions

View File

@ -45,6 +45,9 @@ ada.text_io.put_line("");
null;
when TK_CSTR =>
null;
when TK_DIRECTIVE =>
--Push_Feed_Layer (...
null;
when TK_EOF =>
null;
when TK_EOL =>
@ -124,11 +127,11 @@ ada.text_io.put_line("");
procedure Feed_Char_Code (C: in out Compiler; Code: in R.Code) is
begin
<<Start_Over>>
if R.Is_Eof(Code) then
if R.Is_Eof(Code) then
ada.text_io.put_line ("EOF");
else
else
ada.text_io.put_line (R.To_Rune(Code)'Img);
end if;
end if;
case C.Lx.State is
when LX_START =>
if R.Is_Eof(Code) then
@ -150,10 +153,20 @@ ada.text_io.put_line("");
Set_Lexer_State (C, LX_OP_LESS, Code);
elsif R.Is_Rune(Code, R.V.Right_Arrow) then
Set_Lexer_State (C, LX_OP_GREATER, Code);
elsif R.Is_Rune(Code, R.V.Number_Sign) then
Set_Lexer_State (C, LX_DIRECTIVE);
else
raise Syntax_Error;
end if;
when LX_DIRECTIVE =>
if R.Is_Alnum(Code) or else R.Is_Rune(Code, R.V.Underline) then
Feed_Token (C, Code);
else
End_Token (C, TK_DIRECTIVE);
goto Start_Over;
end if;
when LX_OP_GREATER =>
if R.Is_Rune(Code, R.V.Equal_Sign) then
End_Token (C, TK_GE, Code);

View File

@ -18,6 +18,7 @@ private
type Lexer_State is (
LX_START,
LX_COMMENT,
LX_DIRECTIVE,
LX_IDENT,
LX_NUMBER,
LX_OP_GREATER,
@ -32,6 +33,7 @@ private
TK_BYTE,
TK_CHAR,
TK_CSTR,
TK_DIRECTIVE,
TK_EOF,
TK_EOL,
TK_IDENT,

View File

@ -5,9 +5,6 @@ package body H3.Runes is
package UC renames System.UTF_32;
use type System.UTF_32.Category;
SP: constant Rune := Rune'Val(32);
HT: constant Rune := Rune'Val(9);
function Is_Alpha (V: in Rune) return Boolean is
begin
return UC.Is_UTF_32_Letter(Rune'Pos(V));
@ -31,7 +28,7 @@ package body H3.Runes is
function Is_Blank (V: in Rune) return Boolean is
begin
return V = SP or else V = HT;
return V = Runes.V.Space or else V = Runes.V.HT;
end Is_Blank;
function Is_Blank (C: in Code) return Boolean is
@ -61,7 +58,7 @@ package body H3.Runes is
function Is_Graph (V: in Rune) return Boolean is
begin
return Is_Print(V) and then V /= SP;
return Is_Print(V) and then V /= Runes.V.Space;
end Is_Graph;
function Is_Graph (C: in Code) return Boolean is
@ -104,7 +101,7 @@ package body H3.Runes is
begin
return UC.Is_UTF_32_Space(Rune'Pos(V)) or else
UC.Is_UTF_32_Line_Terminator(Rune'Pos(V)) or else
V = HT;
V = Runes.V.HT;
end Is_Space;
function Is_Space (C: in Code) return Boolean is