changing more part of array handling to use #[
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-01-28 00:03:40 +09:00
parent 2e1ae8d9ee
commit a1f304bdef
4 changed files with 33 additions and 14 deletions

View File

@ -12,7 +12,7 @@
assignment syntax
(k := 20) -> (set k 20)
k := 20 -> (set k 20)
k := 20 -> (set k 20)
[a, b] := (multi-retvar-fun 10 20) -> (set-r a b (multi-retvar-fun 10 20))
implement module -> ::, ., or what notation?
@ -22,9 +22,21 @@
dynamic byte array is supported but we need yet to support byte-string(byte-array) constant
b"..." or B"..." for an byte string constant notation
u"..." or U"..." for an explicit unicode string constant notation?
-> change u to c???
#b[ ] byte array??
#[ ] normal array?
#b[ ] byte array??
#c[ ] charcter array??
#w[ ] word array??
#hw[ ] half-word array??
#u8[ ]
#u16[ ]
#u32[ ]
#u64[ ]
#i8[ ]
#i16[ ]
#i32[ ]
#i64[ ]
allow b'X' or 'X' in byte array in #b[] notation?

View File

@ -199,10 +199,16 @@ enum hcl_tok_type_t
#define HCL_TOK_LPARCOLON HCL_TOK_LPARCOLON
#endif
HCL_TOK_BAPAREN, /* #[ - byte array parenthesis */
HCL_TOK_APAREN, /* #[ - array parenthesis */
HCL_TOK_BAPAREN, /* #b[ - byte array parenthesis */
#if 0
HCL_TOK_CAPAREN, /* #c[ - character array parenthesis */
HCL_TOK_WAPAREN, /* #w[ - word array parenthesis */
HCL_TOK_WAPAREN, /* #hw[ - half-word array parenthesis */
#endif
HCL_TOK_QLPAREN, /* #( - quoted-list parenthesis */
HCL_TOK_DLPAREN, /* #{ - dictionary parenthese */
HCL_TOK_LBRACK, /* [ - array */
HCL_TOK_LBRACK, /* [ - group */
HCL_TOK_RBRACK, /* ] */
HCL_TOK_LBRACE, /* { - block */
HCL_TOK_RBRACE, /* } */
@ -765,7 +771,7 @@ struct hcl_compiler_t
hcl_flx_pn_t pn; /* plain number */
hcl_flx_qt_t qt; /* quoted token */
hcl_flx_st_t st; /* signed token */
hcl_flx_st_t bu; /* b or u prefix */
hcl_flx_bu_t bu; /* b or u prefix */
} u;
} lx;

View File

@ -219,8 +219,8 @@ int hcl_fmt_object_ (hcl_fmtout_t* fmtout, hcl_oop_t obj)
{ "(", "(" }, /*HCL_CONCODE_MLIST */
{ "(", "(" }, /*HCL_CONCODE_ALIST */
{ "{", "{" }, /*HCL_CONCODE_BLOCK */
{ "[", "[" }, /*HCL_CONCODE_ARRAY */
{ "#[", "[" }, /*HCL_CONCODE_BYTEARRAY */
{ "#[", "[" }, /*HCL_CONCODE_ARRAY */
{ "#b[", "[" }, /*HCL_CONCODE_BYTEARRAY */
{ "#{", "{" }, /*HCL_CONCODE_DIC */
{ "#(", "[" } /*HCL_CONCODE_QLIST */
};

View File

@ -62,8 +62,8 @@ static struct voca_t
{ 4, { '(',':',' ',')' /* MLIST */ } },
{ 3, { '(',':','=',')' /* ALIST */ } },
{ 3, { '{',' ','}' /* BLOCK */ } },
{ 3, { '[',' ',']' /* ARRAY */ } },
{ 4, { '#','[',' ',']' } },
{ 4, { '#','[',' ',']' /* ARRAY */ } },
{ 5, { '#','b','[',' ',']' /* BYTE ARRAY */ } },
{ 4, { '#','{',' ','}' } },
{ 4, { '#','(',' ',')' } },
{ 3, { '|',' ','|' } },
@ -1174,6 +1174,7 @@ static int feed_process_token (hcl_t* hcl)
}
case HCL_TOK_LBRACK: /* [ */
case HCL_TOK_APAREN: /* #[ */
/* [] is a data list. so let's treat it like other literal
* expressions(e.g. 1, "abc"). when it's placed at the block beginning,
* create the outer XLIST. */
@ -1183,7 +1184,7 @@ static int feed_process_token (hcl_t* hcl)
LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_ARRAY);
goto start_list;
case HCL_TOK_BAPAREN: /* #[ */
case HCL_TOK_BAPAREN: /* #b[ */
if (auto_forge_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops;
frd->flagv = DATA_LIST;
@ -2019,15 +2020,15 @@ static int flx_hmarked_token (hcl_t* hcl, hcl_ooci_t c)
goto consumed;
/* --------------------------- */
case '[':
FEED_WRAP_UP_WITH_CHAR (hcl, c, HCL_TOK_BAPAREN);
case '[': /* #[ */
FEED_WRAP_UP_WITH_CHAR (hcl, c, HCL_TOK_APAREN);
goto consumed;
case '(':
case '(': /* #( */
FEED_WRAP_UP_WITH_CHAR (hcl, c, HCL_TOK_QLPAREN);
goto consumed;
case '{':
case '{': /* #{ */
FEED_WRAP_UP_WITH_CHAR (hcl, c, HCL_TOK_DLPAREN);
goto consumed;