diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index 77b7f8d..775df1c 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -182,6 +182,7 @@ enum hcl_tok_type_t HCL_TOK_DBLCOLONS, /* :: */ HCL_TOK_TRPCOLONS, /* ::: */ HCL_TOK_DCSTAR, /* ::* */ + HCL_TOK_SEMICOLON, /* ; */ HCL_TOK_COMMA, /* , */ HCL_TOK_LPAREN, /* ( */ HCL_TOK_RPAREN, /* ) */ diff --git a/lib/hcl.h b/lib/hcl.h index 2be9a20..e9b7a3c 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1917,9 +1917,10 @@ enum hcl_concode_t /* these can be set in the SYNCODE flags for a cons cell */ HCL_CONCODE_XLIST = 0, /* ( ) - executable list */ HCL_CONCODE_MLIST, /* (: ) - message send list */ + HCL_CONCODE_BLOCK, /* { } */ HCL_CONCODE_ARRAY, /* [ ] */ HCL_CONCODE_BYTEARRAY, /* #[ ] */ - HCL_CONCODE_DIC, /* { } */ + HCL_CONCODE_DIC, /* #{ } */ HCL_CONCODE_QLIST, /* #( ) - data list */ HCL_CONCODE_VLIST /* | | - symbol list */ }; diff --git a/lib/print.c b/lib/print.c index aafe666..b86026c 100644 --- a/lib/print.c +++ b/lib/print.c @@ -219,6 +219,7 @@ int hcl_fmt_object_ (hcl_fmtout_t* fmtout, hcl_oop_t obj) /* navtive json */ { "(", "(" }, /*HCL_CONCODE_XLIST */ { "(:", "(" }, /*HCL_CONCODE_MLIST */ + { "{", "{" }, /*HCL_CONCODE_BLOCK */ { "[", "[" }, /*HCL_CONCODE_ARRAY */ { "#[", "[" }, /*HCL_CONCODE_BYTEARRAY */ { "#{", "{" }, /*HCL_CONCODE_DIC */ @@ -229,6 +230,7 @@ int hcl_fmt_object_ (hcl_fmtout_t* fmtout, hcl_oop_t obj) { { ")", ")" }, /*HCL_CONCODE_XLIST */ { ")", ")" }, /*HCL_CONCODE_MLIST */ + { "}", "}" }, /*HCL_CONCODE_BLOCK */ { "]", "]" }, /*HCL_CONCODE_ARRAY */ { "]", "]" }, /*HCL_CONCODE_BYTEARRAY */ { "}", "}" }, /*HCL_CONCODE_DIC */ diff --git a/lib/read.c b/lib/read.c index 273d6c0..7bf43f5 100644 --- a/lib/read.c +++ b/lib/read.c @@ -324,7 +324,7 @@ static HCL_INLINE int is_alnumchar (hcl_ooci_t c) static HCL_INLINE int is_delimchar (hcl_ooci_t c) { return c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}' || - c == ';' || c == '|' || c == ',' || c == '.' || c == ':' || + c == ';' || c == '|' || c == ',' || c == '.' || c == ':' || c == ';' || /* the first characters of tokens in delim_token_tab up to this point */ c == '#' || c == '\"' || c == '\'' || is_spacechar(c) || c == HCL_UCI_EOF; } @@ -1082,6 +1082,11 @@ static int feed_process_token (hcl_t* hcl) LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_BYTEARRAY); goto start_list; + case HCL_TOK_LBRACE: /* { */ + frd->flagv = DATA_LIST; + LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_BLOCK); + goto start_list; + case HCL_TOK_DLPAREN: /* #{ */ frd->flagv = DATA_LIST; LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_DIC); @@ -1412,7 +1417,7 @@ static delim_token_t delim_token_tab[] = * The length must not differ by greater than 1 between 2 items in the same group. * * [NOTE 3] - * don't list #( and #[ here because of overlapping use of # for various purposes. + * don't list #(, #[, #{ here because of overlapping use of # for various purposes. * however, # is included in is_delimchar(). */ @@ -1436,7 +1441,9 @@ static delim_token_t delim_token_tab[] = { ":", 1, HCL_TOK_COLON }, { "::", 2, HCL_TOK_DBLCOLONS }, { "::*", 3, HCL_TOK_DCSTAR }, - { ":::", 3, HCL_TOK_TRPCOLONS } + { ":::", 3, HCL_TOK_TRPCOLONS }, + + { ";", 1, HCL_TOK_SEMICOLON } }; static int find_delim_token_char (hcl_t* hcl, const hcl_ooci_t c, int row_start, int row_end, int col, hcl_flx_dt_t* dt)