From e5157250febdec53726f28fdcd186b5d0176cdef Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 3 Dec 2021 06:38:20 +0000 Subject: [PATCH] adding Parse_Data record definition --- lib2/h3-compilers.adb | 16 +++++++++++++--- lib2/h3-compilers.ads | 25 ++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib2/h3-compilers.adb b/lib2/h3-compilers.adb index 0073631..1558f18 100644 --- a/lib2/h3-compilers.adb +++ b/lib2/h3-compilers.adb @@ -185,16 +185,16 @@ package body H3.Compilers is end Pop_Inclusion; -- ------------------------------------------------------------------- + procedure Parse_Ident (C: in out Compiler) is begin if C.Tk.Buf.Equals(LB_CLASS) then - null; Push_Parse_State (C, PS_CLASS_1); elsif C.Tk.Buf.Equals(LB_FUN) then - null; + Push_Parse_State (C, PS_FUN_1); else -- probably a command name or a variable name? - null; + Push_Parse_State (C, PS_PLAIN_STATEMENT_START); end if; end Parse_Ident; @@ -208,6 +208,11 @@ package body H3.Compilers is null; end Parse_Class_2; + -- ------------------------------------------------------------------- + procedure Parse_Plain_Statement_Start (C: in out Compiler) is + begin + null; + end Parse_Plain_Statement_Start; -- ------------------------------------------------------------------- procedure Parse_Start (C: in out Compiler) is @@ -292,10 +297,15 @@ package body H3.Compilers is case C.Prs.States(C.Prs.Top).Current is when PS_START => Parse_Start (C); + when PS_INCLUDE_TARGET => Parse_Include_Target (C); when PS_INCLUDE_TERMINATOR => Parse_Include_Terminator (C); + + when PS_PLAIN_STATEMENT_START => + Parse_Plain_Statement_Start (C); + when others => raise Syntax_Error with "unknown parser state"; -- TODO: change this... end case; diff --git a/lib2/h3-compilers.ads b/lib2/h3-compilers.ads index 2281aff..44dc65e 100644 --- a/lib2/h3-compilers.ads +++ b/lib2/h3-compilers.ads @@ -94,11 +94,34 @@ private PS_INCLUDE_TERMINATOR, PS_CLASS_1, - PS_CLASS_2 + PS_CLASS_2, + + PS_FUN_1, + PS_FUN_2, + + PS_PLAIN_STATEMENT_START ); + type Parse_Data_Code is ( + PD_VOID, + PD_STATEMENT, + PD_ASSIGNMENT + ); + + type Parse_Data(Code: Parse_Data_Code := PD_VOID) is record + case Code is + when PD_VOID => + null; + when PD_STATEMENT => + Cmd_Name: S.Elastic_String; + when PD_ASSIGNMENT => + Var_Name: S.Elastic_String; + end case; + end record; + type Parse_State is record Current: Parse_State_Code := PS_START; + Data: Parse_Data; end record; type Parse_State_Array is array(System_Index range<>) of Parse_State;