tf5-5.0beta8/.git/
tf5-5.0beta8/.git/info/
tf5-5.0beta8/.git/logs/
tf5-5.0beta8/.git/logs/refs/heads/
tf5-5.0beta8/.git/objects/00/
tf5-5.0beta8/.git/objects/01/
tf5-5.0beta8/.git/objects/04/
tf5-5.0beta8/.git/objects/05/
tf5-5.0beta8/.git/objects/07/
tf5-5.0beta8/.git/objects/09/
tf5-5.0beta8/.git/objects/0a/
tf5-5.0beta8/.git/objects/0c/
tf5-5.0beta8/.git/objects/0e/
tf5-5.0beta8/.git/objects/12/
tf5-5.0beta8/.git/objects/13/
tf5-5.0beta8/.git/objects/14/
tf5-5.0beta8/.git/objects/16/
tf5-5.0beta8/.git/objects/17/
tf5-5.0beta8/.git/objects/19/
tf5-5.0beta8/.git/objects/1c/
tf5-5.0beta8/.git/objects/1d/
tf5-5.0beta8/.git/objects/1e/
tf5-5.0beta8/.git/objects/1f/
tf5-5.0beta8/.git/objects/20/
tf5-5.0beta8/.git/objects/21/
tf5-5.0beta8/.git/objects/23/
tf5-5.0beta8/.git/objects/27/
tf5-5.0beta8/.git/objects/29/
tf5-5.0beta8/.git/objects/2a/
tf5-5.0beta8/.git/objects/2b/
tf5-5.0beta8/.git/objects/2f/
tf5-5.0beta8/.git/objects/30/
tf5-5.0beta8/.git/objects/33/
tf5-5.0beta8/.git/objects/34/
tf5-5.0beta8/.git/objects/35/
tf5-5.0beta8/.git/objects/39/
tf5-5.0beta8/.git/objects/3c/
tf5-5.0beta8/.git/objects/3d/
tf5-5.0beta8/.git/objects/3f/
tf5-5.0beta8/.git/objects/40/
tf5-5.0beta8/.git/objects/41/
tf5-5.0beta8/.git/objects/42/
tf5-5.0beta8/.git/objects/44/
tf5-5.0beta8/.git/objects/46/
tf5-5.0beta8/.git/objects/47/
tf5-5.0beta8/.git/objects/48/
tf5-5.0beta8/.git/objects/4a/
tf5-5.0beta8/.git/objects/4d/
tf5-5.0beta8/.git/objects/4f/
tf5-5.0beta8/.git/objects/53/
tf5-5.0beta8/.git/objects/54/
tf5-5.0beta8/.git/objects/58/
tf5-5.0beta8/.git/objects/5b/
tf5-5.0beta8/.git/objects/5c/
tf5-5.0beta8/.git/objects/5e/
tf5-5.0beta8/.git/objects/5f/
tf5-5.0beta8/.git/objects/60/
tf5-5.0beta8/.git/objects/61/
tf5-5.0beta8/.git/objects/62/
tf5-5.0beta8/.git/objects/63/
tf5-5.0beta8/.git/objects/66/
tf5-5.0beta8/.git/objects/67/
tf5-5.0beta8/.git/objects/6c/
tf5-5.0beta8/.git/objects/6e/
tf5-5.0beta8/.git/objects/72/
tf5-5.0beta8/.git/objects/73/
tf5-5.0beta8/.git/objects/75/
tf5-5.0beta8/.git/objects/77/
tf5-5.0beta8/.git/objects/7a/
tf5-5.0beta8/.git/objects/7b/
tf5-5.0beta8/.git/objects/7c/
tf5-5.0beta8/.git/objects/7e/
tf5-5.0beta8/.git/objects/7f/
tf5-5.0beta8/.git/objects/81/
tf5-5.0beta8/.git/objects/84/
tf5-5.0beta8/.git/objects/86/
tf5-5.0beta8/.git/objects/87/
tf5-5.0beta8/.git/objects/88/
tf5-5.0beta8/.git/objects/8b/
tf5-5.0beta8/.git/objects/8c/
tf5-5.0beta8/.git/objects/8f/
tf5-5.0beta8/.git/objects/91/
tf5-5.0beta8/.git/objects/93/
tf5-5.0beta8/.git/objects/96/
tf5-5.0beta8/.git/objects/97/
tf5-5.0beta8/.git/objects/99/
tf5-5.0beta8/.git/objects/9a/
tf5-5.0beta8/.git/objects/9b/
tf5-5.0beta8/.git/objects/9c/
tf5-5.0beta8/.git/objects/9d/
tf5-5.0beta8/.git/objects/9e/
tf5-5.0beta8/.git/objects/a1/
tf5-5.0beta8/.git/objects/a3/
tf5-5.0beta8/.git/objects/a4/
tf5-5.0beta8/.git/objects/a6/
tf5-5.0beta8/.git/objects/a7/
tf5-5.0beta8/.git/objects/a8/
tf5-5.0beta8/.git/objects/a9/
tf5-5.0beta8/.git/objects/ab/
tf5-5.0beta8/.git/objects/ac/
tf5-5.0beta8/.git/objects/ae/
tf5-5.0beta8/.git/objects/b1/
tf5-5.0beta8/.git/objects/b2/
tf5-5.0beta8/.git/objects/b3/
tf5-5.0beta8/.git/objects/b7/
tf5-5.0beta8/.git/objects/b9/
tf5-5.0beta8/.git/objects/bb/
tf5-5.0beta8/.git/objects/bc/
tf5-5.0beta8/.git/objects/bd/
tf5-5.0beta8/.git/objects/bf/
tf5-5.0beta8/.git/objects/c0/
tf5-5.0beta8/.git/objects/c1/
tf5-5.0beta8/.git/objects/c2/
tf5-5.0beta8/.git/objects/c3/
tf5-5.0beta8/.git/objects/c5/
tf5-5.0beta8/.git/objects/c7/
tf5-5.0beta8/.git/objects/ca/
tf5-5.0beta8/.git/objects/ce/
tf5-5.0beta8/.git/objects/d1/
tf5-5.0beta8/.git/objects/d3/
tf5-5.0beta8/.git/objects/d4/
tf5-5.0beta8/.git/objects/d5/
tf5-5.0beta8/.git/objects/d8/
tf5-5.0beta8/.git/objects/d9/
tf5-5.0beta8/.git/objects/dc/
tf5-5.0beta8/.git/objects/dd/
tf5-5.0beta8/.git/objects/e1/
tf5-5.0beta8/.git/objects/e4/
tf5-5.0beta8/.git/objects/e5/
tf5-5.0beta8/.git/objects/e6/
tf5-5.0beta8/.git/objects/e7/
tf5-5.0beta8/.git/objects/e8/
tf5-5.0beta8/.git/objects/ea/
tf5-5.0beta8/.git/objects/eb/
tf5-5.0beta8/.git/objects/ed/
tf5-5.0beta8/.git/objects/ee/
tf5-5.0beta8/.git/objects/ef/
tf5-5.0beta8/.git/objects/f0/
tf5-5.0beta8/.git/objects/f4/
tf5-5.0beta8/.git/objects/f5/
tf5-5.0beta8/.git/objects/f6/
tf5-5.0beta8/.git/objects/f8/
tf5-5.0beta8/.git/objects/f9/
tf5-5.0beta8/.git/objects/fa/
tf5-5.0beta8/.git/objects/fb/
tf5-5.0beta8/.git/objects/fc/
tf5-5.0beta8/.git/objects/fd/
tf5-5.0beta8/.git/refs/heads/
tf5-5.0beta8/.git/refs/tags/
tf5-5.0beta8/autom4te.cache/
tf5-5.0beta8/macos/
tf5-5.0beta8/unix/
tf5-5.0beta8/win32/
/*************************************************************************
 *  TinyFugue - programmable mud client
 *  Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2005, 2006-2007 Ken Keys
 *
 *  TinyFugue (aka "tf") is protected under the terms of the GNU
 *  General Public License.  See the file "COPYING" for details.
 ************************************************************************/
