home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / bwbasic-2.10.sit / bwbasic-2.10 / bwbasic.h < prev    next >
Text File  |  1996-10-14  |  54KB  |  1,394 lines

  1. /***************************************************************
  2.  
  3.         bwbasic.h       Header File
  4.                         for Bywater BASIC Interpreter
  5.  
  6.                         Copyright (c) 1993, Ted A. Campbell
  7.                         Bywater Software
  8.  
  9.                         email: tcamp@delphi.com
  10.  
  11.         Copyright and Permissions Information:
  12.  
  13.         All U.S. and international rights are claimed by the author,
  14.         Ted A. Campbell.
  15.  
  16.     This software is released under the terms of the GNU General
  17.     Public License (GPL), which is distributed with this software
  18.     in the file "COPYING".  The GPL specifies the terms under
  19.     which users may copy and use the software in this distribution.
  20.  
  21.     A separate license is available for commercial distribution,
  22.     for information on which you should contact the author.
  23.  
  24. ***************************************************************/
  25.  
  26.  
  27. #ifndef TRUE
  28. #define TRUE    -1
  29. #define FALSE   0
  30. #endif
  31.  
  32. /***************************************************************
  33.  
  34.     bwbasic.h    Part I: Definitions
  35.  
  36. ***************************************************************/
  37.  
  38. /* Version number */
  39.  
  40. #define VERSION         "2.10"          /* Current version number */
  41.  
  42. /***************************************************************
  43.  
  44.     bwbasic.h:    Part I-A: Define Major Hardware Implementation
  45.  
  46.             Gone is the simplicity of earlier versions.
  47.             You must specify one and only one of the
  48.             following hardware implementations as TRUE.
  49.             IMP_TTY is the default implementation.
  50.             It is the most minimal, but the most
  51.             universal hardware implementation.
  52.  
  53. ***************************************************************/
  54.  
  55. #define IMP_TTY         FASLE     /* simple TTY-style interface using stdio */
  56. #define IMP_IQC         TRUE    /* IBM PC, Microsoft QuickC Compiler */
  57. #define MACINTOSH_CMDS FALSE     // not supported yet
  58.  
  59. #if IMP_TTY
  60. #include "bwx_tty.h"
  61. #endif
  62.  
  63. #if IMP_IQC
  64. #include "bwx_iqc.h"
  65. #endif
  66.  
  67. /***************************************************************
  68.  
  69.     bwbasic.h:    Part I-B: Define Compiler Implementation
  70.  
  71.             You also need to give some information about
  72.             your C compiler.  If your compiler is ANSI-
  73.             compatible, don't worry about these.  But
  74.             if your compiler is "stock," you might
  75.             want to indicate which of the following
  76.             sets of features it has or dosn't have.
  77.  
  78. ***************************************************************/
  79.  
  80. #ifdef MSDOS
  81. #define HAVE_RAISE TRUE
  82. #define HAVE_STRING TRUE
  83. #define HAVE_STDLIB TRUE
  84. #endif
  85.  
  86. #ifdef __STDC__
  87. #define    HAVE_SIGNAL    TRUE
  88. #else
  89. #define    HAVE_SIGNAL    TRUE    /* Compiler supports signal() */
  90. #endif
  91.  
  92. #ifdef __STDC__
  93. #define    HAVE_LONGJUMP    TRUE
  94. #else
  95. #define    HAVE_LONGJUMP    TRUE    /* Compiler supports setjmp() and longjmp() */
  96. #endif
  97.  
  98. /* configure sets this */
  99. #ifndef HAVE_RAISE
  100. #define HAVE_RAISE    TRUE    /* Compiler supports raise() */
  101. #endif
  102.  
  103. /* configure sets this */
  104. #ifndef HAVE_STRING
  105. #define    HAVE_STRING    TRUE    /* Compiler has <string.h> header */
  106. #endif
  107.  
  108. /* configure sets this */
  109. #ifndef HAVE_STDLIB
  110. #define HAVE_STDLIB    TRUE    /* Compiler has <stdlib.h> header */
  111. #endif
  112.  
  113. #ifdef __STDC__
  114. #define HAVE_SYSTYPES    FALSE
  115. #else
  116. #define HAVE_SYSTYPES    FALSE    /* Compiler has <sys/types.h> header */
  117. #endif
  118.  
  119. #ifdef __STDC__
  120. #define HAVE_SYSSTAT    FALSE
  121. #else
  122. #define HAVE_SYSSTAT    FALSE    /* Compiler has <sys/stat.h> header */
  123. #endif
  124.  
  125. /***************************************************************
  126.  
  127.     bwbasic.h:    Part I-C: Define Program Configuration
  128.  
  129.             You must specify one and only one of the
  130.             following progrm configurations as TRUE.
  131.             If you specify CFG_CUSTOM, then you will
  132.             need to fill out the custom section below.
  133.  
  134. ***************************************************************/
  135.  
  136. #define    CFG_ANSIMINIMAL    FALSE   /* Conforms to ANSI Minimal BASIC standard X3.60-1978 */
  137. #define CFG_COMMON      FALSE   /* Small implementation with commands and functions common to GWBASIC (tm) and ANSI full BASIC */
  138. #define CFG_MSTYPE      FALSE   /* Configuration similar to Microsoft line-oriented BASICs */
  139. #define    CFG_ANSIFULL    FALSE    /* Conforms to ANSI Full BASIC standard X3.113-1987 */
  140. #define CFG_CUSTOM      TRUE    /* Custom Configuration specified below */
  141.  
  142. /***************************************************************
  143.  
  144.     bwbasic.h:    Part I-D: Define Custom Program Configuration
  145.  
  146.             If you specified CFG_CUSTOM above, then
  147.             you will need to fill out this section.
  148.  
  149. ***************************************************************/
  150.  
  151. #if CFG_CUSTOM
  152. #define COMMAND_SHELL   TRUE        /* allow command shell processing */
  153. #define PROFILE         FALSE           /* interpret profile at beginning */
  154. #define NUMBER_DOUBLE    FALSE        /* define BASIC number as double: default is float*/
  155. #define MULTISEG_LINES  TRUE            /* allow multi-segment lines delimited by ':' */
  156. #define PARACT        FALSE        /* Implement PARallen ACTion (Multi-tasking) interpreter */
  157. #define INTERACTIVE    TRUE        /* interactive programming environment and related commands */
  158. #define COMMON_CMDS    TRUE        /* commands common to ANSI full BASIC and GWBASIC */
  159. #if UNIX_CMDS
  160. #define UNIX_CMDS    TRUE         /* implement Unix-style directory commands  */
  161. #endif
  162. #define STRUCT_CMDS     TRUE           /* commands for structured programming required by full ANSI BASIC */
  163. #define MS_CMDS         FALSE            /* commands specific to Microsoft GWBASIC (tm) */
  164. #define MS_FUNCS        FALSE            /* Microsoft-specific functions and commands */
  165. #define    COMMON_FUNCS    TRUE        /* functions common to GWBASIC and ANSI full BASIC */
  166. #define ANSI_FUNCS    TRUE        /* functions required by ANSI full BASIC */
  167. #endif                    /* end of CFG_CUSTOM */
  168.  
  169. /***************************************************************
  170.  
  171.     bwbasic.h:    Part I-E: Define Natural Language for Messages
  172.  
  173.             One and only one of the following must be
  174.             defined as TRUE.  Note that the language
  175.             definitions themselves are in file bwb_mes.h.
  176.             If none is specified, then ENGLISH will be
  177.             taken as the default.
  178.  
  179. ***************************************************************/
  180.  
  181. #define STD_ENGLISH     TRUE            /* standard English */
  182. #define POL_ENGLISH     FALSE        /* polite English messages */
  183. #define IMP_ENGLISH    FALSE        /* impolite English messages */
  184. #define LATIN        FALSE        /* Latin language messages */
  185. #define STD_RUSSIAN    FALSE        /* Russian language messages */
  186. #define STD_GERMAN      FALSE           /* German language messages */
  187. #define ESPERANTO       FALSE           /* Esperanto messages */
  188.  
  189. /***************************************************************
  190.  
  191.     bwbasic.h:    Part I-F: Define Debugging Options
  192.  
  193.             You can specify debugging options here.
  194.  
  195. ***************************************************************/
  196.  
  197. #define DEBUG           FALSE         /* current debugging */
  198. #define PROG_ERRORS     FALSE       /* identify serious programming errors */
  199.                     /* and print extensive error messages */
  200.                     /* This will override messages defined in */
  201.                     /* bwb_mes.h, and almost all messages will be in English */
  202. #define CHECK_RECURSION FALSE        /* check for recursion violation in expression parser */
  203. #define INTENSIVE_DEBUG FALSE           /* old debugging; might be useful later */
  204. #define REDIRECT_STDERR FALSE           /* Redirect stderr to file ERRFILE */
  205. #define TEST_BSTRING    FALSE           /* test bstring integrity */
  206.  
  207. #ifdef __STDC__
  208. #define ANSI_C          TRUE            /* FALSE to test and debug non-ANSI-C version
  209.                        with ANSI C compiler (watch out) */
  210. #endif
  211.  
  212. /***************************************************************
  213.  
  214.     bwbasic.h:    This ends the section of definitions that
  215.             users of bwBASIC will normally need to
  216.             specify. The following are internally defined
  217.  
  218. ***************************************************************/
  219.  
  220. #if CFG_ANSIMINIMAL
  221. #define COMMAND_SHELL   FALSE        /* allow command shell processing */
  222. #define PROFILE        FALSE        /* interpret profile at beginning */
  223. #define NUMBER_DOUBLE    FALSE        /* define BASIC number as double: default is float*/
  224. #define MULTISEG_LINES    FALSE        /* allow multi-segment lines delimited by ':' */
  225. #define PARACT        FALSE        /* Implement PARallen ACTion (Multi-tasking) interpreter */
  226. #define INTERACTIVE    TRUE        /* interactive programming environment and related commands */
  227. #define COMMON_CMDS    FALSE        /* commands common to ANSI full BASIC and GWBASIC */
  228. #if UNIX_CMDS
  229. #define UNIX_CMDS    FALSE         /* implement Unix-style directory commands  */
  230. #endif
  231. #define STRUCT_CMDS    FALSE        /* commands for structured programming required by full ANSI BASIC */
  232. #define MS_CMDS    FALSE        /* commands specific to Microsoft GWBASIC (tm) */
  233. #define MS_FUNCS    FALSE        /* Microsoft-specific functions and commands */
  234. #define    COMMON_FUNCS    FALSE        /* functions common to GWBASIC and ANSI full BASIC */
  235. #define ANSI_FUNCS    FALSE        /* functions required by ANSI full BASIC */
  236. #endif                    /* end of CFG_ANSIMINIMAL */
  237.  
  238. #if CFG_COMMON
  239. #define COMMAND_SHELL   FALSE        /* allow command shell processing */
  240. #define PROFILE        FALSE        /* interpret profile at beginning */
  241. #define NUMBER_DOUBLE    FALSE        /* define BASIC number as double: default is float*/
  242. #define MULTISEG_LINES    FALSE        /* allow multi-segment lines delimited by ':' */
  243. #define PARACT        FALSE        /* Implement PARallen ACTion (Multi-tasking) interpreter */
  244. #define INTERACTIVE    TRUE        /* interactive programming environment and related commands */
  245. #define COMMON_CMDS    TRUE        /* commands common to ANSI full BASIC and GWBASIC */
  246. #if UNIX_CMDS
  247. #define UNIX_CMDS    FALSE         /* implement Unix-style directory commands  */
  248. #endif
  249. #define STRUCT_CMDS    FALSE        /* commands for structured programming required by full ANSI BASIC */
  250. #define MS_CMDS    FALSE        /* commands specific to Microsoft GWBASIC (tm) */
  251. #define MS_FUNCS    FALSE        /* Microsoft-specific functions and commands */
  252. #define    COMMON_FUNCS    TRUE        /* functions common to GWBASIC and ANSI full BASIC */
  253. #define ANSI_FUNCS    FALSE        /* functions required by ANSI full BASIC */
  254. #endif                    /* end of CFG_COMMON */
  255.  
  256. #if CFG_ANSIFULL
  257. #define COMMAND_SHELL   TRUE        /* allow command shell processing */
  258. #define PROFILE        TRUE        /* interpret profile at beginning */
  259. #define NUMBER_DOUBLE    FALSE        /* define BASIC number as double: default is float*/
  260. #define MULTISEG_LINES    FALSE        /* allow multi-segment lines delimited by ':' */
  261. #define PARACT        TRUE        /* Implement PARallen ACTion (Multi-tasking) interpreter */
  262. #define INTERACTIVE    TRUE        /* interactive programming environment and related commands */
  263. #define COMMON_CMDS    TRUE        /* commands common to ANSI full BASIC and GWBASIC */
  264. #if UNIX_CMDS
  265. #define UNIX_CMDS    FALSE         /* implement Unix-style directory commands  */
  266. #endif
  267. #define STRUCT_CMDS    TRUE        /* commands for structured programming required by full ANSI BASIC */
  268. #define MS_CMDS    FALSE        /* commands specific to Microsoft GWBASIC (tm) */
  269. #define MS_FUNCS    FALSE        /* Microsoft-specific functions and commands */
  270. #define    COMMON_FUNCS    TRUE        /* functions common to GWBASIC and ANSI full BASIC */
  271. #define ANSI_FUNCS    TRUE        /* functions required by ANSI full BASIC */
  272. #endif                    /* end of CFG_ANSIFULL */
  273.  
  274. #if CFG_MSTYPE
  275. #define COMMAND_SHELL   FALSE        /* allow command shell processing */
  276. #define PROFILE        FALSE        /* interpret profile at beginning */
  277. #define NUMBER_DOUBLE    FALSE        /* define BASIC number as double: default is float*/
  278. #define MULTISEG_LINES    TRUE        /* allow multi-segment lines delimited by ':' */
  279. #define PARACT        FALSE        /* Implement PARallen ACTion (Multi-tasking) interpreter */
  280. #define INTERACTIVE    TRUE        /* interactive programming environment and related commands */
  281. #define COMMON_CMDS    TRUE        /* commands common to ANSI full BASIC and GWBASIC */
  282. #define STRUCT_CMDS    FALSE        /* commands for structured programming required by full ANSI BASIC */
  283. #define MS_CMDS    TRUE        /* commands specific to Microsoft GWBASIC (tm) */
  284. #define MS_FUNCS    TRUE        /* Microsoft-specific functions and commands */
  285. #define    COMMON_FUNCS    TRUE        /* functions common to GWBASIC and ANSI full BASIC */
  286. #define ANSI_FUNCS    FALSE        /* functions required by ANSI full BASIC */
  287. #endif                                  /* end of CFG_MSTYPE */
  288.  
  289. /* inclusions and definitions necessary if C compiler is not ANSI compliant */
  290.  
  291. #if HAVE_STRING
  292. #include <string.h>
  293. #else
  294. #include <strings.h>
  295. #endif
  296.  
  297. #if HAVE_STDLIB
  298. #include <stdlib.h>
  299. #endif
  300.  
  301. #if HAVE_SYSTYPES
  302. #include <sys/types.h>
  303. #endif
  304.  
  305. #if HAVE_STDLIB                /* if neither ANSI */
  306. #else
  307. #if HAVE_SYSTYPES            /* nor SYSTYPES */
  308. #else
  309. #define size_t    unsigned int        /* then define these */
  310. #define time_t     long 
  311. #endif
  312. #endif
  313.  
  314. /* define number of commands */
  315.  
  316. #define CMDS_CORE       22              /* number of core commands defined */
  317. #if UNIX_CMDS
  318. #define CMDS_DIR    5
  319. #else
  320. #define CMDS_DIR    0
  321. #endif
  322. #if COMMON_CMDS
  323. #define CMDS_COMMON    24
  324. #else
  325. #define CMDS_COMMON    0
  326. #endif
  327. #if STRUCT_CMDS
  328. #define CMDS_STC    10
  329. #else
  330. #define CMDS_STC    0
  331. #endif
  332. #if INTERACTIVE
  333. #define CMDS_INT    8
  334. #else
  335. #define CMDS_INT    0
  336. #endif
  337. #if MS_CMDS
  338. #define CMDS_MS         5+IMP_CMDCLS+IMP_CMDLOC+IMP_CMDCOLOR
  339. #else
  340. #define CMDS_MS        0
  341. #endif
  342. #if DEBUG
  343. #define CMDS_DEBUG      3               /* number of debugging cmds */
  344. #else
  345. #define CMDS_DEBUG      0               /* no debugging cmds */
  346. #endif
  347. #define COMMANDS        (CMDS_CORE+CMDS_DEBUG+CMDS_DIR+CMDS_COMMON+CMDS_INT+CMDS_MS+CMDS_STC)
  348.  
  349. /* define number of functions */
  350.  
  351. #define FUNCS_BASE      12        /* number of basic functions */
  352. #ifdef INTENSIVE_DEBUG
  353. #define FUNCS_DEBUG    1        /* number of debugging functions */
  354. #else
  355. #define FUNCS_DEBUG    0        /* number of debugging functions */
  356. #endif
  357. #if MS_FUNCS
  358. #define FUNCS_MS        (25+IMP_FNCINKEY)
  359. #else
  360. #define FUNCS_MS    0
  361. #endif
  362. #if COMMON_FUNCS
  363. #define FUNCS_COMMON    7
  364. #else
  365. #define FUNCS_COMMON    0
  366. #endif
  367. #if ANSI_FUNCS
  368. #define FUNCS_ANSI    0
  369. #else
  370. #define FUNCS_ANSI    0
  371. #endif
  372. #define FUNCTIONS    (FUNCS_BASE+FUNCS_DEBUG+FUNCS_MS+FUNCS_COMMON+FUNCS_ANSI)
  373.  
  374. /* Check for inconsistencies */
  375.  
  376. #if MULTISEG_LINES & STRUCT_CMDS
  377. /* ERROR:  MULTISEG_LINES and STRUCT_CMDS cannot be defined together! */
  378. #endif
  379.  
  380. #define DEF_EDITOR      ""              /* default editor */
  381. #define DEF_FILES       ""              /* default "files" command */
  382. #define DEF_COLORS      0               /* default # of colors */
  383. #define DEFVNAME_EDITOR "BWB.EDITOR$"   /* default variable name for EDITOR */
  384. #define DEFVNAME_PROMPT "BWB.PROMPT$"   /* default variable name for PROMPT */
  385. #define DEFVNAME_FILES  "BWB.FILES$"    /* default variable name for FILES */
  386. #define DEFVNAME_COLORS "BWB.COLORS"    /* default variable name for COLORS */
  387. #define DEFVNAME_IMPL   "BWB.IMPLEMENTATION$" /* default variable name for IMPLEMENTATION */
  388. #define ERRFILE         "err.out"       /* Filename for redirected error messages */
  389. #define PROFILENAME    "profile.bas"    /* Filename for profile execution */
  390. #define    TASKS        4        /* number of tasks available */
  391. #define MAXARGSIZE      128             /* maximum size of argument */
  392. #define MAXREADLINESIZE 256             /* size of read_line buffer */
  393. #define MAXCMDNAMESIZE  64              /* maximum size for command name */
  394. #define MAXLINENO       32766           /* maximum line number */
  395. #define MAXVARNAMESIZE  40              /* maximum size for variable name */
  396. #define MAXFILENAMESIZE 40              /* maximum size for file name */
  397. #define MAXSTRINGSIZE   255             /* maximum string length */
  398. #define EXECLEVELS      64              /* EXEC stack levels */
  399. #define MAX_GOLINES     12              /* Maximum # of lines for ON...GOTO statements */
  400. #define MAX_FARGS       6               /* maximum # arguments to function */
  401. #define MAX_DIMS    64        /* maximum # of dimensions */
  402. #define ESTACKSIZE      64              /* elements in expression stack */
  403. #define XTXTSTACKSIZE   16              /* elements in eXecute TeXT stack */
  404. #define N_OPERATORS     24              /* number of operators defined */
  405. #define N_ERRORS    25        /* number of errors defined */
  406. #define MAX_PRECEDENCE  19              /* highest (last) level of precedence */
  407. #define MININTSIZE      -32767          /* minimum integer size */
  408. #define MAXINTSIZE       32767          /* maximum integer size */
  409. #define DEF_SUBSCRIPT   11              /* default subscript */
  410. #define DEF_DEVICES     16              /* default number of devices available */
  411. #define DEF_WIDTH    128        /* default width for devices */
  412. #define PRN_TAB        0x02        /* send TAB followed by col number to output device */
  413. #define COMPRESS_FUNCS  TRUE
  414.  
  415. /* Derivative definitions */
  416.  
  417. #if MULTISEG_LINES
  418. #define MARK_LINES    FALSE
  419. #else
  420. #define MARK_LINES    TRUE
  421. #endif
  422.  
  423. #if PARACT
  424. #define CURTASK        bwb_tasks[ bwb_curtask ]->
  425. #define LOCALTASK    bwb_tasks[ task ]->
  426. #else
  427. #define CURTASK
  428. #define LOCALTASK
  429. #endif
  430.  
  431. #if DEBUG
  432. #define PERMANENT_DEBUG TRUE
  433. #else
  434. #define PERMANENT_DEBUG FALSE
  435. #endif
  436.  
  437. #if HAVE_STDLIB
  438. #else
  439. extern char *calloc();
  440.  
  441. #ifndef NULL
  442. #define NULL    0L
  443. #endif
  444.  
  445. #endif
  446.  
  447. /* typedef for BASIC number */
  448.  
  449. #if NUMBER_DOUBLE
  450. typedef double bnumber;
  451. #else
  452. typedef float bnumber;
  453. #endif
  454.  
  455. /* define variable types based on last character */
  456.  
  457. #define STRING          '$'
  458.  
  459. /* define mathematical operations */
  460.  
  461. #define MULTIPLY        '*'
  462. #define DIVIDE          '/'
  463. #define ADD             '+'
  464. #define SUBTRACT        '-'
  465. #define ARGUMENT        'A'
  466.  
  467. /* Operations defined */
  468.  
  469. #define OP_ERROR        -255        /* operation error (break out) */
  470. #define OP_NULL         0               /* null: operation not defined yet */
  471. #define NUMBER          1               /* number held as internal variable in uvar */
  472. #define CONST_STRING    2               /* string constant */
  473. #define CONST_NUMERICAL 3               /* numerical constant */
  474. #define FUNCTION        4               /* function header */
  475. #define VARIABLE        5               /* external variable pointed to by xvar */
  476. #define PARENTHESIS     6               /* begin parenthetical expression */
  477. #define OP_ADD          7               /* addition sign '+' */
  478. #define OP_SUBTRACT     8               /* subtraction sign '-' */
  479. #define OP_MULTIPLY     9               /* multiplication sign '*' */
  480. #define OP_DIVIDE       10              /* division sign '/' */
  481. #define OP_MODULUS      11              /* modulus "MOD" */
  482. #define OP_EXPONENT     12              /* exponentiation '^' */
  483. #define OP_INTDIVISION  13              /* integer division sign '¥' */
  484. #define OP_NEGATION     14              /* negation '-' ??? */
  485. #define OP_STRJOIN      15              /* string join ';' */
  486. #define OP_STRTAB       16              /* string tab ',' */
  487. #define OP_EQUALS       17              /* either logical equal operator */
  488. #define OP_ASSIGN       18              /* assignment operator */
  489. #define OP_NOTEQUAL     20              /* inequality */
  490. #define OP_LESSTHAN     21              /* less than */
  491. #define OP_GREATERTHAN  22              /* greater than */
  492. #define OP_LTEQ         23              /* less than or equal to */
  493. #define OP_GTEQ         24              /* greater than or equal to */
  494. #define OP_NOT          25              /* negation */
  495. #define OP_AND          26              /* conjunction */
  496. #define OP_OR           27              /* disjunction */
  497. #define OP_XOR          28              /* exclusive or */
  498. #define OP_IMPLIES      29              /* implication */
  499. #define OP_EQUIV        30              /* equivalence */
  500. #define OP_TERMINATE    31              /* terminate expression parsing */
  501. #define OP_USERFNC    32        /* user-defined function */
  502.  
  503. /* Device input/output modes */
  504.  
  505. #define DEVMODE_AVAILABLE  -1
  506. #define DEVMODE_CLOSED     0
  507. #define DEVMODE_OUTPUT     1
  508. #define DEVMODE_INPUT      2
  509. #define DEVMODE_APPEND     3
  510. #define DEVMODE_RANDOM     4
  511.  
  512. /* codes for EXEC stack and for function-sub-label lookup table */
  513.  
  514. #define EXEC_NORM    0
  515. #define    EXEC_GOSUB    1
  516. #define    EXEC_WHILE    2
  517. #define EXEC_FOR        3
  518. #define EXEC_FUNCTION    4
  519. #define EXEC_CALLSUB    5
  520. #define EXEC_IFTRUE    6
  521. #define EXEC_IFFALSE    7
  522. #define EXEC_MAIN    8
  523. #define EXEC_SELTRUE    9
  524. #define EXEC_SELFALSE    10
  525. #define EXEC_LABEL      11
  526. #define EXEC_DO         12
  527. #define EXEC_ON         13
  528.  
  529. /***************************************************************
  530.  
  531.     bwbasic.h    Part II: Structures
  532.  
  533. ***************************************************************/
  534.  
  535. /* Typdef structure for strings under Bywater BASIC */
  536.  
  537. typedef struct bstr
  538.    {
  539.    unsigned char length;        /* length of string */
  540.    char *sbuffer;            /* pointer to string buffer */
  541.    int rab;                /* is it a random-access buffer? */
  542. #if TEST_BSTRING
  543.    char name[ MAXVARNAMESIZE + 1 ];    /* name for test purposes */
  544. #endif
  545.    } bstring;
  546.  
  547. /* Structure used for all variables under Bywater BASIC */
  548.  
  549. struct bwb_variable
  550.    {
  551.    char name[ MAXVARNAMESIZE + 1 ];    /* name */
  552.    int type;                            /* type, i.e., STRING or NUMBER */
  553. #if OLDWAY
  554.    void *array;                /* pointer to array memory */
  555. #endif
  556.    bnumber *memnum;            /* memory for number */
  557.    bstring *memstr;            /* memory for string */
  558.    size_t array_units;            /* total number of units of memory */
  559.    int  *array_sizes;            /* pointer to array of <dimensions>
  560.                                            integers, with sizes of each
  561.                                            dimension */
  562.    int *array_pos;                      /* current position in array */
  563.    int dimensions;                      /* number of dimensions,
  564.                                            0 = not an array */
  565.    struct bwb_variable *next;           /* next variable in chain */
  566.    int common;                /* should this variable be common to chained programs? */
  567.    int preset;                /* preset variable: CLEAR should not alter */
  568.    };
  569.  
  570. /* Structure to represent program lines under Bywater BASIC */
  571.  
  572. struct bwb_line
  573.    {
  574.    struct bwb_line *next;               /* pointer to next line in chain */
  575.    int number;                          /* line number */
  576.    char xnum;                /* is there actually a line number? */
  577.    char *buffer;            /* buffer to hold the line */
  578.    int position;                        /* current position in line */
  579.    int lnpos;                           /* line number position in buffer */
  580.    int lnum;                            /* line number read from buffer */
  581.    int cmdpos;                          /* command position in buffer */
  582.    int cmdnum;                          /* number of command in command table
  583.                                            read from buffer */
  584.    int startpos;                        /* start of rest of line read from buffer */
  585.    int marked;                          /* has line been checked yet? */
  586.    };
  587.  
  588. /* Structure used for all predefined functions under Bywater BASIC */
  589.  
  590. struct bwb_function
  591.    {
  592.    char name[ MAXVARNAMESIZE + 1 ];     /* name */
  593.    int type;                            /* type, i.e., STRING or NUMBER */
  594.    int arguments;                       /* number of args passed */
  595. #if ANSI_C
  596.    struct bwb_variable * (*vector) ( int argc, struct bwb_variable *argv, int unique_id );  /* vector to function to call */
  597. #else
  598.    struct bwb_variable * (*vector) ();  /* vector to function to call */
  599. #endif
  600.    struct bwb_function *next;           /* next function in chain */
  601.    int id;                              /* id to identify multiple functions */
  602.    };
  603.  
  604. /* Structure to represent all command statements under Bywater BASIC */
  605.  
  606. struct bwb_command
  607.    {
  608.    char name[ MAXCMDNAMESIZE + 1 ];
  609. #if ANSI_C
  610.    struct bwb_line * (*vector) (struct bwb_line *);
  611. #else
  612.    struct bwb_line * (*vector) ();
  613. #endif
  614.    };
  615.  
  616. /* Structure to define device stack for Bywater BASIC */
  617.  
  618. struct dev_element
  619.    {
  620.    int mode;                            /* DEVMODE_ item */
  621.    int width;                /* width for output control */
  622.    int col;                /* current column */
  623.    int reclen;                          /* record length for random access */
  624.    int next_record;            /* next record to read/write */
  625.    int loc;                /* location in file */
  626.    char filename[ MAXFILENAMESIZE + 1 ];/* filename */
  627.    FILE *cfp;                           /* C file pointer for this device */
  628.    char *buffer;            /* pointer to character buffer for random access */
  629.    };
  630.  
  631. /* Structure to define expression stack elements under Bywater BASIC */
  632.  
  633. struct exp_ese
  634.    {
  635.    int operation;                       /* operation at this level */
  636.    char type;                /* type of operation at this level:
  637.                           STRING or NUMBER */
  638.    bstring sval;            /* string */
  639.    bnumber nval;            /* number */
  640.    char string[ MAXSTRINGSIZE + 1 ];     /* string for writing */
  641.    struct bwb_variable *xvar;           /* pointer to external variable */
  642.    struct bwb_function *function;       /* pointer to function structure */
  643.    int array_pos[ MAX_DIMS ];        /* array for variable positions */
  644.    int pos_adv;                         /* position advanced in string */
  645.    int rec_pos;                         /* position marker for recursive calls */
  646.    };
  647.  
  648. /* structure for FUNCTION-SUB loopup table element */
  649.  
  650. struct fslte
  651.    {
  652.    char *name;
  653.    struct bwb_line *line;
  654.    int code;
  655.    int startpos;            /* starting position in line */
  656.    struct fslte *next;
  657.    struct bwb_variable *local_variable;
  658.    };
  659.  
  660. /* Structure to define EXEC stack elements */
  661.  
  662. struct exse
  663.    {
  664.    struct bwb_line *line;        /* line for execution */
  665.    int code;                /* code to note special operations */
  666.    int position;            /* position in line for restore */
  667.    struct bwb_variable *local_variable;    /* local variable chain and current FOR counter */
  668.    struct bwb_variable *calling_variable[ MAX_FARGS ];
  669.    int n_cvs;                /* number of calling variables */
  670.    int for_step;            /* STEP value for FOR */
  671.    int for_target;            /* target value for FOR */
  672.    struct bwb_line *while_line;        /* return line for current WHILE */
  673.    struct bwb_line *wend_line;          /* breakout line for current WHILE (or FOR-NEXT) */
  674.    struct exp_ese expression;        /* expression for evaluation by SELECT CASE */
  675. #if MULTISEG_LINES
  676.    struct bwb_line *for_line;           /* top line for FOR-NEXT loop, multisegmented */
  677.    int for_position;                    /* position in top line for FOR-NEXT loop, multisegmented */
  678. #endif
  679.    };
  680.  
  681. struct xtxtsl
  682.    {
  683.    int  position;
  684.    struct bwb_line l;
  685.    };
  686.  
  687. /* Structure to define bwBASIC task: UNDER CONSTRUCTION */
  688.  
  689. #if PARACT
  690. struct bwb_task
  691.    {
  692.    char progfile[ MAXARGSIZE ];        /* program file */
  693.    int rescan;                /* program needs to be rescanned */
  694.    int number;                /* current line number */
  695.    struct bwb_line *bwb_l;        /* current line pointer */
  696.    struct bwb_line bwb_start;        /* starting line marker */
  697.    struct bwb_line bwb_end;        /* ending line marker */
  698.    struct bwb_line *data_line;          /* current line to read data */
  699.    int data_pos;            /* position in data_line */
  700.    struct bwb_variable var_start;    /* variable list start marker */
  701.    struct bwb_variable var_end;        /* variable list end marker */
  702.    struct bwb_function fnc_start;    /* function list start marker */
  703.    struct bwb_function fnc_end;        /* function list end marker */
  704.    struct fslte fslt_start;        /* function-sub-label lookup table start marker */
  705.    struct fslte fslt_end;        /* function-sub-label lookup table end marker */
  706.    int exsc;                /* EXEC stack counter */
  707.    int expsc;                /* expression stack counter */
  708.    int xtxtsc;                /* eXecute TeXT stack counter */
  709.    struct exse excs[ EXECLEVELS ];    /* EXEC stack */
  710.    struct exp_ese exps[ ESTACKSIZE ];    /* Expression stack */
  711.    struct xtxtsl xtxts[ XTXTSTACKSIZE ];/* Execute Text stack */
  712.    };
  713.  
  714. extern struct bwb_task *bwb_tasks[ TASKS ];    /* table of task pointers */
  715.  
  716. #else                    /* not multi-tasking */
  717.  
  718. extern char progfile[ MAXARGSIZE ];    /* program file */
  719. extern int rescan;            /* program needs to be rescanned */
  720. extern int number;            /* current line number */
  721. extern struct bwb_line *bwb_l;        /* current line pointer */
  722. extern struct bwb_line bwb_start;    /* starting line marker */
  723. extern struct bwb_line bwb_end;        /* ending line marker */
  724. extern struct bwb_line *data_line;      /* current line to read data */
  725. extern int data_pos;            /* position in data_line */
  726. extern struct bwb_variable var_start;    /* variable list start marker */
  727. extern struct bwb_variable var_end;    /* variable list end marker */
  728. extern struct bwb_function fnc_start;    /* function list start marker */
  729. extern struct bwb_function fnc_end;    /* function list end marker */
  730. extern struct fslte fslt_start;        /* function-sub-label lookup table start marker */
  731. extern struct fslte fslt_end;        /* function-sub-label lookup table end marker */
  732. extern int exsc;            /* EXEC stack counter */
  733. extern int expsc;            /* expression stack counter */
  734. extern int xtxtsc;            /* eXecute TeXT stack counter */
  735. extern struct exse *excs;        /* EXEC stack */
  736. extern struct exp_ese *exps;        /* Expression stack */
  737. extern struct xtxtsl *xtxts;        /* Execute Text stack */
  738. #endif
  739.  
  740. extern int bwb_curtask;            /* current task */
  741. extern struct bwb_variable *ed;         /* EDITOR$ variable */
  742. extern struct bwb_variable *fi;         /* FILES$ variable */
  743. extern struct bwb_variable *pr;         /* PROMPT$ variable */
  744. extern struct bwb_variable *im;         /* IMPLEMENTATION$ variable */
  745. extern struct bwb_variable *co;         /* COLORS variable */
  746.  
  747. /***************************************************************
  748.  
  749.     bwbasic.h    Part III: Global Data
  750.  
  751. ***************************************************************/
  752.  
  753. extern char *bwb_ebuf;
  754. extern int bwb_trace;
  755. extern int dim_base;            /* set by OPTION BASE */
  756. extern struct bwb_command bwb_cmdtable[ COMMANDS ];
  757. extern FILE *errfdevice;                /* output device for error messages */
  758. extern int err_line;            /* line in which error occurred */
  759. extern int err_number;            /* number of last error */
  760. extern char err_gosubl[ MAXVARNAMESIZE + 1 ]; /* line for error GOSUB */
  761. extern char *err_table[ N_ERRORS ];    /* table of error messages */
  762. extern int prn_col;
  763. extern struct bwb_function bwb_prefuncs[ FUNCTIONS ];    /* table of predefined functions */
  764.  
  765. #if COMMON_CMDS
  766. extern struct dev_element *dev_table;   /* table of devices */
  767. #endif
  768.  
  769. /* Operator Structure and Table */
  770.  
  771. struct bwb_op
  772.    {
  773.    char symbol[ 8 ];                    /* BASIC symbol for the operator */
  774.    int operation;                       /* internal code for the operator */
  775.    int precedence;                      /* level of precedence, 0 = highest */
  776.    };
  777.  
  778. extern struct bwb_op exp_ops[ N_OPERATORS ]; /* the table itself, filled in in bwb_tbl.c */
  779.  
  780. /***************************************************************
  781.  
  782.     bwbasic.h    Part IV: Function Prototypes
  783.  
  784. ***************************************************************/
  785.  
  786. #if ANSI_C
  787. extern void bwb_init( int argc, char **argv );
  788. extern int bwb_fload( FILE *file );
  789. extern int bwb_ladd( char *buffer, int replace );
  790. extern int bwb_findcmd( int argc, int a, struct bwb_line *l );
  791. extern struct bwb_line *bwb_xtxtline( char *buffer );
  792. extern void bwb_mainloop( void );
  793. extern void bwb_execline( void );
  794. extern int bwb_gets( char *buffer );
  795. extern int bwb_error( char *message );
  796. extern void break_handler( void );
  797. extern void break_mes( int x );
  798. extern struct bwb_line *bwb_null( struct bwb_line *l );
  799. extern struct bwb_line *bwb_rem( struct bwb_line *l );
  800. extern struct bwb_line *bwb_lerror( struct bwb_line *l );
  801. extern struct bwb_line *bwb_run( struct bwb_line *l );
  802. extern struct bwb_line *bwb_let( struct bwb_line *l );
  803. extern struct bwb_line *bwb_load( struct bwb_line *l );
  804. extern struct bwb_line *bwb_merge( struct bwb_line *l );
  805. extern struct bwb_line *bwb_chain( struct bwb_line *l );
  806. extern struct bwb_line *bwb_common( struct bwb_line *l );
  807. extern struct bwb_line *bwb_xload( struct bwb_line *l );
  808. extern struct bwb_line *bwb_new( struct bwb_line *l );
  809. extern struct bwb_line *bwb_save( struct bwb_line *l );
  810. extern struct bwb_line *bwb_list( struct bwb_line *l );
  811. extern struct bwb_line *bwb_xlist( struct bwb_line *l, FILE *file );
  812. extern struct bwb_line *bwb_go( struct bwb_line *l );
  813. extern struct bwb_line *bwb_goto( struct bwb_line *l );
  814. extern struct bwb_line *bwb_gosub( struct bwb_line *l );
  815. extern struct bwb_line *bwb_return( struct bwb_line *l );
  816. extern struct bwb_line *bwb_xend( struct bwb_line *l );
  817. extern struct bwb_line *bwb_system( struct bwb_line *l );
  818. extern struct bwb_line *bwb_tron( struct bwb_line *l );
  819. extern struct bwb_line *bwb_troff( struct bwb_line *l );
  820. extern struct bwb_line *bwb_randomize( struct bwb_line *l );
  821. extern struct bwb_line *bwb_stop( struct bwb_line *l );
  822. extern struct bwb_line *bwb_data( struct bwb_line *l );
  823. extern struct bwb_line *bwb_read( struct bwb_line *l );
  824. extern struct bwb_line *bwb_restore( struct bwb_line *l );
  825. extern struct bwb_line *bwb_delete( struct bwb_line *l );
  826. extern struct bwb_line *bwb_if( struct bwb_line *l );
  827. extern struct bwb_line *bwb_else( struct bwb_line *l );
  828. extern struct bwb_line *bwb_elseif( struct bwb_line *l );
  829. extern struct bwb_line *bwb_select( struct bwb_line *l );
  830. extern struct bwb_line *bwb_case( struct bwb_line *l );
  831. extern struct bwb_line *bwb_endselect( struct bwb_line *l );
  832. extern struct bwb_line *bwb_endif( struct bwb_line *l );
  833. extern struct bwb_line *bwb_while( struct bwb_line *l );
  834. extern struct bwb_line *bwb_wend( struct bwb_line *l );
  835. extern struct bwb_line *bwb_for( struct bwb_line *l );
  836. extern struct bwb_line *bwb_next( struct bwb_line *l );
  837. extern struct bwb_line *bwb_dim( struct bwb_line *l );
  838. extern struct bwb_line *bwb_option( struct bwb_line *l );
  839. extern struct bwb_line *bwb_open( struct bwb_line *l );
  840. extern struct bwb_line *bwb_close( struct bwb_line *l );
  841. extern struct bwb_line *bwb_get( struct bwb_line *l );
  842. extern struct bwb_line *bwb_put( struct bwb_line *l );
  843. extern struct bwb_line *bwb_rmdir( struct bwb_line *l );
  844. extern struct bwb_line *bwb_chdir( struct bwb_line *l );
  845. extern struct bwb_line *bwb_mkdir( struct bwb_line *l );
  846. extern struct bwb_line *bwb_kill( struct bwb_line *l );
  847. extern struct bwb_line *bwb_name( struct bwb_line *l );
  848. extern struct bwb_line *bwb_rset( struct bwb_line *l );
  849. extern struct bwb_line *bwb_lset( struct bwb_line *l );
  850. extern struct bwb_line *bwb_field( struct bwb_line *l );
  851. extern struct bwb_line *bwb_on( struct bwb_line *l );
  852. extern struct bwb_line *bwb_line( struct bwb_line *l );
  853. extern struct bwb_line *bwb_ddbl( struct bwb_line *l );
  854. extern struct bwb_line *bwb_dint( struct bwb_line *l );
  855. extern struct bwb_line *bwb_dsng( struct bwb_line *l );
  856. extern struct bwb_line *bwb_dstr( struct bwb_line *l );
  857. extern struct bwb_line *bwb_clear( struct bwb_line *l );
  858. extern struct bwb_line *bwb_erase( struct bwb_line *l );
  859. extern struct bwb_line *bwb_swap( struct bwb_line *l );
  860. extern struct bwb_line *bwb_environ( struct bwb_line *l );
  861. extern struct bwb_line *bwb_width( struct bwb_line *l );
  862. extern struct bwb_line *bwb_write( struct bwb_line *l );
  863. extern struct bwb_line *bwb_edit( struct bwb_line *l );
  864. extern struct bwb_line *bwb_files( struct bwb_line *l );
  865. extern struct bwb_line *bwb_do( struct bwb_line *l );
  866. extern struct bwb_line *bwb_doloop( struct bwb_line *l );
  867. extern struct bwb_line *bwb_cls( struct bwb_line *l );
  868. extern struct bwb_line *bwb_locate( struct bwb_line *l );
  869. extern struct bwb_line *bwb_color( struct bwb_line *l );
  870. extern struct bwb_line *bwb_do( struct bwb_line *l );
  871. extern struct bwb_line *bwb_loop( struct bwb_line *l );
  872. extern struct bwb_line *bwb_exit( struct bwb_line *l );
  873. extern struct bwb_line *bwb_exitfor( struct bwb_line *l );
  874. extern struct bwb_line *bwb_exitdo( struct bwb_line *l );
  875.  
  876. extern struct bwb_line *bwb_zline( struct bwb_line *l );
  877.  
  878. extern void bwb_incexec( void );
  879. extern void bwb_decexec( void );
  880. extern int bwb_setexec( struct bwb_line *l, int position, int code );
  881. extern int bwb_getcnd( char *lb, char *lhs, char *rhs, char *op, int *n );
  882. extern int bwb_getlhs( char *lb, char *lhs, int *n );
  883. extern int bwb_getop( char *lb, char *op, int *n );
  884. extern int bwb_getrhs( char *lb, char *rhs, int *n );
  885. extern int bwb_evalcnd( char *lhs, char *rhs, char *op );
  886. extern int bwb_isstr( char *b );
  887. extern int eval_int( int l, int r, char *op );
  888. extern int eval_sng( float l, float r, char *op );
  889. extern int eval_dbl( double l, double r, char *op );
  890. extern struct exp_ese *bwb_exp( char *expression, int assignment, int *position );
  891. extern int exp_getvfname( char *source, char *destination );
  892. extern int exp_operation( int entry_level );
  893. extern int inc_esc( void );
  894. extern int dec_esc( void );
  895. extern int fnc_init( int task );
  896. extern struct bwb_function *fnc_find( char *buffer );
  897. extern struct bwb_line *bwb_def( struct bwb_line *l );
  898. extern int bwb_getargs( char *buffer );
  899. extern int bwb_stripcr( char *s );
  900. extern int bwb_numseq( char *buffer, int *start, int *end );
  901. extern int bwb_freeline( struct bwb_line *l );
  902. extern struct bwb_line *bwb_print( struct bwb_line *l );
  903. extern int bwb_xprint( struct bwb_line *l, FILE *f );
  904. extern int bwb_eltype( char *l_buffer, int p );
  905. extern int var_init( int task );
  906. extern int fslt_init( int task );
  907. extern int var_delcvars( void );
  908. extern struct bwb_variable *var_new( char *name );
  909. extern struct bwb_variable *var_islocal( char *buffer );
  910. extern int bwb_strel( char *lb, char *sb, int *n );
  911. extern struct bwb_variable *bwb_numel( char *lb, int *n );
  912. extern int bwb_const( char *lb, char *sb, int *n );
  913. extern int bwb_getvarname( char *lb, char *sb, int *n );
  914. extern struct bwb_variable *var_find( char *buffer );
  915. extern int bwb_isvar( char *buffer );
  916. extern struct bwb_line *bwb_input( struct bwb_line *l );
  917. extern int inp_adv( char *b, int *c );
  918. extern int var_make( struct bwb_variable *v, int type );
  919. extern bstring *var_getsval( struct bwb_variable *nvar );
  920. extern bstring *var_findsval( struct bwb_variable *v, int *pp );
  921. extern bstring *exp_getsval( struct exp_ese *e );
  922. extern int dim_getparams( char *buffer, int *pos, int *n_params, int **pp );
  923. extern int adv_element( char *buffer, int *pos, char *element );
  924. extern int adv_ws( char *buffer, int *pos );
  925. #if MULTISEG_LINES
  926. extern int adv_eos( char *buffer, int *pos );
  927. #endif
  928. extern int line_start( char *buffer, int *pos, int *lnpos, int *lnum,
  929.    int *cmdpos, int *cmdnum, int *startpos );
  930. extern int is_cmd( char *buffer, int *cmdnum );
  931. extern int is_let( char *buffer, int *cmdnum );
  932. extern int is_eol( char *buffer, int *position );
  933. extern int is_numconst( char *buffer );
  934. extern int is_label( char *buffer );
  935. extern struct bwb_line * find_label( char *buffer );
  936. extern struct bwb_line *find_loop( struct bwb_line *l );
  937. extern int int_qmdstr( char *buffer_a, char *buffer_b );
  938. extern struct bwb_line * cnd_xpline( struct bwb_line *l, char *buffer );
  939. extern int scan_element( char *buffer, int *pos, char *element );
  940.  
  941. extern int prn_precision( struct bwb_variable *v );
  942. extern int * prn_getcol( FILE *f );
  943. extern int prn_getwidth( FILE *f );
  944. extern int prn_xprintf( FILE *f, char *buffer );
  945. extern int bwb_strtoupper( char *buffer );
  946. extern int getcmdnum( char *cmdstr );
  947.  
  948. extern int str_btoc( char *buffer, bstring *s );
  949. extern int str_btob( bstring *d, bstring *s );
  950. extern int str_ctob( bstring *s, char *buffer );
  951. extern int str_cmp( bstring *s, bstring *t );
  952. extern char * str_cat( bstring *s, bstring *t );
  953. extern int exp_findop( char *expression );
  954. extern int exp_isop( char *expression );
  955. extern int exp_isfn( char *expression );
  956. extern int exp_isufn( char *expression );
  957. extern int exp_isnc( char *expression );
  958. extern int exp_isvn( char *expression );
  959. extern int exp_iscmd( char *expression );
  960. extern int exp_paren( char *expression );
  961. extern int exp_strconst( char *expression );
  962. extern int exp_numconst( char *expression );
  963. extern int exp_function( char *expression );
  964. extern int exp_ufnc( char *expression );
  965. extern int exp_variable( char *expression );
  966. extern int exp_validarg( char *expression );
  967. extern int ln_asbuf( struct bwb_line *l, char *s );
  968. extern int xputc( FILE *f, char c );
  969. extern int bwx_signon( void );
  970. extern int bwx_message( char *m );
  971. extern int bwx_putc( char c );
  972. extern int bwx_errmes( char *m );
  973. extern int bwx_input( char *prompt, char *buffer );
  974. extern void bwx_terminate( void );
  975.  
  976. #if COMMAND_SHELL
  977. extern int bwx_shell( struct bwb_line *l );
  978. #endif
  979.  
  980. int bwb_scan( void );
  981. struct bwb_line *bwb_call( struct bwb_line *l );
  982. struct bwb_line *bwb_sub( struct bwb_line *l );
  983. struct bwb_line *bwb_endsub( struct bwb_line *l );
  984. struct bwb_line *bwb_endfnc( struct bwb_line *l );
  985. struct bwb_line *bwb_function( struct bwb_line *l );
  986.  
  987. extern bnumber var_getnval( struct bwb_variable *nvar );
  988. extern bnumber *var_findnval( struct bwb_variable *v, int *pp );
  989. extern bnumber exp_getnval( struct exp_ese *e );
  990. extern bnumber *exp_findnval( struct exp_ese *e );
  991.  
  992. #if PARACT
  993. extern int bwb_newtask( int task_requested );
  994. #endif
  995.  
  996. #if INTERACTIVE
  997. extern int bwb_interact( void );
  998. #endif
  999.  
  1000. #if DEBUG
  1001. extern int bwb_debug( char *message );
  1002. extern struct bwb_line *bwb_cmds( struct bwb_line *l );
  1003. extern struct bwb_line *bwb_vars( struct bwb_line *l );
  1004. extern struct bwb_line *bwb_fncs( struct bwb_line *l );
  1005. #endif
  1006.  
  1007. #ifdef ALLOW_RENUM
  1008. extern struct bwb_line *bwb_renum( struct bwb_line *l );
  1009. #endif
  1010.  
  1011. #if UNIX_CMDS
  1012. extern int rmdir( char *path );
  1013. extern int chdir( char *path );
  1014. #if MKDIR_ONE_ARG
  1015. extern int mkdir( char *path );
  1016. #else
  1017. extern int mkdir( char *path, unsigned short permissions );
  1018. #endif
  1019. #endif
  1020.  
  1021. /* declarations of function commands */
  1022.  
  1023. extern struct bwb_variable *fnc_null( int argc, struct bwb_variable *argv, int unique_id );
  1024. #if COMPRESS_FUNCS
  1025. extern struct bwb_variable *fnc_core( int argc, struct bwb_variable *argv, int unique_id );
  1026. #else
  1027. extern struct bwb_variable *fnc_abs( int argc, struct bwb_variable *argv, int unique_id );
  1028. extern struct bwb_variable *fnc_atn( int argc, struct bwb_variable *argv, int unique_id );
  1029. extern struct bwb_variable *fnc_cos( int argc, struct bwb_variable *argv, int unique_id );
  1030. extern struct bwb_variable *fnc_log( int argc, struct bwb_variable *argv, int unique_id );
  1031. extern struct bwb_variable *fnc_sin( int argc, struct bwb_variable *argv, int unique_id );
  1032. extern struct bwb_variable *fnc_sqr( int argc, struct bwb_variable *argv, int unique_id );
  1033. extern struct bwb_variable *fnc_sgn( int argc, struct bwb_variable *argv, int unique_id );
  1034. extern struct bwb_variable *fnc_int( int argc, struct bwb_variable *argv, int unique_id );
  1035. extern struct bwb_variable *fnc_rnd( int argc, struct bwb_variable *argv, int unique_id );
  1036. extern struct bwb_variable *fnc_exp( int argc, struct bwb_variable *argv, int unique_id );
  1037. extern struct bwb_variable *fnc_tan( int argc, struct bwb_variable *argv, int unique_id );
  1038. #endif
  1039. extern struct bwb_variable *fnc_tab( int argc, struct bwb_variable *argv, int unique_id );
  1040. extern struct bwb_variable *fnc_date( int argc, struct bwb_variable *argv, int unique_id );
  1041. extern struct bwb_variable *fnc_time( int argc, struct bwb_variable *argv, int unique_id );
  1042. extern struct bwb_variable *fnc_chr( int argc, struct bwb_variable *argv, int unique_id );
  1043. extern struct bwb_variable *fnc_mid( int argc, struct bwb_variable *argv, int unique_id );
  1044. extern struct bwb_variable *fnc_left( int argc, struct bwb_variable *argv, int unique_id );
  1045. extern struct bwb_variable *fnc_right( int argc, struct bwb_variable *argv, int unique_id );
  1046. extern struct bwb_variable *fnc_timer( int argc, struct bwb_variable *argv, int unique_id );
  1047. extern struct bwb_variable *fnc_val( int argc, struct bwb_variable *argv, int unique_id );
  1048. extern struct bwb_variable *fnc_len( int argc, struct bwb_variable *argv, int unique_id );
  1049. extern struct bwb_variable *fnc_hex( int argc, struct bwb_variable *argv, int unique_id );
  1050. extern struct bwb_variable *fnc_oct( int argc, struct bwb_variable *argv, int unique_id );
  1051. extern struct bwb_variable *fnc_cint( int argc, struct bwb_variable *argv, int unique_id );
  1052. extern struct bwb_variable *fnc_asc( int argc, struct bwb_variable *argv, int unique_id );
  1053. extern struct bwb_variable *fnc_mkd( int argc, struct bwb_variable *argv, int unique_id );
  1054. extern struct bwb_variable *fnc_mki( int argc, struct bwb_variable *argv, int unique_id );
  1055. extern struct bwb_variable *fnc_mks( int argc, struct bwb_variable *argv, int unique_id );
  1056. extern struct bwb_variable *fnc_cvi( int argc, struct bwb_variable *argv, int unique_id );
  1057. extern struct bwb_variable *fnc_cvd( int argc, struct bwb_variable *argv, int unique_id );
  1058. extern struct bwb_variable *fnc_cvs( int argc, struct bwb_variable *argv, int unique_id );
  1059. extern struct bwb_variable *fnc_string( int argc, struct bwb_variable *argv, int unique_id );
  1060. extern struct bwb_variable * fnc_spc( int argc, struct bwb_variable *argv, int unique_id );
  1061. extern struct bwb_variable * fnc_space( int argc, struct bwb_variable *argv, int unique_id );
  1062. extern struct bwb_variable * fnc_environ( int argc, struct bwb_variable *argv, int unique_id );
  1063. extern struct bwb_variable * fnc_pos( int argc, struct bwb_variable *argv, int unique_id );
  1064. extern struct bwb_variable * fnc_err( int argc, struct bwb_variable *argv, int unique_id );
  1065. extern struct bwb_variable * fnc_erl( int argc, struct bwb_variable *argv, int unique_id );
  1066. extern struct bwb_variable * fnc_loc( int argc, struct bwb_variable *argv, int unique_id );
  1067. extern struct bwb_variable * fnc_lof( int argc, struct bwb_variable *argv, int unique_id );
  1068. extern struct bwb_variable * fnc_eof( int argc, struct bwb_variable *argv, int unique_id );
  1069. extern struct bwb_variable * fnc_csng( int argc, struct bwb_variable *argv, int unique_id );
  1070. extern struct bwb_variable * fnc_instr( int argc, struct bwb_variable *argv, int unique_id );
  1071. extern struct bwb_variable * fnc_str( int argc, struct bwb_variable *argv, int unique_id );
  1072. extern struct bwb_variable * fnc_inkey( int argc, struct bwb_variable *argv, int unique_id );
  1073.  
  1074. extern bnumber trnc_int( bnumber x );
  1075. extern int fnc_checkargs( int argc, struct bwb_variable *argv,
  1076.    int min, int max );
  1077. extern int ufsc;            /* user function stack counter */
  1078.  
  1079. #if DEBUG
  1080. extern struct bwb_variable *fnc_test( int argc, struct bwb_variable *argv, int unique_id );
  1081. #endif
  1082.  
  1083. #else                                   /* ANSI_C */
  1084.  
  1085. extern void bwb_init();
  1086. extern int bwb_fload();
  1087. extern int bwb_ladd();
  1088. extern int bwb_findcmd();
  1089. extern struct bwb_line *bwb_xtxtline();
  1090. extern void bwb_mainloop();
  1091. extern void bwb_execline();
  1092. extern int bwb_gets();
  1093. extern int bwb_error();
  1094. extern void break_handler();
  1095. extern void break_mes();
  1096. extern struct bwb_line *bwb_null();
  1097. extern struct bwb_line *bwb_rem();
  1098. extern struct bwb_line *bwb_lerror();
  1099. extern struct bwb_line *bwb_run();
  1100. extern struct bwb_line *bwb_let();
  1101. extern struct bwb_line *bwb_load();
  1102. extern struct bwb_line *bwb_merge();
  1103. extern struct bwb_line *bwb_chain();
  1104. extern struct bwb_line *bwb_common();
  1105. extern struct bwb_line *bwb_xload();
  1106. extern struct bwb_line *bwb_new();
  1107. extern struct bwb_line *bwb_save();
  1108. extern struct bwb_line *bwb_list();
  1109. extern struct bwb_line *bwb_xlist();
  1110. extern struct bwb_line *bwb_go();
  1111. extern struct bwb_line *bwb_goto();
  1112. extern struct bwb_line *bwb_gosub();
  1113. extern struct bwb_line *bwb_return();
  1114. extern struct bwb_line *bwb_xend();
  1115. extern struct bwb_line *bwb_system();
  1116. extern struct bwb_line *bwb_tron();
  1117. extern struct bwb_line *bwb_troff();
  1118. extern struct bwb_line *bwb_randomize();
  1119. extern struct bwb_line *bwb_stop();
  1120. extern struct bwb_line *bwb_data();
  1121. extern struct bwb_line *bwb_read();
  1122. extern struct bwb_line *bwb_restore();
  1123. extern struct bwb_line *bwb_delete();
  1124. extern struct bwb_line *bwb_if();
  1125. extern struct bwb_line *bwb_else();
  1126. extern struct bwb_line *bwb_elseif();
  1127. extern struct bwb_line *bwb_select();
  1128. extern struct bwb_line *bwb_case();
  1129. extern struct bwb_line *bwb_endselect();
  1130. extern struct bwb_line *bwb_endif();
  1131. extern struct bwb_line *bwb_while();
  1132. extern struct bwb_line *bwb_wend();
  1133. extern struct bwb_line *bwb_for();
  1134. extern struct bwb_line *bwb_next();
  1135. extern struct bwb_line *bwb_dim();
  1136. extern struct bwb_line *bwb_option();
  1137. extern struct bwb_line *bwb_open();
  1138. extern struct bwb_line *bwb_close();
  1139. extern struct bwb_line *bwb_get();
  1140. extern struct bwb_line *bwb_put();
  1141. extern struct bwb_line *bwb_rmdir();
  1142. extern struct bwb_line *bwb_chdir();
  1143. extern struct bwb_line *bwb_mkdir();
  1144. extern struct bwb_line *bwb_kill();
  1145. extern struct bwb_line *bwb_name();
  1146. extern struct bwb_line *bwb_rset();
  1147. extern struct bwb_line *bwb_lset();
  1148. extern struct bwb_line *bwb_field();
  1149. extern struct bwb_line *bwb_on();
  1150. extern struct bwb_line *bwb_line();
  1151. extern struct bwb_line *bwb_ddbl();
  1152. extern struct bwb_line *bwb_dint();
  1153. extern struct bwb_line *bwb_dsng();
  1154. extern struct bwb_line *bwb_dstr();
  1155. extern struct bwb_line *bwb_clear();
  1156. extern struct bwb_line *bwb_erase();
  1157. extern struct bwb_line *bwb_swap();
  1158. extern struct bwb_line *bwb_environ();
  1159. extern struct bwb_line *bwb_width();
  1160. extern struct bwb_line *bwb_write();
  1161. extern struct bwb_line *bwb_edit();
  1162. extern struct bwb_line *bwb_files();
  1163. extern struct bwb_line *bwb_do();
  1164. extern struct bwb_line *bwb_doloop();
  1165. extern struct bwb_line *bwb_cls();
  1166. extern struct bwb_line *bwb_locate();
  1167. extern struct bwb_line *bwb_color();
  1168. extern struct bwb_line *bwb_do();
  1169. extern struct bwb_line *bwb_loop();
  1170. extern struct bwb_line *bwb_exit();
  1171. extern struct bwb_line *bwb_exitfor();
  1172. extern struct bwb_line *bwb_exitdo();
  1173.  
  1174. extern struct bwb_line *bwb_zline();
  1175.  
  1176. extern void bwb_incexec();
  1177. extern void bwb_decexec();
  1178. extern int bwb_setexec();
  1179. extern int bwb_getcnd();
  1180. extern int bwb_getlhs();
  1181. extern int bwb_getop();
  1182. extern int bwb_getrhs();
  1183. extern int bwb_evalcnd();
  1184. extern int bwb_isstr();
  1185. extern int eval_int();
  1186. extern int eval_sng();
  1187. extern int eval_dbl();
  1188. extern struct exp_ese *bwb_exp();
  1189. extern int exp_getvfname();
  1190. extern int exp_operation();
  1191. extern int inc_esc();
  1192. extern int dec_esc();
  1193. extern int fnc_init();
  1194. extern struct bwb_function *fnc_find();
  1195. extern struct bwb_line *bwb_def();
  1196. extern int bwb_getargs();
  1197. extern int bwb_stripcr();
  1198. extern int bwb_numseq();
  1199. extern int bwb_freeline();
  1200. extern struct bwb_line *bwb_print();
  1201. extern int bwb_xprint();
  1202. extern int bwb_eltype();
  1203. extern int var_init();
  1204. extern int fslt_init();
  1205. extern int var_delcvars();
  1206. extern struct bwb_variable *var_new();
  1207. extern struct bwb_variable *var_islocal();
  1208. extern int bwb_strel();
  1209. extern struct bwb_variable *bwb_numel();
  1210. extern int bwb_const();
  1211. extern int bwb_getvarname();
  1212. extern struct bwb_variable *var_find();
  1213. extern int bwb_isvar();
  1214. extern struct bwb_line *bwb_input();
  1215. extern int inp_adv();
  1216. extern int var_make();
  1217. extern bstring *var_getsval();
  1218. extern bstring *var_findsval();
  1219. extern bstring *exp_getsval();
  1220. extern int dim_getparams();
  1221. extern int adv_element();
  1222. extern int adv_ws();
  1223. #if MULTISEG_LINES
  1224. extern int adv_eos();
  1225. #endif
  1226. extern int line_start();
  1227. extern int is_cmd();
  1228. extern int is_let();
  1229. extern int is_eol();
  1230. extern int is_numconst();
  1231. extern int is_label();
  1232. extern struct bwb_line * find_label();
  1233. extern struct bwb_line *find_loop();
  1234. extern int int_qmdstr();
  1235. extern struct bwb_line * cnd_xpline();
  1236. extern int scan_element();
  1237.  
  1238. extern int prn_precision();
  1239. extern int * prn_getcol();
  1240. extern int prn_getwidth();
  1241. extern int prn_xprintf();
  1242. extern int bwb_strtoupper();
  1243. extern int getcmdnum();
  1244.  
  1245. extern int str_btoc();
  1246. extern int str_btob();
  1247. extern int str_ctob();
  1248. extern int str_cmp();
  1249. extern char * str_cat();
  1250. extern int exp_findop();
  1251. extern int exp_isop();
  1252. extern int exp_isfn();
  1253. extern int exp_isufn();
  1254. extern int exp_isnc();
  1255. extern int exp_isvn();
  1256. extern int exp_iscmd();
  1257. extern int exp_paren();
  1258. extern int exp_strconst();
  1259. extern int exp_numconst();
  1260. extern int exp_function();
  1261. extern int exp_ufnc();
  1262. extern int exp_variable();
  1263. extern int exp_validarg();
  1264. extern int ln_asbuf();
  1265. extern int xputc();
  1266. extern int bwx_signon();
  1267. extern int bwx_message();
  1268. extern int bwx_putc();
  1269. extern int bwx_errmes();
  1270. extern int bwx_input();
  1271. extern void bwx_terminate();
  1272.  
  1273. #if COMMAND_SHELL
  1274. extern int bwx_shell();
  1275. #endif
  1276.  
  1277. int bwb_scan();
  1278. struct bwb_line *bwb_call();
  1279. struct bwb_line *bwb_sub();
  1280. struct bwb_line *bwb_endsub();
  1281. struct bwb_line *bwb_endfnc();
  1282. struct bwb_line *bwb_function();
  1283.  
  1284. extern bnumber var_getnval();
  1285. extern bnumber *var_findnval();
  1286. extern bnumber exp_getnval();
  1287. extern bnumber *exp_findnval();
  1288.  
  1289. #if PARACT
  1290. extern int bwb_newtask();
  1291. #endif
  1292.  
  1293. #if INTERACTIVE
  1294. extern int bwb_interact();
  1295. #endif
  1296.  
  1297. #if DEBUG
  1298. extern int bwb_debug();
  1299. extern struct bwb_line *bwb_cmds();
  1300. extern struct bwb_line *bwb_vars();
  1301. extern struct bwb_line *bwb_fncs();
  1302. #endif
  1303.  
  1304. #ifdef ALLOW_RENUM
  1305. extern struct bwb_line *bwb_renum();
  1306. #endif
  1307.  
  1308. #if UNIX_CMDS
  1309. extern int rmdir();
  1310. extern int chdir();
  1311. #if MKDIR_ONE_ARG
  1312. extern int mkdir();
  1313. #else
  1314. extern int mkdir();
  1315. #endif
  1316. #endif
  1317.  
  1318. /* declarations of function commands */
  1319.  
  1320. extern struct bwb_variable *fnc_null();
  1321. #if COMPRESS_FUNCS
  1322. extern struct bwb_variable *fnc_core();
  1323. #else
  1324. extern struct bwb_variable *fnc_abs();
  1325. extern struct bwb_variable *fnc_atn();
  1326. extern struct bwb_variable *fnc_cos();
  1327. extern struct bwb_variable *fnc_log();
  1328. extern struct bwb_variable *fnc_sin();
  1329. extern struct bwb_variable *fnc_sqr();
  1330. extern struct bwb_variable *fnc_sgn();
  1331. extern struct bwb_variable *fnc_int();
  1332. extern struct bwb_variable *fnc_rnd();
  1333. extern struct bwb_variable *fnc_exp();
  1334. extern struct bwb_variable *fnc_tan();
  1335. #endif
  1336. extern struct bwb_variable *fnc_tab();
  1337. extern struct bwb_variable *fnc_date();
  1338. extern struct bwb_variable *fnc_time();
  1339. extern struct bwb_variable *fnc_chr();
  1340. extern struct bwb_variable *fnc_mid();
  1341. extern struct bwb_variable *fnc_left();
  1342. extern struct bwb_variable *fnc_right();
  1343. extern struct bwb_variable *fnc_timer();
  1344. extern struct bwb_variable *fnc_val();
  1345. extern struct bwb_variable *fnc_len();
  1346. extern struct bwb_variable *fnc_hex();
  1347. extern struct bwb_variable *fnc_oct();
  1348. extern struct bwb_variable *fnc_cint();
  1349. extern struct bwb_variable *fnc_asc();
  1350. extern struct bwb_variable *fnc_mkd();
  1351. extern struct bwb_variable *fnc_mki();
  1352. extern struct bwb_variable *fnc_mks();
  1353. extern struct bwb_variable *fnc_cvi();
  1354. extern struct bwb_variable *fnc_cvd();
  1355. extern struct bwb_variable *fnc_cvs();
  1356. extern struct bwb_variable *fnc_string();
  1357. extern struct bwb_variable * fnc_spc();
  1358. extern struct bwb_variable * fnc_space();
  1359. extern struct bwb_variable * fnc_environ();
  1360. extern struct bwb_variable * fnc_pos();
  1361. extern struct bwb_variable * fnc_err();
  1362. extern struct bwb_variable * fnc_erl();
  1363. extern struct bwb_variable * fnc_loc();
  1364. extern struct bwb_variable * fnc_lof();
  1365. extern struct bwb_variable * fnc_eof();
  1366. extern struct bwb_variable * fnc_csng();
  1367. extern struct bwb_variable * fnc_instr();
  1368. extern struct bwb_variable * fnc_str();
  1369. extern struct bwb_variable * fnc_inkey();
  1370.  
  1371. extern bnumber trnc_int();
  1372. extern int fnc_checkargs();
  1373. extern int ufsc;            /* user function stack counter */
  1374.  
  1375. #if DEBUG
  1376. extern struct bwb_variable *fnc_test();
  1377. #endif
  1378.  
  1379. #endif                                  /* ANSI_C */
  1380.  
  1381. #if COMPRESS_FUNCS
  1382. #define         F_ABS           1
  1383. #define         F_ATN           2
  1384. #define         F_COS           3
  1385. #define         F_EXP           4
  1386. #define         F_INT           5
  1387. #define         F_LOG           6
  1388. #define         F_RND           7
  1389. #define         F_SGN           8
  1390. #define         F_SIN           9
  1391. #define         F_SQR           10
  1392. #define         F_TAN           11
  1393. #endif
  1394.