1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
// Emacs style mode select -*- C++ -*-
//----------------------------------------------------------------------------
//
// $Id: t_parse.h,v 1.3 2001/08/06 23:57:10 stroggonmeth Exp $
//
// Copyright(C) 2000 Simon Howard
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Log: t_parse.h,v $
// Revision 1.3 2001/08/06 23:57:10 stroggonmeth
// Removed portal code, improved 3D floors in hardware mode.
//
// Revision 1.2 2001/03/13 22:14:20 stroggonmeth
// Long time no commit. 3D floors, FraggleScript, portals, ect.
//
// Revision 1.1 2000/11/02 17:57:28 stroggonmeth
// FraggleScript files...
//
//
//--------------------------------------------------------------------------
#ifndef __PARSE_H__
#define __PARSE_H__
#include "p_mobj.h" // for mobj_t
#include "m_fixed.h"
#define T_MAXTOKENS 128
#define TOKENLENGTH 128
#define intvalue(v) \
( (v).type == svt_string ? atoi((v).value.s) : \
(v).type == svt_fixed ? ((v).value.f / FRACUNIT) : \
(v).type == svt_mobj ? (v).value.mobj ? 1 : 0 : (v).value.i )
#define fixedvalue(v) \
( (v).type == svt_fixed ? (v).value.f : \
(v).type == svt_string ? (atof((v).value.s) * FRACUNIT) : \
intvalue(v) * FRACUNIT )
typedef struct script_s script_t;
typedef struct svalue_s svalue_t;
typedef struct operator_s operator_t;
struct svalue_s
{
int type;
union
{
long i;
fixed_t f;
char *s;
char *labelptr; // goto() label
mobj_t *mobj;
} value;
};
char *stringvalue(svalue_t v);
#include "t_vari.h"
#include "t_prepro.h"
#define MAXSCRIPTS 256
struct script_s
{
// script data
char *data;
int scriptnum; // this script's number
int len;
// {} sections
section_t *sections[SECTIONSLOTS];
// variables:
svariable_t *variables[VARIABLESLOTS];
// ptr to the parent script
// the parent script is the script above this level
// eg. individual linetrigger scripts are children
// of the levelscript, which is a child of the
// global_script
script_t *parent;
// child scripts.
// levelscript holds ptrs to all of the level's scripts
// here.
script_t *children[MAXSCRIPTS];
mobj_t *trigger; // object which triggered this script
//SoM: Used for if/elseif/else statements
boolean lastiftrue;
};
struct operator_s
{
char *string;
svalue_t (*handler)(int, int, int); // left, mid, right
int direction;
};
enum
{
forward,
backward
};
void run_script(script_t *script);
void continue_script(script_t *script, char *continue_point);
void parse_include(char *lumpname);
void run_statement();
void script_error(char *s, ...);
svalue_t evaluate_expression(int start, int stop);
int find_operator(int start, int stop, char *value);
int find_operator_backwards(int start, int stop, char *value);
/******* tokens **********/
typedef enum
{
name, // a name, eg 'count1' or 'frag'
number,
operator,
string,
unset,
function // function name
} tokentype_t;
enum // brace types: where current_section is a { or }
{
bracket_open,
bracket_close
};
extern svalue_t nullvar;
extern int script_debug;
extern script_t *current_script;
extern mobj_t *trigger_obj;
extern int killscript;
extern char *tokens[T_MAXTOKENS];
extern tokentype_t tokentype[T_MAXTOKENS];
extern int num_tokens;
extern char *rover; // current point reached in parsing
extern char *linestart; // start of the current expression
extern section_t *current_section;
extern section_t *prev_section;
extern int bracetype;
// the global_script is the root
// script and contains only built-in
// FraggleScript variables/functions
extern script_t global_script;
extern script_t hub_script;
#endif
//---------------------------------------------------------------------------
//
// $Log: t_parse.h,v $
// Revision 1.3 2001/08/06 23:57:10 stroggonmeth
// Removed portal code, improved 3D floors in hardware mode.
//
// Revision 1.2 2001/03/13 22:14:20 stroggonmeth
// Long time no commit. 3D floors, FraggleScript, portals, ect.
//
// Revision 1.1 2000/11/02 17:57:28 stroggonmeth
// FraggleScript files...
//
// Revision 1.1.1.1 2000/04/30 19:12:09 fraggle
// initial import
//
//
//---------------------------------------------------------------------------
|