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.
 
 
 
 
 
 

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