diff --git a/README.md b/README.md
index 82b0f51..6c2f447 100644
--- a/README.md
+++ b/README.md
@@ -525,6 +525,10 @@ serving files for display or download (Web 1.0).
- [DONE] error_404_page
- [DONE] directory_page
- dynamic pages
+ - dynamic router
+ - views
+ - templates
+ - MVC
- lib
- [DONE] File.exists?
- [DONE] File.list
diff --git a/lib/kc3/0.1/kc3/operator.kc3 b/lib/kc3/0.1/kc3/operator.kc3
index 0aa800f..524e5ae 100644
--- a/lib/kc3/0.1/kc3/operator.kc3
+++ b/lib/kc3/0.1/kc3/operator.kc3
@@ -2,7 +2,7 @@ defmodule KC3.Operator do
defstruct [sym: :+,
symbol_value: ?,
- operator_precedence: (Sw) 0,
+ operator_precedence: 0,
operator_associativity: :left]
def find_by_sym = cfn Tag "kc3_operator_find_by_sym" (Sym, Result)
diff --git a/libkc3/buf_inspect.c b/libkc3/buf_inspect.c
index 7e16383..c0accef 100644
--- a/libkc3/buf_inspect.c
+++ b/libkc3/buf_inspect.c
@@ -23,6 +23,7 @@
#include "buf_inspect_s64_decimal.h"
#include "buf_save.h"
#include "character.h"
+#include "compare.h"
#include "cow.h"
#include "data.h"
#include "ident.h"
@@ -3097,7 +3098,9 @@ sw buf_inspect_str_size (s_pretty *pretty, const s_str *str)
sw buf_inspect_struct (s_buf *buf, const s_struct *s)
{
- uw i = 0;
+ bool display;
+ uw display_last = 0;
+ uw i;
s_tag *k;
s_pretty_save pretty_save;
sw r;
@@ -3123,52 +3126,66 @@ sw buf_inspect_struct (s_buf *buf, const s_struct *s)
pretty_save_init(&pretty_save, &buf->pretty);
pretty_indent_from_column(&buf->pretty, 0);
if (s->data || s->tag) {
+ i = 0;
while (i < s->type->map.count) {
- k = s->type->map.key + i;
- if (k->type != TAG_SYM) {
- err_write_1("buf_inspect_struct: key type is not a symbol: ");
- err_inspect_tag(k);
- err_write_1(" (");
- err_write_1(tag_type_to_string(k->type));
- err_puts(")");
- assert(k->type == TAG_SYM);
- r = -1;
- goto clean;
- }
- if (sym_has_reserved_characters(k->data.sym)) {
- if ((r = buf_inspect_str(buf, &k->data.sym->str)) < 0)
- goto clean;
- }
- else
- if ((r = buf_write_str_without_indent(buf,
- &k->data.sym->str)) < 0)
- goto clean;
- result += r;
- if ((r = buf_write_1(buf, ": ")) < 0)
- goto clean;
- result += r;
- if (s->data) {
- if (s->type->map.value[i].type == TAG_VAR)
- type = s->type->map.value[i].data.var.type;
- else if (! tag_type(s->type->map.value + i, &type))
- goto clean;
- assert(s->type->offset[i] < s->type->size);
- if ((r = data_buf_inspect(buf, type, (char *) s->data +
- s->type->offset[i])) < 0)
+ if (s->data ||
+ compare_tag(s->tag + i, s->type->map.value + i))
+ display_last = i;
+ i++;
+ }
+ i = 0;
+ while (i < s->type->map.count) {
+ display = s->data ||
+ compare_tag(s->tag + i, s->type->map.value + i);
+ if (display) {
+ k = s->type->map.key + i;
+ if (k->type != TAG_SYM) {
+ err_write_1("buf_inspect_struct: key type is not a symbol: ");
+ err_inspect_tag(k);
+ err_write_1(" (");
+ err_write_1(tag_type_to_string(k->type));
+ err_puts(")");
+ assert(k->type == TAG_SYM);
+ r = -1;
goto clean;
+ }
+ if (sym_has_reserved_characters(k->data.sym)) {
+ if ((r = buf_inspect_str(buf, &k->data.sym->str)) < 0)
+ goto clean;
+ }
+ else
+ if ((r = buf_write_str_without_indent(buf,
+ &k->data.sym->str)) < 0)
+ goto clean;
result += r;
- }
- else if (s->tag) {
- if ((r = buf_inspect_tag(buf, s->tag + i)) < 0)
+ if ((r = buf_write_1(buf, ": ")) < 0)
goto clean;
result += r;
+ if (s->data) {
+ if (s->type->map.value[i].type == TAG_VAR)
+ type = s->type->map.value[i].data.var.type;
+ else if (! tag_type(s->type->map.value + i, &type))
+ goto clean;
+ assert(s->type->offset[i] < s->type->size);
+ if ((r = data_buf_inspect(buf, type, (char *) s->data +
+ s->type->offset[i])) < 0)
+ goto clean;
+ result += r;
+ }
+ else if (s->tag) {
+ if ((r = buf_inspect_tag(buf, s->tag + i)) < 0)
+ goto clean;
+ result += r;
+ }
}
- i++;
- if (i < s->type->map.count) {
+ if (display &&
+ i < display_last &&
+ i < s->type->map.count - 1) {
if ((r = buf_write_1(buf, ",\n")) < 0)
goto clean;
result += r;
}
+ i++;
}
}
pretty_save_clean(&pretty_save, &buf->pretty);
@@ -3183,7 +3200,9 @@ sw buf_inspect_struct (s_buf *buf, const s_struct *s)
sw buf_inspect_struct_size (s_pretty *pretty, const s_struct *s)
{
- uw i = 0;
+ bool display;
+ uw display_last = 0;
+ uw i;
s_tag *k;
s_pretty_save pretty_save;
sw r;
@@ -3210,52 +3229,67 @@ sw buf_inspect_struct_size (s_pretty *pretty, const s_struct *s)
pretty_save_init(&pretty_save, pretty);
pretty_indent_from_column(pretty, 0);
if (s->data || s->tag) {
+ i = 0;
while (i < s->type->map.count) {
- k = s->type->map.key + i;
- if (k->type != TAG_SYM) {
- err_write_1("buf_inspect_struct: key type is not a symbol: ");
- err_inspect_tag(k);
- err_write_1(" (");
- err_write_1(tag_type_to_string(k->type));
- err_puts(")");
- assert(k->type == TAG_SYM);
- r = -1;
- goto clean;
- }
- if (sym_has_reserved_characters(k->data.sym)) {
- if ((r = buf_inspect_str_size(pretty, &k->data.sym->str)) < 0)
- goto clean;
- }
- else
- if ((r = buf_write_str_without_indent_size(pretty,
- &k->data.sym->str)) < 0)
- goto clean;
- result += r;
- if ((r = buf_write_1_size(pretty, ": ")) < 0)
- goto clean;
- result += r;
- if (s->data) {
- if (s->type->map.value[i].type == TAG_VAR)
- type = s->type->map.value[i].data.var.type;
- else if (! tag_type(s->type->map.value + i, &type))
- goto clean;
- assert(s->type->offset[i] < s->type->size);
- if ((r = data_buf_inspect_size(pretty, type, (char *) s->data +
- s->type->offset[i])) < 0)
+ if (s->data ||
+ compare_tag(s->tag + i, s->type->map.value + i))
+ display_last = i;
+ i++;
+ }
+ i = 0;
+ while (i < s->type->map.count) {
+ display = s->data ||
+ compare_tag(s->tag + i, s->type->map.value + i);
+ if (display) {
+ k = s->type->map.key + i;
+ if (k->type != TAG_SYM) {
+ err_write_1("buf_inspect_struct: key type is not a symbol: ");
+ err_inspect_tag(k);
+ err_write_1(" (");
+ err_write_1(tag_type_to_string(k->type));
+ err_puts(")");
+ assert(k->type == TAG_SYM);
+ r = -1;
goto clean;
+ }
+ if (sym_has_reserved_characters(k->data.sym)) {
+ if ((r = buf_inspect_str_size(pretty, &k->data.sym->str)) < 0)
+ goto clean;
+ }
+ else
+ if ((r = buf_write_str_without_indent_size
+ (pretty, &k->data.sym->str)) < 0)
+ goto clean;
result += r;
- }
- else if (s->tag) {
- if ((r = buf_inspect_tag_size(pretty, s->tag + i)) < 0)
+ if ((r = buf_write_1_size(pretty, ": ")) < 0)
goto clean;
result += r;
+ if (s->data) {
+ if (s->type->map.value[i].type == TAG_VAR)
+ type = s->type->map.value[i].data.var.type;
+ else if (! tag_type(s->type->map.value + i, &type))
+ goto clean;
+ assert(s->type->offset[i] < s->type->size);
+ if ((r = data_buf_inspect_size(pretty, type,
+ (char *) s->data +
+ s->type->offset[i])) < 0)
+ goto clean;
+ result += r;
+ }
+ else if (s->tag) {
+ if ((r = buf_inspect_tag_size(pretty, s->tag + i)) < 0)
+ goto clean;
+ result += r;
+ }
}
- i++;
- if (i < s->type->map.count) {
+ if (display &&
+ i <= display_last &&
+ i < s->type->map.count - 1) {
if ((r = buf_write_1_size(pretty, ",\n")) < 0)
goto clean;
result += r;
}
+ i++;
}
}
pretty_save_clean(&pretty_save, pretty);
@@ -3782,8 +3816,7 @@ sw buf_inspect_var_size (s_pretty *pretty, const s_var *var)
return r;
}
else {
- if ((r = buf_inspect_paren_sym_size(pretty,
- var->type)) < 0)
+ if ((r = buf_inspect_paren_sym_size(pretty, var->type)) < 0)
return r;
result += r;
if ((r = buf_write_1_size(pretty, " ?")) < 0)
@@ -3794,8 +3827,8 @@ sw buf_inspect_var_size (s_pretty *pretty, const s_var *var)
if ((r = buf_write_1_size(pretty, "0x")) < 0)
return r;
result += r;
- if ((r = buf_inspect_uw_hexadecimal_size
- (pretty, (uw *) &var->ptr)) < 0)
+ if ((r = buf_inspect_uw_hexadecimal
+ _size(pretty, (uw *) &var->ptr)) < 0)
return r;
result += r;
}
diff --git a/libkc3/env.c b/libkc3/env.c
index 28a1e84..fb90c6a 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -1855,7 +1855,8 @@ bool env_eval_tag (s_env *env, const s_tag *tag, s_tag *dest)
assert(dest);
switch (tag->type) {
case TAG_VOID:
- return env_eval_void(env, NULL, dest);
+ tag_init_void(dest);
+ return true;
case TAG_ARRAY:
return env_eval_array_tag(env, &tag->data.array, dest);
case TAG_BLOCK:
@@ -1992,16 +1993,6 @@ bool env_eval_var (s_env *env, const s_var *var, s_tag *dest)
return true;
}
-bool env_eval_void (s_env *env, const void *_, s_tag *dest)
-{
- assert(env);
- assert(dest);
- (void) env;
- (void) _;
- tag_init_void(dest);
- return true;
-}
-
s_fact_w * env_fact_w_eval (s_env *env, const s_fact_w *fact,
s_fact_w *dest)
{
diff --git a/libkc3/env.h b/libkc3/env.h
index 9fb1ce3..c0ac251 100644
--- a/libkc3/env.h
+++ b/libkc3/env.h
@@ -240,7 +240,6 @@ bool env_eval_time (s_env *env, const s_time *time,
bool env_eval_tuple (s_env *env, const s_tuple *tuple,
s_tag *dest);
bool env_eval_var (s_env *env, const s_var *var, s_tag *dest);
-bool env_eval_void (s_env *env, const void *_, s_tag *dest);
/* Modifiers. */
bool env_call_get (s_env *env, s_call *call);
diff --git a/libkc3/struct.c b/libkc3/struct.c
index 6b20b2d..3550c21 100644
--- a/libkc3/struct.c
+++ b/libkc3/struct.c
@@ -238,7 +238,7 @@ s_struct * struct_init_1 (s_struct *s, const char *p)
struct_clean(&tmp);
return NULL;
}
- if (true) {
+ if (false) {
err_write_1("\nstruct_init_1: tmp = ");
err_inspect_struct(&tmp);
err_write_1("\n");
diff --git a/test/ikc3/block.out.expected b/test/ikc3/block.out.expected
index 7de59cd..92564f2 100644
--- a/test/ikc3/block.out.expected
+++ b/test/ikc3/block.out.expected
@@ -18,14 +18,11 @@ do
end
1
do
- 1
- 2
+ 1 ; 2
end
2
do
- 1
- 2
- 3
+ 1 ; 2 ; 3
end
3
do
diff --git a/test/ikc3/defoperator.out.expected b/test/ikc3/defoperator.out.expected
index 03bbca4..4ba44a8 100644
--- a/test/ikc3/defoperator.out.expected
+++ b/test/ikc3/defoperator.out.expected
@@ -1,12 +1,11 @@
-%KC3.Operator{}
+%KC3.Operator{symbol_value: void}
%KC3.Operator{sym: :+,
- symbol_value: ?,
+ symbol_value: void,
operator_precedence: 0,
operator_associativity: :left}
def operator_muul = %KC3.Operator{sym: :****,
symbol_value: cfn Tag "tag_mul" (Tag, Tag, Result),
- operator_precedence: 11,
- operator_associativity: :left}
+ operator_precedence: 11}
operator_muul
4 **** 4
16
@@ -14,3 +13,4 @@ operator_muul
64
4 **** 4 + 4
20
+to_lisp(quote 4 **** 4 + 4)
diff --git a/test/ikc3/facts_with_tags.out.expected b/test/ikc3/facts_with_tags.out.expected
index 644156a..6805aa5 100644
--- a/test/ikc3/facts_with_tags.out.expected
+++ b/test/ikc3/facts_with_tags.out.expected
@@ -26,6 +26,7 @@ operator_not_eq
operator_require
operator_brackets
operator_defstruct
+operator_semicolumn
operator_shift_left
operator_shift_right
1
@@ -57,11 +58,12 @@ operator_not_eq
operator_require
operator_brackets
operator_defstruct
+operator_semicolumn
operator_shift_left
operator_shift_right
2
-op = ?
-?0x
+op = ? ; void
+void
Facts.with_tags(Facts.env_facts(), KC3, :operator, op, fn (fact) { puts(op); 3 })
operator_eq
operator_gt
@@ -90,6 +92,7 @@ operator_not_eq
operator_require
operator_brackets
operator_defstruct
+operator_semicolumn
operator_shift_left
operator_shift_right
3
diff --git a/test/ikc3/facts_with_tuple.out.expected b/test/ikc3/facts_with_tuple.out.expected
index 03807f0..cee9922 100644
--- a/test/ikc3/facts_with_tuple.out.expected
+++ b/test/ikc3/facts_with_tuple.out.expected
@@ -21,10 +21,12 @@ operator_bnot
operator_bxor
operator_equal
operator_paren
+operator_assign
operator_not_eq
operator_require
operator_brackets
operator_defstruct
+operator_semicolumn
operator_shift_left
operator_shift_right
void
diff --git a/test/ikc3/let.kc3 b/test/ikc3/let.kc3
index 8542214..d5dac07 100644
--- a/test/ikc3/let.kc3
+++ b/test/ikc3/let.kc3
@@ -1,4 +1,4 @@
-quote let %{a: 1} do a; end
-let %{a: 1} do a; end
-quote let %{a: 1, b: 2} do a + b; end
-let %{a: 1, b: 2} do a + b; end
+quote let %{a: 1} do a end
+let %{a: 1} do a end
+quote let %{a: 1, b: 2} do a + b end
+let %{a: 1, b: 2} do a + b end
diff --git a/test/inspect_test.c b/test/inspect_test.c
index fb292e4..5733b05 100644
--- a/test/inspect_test.c
+++ b/test/inspect_test.c
@@ -430,17 +430,17 @@ TEST_CASE(inspect_struct)
INSPECT_TEST_STRUCT("%KC3.Operator{symbol_value: 1}",
"%KC3.Operator{sym: :+,\n"
" symbol_value: 1,\n"
- " operator_precedence: (Sw) 0,\n"
+ " operator_precedence: 0,\n"
" operator_associativity: :left}");
INSPECT_TEST_STRUCT("%KC3.Operator{symbol_value: void}",
"%KC3.Operator{sym: :+,\n"
" symbol_value: void,\n"
- " operator_precedence: (Sw) 0,\n"
+ " operator_precedence: 0,\n"
" operator_associativity: :left}");
INSPECT_TEST_STRUCT("%KC3.Operator{sym: :-, symbol_value: void}",
"%KC3.Operator{sym: :-,\n"
" symbol_value: void,\n"
- " operator_precedence: (Sw) 0,\n"
+ " operator_precedence: 0,\n"
" operator_associativity: :left}");
}
TEST_CASE_END(inspect_struct)