ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1488 lines
56 KiB

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