/* $Id: parse.h,v 35004.51 2007/01/13 23:12:39 kkeys Exp $ */

#ifndef PARSE_H
#define PARSE_H

/* keywords: must be sorted and numbered sequentially */
typedef enum {
    BREAK = 0200, DO, DONE, ELSE, ELSEIF, ENDIF, EXIT, IF,
    LET, RESULT, RETURN, SET, SETENV, TEST, THEN, WHILE
} keyword_id_t;

#define OPNUM_MASK	0x007F

/* opcode type */
#define OPT_MASK	0x7000
#define OPT_EXPR	0x0000	/* must be zero, for ascii operators */
#define OPT_SUB		0x1000
#define OPT_JUMP	0x2000
#define OPT_CTRL	0x3000

/* opcode flag */
#define OPF_MASK	0x0080
#define OPF_0		0x0000
#define OPF_APP		0x0080	/* append (SUB & PSUB) */
#define OPF_NEG		0x0080	/* negate result (CTRL); negate cond (JUMP) */
#define OPF_SIDE	0x0080	/* has side effect (EXPR) */

/* opcode arg type */
#define OPA_MASK	0x0700
#define OPA_INT		0x0000	/* must be zero, for ascii operators */
#define OPA_NONE	0x0100
#define OPA_STRP	0x0200
#define OPA_CHAR	0x0300
#define OPA_VALP	0x0400
#define OPA_CMDP	0x0500

