added a new special word and and or. compiler yet to be enhanced
This commit is contained in:
parent
5aee382e9e
commit
c387772803
19
lib/comp.c
19
lib/comp.c
@ -650,6 +650,17 @@ enum
|
||||
};
|
||||
|
||||
/* ========================================================================= */
|
||||
static int compile_and (hcl_t* hcl, hcl_oop_t src)
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_ENOIMPL, "and not implemented");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int compile_or (hcl_t* hcl, hcl_oop_t src)
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_ENOIMPL, "or not implemented");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int compile_break (hcl_t* hcl, hcl_oop_t src)
|
||||
{
|
||||
@ -1301,6 +1312,10 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
|
||||
{
|
||||
switch (syncode)
|
||||
{
|
||||
case HCL_SYNCODE_AND:
|
||||
if (compile_and(hcl, obj) <= -1) return -1;
|
||||
break;
|
||||
|
||||
case HCL_SYNCODE_BREAK:
|
||||
/* break */
|
||||
if (compile_break(hcl, obj) <= -1) return -1;
|
||||
@ -1331,6 +1346,10 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
|
||||
if (compile_lambda(hcl, obj, 0) <= -1) return -1;
|
||||
break;
|
||||
|
||||
case HCL_SYNCODE_OR:
|
||||
if (compile_or(hcl, obj) <= -1) return -1;
|
||||
break;
|
||||
|
||||
case HCL_SYNCODE_SET:
|
||||
/* (set x 10)
|
||||
* (set x (lambda (x y) (+ x y)) */
|
||||
|
3
lib/gc.c
3
lib/gc.c
@ -34,7 +34,7 @@ static struct
|
||||
hcl_oow_t offset;
|
||||
} syminfo[] =
|
||||
{
|
||||
|
||||
{ 3, { 'a','n','d' }, HCL_SYNCODE_AND, HCL_OFFSETOF(hcl_t,_and) },
|
||||
{ 5, { 'b','r','e','a','k' }, HCL_SYNCODE_BREAK, HCL_OFFSETOF(hcl_t,_break) },
|
||||
{ 5, { 'd','e','f','u','n' }, HCL_SYNCODE_DEFUN, HCL_OFFSETOF(hcl_t,_defun) },
|
||||
{ 2, { 'd','o' }, HCL_SYNCODE_DO, HCL_OFFSETOF(hcl_t,_do) },
|
||||
@ -42,6 +42,7 @@ static struct
|
||||
{ 4, { 'e','l','s','e' }, HCL_SYNCODE_ELSE, HCL_OFFSETOF(hcl_t,_else) },
|
||||
{ 2, { 'i','f' }, HCL_SYNCODE_IF, HCL_OFFSETOF(hcl_t,_if) },
|
||||
{ 6, { 'l','a','m','b','d','a' }, HCL_SYNCODE_LAMBDA, HCL_OFFSETOF(hcl_t,_lambda) },
|
||||
{ 2, { 'o','r' }, HCL_SYNCODE_OR, HCL_OFFSETOF(hcl_t,_or) },
|
||||
{ 6, { 'r','e','t','u','r','n'}, HCL_SYNCODE_RETURN, HCL_OFFSETOF(hcl_t,_return) },
|
||||
{ 3, { 's','e','t' }, HCL_SYNCODE_SET, HCL_OFFSETOF(hcl_t,_set) },
|
||||
{ 5, { 'u','n','t','i','l' }, HCL_SYNCODE_UNTIL, HCL_OFFSETOF(hcl_t,_until) },
|
||||
|
@ -1004,6 +1004,7 @@ struct hcl_t
|
||||
hcl_oop_t _true;
|
||||
hcl_oop_t _false;
|
||||
|
||||
hcl_oop_t _and; /* symbol */
|
||||
hcl_oop_t _break; /* symbol */
|
||||
hcl_oop_t _defun; /* symbol */
|
||||
hcl_oop_t _do; /* symbol */
|
||||
@ -1011,6 +1012,7 @@ struct hcl_t
|
||||
hcl_oop_t _else; /* symbol */
|
||||
hcl_oop_t _if; /* symbol */
|
||||
hcl_oop_t _lambda; /* symbol */
|
||||
hcl_oop_t _or; /* symbol */
|
||||
hcl_oop_t _return; /* symbol */
|
||||
hcl_oop_t _set; /* symbol */
|
||||
hcl_oop_t _until; /* symbol */
|
||||
@ -1269,13 +1271,15 @@ typedef enum hcl_brand_t hcl_brand_t;
|
||||
enum hcl_syncode_t
|
||||
{
|
||||
/* SYNCODE 0 means it's not a syncode object. so it begins with 1 */
|
||||
HCL_SYNCODE_BREAK = 1,
|
||||
HCL_SYNCODE_AND = 1,
|
||||
HCL_SYNCODE_BREAK,
|
||||
HCL_SYNCODE_DEFUN,
|
||||
HCL_SYNCODE_DO,
|
||||
HCL_SYNCODE_ELIF,
|
||||
HCL_SYNCODE_ELSE,
|
||||
HCL_SYNCODE_IF,
|
||||
HCL_SYNCODE_LAMBDA,
|
||||
HCL_SYNCODE_OR,
|
||||
HCL_SYNCODE_RETURN,
|
||||
HCL_SYNCODE_SET,
|
||||
HCL_SYNCODE_UNTIL,
|
||||
|
Loading…
Reference in New Issue
Block a user