⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node.dc

📁 Object-Oriented Programming With ANSI-C这本书中的源代码!找了很久
💻 DC
字号:
#include "parse.h"#include "Symbol.h"static void * nodes;		// chains all nodes% Node new {	struct Node * result =				cast(Node(), super_new(Node(), _self, app));	result -> next = nodes, nodes = result;	return (void *) result;}% Node sunder {%casts	if (nodes == self)				// first node		nodes = self -> next;	else if (nodes)					// other node	{	struct Node * np = nodes;		while (np -> next && np -> next != self)			np = np -> next;		// if this is called by delete() for a Fun expression		// the node has been detached when the expression was		// sent to setfun() by the parser, therefore, the node		// need not be on the chain...		if (np -> next)			np -> next = self -> next;	}	self -> next = 0;}% Node delete {%casts	sunder(self);	super_delete(Node(), self);}% Node reclaim {%casts	while (nodes)		how(nodes);}% Number ctor {	struct Number * self = super_ctor(Number(), _self, app);	self -> value = va_arg(* app, double);	return self;}% Number exec {%casts	return self -> value;}% Monad ctor {	struct Monad * self = super_ctor(Monad(), _self, app);	self -> down = va_arg(* app, void *);	return self;}% Val exec {%casts	return value(down(self));}% Unary dtor {%casts	delete(down(self));	return super_dtor(Unary(), self);}% Minus exec {%casts	return - exec(down(self));}% Dyad ctor {	struct Dyad * self = super_ctor(Dyad(), _self, app);	self -> left = va_arg(* app, void *);	self -> right = va_arg(* app, void *);	return self;}% Ref dtor {%casts	delete(right(self));	return super_dtor(Ref(), self);}% Assign exec {%casts	return setvalue(left(self), exec(right(self)));}% Builtin exec {%casts	return mathvalue(left(self), exec(right(self)));}% User exec {%casts	return funvalue(left(self), exec(right(self)));}% Binary dtor {%casts	delete(left(self));	delete(right(self));	return super_dtor(Binary(), self);}% Add exec {%casts	return exec(left(self)) + exec(right(self));}% Sub exec {%casts	return exec(left(self)) - exec(right(self));}% Mult exec {%casts	return exec(left(self)) * exec(right(self));}% Div exec {	double x;%casts	if ((x = exec(right(self))) == 0.0)		error("division by zero");	return exec(left(self)) / x;}%init

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -