summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tree.h232
-rw-r--r--tree.txt90
2 files changed, 267 insertions, 55 deletions
diff --git a/tree.h b/tree.h
index d945053..94caad7 100644
--- a/tree.h
+++ b/tree.h
@@ -3,8 +3,8 @@ typedef struct treeNode {
int pos; // Position (index) relative to the first treeNode to match
int identity; // What happens when this treeNode is the last to be matched
// 0: Invalid match: Match pattern is most likely incomplete (or escaped)
- // 1: bold delimiter
- // 2: italics delimiter
+ // 1: italics delimiter
+ // 2: bold delimiter
// 3: bold&italics delimiter
// 4: inline code delimiter
// 5: code block delimiter
@@ -21,11 +21,223 @@ typedef struct treeNode {
struct treeNode *child[]; // Pointer array to other child nodes
} node ;
-node root {
- ' ', 0, 0, 4,
- { node = {
- '*', 0, 2, 4,
- {}
- };
- }
-}
+node n_a = {
+ '*', 0, 1, 4,
+ {&n_aa, &n_ab, &n_ac, &n_ad}
+};
+
+node n_aa = {
+ '\\', -1, 0, 0,
+ {}
+};
+
+node n_ab = {
+ '*', 1, 2, 3,
+ {&n_aba, &n_abb, &n_abc}
+};
+
+node n_aba = {
+ '_', -1, 3, 0,
+ {}
+};
+
+node n_abb = {
+ '*', 2, 3, 0,
+ {}
+};
+
+node n_abc = {
+ '_', 2, 3, 0,
+ {}
+};
+
+node n_ac = {
+ '_', -1, 0, 1,
+ {&n_aca}
+};
+
+node n_aca = {
+ '_', -2, 3, 0,
+ {}
+};
+
+node n_ad = {
+ '_', 1, 0, 1,
+ {&n_ada}
+};
+
+node n_ada = {
+ '_', 2, 3, 0,
+ {}
+};
+
+node n_b = {
+ '_', 0, 1, 2,
+ {&n_ba, &n_bb}
+};
+
+node n_ba = {
+ '\\', -1, 0, 0,
+ {}
+};
+
+node n_bb = {
+ '_', 1, 0, 1,
+ {&n_bba}
+};
+
+node n_bba = {
+ '_', 2, 3, 0,
+ {}
+};
+
+node n_c = {
+ '`', 0, 4, 2,
+ {&n_ca, &n_cb}
+};
+
+node n_ca = {
+ '\\', -1, 0, 0,
+ {}
+};
+
+node n_cb = {
+ '`', 1, 0, 1,
+ {&n_cba}
+};
+
+node n_cba = {
+ '`', 2, 0, 1,
+ {&n_cbaa}
+};
+
+node n_cbaa = {
+ '\n', -1, 5, 0,
+ {}
+};
+
+node n_d = {
+ '\n', 0, 0, 6,
+ {&n_da, &n_db, &n_dc, &n_dd, &n_de, &n_df, }
+};
+
+node n_da = {
+ '#', 1, 8, 0,
+ {}
+};
+
+node n_db = {
+ '=', 1, 6, 0,
+ {}
+};
+
+node n_dc = {
+ '-', 1, 7, 0,
+ {}
+};
+
+node n_dd = {
+ '>', 1, 14, 0,
+ {}
+};
+
+node n_de = {
+ '-', -1, 0, 1,
+ {&n_dea}
+};
+
+node n_dea = {
+ '-', -2, 0, 1,
+ {&n_deaa}
+};
+
+node n_deaa = {
+ '-', -3, 9, 0,
+ {}
+};
+
+node n_df = {
+ 't', 3, 0, 3,
+ {&n_dfa, &n_dfb, &n_dfc}
+};
+
+node n_dfa = {
+ 'a', 1, 0, 1,
+ {&n_dfaa}
+};
+
+node n_dfaa = {
+ 'u', 2, 0, 1,
+ {&n_dfaaa}
+};
+
+node n_dfaaa = {
+ 'h', 4, 0, 1,
+ {&n_dfaaaa}
+};
+
+node n_dfaaaa = {
+ 'o', 5, 0, 1,
+ {&n_dfaaaaa}
+};
+
+node n_dfaaaaa = {
+ 'r', 6, 0, 1,
+ {&n_dfaaaaaa}
+};
+
+node &n_dfaaaaaa = {
+ ':', 7, 11, 0,
+ {}
+};
+
+node n_dfb = {
+ 'd', 1, 0, 1,
+ {&n_dfba}
+};
+
+node n_dfba = {
+ 'a', 2, 0, 1,
+ {&n_dfbaa}
+};
+
+node n_dfbaa = {
+ 'e', 4, 0, 2,
+ {&n_dfbaaa, &n_dfbaab}
+};
+
+node n_dfbaaa = {
+ ':', 5, 13, 0,
+ {}
+};
+
+node n_dfbaab = {
+ '\n', 5, 12, 0,
+ {}
+};
+
+node n_dfc = {
+ 't', 1, 0, 1,
+ {&n_dfca}
+};
+
+node n_dfca = {
+ 'i', 2, 0, 1,
+ {&n_dfcaa}
+};
+
+node n_dfcaa = {
+ 'l', 4, 0, 1,
+ {&n_dfcaaa}
+};
+
+node n_dfcaaa = {
+ 'e', 5, 0, 1,
+ {&n_dfcaaaa}
+};
+
+node n_dfcaaaa = {
+ ':', 6, 10, 0,
+ {}
+};
+
diff --git a/tree.txt b/tree.txt
index b87ee92..59d5750 100644
--- a/tree.txt
+++ b/tree.txt
@@ -2,52 +2,52 @@ This is a visual representation of the node tree used for the pattern matching
alogorithm. It is in this repository as a reference. I'm a human too. I can
make mistakes. Let's keep this as a debugging tool if I miswrite code.
-| VISUAL TREE | NODE IDs | MATCHED PATTERN |
+| VISUAL TREE | NODE IDs | MATCHED PATTERN | IDENTITY |
.
-├── *,0 | (A) | * |
-│   ├── *,1 | (AA) | ** |
-│   │   ├── _,-1 | (AAA) | _** |
-│   │   ├── *,2 | (AAB) | *** |
-│   │   └── _,2 | (AAC) | **_ |
-│   ├── \,-1 | (AB) | \* |
-│   ├── _,-1 | (AC) | _* |
-│   │   └── _,-2 | (ACA) | __* |
-│   └── _,1 | (AD) | *_ |
-│   └── _,2 | (ADA) | *__ |
-├── _,0 | (B) | _ |
-│   ├── \,-1 | (BA) | \_ |
-│   └── _,1 | (BB) | __ |
-│   └── _,2 | (BBA) | ___ |
-├── `,0 | (C) | ` |
-│   ├── \,-1 | (CA) | \` |
-│   └── `,1 | (CB) | `` |
-│   └── `,2 | (CBA) | ``` |
-│   └── ¶,-1 | (CBAA) | ¶` |
-└── ¶,0 | (D) | ¶ |
-    ├── #,1 | (DA) | ¶# |
-    ├── -,1 | (DB) | ¶- |
-    ├── =,1 | (DC) | ¶= |
-    ├── >,1 | (DD) | ¶> |
-    ├── `,-1 | (DE) | `¶ |
-    │   └── `,-2 | (DEA) | ``¶ |
-    │   └── `,-3 | (DEAA) | ```¶ |
-    └── t,3 | (DF) | ¶ t |
-    ├── a,1 | (DFA) | ¶a t |
-    │   └── u,2 | (DFAA) | ¶aut |
-    │   └── h,4 | (DFAAA) | ¶auth |
-    │   └── o,5 | (DFAAAA) | ¶autho |
-    │   └── r,6 | (DFAAAAA) | ¶author |
-    │   └── :,7 | (DFAAAAAA) | ¶author: |
-    ├── d,1 | (DFB) | ¶ t |
-    │   └── a,2 | (DFBA) | ¶d t |
-    │   └── e,4 | (DFBAA) | ¶date |
-    │   ├── :,5 | (DFBAAA) | ¶date: |
-    │   └── ¶,5 | (DFBAAB) | ¶date¶ |
-    └── t,1 | (DFC) | ¶t t |
-    └── i,2 | (DFCA) | ¶tit |
-    └── l,4 | (DFCAA) | ¶titl |
-    └── e,5 | (DFCAAA) | ¶title |
-    └── :,6 | (DFCAAAA) | ¶title: |
+├── *,0 | (A) | * | italic (1) |
+│   ├── \,-1 | (AA) | \* | void (0) |
+│   ├── *,1 | (AB) | ** | bold (2) |
+│   │   ├── _,-1 | (ABA) | _** | boldit (3) |
+│   │   ├── *,2 | (ABB) | *** | boldit (3) |
+│   │   └── _,2 | (ABC) | **_ | boldit (3) |
+│   ├── _,-1 | (AC) | _* | void (0) |
+│   │   └── _,-2 | (ACA) | __* | boldit (3) |
+│   └── _,1 | (AD) | *_ | void (0) |
+│   └── _,2 | (ADA) | *__ | boldit (3) |
+├── _,0 | (B) | _ | italic (1) |
+│   ├── \,-1 | (BA) | \_ | void (0) |
+│   └── _,1 | (BB) | __ | bold (2) |
+│   └── _,2 | (BBA) | ___ | boldit (3) |
+├── `,0 | (C) | ` | code (4) |
+│   ├── \,-1 | (CA) | \` | void (0) |
+│   └── `,1 | (CB) | `` | void (0) |
+│   └── `,2 | (CBA) | ``` | void (0) |
+│   └── ¶,-1 | (CBAA) | ¶``` | codeB (5) |
+└── ¶,0 | (D) | ¶ | void (0) |
+    ├── #,1 | (DA) | ¶# | header (8) |
+    ├── =,1 | (DB) | ¶= | h1 (6) |
+    ├── -,1 | (DC) | ¶- | h2 (7) |
+    ├── >,1 | (DD) | ¶> | indent(14) |
+    ├── -,-1 | (DE) | -¶ | void (0) |
+    │   └── -,-2 | (DEA) | --¶ | void (0) |
+    │   └── -,-3 | (DEAA) | ---¶ | yaml (9) |
+    └── t,3 | (DF) | ¶ t | void (0) |
+    ├── a,1 | (DFA) | ¶a t | void (0) |
+    │   └── u,2 | (DFAA) | ¶aut | void (0) |
+    │   └── h,4 | (DFAAA) | ¶auth | void (0) |
+    │   └── o,5 | (DFAAAA) | ¶autho | void (0) |
+    │   └── r,6 | (DFAAAAA) | ¶author | void (0) |
+    │   └── :,7 | (DFAAAAAA) | ¶author: | author(11) |
+    ├── d,1 | (DFB) | ¶d t | void (0) |
+    │   └── a,2 | (DFBA) | ¶dat | void (0) |
+    │   └── e,4 | (DFBAA) | ¶date | void (0) |
+    │   ├── :,5 | (DFBAAA) | ¶date: | mdate (13) |
+    │   └── ¶,5 | (DFBAAB) | ¶date¶ | adata (12) |
+    └── t,1 | (DFC) | ¶t t | void (0) |
+    └── i,2 | (DFCA) | ¶tit | void (0) |
+    └── l,4 | (DFCAA) | ¶titl | void (0) |
+    └── e,5 | (DFCAAA) | ¶title | void (0) |
+    └── :,6 | (DFCAAAA) | ¶title: | title (10) |
43 nodes in total.