#define OPLABEL_MASK	(OPNUM_MASK | OPF_MASK)

#define op_type(op)			((op) & OPT_MASK)
#define op_type_is(op, type)		(op_type(op) == OPT_##type)
#define op_arg_type(op)			((op) & OPA_MASK)
#define op_arg_type_is(op, type)	(op_arg_type(op) == OPA_##type)
#define op_is_push(op)			(((op) & OPF_MASK) != OPF_APP)
#define op_is_append(op)		(((op) & OPF_MASK) == OPF_APP)
#define op_has_sideeffect(op)		(((op) & OPF_MASK) == OPF_SIDE)
#define opnum(op)			((op) & OPNUM_MASK)
#define opnum_eq(op1, op2)		(opnum(op1) == opnum(op2))

typedef enum {
#define defopcode(name, num, optype, argtype, flag) \
    OP_##name = (num | OPT_##optype | OPA_##argtype | OPF_##flag),
#include "opcodes.h"
    OP_ENDOFLIST = 0xffff
} opcode_t;


typedef union InstructionArg {
    int i;
    char c;
    conString *str;
    Value *val;
    struct BuiltinCmd *cmd;
} InstructionArg;

typedef struct Instruction {
    opcode_t op;
    union InstructionArg arg;
    const char *start, *end;	/* start/end points in source code, for mecho */
    int comefroms;		/* number of insts that jump to this one */
} Instruction;

struct Program {
    conString *src;	/* source code */
    int srcstart;	/* offset of start in src */
    const char *sip;	/* pointer into src->data, for compiling */
    Instruction *code;	/* compiled code */
    int len;		/* length of compiled code */
    int size;		/* size of code array */
    const char *mark;	/* pointer into source code, for mecho */
    int optimize;	/* opimization level */
};

typedef struct Arg {
    int start, end;
} Arg;

extern void        parse_error(Program *prog, const char *type,
		    const char *expect);
extern void        parse_error_suggest(Program *prog, const char *type,
		    const char *expect, const char *suggestion);
extern int         varsub(Program *prog, int sub_warn, int in_expr);
extern int         exprsub(Program *prog, int in_expr);
extern int         dollarsub(Program *prog, String **destp);
extern conString  *valstr(Value *val);
extern const char *valstd(Value *val);
extern long        valint(const Value *val);
extern int         valtime(struct timeval *tv, const Value *val);
extern int         valbool(const Value *val);
#if !NO_FLOAT
extern double      valfloat(const Value *val);
#endif /* NO_FLOAT */
extern void       *valptr(Value *val);
extern int         pushval(Value *val);
extern void        freeval_fl(Value *val, const char *file, int line);
extern Value      *expr_value(const char *expression);
extern Value      *expr_value_safe(Program *prog);
extern void        code_add(Program *prog, opcode_t op, ...);
extern int         reduce(opcode_t op, int n);
extern const char *oplabel(opcode_t op);

extern struct Value *newptr_fl(void *ptr, const char *file, int line);

#define popval() \
    ((Value*)stack[--stacktop])

/* get Nth operand from stack (counting backwards from top) */
#define opd(N)          (stack[stacktop-(N)])
#define opdfloat(N)     valfloat(opd(N))	/* float value of opd(N) */
#define opdint(N)       valint(opd(N))		/* int value of opd(N) */
#define opdbool(N)      valbool(opd(N))		/* boolean value of opd(N) */
#define opdstr(N)       valstr(opd(N))		/* String value of opd(N) */
#define opdstd(N)       valstd(opd(N))		/* String data of opd(N) */
#define opdtime(tv, N)  valtime(tv, opd(N))	/* copy timeval of opd(N) */

#define freeval(val)	freeval_fl((val), __FILE__, __LINE__)

#define comefrom(prog, from, to) \
    do { \
	if (from >= 0) { \
	    (prog)->code[(from)].arg.i = (to); \
	    (prog)->code[(to)].comefroms++; \
	} \
    } while (0)

#define ip  (prog->sip)	/* XXX */

extern Value *stack[];			/* expression stack */
extern int stacktop;			/* first free position on stack */
extern Arg *tf_argv;			/* shifted command argument vector */
extern int tf_argc;			/* shifted command/function arg count */
extern int argtop;			/* top of function argument stack */
extern const conString *argstring;	/* command argument text */
extern keyword_id_t block;		/* type of current expansion block */
extern int condition;			/* checked by /if and /while */
extern int evalflag;			/* flag: should we evaluate? */

#endif /* PARSE_H */