diff options
author | Jed Barber <jjbarber@y7mail.com> | 2020-11-07 01:21:54 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2020-11-07 01:21:54 +1100 |
commit | 8828e68cb86c865d625961c07c7ce2eb4ae191bc (patch) | |
tree | a90555326581688a32cf38fef15d0893e3df1f3d /test | |
parent | 731e861f233ab90078c00b3dad5ace4eaed45e95 (diff) |
Parse_Graphs complete aside from isomorphism and testing
Diffstat (limited to 'test')
-rw-r--r-- | test/rat_tests-lexer.adb | 4 | ||||
-rw-r--r-- | test/rat_tests-parse_graphs.adb | 126 | ||||
-rw-r--r-- | test/rat_tests-parse_graphs.ads | 27 |
3 files changed, 155 insertions, 2 deletions
diff --git a/test/rat_tests-lexer.adb b/test/rat_tests-lexer.adb index 702de18..484c86b 100644 --- a/test/rat_tests-lexer.adb +++ b/test/rat_tests-lexer.adb @@ -16,7 +16,7 @@ package body Rat_Tests.Lexer is package String_Tokens is new Packrat.Tokens (My_Labels, Character, String); - package Slexy is new Packrat.Lexer (My_Labels, Character, String, String_Tokens); + package Slexy is new Packrat.Lexer (My_Labels, Character, String, "<", String_Tokens); package Slebug is new Slexy.Debug; @@ -649,7 +649,7 @@ package body Rat_Tests.Lexer is type Word_Enum is (Blank, Word, Whitespace); package Word_Tokens is new Packrat.Tokens (Word_Enum, Character, String); - package Swordy is new Packrat.Lexer (Word_Enum, Character, String, Word_Tokens); + package Swordy is new Packrat.Lexer (Word_Enum, Character, String, "<", Word_Tokens); package Swolbug is new Swordy.Debug; use type Word_Tokens.Token; diff --git a/test/rat_tests-parse_graphs.adb b/test/rat_tests-parse_graphs.adb new file mode 100644 index 0000000..074bc27 --- /dev/null +++ b/test/rat_tests-parse_graphs.adb @@ -0,0 +1,126 @@ + + +with Packrat.Parse_Graphs; + + +package body Rat_Tests.Parse_Graphs is + + + type My_Labels is + (Noun, Determiner, Noun_Phrase, Preposition, + Prepositional_Phrase, Verb, Verb_Phrase, Sentence); + + package String_Tokens is new Packrat.Tokens (My_Labels, Character, String); + package Graphs is new Packrat.Parse_Graphs (My_Labels, Character, String, String_Tokens); + + Paper_Nodes : Graphs.Node_Array := + (1, -- Noun at position 1, value "i" + 2, -- Noun at position 4, value "man" + 3, -- Noun at position 7, value "park" + 4, -- Noun at position 10, value "bat" + 5, -- Determiner at position 3, value "a" + 6, -- Determiner at position 6, value "the" + 7, -- Determiner at position 9, value "a" + 8, -- Noun_Phrase at position 1 + 9, -- Noun_Phrase at position 3 + 10, -- Noun_Phrase at position 6 + 11, -- Noun_Phrase at position 9 + 12, -- Preposition at position 5, value "in" + 13, -- Preposition at position 8, value "with" + 14, -- Prepositional_Phrase at position 5 + 15, -- Prepositional_Phrase at position 8 + 16, -- Verb at position 2, value "saw" + 17, -- Verb_Phrase at position 2 + 18); -- Sentence at position 1 + + + + -- Cursors in Directed Graph library should be tagged + -- This will allow creation of an extended Cursor type in Parse Graphs + -- Edge labels need to contain group, finish, order, and restrict + -- The extended Cursor type should take the restrict into account with its functions + + -- There should be a validity checking function for Parse Graphs + -- There should also be a pretty print debug function for Parse Graphs + + + + Paper_Edges : Graphs.Edge_Array := + ((1, 8, 1) -- Finish 2, Order 1 + (2, 9, 5) -- Finish 5, Order 1 + (3, 9, 2); -- Finish 5, Order 2 + + Paper_Graph : Graphs.Parse_Graph := Graphs.To_Graph (Amb_Nodes, Amb_Edges, 18); + + + function Root_Check + return Test_Result + is + begin + end Root_Check; + + + function Finish_List_Check + return Test_Result + is + begin + end Finish_List_Check; + + + function Sub_Nodes_Check + return Test_Result + is + begin + end Sub_Nodes_Check; + + + function Prune_Check + return Test_Result + is + begin + end Prune_Check; + + + function Ambiguous_Check + return Test_Result + is + begin + end Ambiguous_Check; + + +begin + + -- Node labels + Paper_Graph.Append_Label (1, String_Tokens.Create (Noun, 1, "i")); + Paper_Graph.Append_Label (2, String_Tokens.Create (Noun, 4, "man")); + Paper_Graph.Append_Label (3, String_Tokens.Create (Noun, 7, "park")); + Paper_Graph.Append_Label (4, String_Tokens.Create (Noun, 10, "bat")); + + Paper_Graph.Append_Label (5, String_Tokens.Create (Determiner, 3, "a")); + Paper_Graph.Append_Label (6, String_Tokens.Create (Determiner, 6, "the")); + Paper_Graph.Append_Label (7, String_Tokens.Create (Determiner, 9, "a")); + + Paper_Graph.Append_Label (8, String_Tokens.Create (Noun_Phrase, 1, "")); + Paper_Graph.Append_Label (9, String_Tokens.Create (Noun_Phrase, 3, "")); + Paper_Graph.Append_Label (10, String_Tokens.Create (Noun_Phrase, 6, "")); + Paper_Graph.Append_Label (11, String_Tokens.Create (Noun_Phrase, 9, "")); + + Paper_Graph.Append_Label (12, String_Tokens.Create (Preposition, 5, "in")); + Paper_Graph.Append_Label (13, String_Tokens.Create (Preposition, 8, "with")); + + Paper_Graph.Append_Label (14, String_Tokens.Create (Prepositional_Phrase, 5, "")); + Paper_Graph.Append_Label (15, String_Tokens.Create (Prepositional_Phrase, 8, "")); + + Paper_Graph.Append_Label (16, String_Tokens.Create (Verb, 2, "saw")); + + Paper_Graph.Append_Label (17, String_Tokens.Create (Verb_Phrase, 2, "")); + + Paper_Graph.Append_Label (18, String_Tokens.Create (Sentence, 1, "")); + + + -- Edge labels + + +end Rat_Tests.Parse_Graphs; + + diff --git a/test/rat_tests-parse_graphs.ads b/test/rat_tests-parse_graphs.ads new file mode 100644 index 0000000..bec4853 --- /dev/null +++ b/test/rat_tests-parse_graphs.ads @@ -0,0 +1,27 @@ + + +with Unit_Tests; +use Unit_Tests; + + +package Rat_Tests.Parse_Graphs is + + + function Root_Check return Test_Result; + function Finish_List_Check return Test_Result; + function Sub_Nodes_Check return Test_Result; + function Prune_Check return Test_Result; + function Ambiguous_Check return Test_Result; + + + Tests : Test_Array := + ((+"Root getter, setter", Root_Check'Access), + (+"Finish_List", Finish_List_Check'Access), + (+"Sub_Nodes", Sub_Nodes_Check'Access), + (+"Prune", Prune_Check'Access), + (+"Is_Ambiguous", Ambiguous_Check'Access)); + + +end Rat_Tests.Parse_Graphs; + + |