From c2928615a4b9c5ff1ff5530b2612f2fe79de519f Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 3 Feb 2024 18:50:10 +0900 Subject: [PATCH] shortened ::* to :* --- lang.txt | 6 +++--- lib/cnode.c | 9 +++++++-- lib/comp.c | 5 +++-- lib/hcl-prv.h | 12 ++++++++---- lib/print.c | 3 ++- lib/read.c | 11 ++++++++--- t/class-5001.err | 2 +- t/fun-01.hcl | 2 +- t/insta-01.hcl | 4 ++-- t/insta-02.hcl | 2 +- t/var-01.hcl | 2 +- t/var-5001.err | 4 ++-- 12 files changed, 39 insertions(+), 23 deletions(-) diff --git a/lang.txt b/lang.txt index afd4782..dd9ed99 100644 --- a/lang.txt +++ b/lang.txt @@ -51,7 +51,7 @@ default return value for some class methods. ::: method -> return what?? - ::* method -> return the new instance + :* method -> return the new instance normal method -> return the last evaluated value? @@ -148,7 +148,7 @@ send the message dump to the object pointed to by x with arguments 1, 2, 3. (defclass P | x y | - (defun ::* new () + (defun :* new () (set x 1) (set y 1) (return self) @@ -158,7 +158,7 @@ send the message dump to the object pointed to by x with arguments 1, 2, 3. ) (defclass X ::: P | x y | - (defun ::* new (a b) + (defun :* new (a b) (super:new) x = a y = b diff --git a/lib/cnode.c b/lib/cnode.c index 3c30e1b..d5bcbdb 100644 --- a/lib/cnode.c +++ b/lib/cnode.c @@ -86,9 +86,14 @@ hcl_cnode_t* hcl_makecnodetrpcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc return make_cnode(hcl, HCL_CNODE_TRPCOLONS, flags, loc, tok); } -hcl_cnode_t* hcl_makecnodedcstar (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok) +hcl_cnode_t* hcl_makecnodecolonplus (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok) { - return make_cnode(hcl, HCL_CNODE_DCSTAR, flags, loc, tok); + return make_cnode(hcl, HCL_CNODE_COLONPLUS, flags, loc, tok); +} + +hcl_cnode_t* hcl_makecnodecolonstar (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok) +{ + return make_cnode(hcl, HCL_CNODE_COLONSTAR, flags, loc, tok); } hcl_cnode_t* hcl_makecnodecharlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_ooch_t v) diff --git a/lib/comp.c b/lib/comp.c index 0d6b972..dfe5dbf 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -2745,10 +2745,11 @@ static int compile_lambda (hcl_t* hcl, hcl_cnode_t* src, int defun) defun_name = HCL_CNODE_CONS_CAR(obj); if (is_in_class_init_scope(hcl)) { - if ((HCL_CNODE_IS_TRPCOLONS(defun_name) || HCL_CNODE_IS_DCSTAR(defun_name))) + if ((HCL_CNODE_IS_TRPCOLONS(defun_name) || HCL_CNODE_IS_COLONSTAR(defun_name))) { /* class method - (defun ::: xxxx () ...) inside class definition */ - /* class instantiation method - (defun ::* xxxx () ...) inside class definition */ + /* class method - (defun:+ xxxx() ...) inside class definition */ + /* class instantiation method - (defun:* xxxx() ...) inside class definition */ obj = HCL_CNODE_CONS_CDR(obj); if (!obj) { diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index 4cacbf9..fb06fe7 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -187,8 +187,9 @@ enum hcl_tok_type_t HCL_TOK_COLON, /* : */ HCL_TOK_DBLCOLONS, /* :: */ HCL_TOK_TRPCOLONS, /* ::: */ - HCL_TOK_DCSTAR, /* ::* */ HCL_TOK_COLONEQ, /* := */ + HCL_TOK_COLONPLUS, /* :+ */ + HCL_TOK_COLONSTAR, /* :* */ HCL_TOK_SEMICOLON, /* ; */ HCL_TOK_COMMA, /* , */ HCL_TOK_LPAREN, /* ( */ @@ -256,7 +257,8 @@ enum hcl_cnode_type_t HCL_CNODE_SUPER, HCL_CNODE_ELLIPSIS, HCL_CNODE_TRPCOLONS, - HCL_CNODE_DCSTAR, + HCL_CNODE_COLONPLUS, /* :+ */ + HCL_CNODE_COLONSTAR, /* :* */ HCL_CNODE_CONS, HCL_CNODE_ELIST, /* empty list */ @@ -279,7 +281,8 @@ typedef enum hcl_cnode_flagt hcl_cnode_flag_t; #define HCL_CNODE_IS_ELLIPSIS(x) ((x)->cn_type == HCL_CNODE_ELLIPSIS) #define HCL_CNODE_IS_TRPCOLONS(x) ((x)->cn_type == HCL_CNODE_TRPCOLONS) -#define HCL_CNODE_IS_DCSTAR(x) ((x)->cn_type == HCL_CNODE_DCSTAR) +#define HCL_CNODE_IS_COLONPLUS(x) ((x)->cn_type == HCL_CNODE_COLONPLUS) +#define HCL_CNODE_IS_COLONSTAR(x) ((x)->cn_type == HCL_CNODE_COLONSTAR) #define HCL_CNODE_IS_SYMBOL(x) ((x)->cn_type == HCL_CNODE_SYMBOL) #define HCL_CNODE_IS_SYMBOL_PLAIN(x) ((x)->cn_type == HCL_CNODE_SYMBOL && (x)->u.symbol.syncode == 0) @@ -1777,7 +1780,8 @@ hcl_cnode_t* hcl_makecnodeself (hcl_t* hcl, int flags, const hcl_loc_t* loc, con hcl_cnode_t* hcl_makecnodesuper (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok); hcl_cnode_t* hcl_makecnodeellipsis (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok); hcl_cnode_t* hcl_makecnodetrpcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok); -hcl_cnode_t* hcl_makecnodedcstar (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok); +hcl_cnode_t* hcl_makecnodecolonplus (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok); +hcl_cnode_t* hcl_makecnodecolonstar (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok); hcl_cnode_t* hcl_makecnodecharlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_ooch_t v); hcl_cnode_t* hcl_makecnodebchrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_oob_t v); hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok); diff --git a/lib/print.c b/lib/print.c index e33bff0..787c582 100644 --- a/lib/print.c +++ b/lib/print.c @@ -817,7 +817,8 @@ void hcl_dumpcnode (hcl_t* hcl, hcl_cnode_t* cnode, int newline) case HCL_CNODE_SUPER: case HCL_CNODE_ELLIPSIS: case HCL_CNODE_TRPCOLONS: - case HCL_CNODE_DCSTAR: + case HCL_CNODE_COLONSTAR: + case HCL_CNODE_COLONPLUS: hcl_logbfmt (hcl, HCL_LOG_FATAL, " %.*js ", HCL_CNODE_GET_TOKLEN(cnode), HCL_CNODE_GET_TOKPTR(cnode)); break; diff --git a/lib/read.c b/lib/read.c index b7e6375..cf4be6c 100644 --- a/lib/read.c +++ b/lib/read.c @@ -1432,8 +1432,12 @@ static int feed_process_token (hcl_t* hcl) frd->obj = hcl_makecnodetrpcolons(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl)); goto auto_xlist; - case HCL_TOK_DCSTAR: - frd->obj = hcl_makecnodedcstar(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl)); + case HCL_TOK_COLONPLUS: + frd->obj = hcl_makecnodecolonplus(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl)); + goto auto_xlist; + + case HCL_TOK_COLONSTAR: + frd->obj = hcl_makecnodecolonstar(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl)); goto auto_xlist; case HCL_TOK_SMPTRLIT: @@ -1652,8 +1656,9 @@ static delim_token_t delim_token_tab[] = { ":", 1, HCL_TOK_COLON }, /* key-value separator in dictionary */ { ":=", 2, HCL_TOK_COLONEQ }, /* assignment */ + { ":+", 2, HCL_TOK_COLONPLUS }, + { ":*", 2, HCL_TOK_COLONSTAR }, /* class instantiation method */ { "::", 2, HCL_TOK_DBLCOLONS }, - { "::*", 3, HCL_TOK_DCSTAR }, /* class instantiation method */ { ":::", 3, HCL_TOK_TRPCOLONS }, /* superclass, class variables, class methods */ { ";", 1, HCL_TOK_SEMICOLON } diff --git a/t/class-5001.err b/t/class-5001.err index 6436ff0..4ae97c6 100644 --- a/t/class-5001.err +++ b/t/class-5001.err @@ -3,7 +3,7 @@ defclass B | x y | { }; defclass X ::: B | a b | { - defun ::* new(t) { + defun :* new(t) { | a | set self.a t; set a 100; diff --git a/t/fun-01.hcl b/t/fun-01.hcl index f2eb65c..0f9d972 100644 --- a/t/fun-01.hcl +++ b/t/fun-01.hcl @@ -32,7 +32,7 @@ if (= k 70) { ## -------------------------------------- defclass A | a b c | { - defun ::* newInstance(x y z) { + defun :* newInstance(x y z) { (set a x) (set b y) (set c z) diff --git a/t/insta-01.hcl b/t/insta-01.hcl index ee6c55f..1154cf7 100644 --- a/t/insta-01.hcl +++ b/t/insta-01.hcl @@ -2,7 +2,7 @@ defclass A | a b c | { - defun ::* newInstance(x y z) { + defun:*newInstance(x y z) { set a x; set b y; set c z; @@ -16,7 +16,7 @@ defclass A | a b c | { defclass B ::: A | d e f | { - defun ::* newInstance(x y z) { + defun:*newInstance(x y z) { super:newInstance (* x 2) (* y 2) (* z 2); set d x; set e y; diff --git a/t/insta-02.hcl b/t/insta-02.hcl index 3152f1f..e25b362 100644 --- a/t/insta-02.hcl +++ b/t/insta-02.hcl @@ -1,6 +1,6 @@ set t ( class | x | { - defun ::* make() { set x 1234; return self; }; + defun :* make() { set x 1234; return self; }; defun get-x() { return x }; } ); diff --git a/t/var-01.hcl b/t/var-01.hcl index 7580616..7b15b09 100644 --- a/t/var-01.hcl +++ b/t/var-01.hcl @@ -68,7 +68,7 @@ (defclass T | j | - (defun ::* new() + (defun :* new() (set j 99) (return self) ) diff --git a/t/var-5001.err b/t/var-5001.err index bd4ea4a..c69935c 100644 --- a/t/var-5001.err +++ b/t/var-5001.err @@ -1,5 +1,5 @@ defclass A | a | { - defun ::* init1() { + defun :* init1() { | b | set b (+ 1 2); set a b; @@ -15,7 +15,7 @@ defclass A | a | { printf ">>> %d\n" j; } - defun ::* init2() { + defun :* init2() { | b | set b (+ 10 20); set a b;