view src/ploki/op.h @ 12292:d51f2100210c draft

<kspalaiologos> `` cat <<<"asmbf && bfi output.b" > /hackenv/ibin/asmbf
author HackEso <hackeso@esolangs.org>
date Thu, 02 Jan 2020 15:38:21 +0000
parents ac0403686959
children
line wrap: on
line source

#ifndef OP_H_
#define OP_H_

#include "IO.h"
#include "Str.h"
#include "expr.h"

#include <stddef.h>

enum t_op {
	OP_NOP,
	OP_ASSIGN,
	OP_CALL,
	OP_CALL_BACK,
	OP_CALL_DYN,
	OP_CLOSE,
	OP_ELSE,
	OP_EXIT,
	OP_FI,
	OP_FLUSH,
	OP_GOBACK,
	OP_GOTO,
	OP_HANG,
	OP_IF,
	OP_MODIFY,
	OP_PRINT,
	OP_PUTC,
	OP_RESET,
	OP_RETURN,
	OP_SET_VAL,
	OP_SYSTEM,
	OP_TEMP,
	OP_THROW
};

struct op {
	enum t_op type;
	struct expr *arg;
	union {
		struct expr *expr;
		struct op *op;
	} arh;
	struct op *next;
	String txt;
	size_t line;
};

void op_init(struct op *);
void op_end(struct op *);
void op_getop(struct op *);

#define OP_1ARG_P(op)                                             \
(                                                                 \
 (op) == OP_CALL   || (op) == OP_CALL_DYN || (op) == OP_CLOSE  || \
 (op) == OP_EXIT   || (op) == OP_FLUSH    || (op) == OP_GOTO   || \
 (op) == OP_IF     || (op) == OP_RESET    || (op) == OP_RETURN || \
 (op) == OP_SYSTEM || (op) == OP_THROW                            \
)

#define OP_2ARG_P(op)                                               \
(                                                                   \
 (op) == OP_ASSIGN || (op) == OP_CALL_BACK || (op) == OP_MODIFY  || \
 (op) == OP_PRINT  || (op) == OP_PUTC      || (op) == OP_SET_VAL || \
 (op) == OP_TEMP                                                    \
)

#endif /* OP_H_ */