From c14c9033174662706ae7283b91a9a42390291ef2 Mon Sep 17 00:00:00 2001 From: Randy Brukardt Date: Thu, 5 Jan 2023 05:50:30 -0500 Subject: [PATCH] Updates (and new commands) for FDIS/Draft 35 of Ada 2022. --- progs/arm_frm.adb | 194 ++++++++++++++++++++++++++++++++++++++++++--- progs/arm_frmd.adb | 9 +++ progs/arm_frmd.ads | 6 +- progs/arm_rtf.adb | 10 +-- progs/command.txt | 21 ++++- 5 files changed, 223 insertions(+), 17 deletions(-) diff --git a/progs/arm_frm.adb b/progs/arm_frm.adb index 863b74bd..079528a3 100644 --- a/progs/arm_frm.adb +++ b/progs/arm_frm.adb @@ -313,6 +313,9 @@ package body ARM_Format is -- 8/22/22 - RLB - Added AllFormats parameter to URL_Link. -- - Added Nonterminal_Font. -- 9/15/22 - RLB - Added Examples_Format, renamed Group_Format_Kind. + -- 11/11/22 - RLB - Added ISO_Diff. + -- 12/20/22 - RLB - Added RefSecFullNum. + type Command_Kind_Type is (Normal, Begin_Word, Parameter); @@ -7998,7 +8001,8 @@ Ada.Text_IO.Put_Line ("** Unimplemented disposition on line " & ARM_Input.Line_S Format_Object.In_Paragraph := True; Format_Object.No_Start_Paragraph := False; - when Ref_Section | Ref_Section_Number => + when Ref_Section | Ref_Section_Full | + Ref_Section_Number | Ref_Section_Full_Number => -- Load the title into the Title string: declare Ch : Character; @@ -8020,8 +8024,39 @@ Ada.Text_IO.Put_Line ("** Unimplemented disposition on line " & ARM_Input.Line_S Clause_Number_Text : constant String := ARM_Contents.Lookup_Clause_Number (Title); begin - if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section then + if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section or else + Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section_Full then Check_Paragraph; + if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section_Full then + -- Add the prefix: + case ARM_Contents.Lookup_Level (Title) is + -- Determine the prefix needed, if any. + when ARM_Contents.Section => + case Format_Object.Top_Level_Subdivision_Name is + when ARM_Output.Chapter => + ARM_Output.Ordinary_Text (Output_Object, "Chapter "); + when ARM_Output.Section => + ARM_Output.Ordinary_Text (Output_Object, "Section "); + when ARM_Output.Clause => + ARM_Output.Ordinary_Text (Output_Object, "Clause "); + end case; + + when ARM_Contents.Plain_Annex | + ARM_Contents.Normative_Annex | + ARM_Contents.Informative_Annex => + -- For some odd reason, "Annex" is already included with these references. + null; -- ARM_Output.Ordinary_Text (Output_Object, "Annex "); + + when ARM_Contents.Clause | ARM_Contents.Subclause | + ARM_Contents.Subsubclause => + null; -- No prefix needed. + + when ARM_Contents.Unnumbered_Section | ARM_Contents.Dead_Clause => + Ada.Text_IO.Put_Line ("** Cannot make a numbered section reference for this kind os section, line " & ARM_Input.Line_String (Input_Object)); + Ada.Text_IO.Put_Line (" Looking for " & Title(1..Title_Length)); + end case; + -- else nothing extra needed. + end if; ARM_Output.Clause_Reference (Output_Object, Text => Clause_Number_Text, Clause_Number => Clause_Number_Text); @@ -8056,6 +8091,37 @@ Ada.Text_IO.Put_Line ("** Unimplemented disposition on line " & ARM_Input.Line_S --ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Quote); --ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Quote); ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Double_Quote); + elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section_Full_Number then + Check_Paragraph; + case ARM_Contents.Lookup_Level (Title) is + -- Determine the prefix needed, if any. + when ARM_Contents.Section => + case Format_Object.Top_Level_Subdivision_Name is + when ARM_Output.Chapter => + ARM_Output.Ordinary_Text (Output_Object, "Chapter "); + when ARM_Output.Section => + ARM_Output.Ordinary_Text (Output_Object, "Section "); + when ARM_Output.Clause => + ARM_Output.Ordinary_Text (Output_Object, "Clause "); + end case; + + when ARM_Contents.Plain_Annex | + ARM_Contents.Normative_Annex | + ARM_Contents.Informative_Annex => + -- For some odd reason, "Annex" is already included with these references. + null; -- ARM_Output.Ordinary_Text (Output_Object, "Annex "); + + when ARM_Contents.Clause | ARM_Contents.Subclause | + ARM_Contents.Subsubclause => + null; -- No prefix needed. + + when ARM_Contents.Unnumbered_Section | ARM_Contents.Dead_Clause => + Ada.Text_IO.Put_Line ("** Cannot make a numbered section reference for this kind os section, line " & ARM_Input.Line_String (Input_Object)); + Ada.Text_IO.Put_Line (" Looking for " & Title(1..Title_Length)); + end case; + ARM_Output.Clause_Reference (Output_Object, + Text => Clause_Number_Text, + Clause_Number => Clause_Number_Text); else -- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section_Number then Check_Paragraph; ARM_Output.Clause_Reference (Output_Object, @@ -8330,6 +8396,60 @@ Ada.Text_IO.Put_Line ("** Unimplemented disposition on line " & ARM_Input.Line_S -- Leave the command end marker, let normal processing -- get rid of it. + when ISO_Diff => + -- @ISODiff{NotISO=[],ISOOnly=[]} + -- Use the appropriate text depending on the ISO show state. + declare + Close_Ch : Character; + NText : String(1..200); + NText_Len : Natural; + IText : String(1..200); + IText_Len : Natural; + begin + ARM_Input.Check_Parameter_Name (Input_Object, + Param_Name => "NotISO" & (7..ARM_Input.Command_Name_Type'Last => ' '), + Is_First => True, + Param_Close_Bracket => Close_Ch); + if Close_Ch /= ' ' then + -- Save AI: + ARM_Input.Copy_to_String_until_Close_Char ( + Input_Object, + Close_Ch, + NText, + NText_Len); + -- else no parameter. An error message has already been produced. + end if; + + ARM_Input.Check_Parameter_Name (Input_Object, + Param_Name => "ISOOnly" & (8..ARM_Input.Command_Name_Type'Last => ' '), + Is_First => False, + Param_Close_Bracket => Close_Ch); + if Close_Ch /= ' ' then + -- Save name: + ARM_Input.Copy_to_String_until_Close_Char ( + Input_Object, + Close_Ch, + IText, + IText_Len); + -- else no parameter. An error message has already been produced. + end if; + + Check_Paragraph; + if Format_Object.Include_ISO then -- @ShowISO + Format_Text (IText(1..IText_Len), Text_Name => "ISO_Only"); + if IText_Len /= 0 and then IText(IText_Len) /= ' ' then + Format_Object.Last_Non_Space := True; + end if; + else -- @HideISO + Format_Text (NText(1..NText_Len), Text_Name => "Not_ISO"); + if NText_Len /= 0 and then NText(NText_Len) /= ' ' then + Format_Object.Last_Non_Space := True; + end if; + end if; + end; + -- Leave the command end marker, let normal processing + -- get rid of it. + -- Change commands: when Change => @@ -9766,9 +9886,12 @@ Ada.Text_IO.Put_Line ("-- Report Term list for Group" & Group'Image & " on line Unnumbered_Section | Subheading | Added_Subheading | Deleted_Subheading | Heading | Center | Right | - Preface_Section | Ref_Section | Ref_Section_Number | Ref_Section_by_Number | + Preface_Section | Ref_Section | Ref_Section_Full | + Ref_Section_Number | Ref_Section_Full_Number | + Ref_Section_by_Number | Local_Target | Local_Link | URL_Link | AI_Link | - Change | Change_Reference | Change_Note | + ISO_Diff | + Change | Change_Reference | Change_Note | Change_Added | Change_Deleted | Change_Implementation_Defined | Change_Implementation_Advice | @@ -10255,7 +10378,22 @@ Ada.Text_IO.Put_Line ("-- Report Term list for Group" & Group'Image & " on line Format_Object.Impdef_Info.Paragraph_String (1..Format_Object.Impdef_Info.Paragraph_Len) & ")."; else -- No paragraph numbers. - return " See @RefSecbyNum{" & DB_Clause_String & "}."; + if Format_Object.Clause_Number.Clause = 0 then -- Plain section/annex: + if ARM_Contents.">=" (Format_Object.Clause_Number.Section, ARM_Contents.ANNEX_START) then + return " See Annex @RefSecbyNum{" & DB_Clause_String & "}."; + else + case Format_Object.Top_Level_Subdivision_Name is + when ARM_Output.Chapter => + return " See Chapter @RefSecbyNum{" & DB_Clause_String & "}."; + when ARM_Output.Section => + return " See Section @RefSecbyNum{" & DB_Clause_String & "}."; + when ARM_Output.Clause => + return " See Clause @RefSecbyNum{" & DB_Clause_String & "}."; + end case; + end if; + else + return " See @RefSecbyNum{" & DB_Clause_String & "}."; + end if; end if; when ARM_Database.Inserted | ARM_Database.Inserted_Normal_Number => if Format_Object.Number_Paragraphs and then @@ -10265,8 +10403,27 @@ Ada.Text_IO.Put_Line ("-- Report Term list for Group" & Group'Image & " on line Format_Object.Impdef_Info.Paragraph_String (1..Format_Object.Impdef_Info.Paragraph_Len) & ").],Old=[]}"; else -- No paragraph numbers. - return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & - "], New=[ See @RefSecbyNum{" & DB_Clause_String & "}.],Old=[]}"; + if Format_Object.Clause_Number.Clause = 0 then -- Plain section/annex: + if ARM_Contents.">=" (Format_Object.Clause_Number.Section, ARM_Contents.ANNEX_START) then + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[ See Annex @RefSecbyNum{" & DB_Clause_String & "}.],Old=[]}"; + else + case Format_Object.Top_Level_Subdivision_Name is + when ARM_Output.Chapter => + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[ See Chapter @RefSecbyNum{" & DB_Clause_String & "}.],Old=[]}"; + when ARM_Output.Section => + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[ See Section @RefSecbyNum{" & DB_Clause_String & "}.],Old=[]}"; + when ARM_Output.Clause => + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[ See Clause @RefSecbyNum{" & DB_Clause_String & "}.],Old=[]}"; + end case; + end if; + else + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[ See @RefSecbyNum{" & DB_Clause_String & "}.],Old=[]}"; + end if; end if; when ARM_Database.Deleted | ARM_Database.Deleted_Inserted_Number | @@ -10279,8 +10436,27 @@ Ada.Text_IO.Put_Line ("-- Report Term list for Group" & Group'Image & " on line Format_Object.Impdef_Info.Paragraph_String (1..Format_Object.Impdef_Info.Paragraph_Len) & ").]}"; else -- No paragraph numbers. - return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & - "], New=[],Old=[ See @RefSecbyNum{" & DB_Clause_String & "}.]}"; + if Format_Object.Clause_Number.Clause = 0 then -- Plain section/annex: + if ARM_Contents.">=" (Format_Object.Clause_Number.Section, ARM_Contents.ANNEX_START) then + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[],Old=[ See Annex @RefSecbyNum{" & DB_Clause_String & "}.]}"; + else + case Format_Object.Top_Level_Subdivision_Name is + when ARM_Output.Chapter => + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[],Old=[ See Chapter @RefSecbyNum{" & DB_Clause_String & "}.]}"; + when ARM_Output.Section => + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[],Old=[ See Section @RefSecbyNum{" & DB_Clause_String & "}.]}"; + when ARM_Output.Clause => + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[],Old=[ See Clause @RefSecbyNum{" & DB_Clause_String & "}.]}"; + end case; + end if; + else + return "@Chg{Version=[" & Format_Object.Impdef_Info.Version & + "], New=[],Old=[ See @RefSecbyNum{" & DB_Clause_String & "}.]}"; + end if; end if; end case; end See_String; diff --git a/progs/arm_frmd.adb b/progs/arm_frmd.adb index 74e6e669..896892cb 100644 --- a/progs/arm_frmd.adb +++ b/progs/arm_frmd.adb @@ -51,6 +51,9 @@ package body ARM_Format.Data is -- 5/ 8/22 - RLB - Added Deleted_Subheading. -- 5/11/22 - RLB - Added LabeledRevisedSubClauseIsoClause. -- 5/25/22 - RLB - Added ChgTermDef and AddedTermList. + -- 9/15/22 - RLB - Added NewExample. + -- 11/11/22 - RLB - Added ISODiff. + -- 12/20/22 - RLB - Added RefSecFullNum. function Command (Name : in ARM_Input.Command_Name_Type) return Command_Type is @@ -352,8 +355,12 @@ package body ARM_Format.Data is return Preface_Section; elsif Canonical_Name = "refsec" then return Ref_Section; + elsif Canonical_Name = "refsecfull" then + return Ref_Section_Full; elsif Canonical_Name = "refsecnum" then return Ref_Section_Number; + elsif Canonical_Name = "refsecfullnum" then + return Ref_Section_Full_Number; elsif Canonical_Name = "refsecbynum" then return Ref_Section_By_Number; elsif Canonical_Name = "locallink" then @@ -364,6 +371,8 @@ package body ARM_Format.Data is return URL_Link; elsif Canonical_Name = "ailink" then return AI_Link; + elsif Canonical_Name = "isodiff" then + return ISO_Diff; elsif Canonical_Name = "chg" then return Change; elsif Canonical_Name = "chgadded" then diff --git a/progs/arm_frmd.ads b/progs/arm_frmd.ads index d8b69ea9..6ab9adb6 100644 --- a/progs/arm_frmd.ads +++ b/progs/arm_frmd.ads @@ -52,6 +52,8 @@ private package ARM_Format.Data is -- 5/11/22 - RLB - Added LabeledRevisedSubClauseIsoClause. -- 5/26/22 - RLB - Added ChgTermDef, AddedTermList, and Subnumber. -- 9/15/22 - RLB - Added NewExample. + -- 11/11/22 - RLB - Added ISODiff. + -- 12/20/22 - RLB - Added RefSecFullNum. type Command_Type is ( -- Paragraphs: @@ -94,7 +96,8 @@ private package ARM_Format.Data is Unnumbered_Section, Subheading, Heading, Center, Right, Added_Subheading, Deleted_Subheading, -- Clause references: - Ref_Section, Ref_Section_Number, Ref_Section_by_Number, + Ref_Section, Ref_Section_Full, + Ref_Section_Number, Ref_Section_Full_Number, Ref_Section_by_Number, -- Links: Local_Target, Local_Link, URL_Link, AI_Link, -- Information: @@ -112,6 +115,7 @@ private package ARM_Format.Data is Pragma_Syntax, Pragma_List, Added_Pragma_Syntax, Deleted_Pragma_Syntax, Package_List, Type_List, Subprogram_List, Exception_List, Object_List, -- Corrigendum changes: + ISO_Diff, Change, Change_Param_Old, Change_Param_New, -- The latter are the parameters of "Change". Change_Reference, Change_Note, Change_Added, Change_Added_Param, Change_Deleted, Change_Deleted_Param, diff --git a/progs/arm_rtf.adb b/progs/arm_rtf.adb index 4894221a..806b2745 100644 --- a/progs/arm_rtf.adb +++ b/progs/arm_rtf.adb @@ -3068,7 +3068,7 @@ package body ARM_RTF is Style_Justified => FALSE, Style_String_Prefix => "\s8\widctlpar\adjustright", - Style_String_Suffix => "\cgrid\ql\sl-200\slmult0 \snext8 "); + Style_String_Suffix => "\cgrid\ql\sl-210\slmult0 \snext8 "); Set_Style (Paragraph_Info(ARM_Output.Small_Examples, 3), Font => ARM_Output.Fixed, Body_Font => Output_Object.Body_Font, @@ -3289,7 +3289,7 @@ package body ARM_RTF is Style_Justified => FALSE, Style_String_Prefix => "\s26\widctlpar\adjustright", - Style_String_Suffix => "\cgrid\ql\sl-200\slmult0 \snext26 "); + Style_String_Suffix => "\cgrid\ql\sl-210\slmult0 \snext26 "); Set_Style (Paragraph_Info(ARM_Output.Small_Examples, 6), -- Indented examples in annotations. Font => ARM_Output.Fixed, Body_Font => Output_Object.Body_Font, @@ -3653,7 +3653,7 @@ package body ARM_RTF is Style_Justified => FALSE, Style_String_Prefix => "\s57\widctlpar\adjustright", - Style_String_Suffix => "\cgrid\ql\sl-200\slmult0 \snext57 "); + Style_String_Suffix => "\cgrid\ql\sl-210\slmult0 \snext57 "); Set_Style (Paragraph_Info(ARM_Output.Small_Examples, 4), -- Syntax Indented examples in annotations. Font => ARM_Output.Fixed, Body_Font => Output_Object.Body_Font, @@ -3697,7 +3697,7 @@ package body ARM_RTF is Style_Justified => FALSE, Style_String_Prefix => "\s61\widctlpar\adjustright", - Style_String_Suffix => "\cgrid\ql\sl-200\slmult0 \snext61 "); + Style_String_Suffix => "\cgrid\ql\sl-210\slmult0 \snext61 "); Set_Style (Paragraph_Info(ARM_Output.Small_Examples, 5), -- Code Indented examples in annotations. Font => ARM_Output.Fixed, Body_Font => Output_Object.Body_Font, @@ -3982,7 +3982,7 @@ package body ARM_RTF is Style_Justified => FALSE, Style_String_Prefix => "\s84\widctlpar\adjustright", - Style_String_Suffix => "\cgrid\ql\sl-200\slmult0 \snext84 "); + Style_String_Suffix => "\cgrid\ql\sl-210\slmult0 \snext84 "); Set_Style (Paragraph_Info(ARM_Output.Small_Examples, 7), -- Child Indented examples in annotations. Font => ARM_Output.Fixed, Body_Font => Output_Object.Body_Font, diff --git a/progs/command.txt b/progs/command.txt index 851e9fd0..52b2415f 100644 --- a/progs/command.txt +++ b/progs/command.txt @@ -697,10 +697,22 @@ Text commands: @RefSec{} - Generates a reference to the clause "title". (This must match exactly except for case). The reference is of the form "<clause number>, ``<title>''". (The ARG has directed that this be - changed to '<clause number>, "<title>"'). + changed to '<clause number>, "<title>"'). For historical reasons, + "Annex" is included with top-level references, but not "Clause". + (No idea why this is.) +@RefSecFull{<title>} - Generates a reference to the clause "title". (This must + match exactly except for case). The reference is of the form + '<clause number>, "<title>"'. If this is a top-level reference, it is + also prefixed with the subdivision name ("Clause", "Annex", etc.) + Note that the subdivision names are set by the @SubdivisionNames master + command. @RefSecNum{<title>} - Generates a reference to the clause "title". (This must match exactly except for case). The reference is of the form "<clause number>". +@RefSecFullNum{<title>} - Generates a reference to the clause "title". (This must + match exactly except for case). The reference is of the form + "<clause number>", unless this is a top-level reference, in which + case it is "<subdivision_name> <clause number>". @RefSecbyNum{<num>} - Generates a reference to the clause with <num> as a clause number. This is intended to be used internally to the tool, not in document source (the tool assigns the clause numbers). @@ -1010,6 +1022,10 @@ italized in curly brackets. RootDefn adds "[distributed]", PDefn adds paragraph properties; they work as described in ChgAdded. Note that they're conditional on the paragraph text being included in the document (even if it is marked as deleted). +@ISODiff{NotISO=[text],ISOOnly=[text]} + Specifies a difference in text between ISO and non-ISO versions. + NotISO text is used if @HideISO was specified in the master file, + and ISOOnly text is used if @ShowISO was specified. @ChgAttribute{Version=[<version>],Kind=(<kind>),ChginAnnex=[T|F], Leading=[T|F],Prefix=<Prefix>,AttrName=<Name>, @@ -1512,7 +1528,8 @@ version used by most users. The master file ISO-RM.MSM specifies Ada Reference Manual in ISO format. This version lacks some sections, paragraph numbers, and is formatted for A4 paper. Note that the Ada 2022 is reorganized and has completely different -clause numbers, and uses different fonts for some commands as well. +clause numbers, and uses different fonts for some commands as well. This +has its own master file, ISO-FDIS.MSM. Versions: 0-Original Ada 95 (equivalent to No-Changes)