summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example/ssss.adb67
-rw-r--r--examples.gpr7
2 files changed, 71 insertions, 3 deletions
diff --git a/example/ssss.adb b/example/ssss.adb
new file mode 100644
index 0000000..56f980d
--- /dev/null
+++ b/example/ssss.adb
@@ -0,0 +1,67 @@
+
+
+with
+
+ Ada.Text_IO,
+ Packrat.No_Lex,
+ Packrat.Utilities;
+
+use
+
+ Ada.Text_IO;
+
+
+procedure Ssss is
+
+
+ Input : String := "xxxx";
+
+ type Parser_Labels is (S);
+
+ package My_Rat is new Packrat.No_Lex (Parser_Labels, Character, String);
+
+
+
+
+ package S_Redir is new My_Rat.Parsers.Redirect;
+
+ function Match_X is new My_Rat.Parsers.Match ('x');
+ function S_Seq is new My_Rat.Parsers.Sequence
+ ((Match_X'Access, S_Redir.Call'Access, S_Redir.Call'Access));
+ function S_Choice is new My_Rat.Parsers.Choice
+ ((S_Seq'Access, My_Rat.Parsers.Empty'Access));
+ function S is new My_Rat.Parsers.Stamp (S, S_Choice);
+
+ package Parser is new My_Rat.Parsers.Parse_Once (S);
+
+
+
+
+ Result_Graph : My_Rat.Parser_Result;
+
+
+begin
+
+
+ S_Redir.Set (S'Access);
+
+ Result_Graph := Parser.Parse (Input);
+
+
+ Put_Line ("Input:");
+ Put_Line (Input);
+ New_Line;
+
+ Put_Line ("Parser graph output:");
+ Put_Line (My_Rat.Parse_Graphs.Debug_String (Result_Graph));
+ New_Line;
+
+ Put_Line ("Root tokens:");
+ for T of Result_Graph.Root_Elements loop
+ Put (My_Rat.Parser_Tokens.Debug_String (T));
+ end loop;
+
+
+end Ssss;
+
+
diff --git a/examples.gpr b/examples.gpr
index 1921d31..9e1d531 100644
--- a/examples.gpr
+++ b/examples.gpr
@@ -12,16 +12,17 @@ project Examples is
for Source_Dirs use ("example/**");
for Object_Dir use "obj";
for Exec_Dir use "bin";
- for Main use ("sentence.adb");
+ for Main use ("sentence.adb", "ssss.adb");
package Builder is
- for Executable("sentence.adb") use "sentence";
+ for Executable ("sentence.adb") use "sentence";
+ for Executable ("ssss.adb") use "ssss";
end Builder;
package Compiler is
- for Default_Switches("Ada") use ("-gnaty4aAbcefhiklM100nprt");
+ for Default_Switches ("Ada") use ("-gnaty4aAbcefhiklM100nprt");
end Compiler;