Skip to content

Commit

Permalink
Replaced Dict with more versatile Table which can take keys of any ty…
Browse files Browse the repository at this point in the history
…pe. Also changed 'Get' to '.'
  • Loading branch information
StavromulaBeta committed Aug 31, 2024
1 parent 05c166f commit 2151742
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 82 deletions.
6 changes: 3 additions & 3 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@
{.name="cosh", .calltype=call, .argc=1, .args={number}, .returns=true, .rettype=number},
{.name="tanh", .calltype=call, .argc=1, .args={number}, .returns=true, .rettype=number},

{.name="dict", .calltype=call, .argc=1, .args={block}, .returns=true, .rettype=dict},
{.name="insert", .calltype=call, .argc=3, .args={string, any, dict}, .returns=true, .rettype=dict},
{.name="get", .calltype=call, .argc=2, .args={string, dict}, .returns=true, .rettype=any},
{.name="table", .calltype=call, .argc=1, .args={block}, .returns=true, .rettype=table},
{.name="insert", .calltype=call, .argc=3, .args={any, any, table}, .returns=true, .rettype=table},
{.name=".", .calltype=call, .argc=2, .args={any, table}, .returns=true, .rettype=any},

/* Builtin stack operations */
//{.name="drop", .calltype=stack_op, .stack_shuffle=&drop_register},
Expand Down
7 changes: 4 additions & 3 deletions src/cognac.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ const char* print_val_type(val_type_t type)
switch (type)
{
case number: return "number";
case dict: return "dict";
case table: return "table";
case symbol: return "symbol";
case string: return "string";
case block: return "block";
Expand All @@ -749,7 +749,7 @@ const char* c_val_type(val_type_t type)
switch (type)
{
case number: return "NUMBER";
case dict: return "DICT";
case table: return "TABLE";
case symbol: return "SYMBOL";
case string: return "STRING";
case block: return "BLOCK";
Expand All @@ -771,7 +771,8 @@ char* sanitize(char* s)
{
switch(str[i])
{
case '-': str[i] = 'D'; break;
case '.': str[i] = 'D'; break;
case '-': str[i] = 'H'; break;
case '!': str[i] = 'X'; break;
case '?': str[i] = 'Q'; break;
case '=': str[i] = 'E'; break;
Expand Down
2 changes: 1 addition & 1 deletion src/cognac.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef enum _val_type_t
NIL=0,
number,
symbol,
dict,
table,
string,
boolean,
block,
Expand Down
4 changes: 2 additions & 2 deletions src/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ int last_openbrace_col;

%x BLOCK_COMMENT

ALLOWCHAR [A-Za-z0-9\-\?\!\'\+\/\*\>\=\<\^]
FORMAL [A-Z\-\?\!\+\/\*\>\<\=\^]
ALLOWCHAR [A-Za-z0-9\-\?\!\'\+\/\*\>\=\<\^\.]
FORMAL [A-Z\-\?\!\+\/\*\>\<\=\^\.]
END [;\(\)$^\~[:space:]]
ESCAPES [abfnrtv\\\"]

Expand Down
Loading

0 comments on commit 2151742

Please sign in to comment.