From 84762f76827a439e2c8b381f52c346746509db26 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 2 Nov 2021 00:31:30 +0000 Subject: [PATCH] changed to use the subpackaged rune symbols in the rune classification functions --- lib2/h3-compilers.adb | 19 ++++++++++++++++--- lib2/h3-compilers.ads | 2 ++ lib2/h3-runes.adb | 9 +++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib2/h3-compilers.adb b/lib2/h3-compilers.adb index cde0c12..87d263e 100644 --- a/lib2/h3-compilers.adb +++ b/lib2/h3-compilers.adb @@ -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 <> - 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); diff --git a/lib2/h3-compilers.ads b/lib2/h3-compilers.ads index f349352..5da7dc2 100644 --- a/lib2/h3-compilers.ads +++ b/lib2/h3-compilers.ads @@ -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, diff --git a/lib2/h3-runes.adb b/lib2/h3-runes.adb index 53d6b1c..6843e41 100644 --- a/lib2/h3-runes.adb +++ b/lib2/h3-runes.adb @@ -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