diff options
author | Akshay <[email protected]> | 2024-07-14 13:01:23 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2024-07-14 13:01:23 +0100 |
commit | 9ad06d721c1e481c82b4f43df819d76e35757282 (patch) | |
tree | debfca71dcdaeac93ac12abedd377f66cf4341fc /examples/code-overview | |
parent | 83b537bb860643ebdabc43ab47cb8645da8a2e6d (diff) |
add examples
Diffstat (limited to 'examples/code-overview')
-rw-r--r-- | examples/code-overview/out.txt | 68 | ||||
-rw-r--r-- | examples/code-overview/overview.tbsp | 56 |
2 files changed, 124 insertions, 0 deletions
diff --git a/examples/code-overview/out.txt b/examples/code-overview/out.txt new file mode 100644 index 0000000..78c76b1 --- /dev/null +++ b/examples/code-overview/out.txt | |||
@@ -0,0 +1,68 @@ | |||
1 | module | ||
2 | └╴struct Variable | ||
3 | └╴trait Variable | ||
4 | └╴fn value | ||
5 | └╴fn ty | ||
6 | └╴fn assign | ||
7 | └╴enum Value | ||
8 | └╴trait Value | ||
9 | └╴fn ty | ||
10 | └╴fn default | ||
11 | └╴fn default_int | ||
12 | └╴fn default_bool | ||
13 | └╴fn default_string | ||
14 | └╴fn as_boolean | ||
15 | └╴fn add | ||
16 | └╴fn sub | ||
17 | └╴fn mul | ||
18 | └╴fn div | ||
19 | └╴fn mod_ | ||
20 | └╴fn equals | ||
21 | └╴fn greater_than | ||
22 | └╴fn less_than | ||
23 | └╴fn greater_than_equals | ||
24 | └╴fn less_than_equals | ||
25 | └╴fn not | ||
26 | └╴fn and | ||
27 | └╴fn or | ||
28 | └╴trait Value | ||
29 | └╴fn fmt | ||
30 | └╴struct Visitor | ||
31 | └╴struct Visitors | ||
32 | └╴trait Visitors | ||
33 | └╴fn default | ||
34 | └╴trait Visitors | ||
35 | └╴fn new | ||
36 | └╴fn insert | ||
37 | └╴fn get_by_node | ||
38 | └╴enum Error | ||
39 | └╴struct Context | ||
40 | └╴trait Context<'a> | ||
41 | └╴fn fmt | ||
42 | └╴trait Context<'a> | ||
43 | └╴fn new | ||
44 | └╴fn with_program | ||
45 | └╴fn with_input | ||
46 | └╴fn with_cursor | ||
47 | └╴fn eval_expr | ||
48 | └╴fn eval_lit | ||
49 | └╴fn lookup | ||
50 | └╴fn lookup_mut | ||
51 | └╴fn bind | ||
52 | └╴fn eval_bin | ||
53 | └╴fn eval_assign | ||
54 | └╴fn eval_arith | ||
55 | └╴fn eval_cmp | ||
56 | └╴fn eval_logic | ||
57 | └╴fn eval_unary | ||
58 | └╴fn eval_if | ||
59 | └╴fn eval_call | ||
60 | └╴fn eval_declaration | ||
61 | └╴fn eval_statement | ||
62 | └╴fn eval_block | ||
63 | └╴fn eval | ||
64 | └╴fn evaluate | ||
65 | └╴mod test | ||
66 | └╴fn bin | ||
67 | └╴fn test_evaluate_blocks | ||
68 | └╴fn test_evaluate_if | ||
diff --git a/examples/code-overview/overview.tbsp b/examples/code-overview/overview.tbsp new file mode 100644 index 0000000..dd56c55 --- /dev/null +++ b/examples/code-overview/overview.tbsp | |||
@@ -0,0 +1,56 @@ | |||
1 | BEGIN { | ||
2 | int indent = 1; | ||
3 | string tab = " "; | ||
4 | string tree = "└╴"; | ||
5 | print("module\n"); | ||
6 | } | ||
7 | |||
8 | enter declaration_list { | ||
9 | indent += 1; | ||
10 | } | ||
11 | leave declaration_list { | ||
12 | indent -= 1; | ||
13 | } | ||
14 | |||
15 | enter block { | ||
16 | indent += 1; | ||
17 | } | ||
18 | leave block { | ||
19 | indent -= 1; | ||
20 | } | ||
21 | |||
22 | enter function_item { | ||
23 | print(tab * indent); | ||
24 | print(tree); | ||
25 | print("fn " + text(node.name) + "\n"); | ||
26 | } | ||
27 | |||
28 | enter function_signature_item { | ||
29 | print(tab * indent); | ||
30 | print(tree); | ||
31 | print("fn " + text(node.name) + "\n"); | ||
32 | } | ||
33 | |||
34 | enter struct_item { | ||
35 | print(tab * indent); | ||
36 | print(tree); | ||
37 | print("struct " + text(node.name) + "\n"); | ||
38 | } | ||
39 | |||
40 | enter enum_item { | ||
41 | print(tab * indent); | ||
42 | print(tree); | ||
43 | print("enum " + text(node.name) + "\n"); | ||
44 | } | ||
45 | |||
46 | enter mod_item { | ||
47 | print(tab * indent); | ||
48 | print(tree); | ||
49 | print("mod " + text(node.name) + "\n"); | ||
50 | } | ||
51 | |||
52 | enter impl_item { | ||
53 | print(tab * indent); | ||
54 | print(tree); | ||
55 | print("trait " + text(node.type) + "\n"); | ||
56 | } | ||