]> www.ljiriste.work Git - KyciFTA/commitdiff
Create some structures for parsing parsing
authorLukáš Jiřiště <redacted>
Sat, 25 Jul 2026 04:29:09 +0000 (06:29 +0200)
committerLukáš Jiřiště <redacted>
Sat, 25 Jul 2026 04:29:09 +0000 (06:29 +0200)
I am not yet sure about how to approach the parsing entirely, the
structure may prove to be quite useless.

src/main.c
src/parsing.c [new file with mode: 0644]

index 8b72e33a2acb80963df521cbf12aeb83d9b776ba..8cfe01c5fa5b0e1aae763c87d3a11c3aecb97334 100644 (file)
@@ -20,6 +20,7 @@ int   main(int argc, char **argv)
                ft_printf("An error has occured.\n");
                return (1);
        }
+       //parse_into_logic(parse_tree);
        ft_parse_tree_print(parse_tree);
        ft_parse_tree_free(parse_tree);
        return (0);
diff --git a/src/parsing.c b/src/parsing.c
new file mode 100644 (file)
index 0000000..530cd65
--- /dev/null
@@ -0,0 +1,53 @@
+#include "libft.h"
+
+typedef double (*probability_function)(double time);
+
+typedef struct s_atom
+{
+       int                                             state;
+       char                                    *name;
+       double                                  failure_probability;
+       probability_function    func;
+}                                                      t_atom;
+
+typedef enum e_gate_type
+{
+       and_gate,
+       or_gate,
+       nook_gate,
+}      t_gate_type;
+
+typedef struct s_gate
+{
+       int                     state;
+       int                     n;      // for NooK gate
+       int                     k;      // for NooK gate
+       t_gate_type     type;
+}                              t_gate;
+
+typedef struct s_fta_member
+{
+       t_tree_node     *parent;
+       union
+       {
+               t_atom  atom;
+               t_gate  gate;
+       }
+}                              t_fta_member;
+
+typedef struct s_fta_object
+{
+       char    *name;
+       char    *class_name;
+}
+
+typedef struct s_fta_class
+{
+       char    *class_name;
+       t_vec   objects_used;
+}
+
+t_tree *parse_into_logic(const t_parse_tree_node *tree)
+{
+       
+}