]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.10/Include/grammar.h
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 1/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Include / grammar.h
diff --git a/AppPkg/Applications/Python/Python-2.7.10/Include/grammar.h b/AppPkg/Applications/Python/Python-2.7.10/Include/grammar.h
new file mode 100644 (file)
index 0000000..f82ee9c
--- /dev/null
@@ -0,0 +1,93 @@
+\r
+/* Grammar interface */\r
+\r
+#ifndef Py_GRAMMAR_H\r
+#define Py_GRAMMAR_H\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include "bitset.h" /* Sigh... */\r
+\r
+/* A label of an arc */\r
+\r
+typedef struct {\r
+    int                 lb_type;\r
+    char       *lb_str;\r
+} label;\r
+\r
+#define EMPTY 0                /* Label number 0 is by definition the empty label */\r
+\r
+/* A list of labels */\r
+\r
+typedef struct {\r
+    int                 ll_nlabels;\r
+    label      *ll_label;\r
+} labellist;\r
+\r
+/* An arc from one state to another */\r
+\r
+typedef struct {\r
+    short      a_lbl;          /* Label of this arc */\r
+    short      a_arrow;        /* State where this arc goes to */\r
+} arc;\r
+\r
+/* A state in a DFA */\r
+\r
+typedef struct {\r
+    int                 s_narcs;\r
+    arc                *s_arc;         /* Array of arcs */\r
+       \r
+    /* Optional accelerators */\r
+    int                 s_lower;       /* Lowest label index */\r
+    int                 s_upper;       /* Highest label index */\r
+    int                *s_accel;       /* Accelerator */\r
+    int                 s_accept;      /* Nonzero for accepting state */\r
+} state;\r
+\r
+/* A DFA */\r
+\r
+typedef struct {\r
+    int                 d_type;        /* Non-terminal this represents */\r
+    char       *d_name;        /* For printing */\r
+    int                 d_initial;     /* Initial state */\r
+    int                 d_nstates;\r
+    state      *d_state;       /* Array of states */\r
+    bitset      d_first;\r
+} dfa;\r
+\r
+/* A grammar */\r
+\r
+typedef struct {\r
+    int                 g_ndfas;\r
+    dfa                *g_dfa;         /* Array of DFAs */\r
+    labellist   g_ll;\r
+    int                 g_start;       /* Start symbol of the grammar */\r
+    int                 g_accel;       /* Set if accelerators present */\r
+} grammar;\r
+\r
+/* FUNCTIONS */\r
+\r
+grammar *newgrammar(int start);\r
+dfa *adddfa(grammar *g, int type, char *name);\r
+int addstate(dfa *d);\r
+void addarc(dfa *d, int from, int to, int lbl);\r
+dfa *PyGrammar_FindDFA(grammar *g, int type);\r
+\r
+int addlabel(labellist *ll, int type, char *str);\r
+int findlabel(labellist *ll, int type, char *str);\r
+char *PyGrammar_LabelRepr(label *lb);\r
+void translatelabels(grammar *g);\r
+\r
+void addfirstsets(grammar *g);\r
+\r
+void PyGrammar_AddAccelerators(grammar *g);\r
+void PyGrammar_RemoveAccelerators(grammar *);\r
+\r
+void printgrammar(grammar *g, FILE *fp);\r
+void printnonterminals(grammar *g, FILE *fp);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif /* !Py_GRAMMAR_H */\r