diff options
Diffstat (limited to 'test/rat_tests-parse_graphs.adb')
-rw-r--r-- | test/rat_tests-parse_graphs.adb | 126 |
1 files changed, 126 insertions, 0 deletions
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; + + |